From: Richard Jones Date: Thu, 2 Sep 2010 21:45:54 +0000 (+0100) Subject: Define LIBGUESTFS_HAVE_ for C API functions. X-Git-Tag: 1.5.8~2 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=2d8fd7dacd77361bc385be42112289faafb5c60d Define LIBGUESTFS_HAVE_ for C API functions. The actions each have a corresponding define, eg: #define LIBGUESTFS_HAVE_VGUUID 1 extern char *guestfs_vguuid (guestfs_h *g, const char *vgname); However functions which are for testing, debugging or deprecated do not have the corresponding define. Also a few functions are so basic (eg. guestfs_create) that there is no point defining a symbol for them. --- diff --git a/src/generator.ml b/src/generator.ml index 3f5fd6c..1d5707d 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -6451,11 +6451,21 @@ and generate_structs_h () = and generate_actions_h () = generate_header CStyle LGPLv2plus; List.iter ( - fun (shortname, style, _, _, _, _, _) -> + fun (shortname, style, _, flags, _, _, _) -> let name = "guestfs_" ^ shortname in + + let deprecated = + List.exists (function DeprecatedBy _ -> true | _ -> false) flags in + let test0 = + String.length shortname >= 5 && String.sub shortname 0 5 = "test0" in + let debug = + String.length shortname >= 5 && String.sub shortname 0 5 = "debug" in + if not deprecated && not test0 && not debug then + pr "#define LIBGUESTFS_HAVE_%s 1\n" (String.uppercase shortname); + generate_prototype ~single_line:true ~newline:true ~handle:"g" name style - ) all_functions + ) all_functions_sorted (* Generate the guestfs-internal-actions.h file. *) and generate_internal_actions_h () = diff --git a/src/guestfs.h b/src/guestfs.h index 9fc6ca5..c23b9eb 100644 --- a/src/guestfs.h +++ b/src/guestfs.h @@ -64,11 +64,15 @@ typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque, int proc_nr, in extern void guestfs_set_log_message_callback (guestfs_h *g, guestfs_log_message_cb cb, void *opaque); extern void guestfs_set_subprocess_quit_callback (guestfs_h *g, guestfs_subprocess_quit_cb cb, void *opaque); extern void guestfs_set_launch_done_callback (guestfs_h *g, guestfs_launch_done_cb cb, void *opaque); +#define LIBGUESTFS_HAVE_SET_CLOSE_CALLBACK 1 extern void guestfs_set_close_callback (guestfs_h *g, guestfs_close_cb cb, void *opaque); +#define LIBGUESTFS_HAVE_SET_PROGRESS_CALLBACK 1 extern void guestfs_set_progress_callback (guestfs_h *g, guestfs_progress_cb cb, void *opaque); /*--- Private data area ---*/ +#define LIBGUESTFS_HAVE_SET_PRIVATE 1 extern void guestfs_set_private (guestfs_h *g, const char *key, void *data); +#define LIBGUESTFS_HAVE_GET_PRIVATE 1 extern void *guestfs_get_private (guestfs_h *g, const char *key); /*--- Structures and actions ---*/ diff --git a/src/guestfs.pod b/src/guestfs.pod index ccc719d..24d5aef 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -940,10 +940,17 @@ Note however that you have to do C first. =head2 SINGLE CALLS AT COMPILE TIME -If you need to test whether a single libguestfs function is -available at compile time, we recommend using build tools -such as autoconf or cmake. For example in autotools you could -use: +Since version 1.5.8, Cguestfs.hE> defines symbols +for each C API function, such as: + + #define LIBGUESTFS_HAVE_DD 1 + +if L is available. + +Before version 1.5.8, if you needed to test whether a single +libguestfs function is available at compile time, we recommended using +build tools such as autoconf or cmake. For example in autotools you +could use: AC_CHECK_LIB([guestfs],[guestfs_create]) AC_CHECK_FUNCS([guestfs_dd]) @@ -964,8 +971,6 @@ You can use L to test if a function is available at run time, as in this example program (note that you still need the compile time check as well): - #include - #include #include #include @@ -974,7 +979,7 @@ need the compile time check as well): main () { - #ifdef HAVE_GUESTFS_DD + #ifdef LIBGUESTFS_HAVE_DD void *dl; int has_function;