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.
This commit is contained in:
Richard Jones
2010-09-02 22:45:54 +01:00
parent 5fc69ce3ec
commit 2d8fd7dacd
3 changed files with 28 additions and 9 deletions

View File

@@ -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 () =

View 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);
#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 ---*/

View File

@@ -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;