- ) (List.combine (snd style) args);
-
- let error_code =
- match fst style with
- | RErr | RInt _ | RBool _ -> pr " int r;\n"; "-1"
- | RInt64 _ -> pr " int64_t r;\n"; "-1"
- | RConstString _ | RConstOptString _ ->
- pr " const char *r;\n"; "NULL"
- | RString _ -> pr " char *r;\n"; "NULL"
- | RStringList _ | RHashtable _ ->
- pr " char **r;\n";
- pr " size_t i;\n";
- "NULL"
- | RStruct (_, typ) ->
- pr " struct guestfs_%s *r;\n" typ; "NULL"
- | RStructList (_, typ) ->
- pr " struct guestfs_%s_list *r;\n" typ; "NULL"
- | RBufferOut _ ->
- pr " char *r;\n";
- pr " size_t size;\n";
- "NULL" in
+ | Pointer _, _ ->
+ (* Difficult to make these pointers in order to run a test. *)
+ assert false
+ ) args;
+
+ (* Currently can only deal with a complete, in-order list of optargs. *)
+ if optargs <> [] then (
+ pr " struct guestfs_%s_argv optargs;\n" name;
+ let len = List.length style_optargs in
+ let bitmask = Int64.pred (Int64.shift_left 1L len) in
+ pr " optargs.bitmask = UINT64_C(0x%Lx);\n" bitmask;
+ List.iter (
+ function
+ | Bool n, arg
+ | Int n, arg
+ | Int64 n, arg ->
+ pr " optargs.%s = %s;\n" n arg
+ | String n, arg ->
+ pr " optargs.%s = \"%s\";\n" n (c_quote arg);
+ | _ -> assert false
+ ) optargs;
+ );
+
+ (match style_ret with
+ | RErr | RInt _ | RBool _ -> pr " int r;\n"
+ | RInt64 _ -> pr " int64_t r;\n"
+ | RConstString _ | RConstOptString _ ->
+ pr " const char *r;\n"
+ | RString _ -> pr " char *r;\n"
+ | RStringList _ | RHashtable _ ->
+ pr " char **r;\n";
+ pr " size_t i;\n"
+ | RStruct (_, typ) ->
+ pr " struct guestfs_%s *r;\n" typ
+ | RStructList (_, typ) ->
+ pr " struct guestfs_%s_list *r;\n" typ
+ | RBufferOut _ ->
+ pr " char *r;\n";
+ pr " size_t size;\n"
+ );