loop 0 xs
let name_of_argt = function
- | Pathname n | Device n | String n | OptString n | StringList n | Bool n | Int n
+ | Pathname n | Device n | Dev_or_Path n | String n | OptString n | StringList n | Bool n | Int n
| FileIn n | FileOut n -> n
let java_name_of_struct typ =
pr "struct %s_args {\n" name;
List.iter (
function
- | Pathname n | Device n | String n -> pr " string %s<>;\n" n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr " string %s<>;\n" n
| OptString n -> pr " str *%s;\n" n
| StringList n -> pr " str %s<>;\n" n
| Bool n -> pr " bool %s;\n" n
| args ->
List.iter (
function
- | Pathname n | Device n | String n ->
+ | Pathname n | Device n | Dev_or_Path n | String n ->
pr " args.%s = (char *) %s;\n" n n
| OptString n ->
pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
pr " struct guestfs_%s_args args;\n" name;
List.iter (
function
- | Device n
+ | Device n | Dev_or_Path n
| Pathname n
| String n -> ()
| OptString n -> pr " char *%s;\n" n
| Device n ->
pr " char *%s = args.%s;\n" n n;
pr " RESOLVE_DEVICE (%s, goto done);" n;
+ | Dev_or_Path n ->
+ pr " char *%s = args.%s;\n" n n;
+ pr " REQUIRE_ROOT_OR_RESOLVE_DEVICE (%s, goto done);" n;
| String n -> pr " char *%s = args.%s;\n" n n
| OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n n
| StringList n ->
| OptString n, "NULL" -> ()
| Pathname n, arg
| Device n, arg
+ | Dev_or_Path n, arg
| String n, arg
| OptString n, arg ->
pr " const char *%s = \"%s\";\n" n (c_quote arg);
function
| OptString _, "NULL" -> pr ", NULL"
| Pathname n, _
- | Device n, _
+ | Device n, _ | Dev_or_Path n, _
| String n, _
| OptString n, _ ->
pr ", %s" n
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
fun i ->
function
| Pathname name
- | Device name | String name -> pr " %s = argv[%d];\n" name i
+ | Device name | Dev_or_Path name | String name -> pr " %s = argv[%d];\n" name i
| OptString name ->
pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] : NULL;\n"
name i i
pr " %s" name;
List.iter (
function
- | Pathname n | Device n | String n -> pr " %s" n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr " %s" n
| OptString n -> pr " %s" n
| StringList n -> pr " '%s ...'" n
| Bool _ -> pr " true|false"
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n ->
next ();
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
function
| StringList n ->
pr " ocaml_guestfs_free_strings (%s);\n" n;
- | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | OptString _ | Bool _ | Int _
| FileIn _ | FileOut _ -> ()
) (snd style);
pr "%s : t -> " name;
List.iter (
function
- | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "string -> "
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | FileIn _ | FileOut _ -> pr "string -> "
| OptString _ -> pr "string option -> "
| StringList _ -> pr "string array -> "
| Bool _ -> pr "bool -> "
iteri (
fun i ->
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr " char *%s;\n" n
| OptString n ->
(* http://www.perlmonks.org/?node_id=554277
let do_cleanups () =
List.iter (
function
- | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | OptString _ | Bool _ | Int _
| FileIn _ | FileOut _ -> ()
| StringList n -> pr " free (%s);\n" n
) (snd style)
if !comma then pr ", ";
comma := true;
match arg with
- | Pathname n | Device n | String n
+ | Pathname n | Device n | Dev_or_Path n | String n
| OptString n | Bool n | Int n | FileIn n | FileOut n ->
pr "$%s" n
| StringList n ->
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr " const char *%s;\n" n
| OptString n -> pr " const char *%s;\n" n
| StringList n ->
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
function
- | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "s"
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | FileIn _ | FileOut _ -> pr "s"
| OptString _ -> pr "z"
| StringList _ -> pr "O"
| Bool _ -> pr "i" (* XXX Python has booleans? *)
pr " &py_g";
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n -> pr ", &%s" n
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n -> pr ", &%s" n
| OptString n -> pr ", &%s" n
| StringList n -> pr ", &py_%s" n
| Bool n -> pr ", &%s" n
pr " g = get_handle (py_g);\n";
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " %s = get_string_list (py_%s);\n" n n;
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr " Check_Type (%sv, T_STRING);\n" n;
pr " const char *%s = StringValueCStr (%sv);\n" n n;
pr " if (!%s)\n" n;
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
match arg with
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
function
| FileIn n
| FileOut n
- | Pathname n | Device n | String n -> pr "withCString %s $ \\%s -> " n n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr "withCString %s $ \\%s -> " n n
| OptString n -> pr "maybeWith withCString %s $ \\%s -> " n n
| StringList n -> pr "withMany withCString %s $ \\%s -> withArray0 nullPtr %s $ \\%s -> " n n n n
| Bool _ | Int _ -> ()
| Bool n -> sprintf "(fromBool %s)" n
| Int n -> sprintf "(fromIntegral %s)" n
| FileIn n | FileOut n
- | Pathname n | Device n | String n | OptString n | StringList n -> n
+ | Pathname n | Device n | Dev_or_Path n | String n | OptString n | StringList n -> n
) (snd style) in
pr "withForeignPtr h (\\p -> c_%s %s)\n" name
(String.concat " " ("p" :: args));
List.iter (
fun arg ->
(match arg with
- | Pathname _ | Device _ | String _ -> pr "%s" string
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ -> pr "%s" string
| OptString _ -> if hs then pr "Maybe String" else pr "CString"
| StringList _ -> if hs then pr "[String]" else pr "Ptr CString"
| Bool _ -> pr "%s" bool
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n -> pr " printf (\"%%s\\n\", %s);\n" n