From: Jim Meyering <meyering(a)redhat.com>
---
src/generator.ml | 67 +++++++++++++++++++++++++++++++++++------------------
1 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/src/generator.ml b/src/generator.ml
index 8d16945..8159027 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -134,6 +134,7 @@ and args = argt list (* Function parameters, guestfs handle is
implicit. *)
*)
and argt =
| String of string (* const char *name, cannot be NULL *)
+ | Device of string (* /dev device name, cannot be NULL *)
| OptString of string (* const char *name, may be NULL *)
| StringList of string(* list of strings (each string cannot be NULL) *)
| Bool of string (* boolean *)
@@ -1634,7 +1635,7 @@ C<path> should be a file or directory in the mounted file
system
This is the same as the C<statvfs(2)> system call.");
- ("tune2fs_l", (RHashtable "superblock", [String
"device"]), 55, [],
+ ("tune2fs_l", (RHashtable "superblock", [Device
"device"]), 55, [],
[], (* XXX test *)
"get ext2/ext3/ext4 superblock details",
"\
@@ -3726,7 +3727,7 @@ let mapi f xs =
loop 0 xs
let name_of_argt = function
- | String n | OptString n | StringList n | Bool n | Int n
+ | Device n | String n | OptString n | StringList n | Bool n | Int n
| FileIn n | FileOut n -> n
let java_name_of_struct typ =
@@ -4113,7 +4114,7 @@ and generate_xdr () =
pr "struct %s_args {\n" name;
List.iter (
function
- | String n -> pr " string %s<>;\n" n
+ | Device 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
@@ -4474,7 +4475,8 @@ check_state (guestfs_h *g, const char *caller)
| args ->
List.iter (
function
- | String n ->
+ (* FIXME *)
+ | Device n | String n ->
pr " args.%s = (char *) %s;\n" n n
| OptString n ->
pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
@@ -4683,7 +4685,8 @@ and generate_daemon_actions () =
* allow device name translation. This is safe because
* we can modify the string (passed from RPC).
*)
- | String n
+ (* FIXME *)
+ | Device n | String n
| OptString n -> pr " char *%s;\n" n
| StringList n -> pr " char **%s;\n" n
| Bool n -> pr " int %s;\n" n
@@ -4704,7 +4707,7 @@ and generate_daemon_actions () =
pr " }\n";
List.iter (
function
- | String n -> pr " %s = args.%s;\n" n n
+ | Device n | String n -> pr " %s = args.%s;\n" n n
| OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n
n
| StringList n ->
pr " %s = realloc (args.%s.%s_val,\n" n n n;
@@ -5608,6 +5611,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
List.iter (
function
| OptString n, "NULL" -> ()
+ | Device n, arg
| String n, arg
| OptString n, arg ->
pr " const char *%s = \"%s\";\n" n (c_quote arg);
@@ -5655,6 +5659,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
List.iter (
function
| OptString _, "NULL" -> pr ", NULL"
+ | Device n, _
| String n, _
| OptString n, _ ->
pr ", %s" n
@@ -5903,6 +5908,7 @@ and generate_fish_cmds () =
);
List.iter (
function
+ | Device n
| String n
| OptString n
| FileIn n
@@ -5923,7 +5929,7 @@ and generate_fish_cmds () =
iteri (
fun i ->
function
- | String name -> pr " %s = argv[%d];\n" name i
+ | Device 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
@@ -6156,7 +6162,7 @@ and generate_fish_actions_pod () =
pr " %s" name;
List.iter (
function
- | String n -> pr " %s" n
+ | Device n | String n -> pr " %s" n
| OptString n -> pr " %s" n
| StringList n -> pr " '%s ...'" n
| Bool _ -> pr " true|false"
@@ -6222,9 +6228,11 @@ and generate_prototype ?(extern = true) ?(static = false)
?(semicolon = true)
in
List.iter (
function
+ | Device n
| String n
| OptString n ->
next ();
+(* FIXME *)
if not in_daemon then pr "const char *%s" n
else pr "char *%s" n
| StringList n ->
@@ -6484,6 +6492,7 @@ copy_table (char * const * argv)
List.iter (
function
+ | Device n
| String n
| FileIn n
| FileOut n ->
@@ -6536,7 +6545,8 @@ copy_table (char * const * argv)
function
| StringList n ->
pr " ocaml_guestfs_free_strings (%s);\n" n;
- | String _ | OptString _ | Bool _ | Int _ | FileIn _ | FileOut _ -> ()
+ | Device _ | String _ | OptString _ | Bool _ | Int _
+ | FileIn _ | FileOut _ -> ()
) (snd style);
pr " if (r == %s)\n" error_code;
@@ -6619,7 +6629,7 @@ and generate_ocaml_prototype ?(is_external = false) name style =
pr "%s : t -> " name;
List.iter (
function
- | String _ | FileIn _ | FileOut _ -> pr "string -> "
+ | Device _ | String _ | FileIn _ | FileOut _ -> pr "string -> "
| OptString _ -> pr "string option -> "
| StringList _ -> pr "string array -> "
| Bool _ -> pr "bool -> "
@@ -6764,7 +6774,7 @@ DESTROY (g)
iteri (
fun i ->
function
- | String n | FileIn n | FileOut n -> pr " char *%s;\n" n
+ | Device n | String n | FileIn n | FileOut n -> pr " char
*%s;\n" n
| OptString n ->
(*
http://www.perlmonks.org/?node_id=554277
* Note that the implicit handle argument means we have
@@ -6779,7 +6789,7 @@ DESTROY (g)
let do_cleanups () =
List.iter (
function
- | String _ | OptString _ | Bool _ | Int _
+ | Device _ | String _ | OptString _ | Bool _ | Int _
| FileIn _ | FileOut _ -> ()
| StringList n -> pr " free (%s);\n" n
) (snd style)
@@ -7151,7 +7161,8 @@ and generate_perl_prototype name style =
if !comma then pr ", ";
comma := true;
match arg with
- | String n | OptString n | Bool n | Int n | FileIn n | FileOut n ->
+ | Device n | String n
+ | OptString n | Bool n | Int n | FileIn n | FileOut n ->
pr "$%s" n
| StringList n ->
pr "\\@%s" n
@@ -7398,7 +7409,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | String n | FileIn n | FileOut n -> pr " const char *%s;\n" n
+ | Device n | String n | FileIn n | FileOut n -> pr " const char
*%s;\n" n
| OptString n -> pr " const char *%s;\n" n
| StringList n ->
pr " PyObject *py_%s;\n" n;
@@ -7413,7 +7424,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
function
- | String _ | FileIn _ | FileOut _ -> pr "s"
+ | Device _ | String _ | FileIn _ | FileOut _ -> pr "s"
| OptString _ -> pr "z"
| StringList _ -> pr "O"
| Bool _ -> pr "i" (* XXX Python has booleans? *)
@@ -7423,7 +7434,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " &py_g";
List.iter (
function
- | String n | FileIn n | FileOut n -> pr ", &%s" n
+ | Device 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
@@ -7436,7 +7447,8 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " g = get_handle (py_g);\n";
List.iter (
function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | Device _ | String _
+ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " %s = get_string_list (py_%s);\n" n n;
pr " if (!%s) return NULL;\n" n
@@ -7450,7 +7462,8 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | Device _ | String _
+ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
) (snd style);
@@ -7758,7 +7771,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | String n | FileIn n | FileOut n ->
+ | Device 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;
@@ -7810,7 +7823,8 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | String _ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
+ | Device _ | String _
+ | FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
) (snd style);
@@ -8120,6 +8134,7 @@ and generate_java_prototype ?(public=false) ?(privat=false)
?(native=false)
needs_comma := true;
match arg with
+ | Device n
| String n
| OptString n
| FileIn n
@@ -8237,6 +8252,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
pr " (JNIEnv *env, jobject obj, jlong jg";
List.iter (
function
+ | Device n
| String n
| OptString n
| FileIn n
@@ -8288,6 +8304,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
"NULL", "NULL" in
List.iter (
function
+ | Device n
| String n
| OptString n
| FileIn n
@@ -8316,6 +8333,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* Get the parameters. *)
List.iter (
function
+ | Device n
| String n
| FileIn n
| FileOut n ->
@@ -8347,6 +8365,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
(* Release the parameters. *)
List.iter (
function
+ | Device n
| String n
| FileIn n
| FileOut n ->
@@ -8621,7 +8640,7 @@ last_error h = do
function
| FileIn n
| FileOut n
- | String n -> pr "withCString %s $ \\%s -> " n n
+ | Device 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 _ -> ()
@@ -8632,7 +8651,8 @@ last_error h = do
function
| Bool n -> sprintf "(fromBool %s)" n
| Int n -> sprintf "(fromIntegral %s)" n
- | FileIn n | FileOut n | String n | OptString n | StringList n -> n
+ | FileIn n | FileOut n
+ | Device n | String n | OptString n | StringList n -> n
) (snd style) in
pr "withForeignPtr h (\\p -> c_%s %s)\n" name
(String.concat " " ("p" :: args));
@@ -8682,7 +8702,7 @@ and generate_haskell_prototype ~handle ?(hs = false) style =
List.iter (
fun arg ->
(match arg with
- | String _ -> pr "%s" string
+ | Device _ | 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
@@ -8757,6 +8777,7 @@ print_strings (char * const* const argv)
pr "{\n";
List.iter (
function
+ | Device n
| String n
| FileIn n
| FileOut n -> pr " printf (\"%%s\\n\", %s);\n" n
--
1.6.4.337.g5420e