public
Authored by avatar PotatoGim

[Perl] FFI::Platypus for gfapi

ffi_gfapi.pl 1.15 KiB
use FFI::Platypus;
use FFI::Platypus::API;
use FFI::Platypus::Declare  qw/void string opaque/;
use FFI::Platypus::Memory   qw/malloc/;
use FFI::Platypus::Buffer   qw/scalar_to_buffer buffer_to_scalar/;

my $ffi = FFI::Platypus->new;

$ffi->find_lib(lib => 'gfapi');

$ffi->type('opaque' => 'glfs');

my $new                = $ffi->function(glfs_new => ['string'] => 'glfs');
my $set_volfile_server = $ffi->function(glfs_set_volfile_server => ['glfs', 'string', 'string', 'int'] => 'int');
my $init               = $ffi->function(glfs_init => ['glfs'], => 'int');
my $get_volfile        = $ffi->function(glfs_get_volfile => ['glfs', 'void', 'int'] => 'int');
my $finish             = $ffi->function(glfs_fini => ['glfs'] => 'int');

print "new()\n";
my $fs = $new->call('private');

print "set_volfile_server()\n";
$set_volfile_server->call($fs, 'tcp', '127.0.0.1', 24007);

print "init()\n";
$init->call($fs);

#print "get_volfile()\n";
#
#my $vbuf_len = 100;
#my $vbuf     = malloc($vbuf_len);
#
#$get_volfile->call($fs, cast($vbuf, $vbuf_len);
#
#my $converted = $ffi->cast('opaque', 'glfs', $vbuf);

print "finish()\n";
$finish->call($fs);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment