perl: Expose nbdkit_set_error to perl script
commitd1e69d156745f11383a2ebaf1dbfcc78d2de35c3
authorEric Blake <eblake@redhat.com>
Tue, 31 Jan 2017 04:24:46 +0000 (30 22:24 -0600)
committerRichard W.M. Jones <rjones@redhat.com>
Tue, 31 Jan 2017 17:33:45 +0000 (31 17:33 +0000)
tree0448c75ca1d141ed26c3c1f237c37a35e07d1498
parent06f3ea6e360a8b0daafe8950af27db3abc273d85
perl: Expose nbdkit_set_error to perl script

In addition to calling Perl functions from C, we want to make
script writing easier by exposing C functions to perl.  For
now, just wrap nbdkit_set_error(), as that will be needed for
an optimal implementation of a zero() callback.

I intentionally decided to go with a hand-rolled XSUB statically
compiled in, rather than a full-blown dynamically loadable Nbdkit
module compatible with CPAN, in part because the machinery to hook
in a call to xsubcc would be lots of code, and in part because we
already document that the user's script is not executable as a
stand-alone perl script anyways.

Perl is very picky: I found that including <XSUB.h> after <EXTERN.h>,
even with no other changes in the file, caused the embedded
interpreter to segfault during perl_open(); but listing <XSUB.h>
first worked for me (tested on Fedora 25).

Signed-off-by: Eric Blake <eblake@redhat.com>
plugins/perl/nbdkit-perl-plugin.pod
plugins/perl/perl.c