public
Authored by
PotatoGim

[Perl] FFI::Platypus for gfapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
Please register or sign in to comment