Define LIBGUESTFS_HAVE_<shortname> for C API functions.
authorRichard Jones <rjones@redhat.com>
Thu, 2 Sep 2010 21:45:54 +0000 (22:45 +0100)
committerRichard Jones <rjones@redhat.com>
Sat, 4 Sep 2010 12:38:03 +0000 (13:38 +0100)
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.

src/generator.ml
src/guestfs.h
src/guestfs.pod

index 3f5fd6c..1d5707d 100755 (executable)
@@ -6451,11 +6451,21 @@ and generate_structs_h () =
 and generate_actions_h () =
   generate_header CStyle LGPLv2plus;
   List.iter (
 and generate_actions_h () =
   generate_header CStyle LGPLv2plus;
   List.iter (
-    fun (shortname, style, _, _, _, _, _) ->
+    fun (shortname, style, _, flags, _, _, _) ->
       let name = "guestfs_" ^ shortname in
       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
       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 () =
 
 (* Generate the guestfs-internal-actions.h file. *)
 and generate_internal_actions_h () =
index 9fc6ca5..c23b9eb 100644 (file)
@@ -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);
 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);
 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 ---*/
 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);
 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 ---*/
 extern void *guestfs_get_private (guestfs_h *g, const char *key);
 
 /*--- Structures and actions ---*/
index ccc719d..24d5aef 100644 (file)
@@ -940,10 +940,17 @@ Note however that you have to do C<run> first.
 
 =head2 SINGLE CALLS AT COMPILE TIME
 
 
 =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])
 
  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):
 
 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>
  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>
@@ -974,7 +979,7 @@ need the compile time check as well):
  
  main ()
  {
  
  main ()
  {
- #ifdef HAVE_GUESTFS_DD
+ #ifdef LIBGUESTFS_HAVE_DD
    void *dl;
    int has_function;
  
    void *dl;
    int has_function;