summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-09 17:47:07 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-11-09 19:50:57 +0000
commita3b6751863b4e7e620dd1b75b4a8d8187d2069a5 (patch)
treee217f7c6b152612453fb0054f16112a610180e77 /generator
parent2013e005bd02f5706887c8861f10410ffd82084f (diff)
downloadlibguestfs-a3b6751863b4e7e620dd1b75b4a8d8187d2069a5.tar.gz
libguestfs-a3b6751863b4e7e620dd1b75b4a8d8187d2069a5.tar.xz
libguestfs-a3b6751863b4e7e620dd1b75b4a8d8187d2069a5.zip
lib: Add new C API calls: guestfs_push_error_handler,
guestfs_pop_error_handler. The addition of these calls makes it much simpler to temporarily disable or ignore errors: guestfs_push_error_handler (g, NULL, NULL); guestfs_mkdir (g, "/foo"); /* We don't care if this fails. */ guestfs_pop_error_handler (g); Note these calls are used by the C API only. They are not necessary in other languages, because those map errors to exceptions. The subsequent commits change existing code to use push/pop instead of laboriously saving and restoring the error handler.
Diffstat (limited to 'generator')
-rw-r--r--generator/c.ml6
1 files changed, 6 insertions, 0 deletions
diff --git a/generator/c.ml b/generator/c.ml
index b8c601be..1b99e519 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -449,6 +449,10 @@ typedef void (*guestfs_abort_cb) (void) __attribute__((__noreturn__));
extern GUESTFS_DLL_PUBLIC void guestfs_set_error_handler (guestfs_h *g, guestfs_error_handler_cb cb, void *opaque);
extern GUESTFS_DLL_PUBLIC guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g, void **opaque_rtn);
+#define LIBGUESTFS_HAVE_PUSH_ERROR_HANDLER 1
+extern GUESTFS_DLL_PUBLIC void guestfs_push_error_handler (guestfs_h *g, guestfs_error_handler_cb cb, void *opaque);
+#define LIBGUESTFS_HAVE_POP_ERROR_HANDLER 1
+extern GUESTFS_DLL_PUBLIC void guestfs_pop_error_handler (guestfs_h *g);
extern GUESTFS_DLL_PUBLIC void guestfs_set_out_of_memory_handler (guestfs_h *g, guestfs_abort_cb);
extern GUESTFS_DLL_PUBLIC guestfs_abort_cb guestfs_get_out_of_memory_handler (guestfs_h *g);
@@ -1566,6 +1570,8 @@ and generate_linker_script () =
"guestfs_last_errno";
"guestfs_last_error";
"guestfs_next_private";
+ "guestfs_pop_error_handler";
+ "guestfs_push_error_handler";
"guestfs_set_close_callback";
"guestfs_set_error_handler";
"guestfs_set_event_callback";