SPVM::Resource::Zlib - zlib Resource
SPVM::Resource::Zlib is the document of the resource of the zlib library.
SPVM::Resource::Zlib
MyZlib.pl
use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use SPVM 'MyZlib'; my $gz_file = "$FindBin::Bin/minitest.txt.gz"; SPVM::MyZlib->test_gzopen_gzread($gz_file);
lib/SPVM/MyZlib.spvm
class MyZlib { native static method test_gzopen_gzread : void ($file : string); }
lib/SPVM/MyZlib.config
use strict; use warnings; my $config = SPVM::Builder::Config->new_gnu99(file => __FILE__); $config->use_resource('Resource::Zlib::V1_2_11'); $config;
lib/SPVM/MyZlib.c
#include "spvm_native.h" #include <zlib.h> int32_t SPVM__MyZlib__test_gzopen_gzread(SPVM_ENV* env, SPVM_VALUE* stack) { (void)env; void* sp_file = stack[0].oval; const char* file = env->get_chars(env, sp_file); z_stream z; gzFile gz_fh = gzopen(file, "rb"); if (gz_fh == NULL){ return env->die(env, "Can't open file \"%s\"\n", file); } char buffer[256] = {0}; int32_t cnt; while((cnt = gzread(gz_fh, buffer, sizeof(buffer))) > 0){ } printf("%s", buffer); return 0; }
The list of zlib resources.
zlib
* SPVM::Resource::Zlib::V1_2_11 - zlib v1.2.11
To install SPVM::Resource::Zlib, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM::Resource::Zlib
CPAN shell
perl -MCPAN -e shell install SPVM::Resource::Zlib
For more information on module installation, please visit the detailed CPAN module installation guide.