if newline then pr "\n"
(* Generate C call arguments, eg "(handle, foo, bar)" *)
-and generate_c_call_args ?handle (ret, args, optargs) =
+and generate_c_call_args ?handle ?(implicit_size_ptr = "&size")
+ (ret, args, optargs) =
pr "(";
let comma = ref false in
let next () =
next ();
pr "%s" (name_of_argt arg)
) args;
- (* For RBufferOut calls, add implicit &size parameter. *)
+ (* For RBufferOut calls, add implicit size pointer parameter. *)
(match ret with
| RBufferOut _ ->
next ();
- pr "&size"
+ pr "%s" implicit_size_ptr
| _ -> ()
);
(* For calls with optional arguments, add implicit optargs parameter. *)
pr "This function takes a key or passphrase parameter which
could contain sensitive material. Read the section
L</KEYS AND PASSPHRASES> for more information.\n\n";
- (match deprecation_notice flags with
+ (match deprecation_notice ~prefix:"guestfs_" flags with
| None -> ()
| Some txt -> pr "%s\n\n" txt
);
#include <stdint.h>
#include <stdarg.h>
+#ifdef __GNUC__
+# define GUESTFS_GCC_VERSION \\
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#endif
+
/* The handle. */
#ifndef GUESTFS_TYPEDEF_H
#define GUESTFS_TYPEDEF_H 1
#endif
#define LIBGUESTFS_HAVE_SET_EVENT_CALLBACK 1
-int guestfs_set_event_callback (guestfs_h *g,
- guestfs_event_callback cb,
- uint64_t event_bitmask,
- int flags,
- void *opaque);
+extern int guestfs_set_event_callback (guestfs_h *g,
+ guestfs_event_callback cb,
+ uint64_t event_bitmask,
+ int flags,
+ void *opaque);
#define LIBGUESTFS_HAVE_DELETE_EVENT_CALLBACK 1
-void guestfs_delete_event_callback (guestfs_h *g, int event_handle);
+extern void guestfs_delete_event_callback (guestfs_h *g, int event_handle);
/* Old-style event handling. In new code use guestfs_set_event_callback. */
#ifndef GUESTFS_TYPEDEF_LOG_MESSAGE_CB
| RBufferOut _ ->
pr "%s guestfs___print_BufferOut (trace_fp, %s, *size_r);\n" indent rv
| RStringList _ | RHashtable _ ->
- pr "%s fputs (\"[\\\"\", trace_fp);\n" indent;
+ pr "%s fputs (\"[\", trace_fp);\n" indent;
pr "%s for (i = 0; %s[i]; ++i) {\n" indent rv;
- pr "%s if (i > 0) fputs (\"\\\", \\\"\", trace_fp);\n" indent;
+ pr "%s if (i > 0) fputs (\", \", trace_fp);\n" indent;
+ pr "%s fputs (\"\\\"\", trace_fp);\n" indent;
pr "%s fputs (%s[i], trace_fp);\n" indent rv;
+ pr "%s fputs (\"\\\"\", trace_fp);\n" indent;
pr "%s }\n" indent;
- pr "%s fputs (\"\\\"]\", trace_fp);\n" indent;
+ pr "%s fputs (\"]\", trace_fp);\n" indent;
| RStruct (_, typ) ->
(* XXX There is code generated for guestfish for printing
* these structures. We need to make it generally available
reject_unknown_optargs shortname style;
trace_call shortname style;
pr " r = guestfs__%s " shortname;
- generate_c_call_args ~handle:"g" style;
+ generate_c_call_args ~handle:"g" ~implicit_size_ptr:"size_r" style;
pr ";\n";
pr "\n";
(match errcode_of_ret ret with
(* Get the name of the last regular argument. *)
let last_arg =
- match args with
- | [] -> "g"
- | args -> name_of_argt (List.hd (List.rev args)) in
+ match ret with
+ | RBufferOut _ -> "size_r"
+ | _ ->
+ match args with
+ | [] -> "g"
+ | args -> name_of_argt (List.hd (List.rev args)) in
let rtype =
match ret with
pr "\n";
pr " va_start (optargs, %s);\n" last_arg;
pr " %sr = guestfs_%s_va " rtype shortname;
- generate_c_call_args ~handle:"g" style;
+ generate_c_call_args ~handle:"g" ~implicit_size_ptr:"size_r" style;
pr ";\n";
pr " va_end (optargs);\n";
pr "\n";
pr " }\n";
pr "\n";
pr " return guestfs_%s_argv " shortname;
- generate_c_call_args ~handle:"g" style;
+ generate_c_call_args ~handle:"g" ~implicit_size_ptr:"size_r" style;
pr ";\n";
pr "}\n\n"
| _ -> ()