X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_perl.ml;h=e2ec254bcf0b4a8eedf9216a0a2581246aff3d2e;hb=c446e6e26e317e105870b0ab25fb082887e23bf6;hp=09bf20ff74a723adff8d9ba1a457d5e195fd9825;hpb=bc468c87d04b34faacd208c49cca4a5096e5103c;p=libguestfs.git diff --git a/generator/generator_perl.ml b/generator/generator_perl.ml index 09bf20f..e2ec254 100644 --- a/generator/generator_perl.ml +++ b/generator/generator_perl.ml @@ -256,11 +256,26 @@ delete_event_callback (g, event_handle) int event_handle; PREINIT: char key[64]; + SV *cb; CODE: snprintf (key, sizeof key, \"_perl_event_%%d\", event_handle); - guestfs_set_private (g, key, NULL); + cb = guestfs_get_private (g, key); + if (cb) { + SvREFCNT_dec (cb); + guestfs_set_private (g, key, NULL); + guestfs_delete_event_callback (g, event_handle); + } - guestfs_delete_event_callback (g, event_handle); +SV * +last_errno (g) + guestfs_h *g; +PREINIT: + int errnum; + CODE: + errnum = guestfs_last_errno (g); + RETVAL = newSViv (errnum); + OUTPUT: + RETVAL "; @@ -625,6 +640,9 @@ with libvirt. All errors turn into calls to C (see L). +The error string from libguestfs is directly available from +C<$@>. Use the C method if you want to get the errno. + =head1 METHODS =over 4 @@ -738,6 +756,26 @@ this function. This removes the callback which was previously registered using C. +=item $errnum = $h->last_errno (); + +This returns the last error number (errno) that happened on the +handle C<$h>. + +If successful, an errno integer not equal to zero is returned. + +If no error number is available, this returns 0. +See L for more details of why +this can happen. + +You can use the standard Perl module L to compare +the numeric error returned from this call with symbolic +errnos: + + $h->mkdir (\"/foo\"); + if ($h->last_errno() == Errno::EEXIST()) { + # mkdir failed because the directory exists already. + } + =cut ";