X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_c.ml;h=5460a35f5d3b4eb2b3938d20a594e35678e5c0e7;hb=8876b2d3764b42ebae3c5fdf61b1899095508169;hp=61cb0a33202ae229cfc5b61a917e15c849365df0;hpb=478f6c5bdbe4b7e466fe7eaca63aaba002f585ce;p=libguestfs.git diff --git a/generator/generator_c.ml b/generator/generator_c.ml index 61cb0a3..5460a35 100644 --- a/generator/generator_c.ml +++ b/generator/generator_c.ml @@ -135,7 +135,8 @@ let rec generate_prototype ?(extern = true) ?(static = false) 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 () = @@ -155,11 +156,11 @@ and generate_c_call_args ?handle (ret, args, optargs) = 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. *) @@ -179,6 +180,11 @@ and generate_actions_pod () = generate_prototype ~extern:false ~indent:" " ~handle:"g" name style; pr "\n\n"; + (match deprecation_notice ~prefix:"guestfs_" flags with + | None -> () + | Some txt -> pr "%s\n\n" txt + ); + let uc_shortname = String.uppercase shortname in if optargs <> [] then ( pr "You may supply a list of optional arguments to this call.\n"; @@ -254,10 +260,6 @@ I.\n\n" pr "This function takes a key or passphrase parameter which could contain sensitive material. Read the section L for more information.\n\n"; - (match deprecation_notice flags with - | None -> () - | Some txt -> pr "%s\n\n" txt - ); (match lookup_api_version name with | Some version -> pr "(Added in %s)\n\n" version | None -> () @@ -435,13 +437,13 @@ typedef void (*guestfs_event_callback) ( #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. */ #ifndef GUESTFS_TYPEDEF_LOG_MESSAGE_CB @@ -482,6 +484,10 @@ extern void guestfs_set_close_callback (guestfs_h *g, guestfs_close_cb cb, void extern void guestfs_set_progress_callback (guestfs_h *g, guestfs_progress_cb cb, void *opaque) GUESTFS_DEPRECATED_BY(\"set_event_callback\"); +/* User cancellation. */ +#define LIBGUESTFS_HAVE_USER_CANCEL 1 +extern void guestfs_user_cancel (guestfs_h *g); + /* Private data area. */ #define LIBGUESTFS_HAVE_SET_PRIVATE 1 extern void guestfs_set_private (guestfs_h *g, const char *key, void *data); @@ -1025,7 +1031,7 @@ trace_send_line (guestfs_h *g) 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 @@ -1371,9 +1377,12 @@ trace_send_line (guestfs_h *g) (* 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 @@ -1394,7 +1403,7 @@ trace_send_line (guestfs_h *g) 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"; @@ -1451,7 +1460,7 @@ trace_send_line (guestfs_h *g) 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" | _ -> () @@ -1484,6 +1493,7 @@ and generate_linker_script () = "guestfs_set_private"; "guestfs_set_progress_callback"; "guestfs_set_subprocess_quit_callback"; + "guestfs_user_cancel"; (* Unofficial parts of the API: the bindings code use these * functions, so it is useful to export them.