diff options
author | Richard Jones <rjones@redhat.com> | 2010-09-02 22:45:54 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-09-04 13:38:03 +0100 |
commit | 2d8fd7dacd77361bc385be42112289faafb5c60d (patch) | |
tree | ef9d1526e8c22f4f79d00638e76bdba422d973c3 | |
parent | 5fc69ce3ece5e4d4a3da9d78da244c4fa301b5ac (diff) | |
download | libguestfs-2d8fd7dacd77361bc385be42112289faafb5c60d.tar.gz libguestfs-2d8fd7dacd77361bc385be42112289faafb5c60d.tar.xz libguestfs-2d8fd7dacd77361bc385be42112289faafb5c60d.zip |
Define LIBGUESTFS_HAVE_<shortname> 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.
-rwxr-xr-x | src/generator.ml | 14 | ||||
-rw-r--r-- | src/guestfs.h | 4 | ||||
-rw-r--r-- | src/guestfs.pod | 19 |
3 files changed, 28 insertions, 9 deletions
diff --git a/src/generator.ml b/src/generator.ml index 3f5fd6c4..1d5707dd 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 9fc6ca5b..c23b9eb7 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 ccc719d7..24d5aef1 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -940,10 +940,17 @@ Note however that you have to do C<run> 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, C<E<lt>guestfs.hE<gt>> defines symbols +for each C API function, such as: + + #define LIBGUESTFS_HAVE_DD 1 + +if L</guestfs_dd> 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<dlopen(3)> 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 <config.h> - #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -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; |