X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fgenerator.ml;h=532aba98a7257736943b84d7495e2964df2836fd;hp=607b6d16e33d5d6283268e04677684f830d96460;hb=2bec01ba1fcceb4880aa991e599920be9b68996a;hpb=946dc06bb861a38cae959416362e4561c9e4829a diff --git a/src/generator.ml b/src/generator.ml index 607b6d1..532aba9 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -19,17 +19,17 @@ (* This script generates a large amount of code and documentation for * all the daemon actions. - * + * * To add a new action there are only two files you need to change, * this one to describe the interface (see the big table of * 'daemon_functions' below), and daemon/.c to write the * implementation. - * + * * After editing this file, run it (./src/generator.ml) to regenerate * all the output files. 'make' will rerun this automatically when * necessary. Note that if you are using a separate build directory * you must run generator.ml from the _source_ directory. - * + * * IMPORTANT: This script should NOT print any warnings. If it prints * warnings, you should treat them as errors. * @@ -42,6 +42,7 @@ #load "unix.cma";; #load "str.cma";; #directory "+xml-light";; +#directory "+../pkg-lib/xml-light";; (* for GODI users *) #load "xml-light.cma";; open Unix @@ -544,13 +545,15 @@ handle is closed. We don't currently have any method to enable changes to be committed, although qemu can support this. This is equivalent to the qemu parameter -C<-drive file=filename,snapshot=on,if=...>. +C<-drive file=filename,snapshot=on,readonly=on,if=...>. C is set at compile time by the configuration option C<./configure --with-drive-if=...>. In the rare case where you might need to change this at run time, use C or C. +C is only added where qemu supports this option. + Note that this call checks for the existence of C. This stops you from specifying other types of drive which are supported by qemu such as C and C URLs. To specify those, use @@ -581,7 +584,15 @@ configure script. You can also override this by setting the C environment variable. -Setting C to C restores the default qemu binary."); +Setting C to C restores the default qemu binary. + +Note that you should call this function as early as possible +after creating the handle. This is because some pre-launch +operations depend on testing qemu features (by running C). +If the qemu binary changes, we don't retest features, and +so you might see inconsistent results. Using the environment +variable C is safest of all since that picks +the qemu binary at the same time as the handle is created."); ("get_qemu", (RConstString "qemu", []), -1, [], [InitNone, Always, TestRun ( @@ -2014,7 +2025,8 @@ The checksum is returned as a printable string."); This command uploads and unpacks local file C (an I tar file) into C. -To upload a compressed tarball, use C."); +To upload a compressed tarball, use C +or C."); ("tar_out", (RErr, [String "directory"; FileOut "tarfile"]), 70, [], [], @@ -2023,7 +2035,8 @@ To upload a compressed tarball, use C."); This command packs the contents of C and downloads it to local file C. -To download a compressed tarball, use C."); +To download a compressed tarball, use C +or C."); ("tgz_in", (RErr, [FileIn "tarball"; String "directory"]), 71, [], [InitBasicFS, Always, TestOutput ( @@ -2283,7 +2296,7 @@ How many blocks are zeroed isn't specified (but it's I enough to securely wipe the device). It should be sufficient to remove any partition tables, filesystem superblocks and so on. -See also: C."); +See also: C, C."); ("grub_install", (RErr, [Pathname "root"; Device "device"]), 86, [], (* Test disabled because grub-install incompatible with virtio-blk driver. @@ -4082,10 +4095,9 @@ but other possible values are described in C."); This sets the bootable flag on partition numbered C on device C. Note that partitions are numbered from 1. -The bootable flag is used by some PC BIOSes to determine which -partition to boot from. It is by no means universally recognized, -and in any case if your operating system installed a boot -sector on the device itself, then that takes precedence."); +The bootable flag is used by some operating systems (notably +Windows) to determine which partition to boot from. It is by +no means universally recognized."); ("part_set_name", (RErr, [Device "device"; Int "partnum"; String "name"]), 212, [], [InitEmpty, Always, TestRun ( @@ -4229,7 +4241,7 @@ example to duplicate a filesystem. If the destination is a device, it must be as large or larger than the source file or device, otherwise the copy will fail. -This command cannot do partial copies."); +This command cannot do partial copies (see C)."); ("filesize", (RInt64 "size", [Pathname "file"]), 218, [], [InitBasicFS, Always, TestOutputInt ( @@ -4263,7 +4275,7 @@ Rename a logical volume C with the new name C."); "\ Rename a volume group C with the new name C."); - ("initrd_cat", (RBufferOut "content", [Pathname "initrdpath"; String "filename"]), 221, [], + ("initrd_cat", (RBufferOut "content", [Pathname "initrdpath"; String "filename"]), 221, [ProtocolLimitWarning], [InitISOFS, Always, TestOutputBuffer ( [["initrd_cat"; "/initrd"; "known-4"]], "abc\ndef\nghi")], "list the contents of a single file in an initrd", @@ -4280,6 +4292,182 @@ contained in a Linux initrd or initramfs image: See also C."); + ("pvuuid", (RString "uuid", [Device "device"]), 222, [], + [], + "get the UUID of a physical volume", + "\ +This command returns the UUID of the LVM PV C."); + + ("vguuid", (RString "uuid", [String "vgname"]), 223, [], + [], + "get the UUID of a volume group", + "\ +This command returns the UUID of the LVM VG named C."); + + ("lvuuid", (RString "uuid", [Device "device"]), 224, [], + [], + "get the UUID of a logical volume", + "\ +This command returns the UUID of the LVM LV C."); + + ("vgpvuuids", (RStringList "uuids", [String "vgname"]), 225, [], + [], + "get the PV UUIDs containing the volume group", + "\ +Given a VG called C, this returns the UUIDs of all +the physical volumes that this volume group resides on. + +You can use this along with C and C +calls to associate physical volumes and volume groups. + +See also C."); + + ("vglvuuids", (RStringList "uuids", [String "vgname"]), 226, [], + [], + "get the LV UUIDs of all LVs in the volume group", + "\ +Given a VG called C, this returns the UUIDs of all +the logical volumes created in this volume group. + +You can use this along with C and C +calls to associate logical volumes and volume groups. + +See also C."); + + ("copy_size", (RErr, [Dev_or_Path "src"; Dev_or_Path "dest"; Int64 "size"]), 227, [], + [InitBasicFS, Always, TestOutputBuffer ( + [["write_file"; "/src"; "hello, world"; "0"]; + ["copy_size"; "/src"; "/dest"; "5"]; + ["read_file"; "/dest"]], "hello")], + "copy size bytes from source to destination using dd", + "\ +This command copies exactly C bytes from one source device +or file C to another destination device or file C. + +Note this will fail if the source is too short or if the destination +is not large enough."); + + ("zero_device", (RErr, [Device "device"]), 228, [DangerWillRobinson], + [InitBasicFSonLVM, Always, TestRun ( + [["zero_device"; "/dev/VG/LV"]])], + "write zeroes to an entire device", + "\ +This command writes zeroes over the entire C. Compare +with C which just zeroes the first few blocks of +a device."); + + ("txz_in", (RErr, [FileIn "tarball"; String "directory"]), 229, [], + [InitBasicFS, Always, TestOutput ( + [["txz_in"; "../images/helloworld.tar.xz"; "/"]; + ["cat"; "/hello"]], "hello\n")], + "unpack compressed tarball to directory", + "\ +This command uploads and unpacks local file C (an +I tar file) into C."); + + ("txz_out", (RErr, [Pathname "directory"; FileOut "tarball"]), 230, [], + [], + "pack directory into compressed tarball", + "\ +This command packs the contents of C and downloads +it to local file C (as an xz compressed tar archive)."); + + ("ntfsresize", (RErr, [Device "device"]), 231, [Optional "ntfsprogs"], + [], + "resize an NTFS filesystem", + "\ +This command resizes an NTFS filesystem, expanding or +shrinking it to the size of the underlying device. +See also L."); + + ("vgscan", (RErr, []), 232, [], + [InitEmpty, Always, TestRun ( + [["vgscan"]])], + "rescan for LVM physical volumes, volume groups and logical volumes", + "\ +This rescans all block devices and rebuilds the list of LVM +physical volumes, volume groups and logical volumes."); + + ("part_del", (RErr, [Device "device"; Int "partnum"]), 233, [], + [InitEmpty, Always, TestRun ( + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "primary"; "1"; "-1"]; + ["part_del"; "/dev/sda"; "1"]])], + "delete a partition", + "\ +This command deletes the partition numbered C on C. + +Note that in the case of MBR partitioning, deleting an +extended partition also deletes any logical partitions +it contains."); + + ("part_get_bootable", (RBool "bootable", [Device "device"; Int "partnum"]), 234, [], + [InitEmpty, Always, TestOutputTrue ( + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "primary"; "1"; "-1"]; + ["part_set_bootable"; "/dev/sda"; "1"; "true"]; + ["part_get_bootable"; "/dev/sda"; "1"]])], + "return true if a partition is bootable", + "\ +This command returns true if the partition C on +C has the bootable flag set. + +See also C."); + + ("part_get_mbr_id", (RInt "idbyte", [Device "device"; Int "partnum"]), 235, [], + [InitEmpty, Always, TestOutputInt ( + [["part_init"; "/dev/sda"; "mbr"]; + ["part_add"; "/dev/sda"; "primary"; "1"; "-1"]; + ["part_set_mbr_id"; "/dev/sda"; "1"; "0x7f"]; + ["part_get_mbr_id"; "/dev/sda"; "1"]], 0x7f)], + "get the MBR type byte (ID byte) from a partition", + "\ +Returns the MBR type byte (also known as the ID byte) from +the numbered partition C. + +Note that only MBR (old DOS-style) partitions have type bytes. +You will get undefined results for other partition table +types (see C)."); + + ("part_set_mbr_id", (RErr, [Device "device"; Int "partnum"; Int "idbyte"]), 236, [], + [], (* tested by part_get_mbr_id *) + "set the MBR type byte (ID byte) of a partition", + "\ +Sets the MBR type byte (also known as the ID byte) of +the numbered partition C to C. Note +that the type bytes quoted in most documentation are +in fact hexadecimal numbers, but usually documented +without any leading \"0x\" which might be confusing. + +Note that only MBR (old DOS-style) partitions have type bytes. +You will get undefined results for other partition table +types (see C)."); + + ("checksum_device", (RString "checksum", [String "csumtype"; Device "device"]), 237, [], + [InitISOFS, Always, TestOutput ( + [["checksum_device"; "md5"; "/dev/sdd"]], + (Digest.to_hex (Digest.file "images/test.iso")))], + "compute MD5, SHAx or CRC checksum of the contents of a device", + "\ +This call computes the MD5, SHAx or CRC checksum of the +contents of the device named C. For the types of +checksums supported see the C command."); + + ("lvresize_free", (RErr, [Device "lv"; Int "percent"]), 238, [Optional "lvm2"], + [InitNone, Always, TestRun ( + [["part_disk"; "/dev/sda"; "mbr"]; + ["pvcreate"; "/dev/sda1"]; + ["vgcreate"; "VG"; "/dev/sda1"]; + ["lvcreate"; "LV"; "VG"; "10"]; + ["lvresize_free"; "/dev/VG/LV"; "100"]])], + "expand an LV to fill free space", + "\ +This expands an existing logical volume C so that it fills +C% of the remaining free space in the volume group. Commonly +you would call this with pc = 100 which expands the logical volume +as much as possible, using all remaining free space in the volume +group."); + ] let all_functions = non_daemon_functions @ daemon_functions @@ -4704,8 +4892,7 @@ let seq_of_test = function (* Handling for function flags. *) let protocol_limit_warning = "Because of the message protocol, there is a transfer limit -of somewhere between 2MB and 4MB. To transfer large files you should use -FTP." +of somewhere between 2MB and 4MB. See L." let danger_will_robinson = "B #include #include +#include #include #include \"guestfs.h\" @@ -5810,7 +5997,7 @@ and generate_daemon_actions () = pr " memset (&args, 0, sizeof args);\n"; pr "\n"; pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name; - pr " reply_with_error (\"%%s: daemon failed to decode procedure arguments\", \"%s\");\n" name; + pr " reply_with_error (\"daemon failed to decode procedure arguments\");\n"; pr " return;\n"; pr " }\n"; let pr_args n = @@ -6080,7 +6267,7 @@ and generate_daemon_actions () = pr " ret->guestfs_int_lvm_%s_list_val = NULL;\n" typ; pr "\n"; pr " r = command (&out, &err,\n"; - pr " \"/sbin/lvm\", \"%ss\",\n" typ; + pr " \"lvm\", \"%ss\",\n" typ; pr " \"-o\", lvm_%s_cols, \"--unbuffered\", \"--noheadings\",\n" typ; pr " \"--nosuffix\", \"--separator\", \",\", \"--units\", \"b\", NULL);\n"; pr " if (r == -1) {\n"; @@ -6385,14 +6572,14 @@ int main (int argc, char *argv[]) exit (EXIT_FAILURE); } + /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */ + alarm (600); + if (guestfs_launch (g) == -1) { printf (\"guestfs_launch FAILED\\n\"); exit (EXIT_FAILURE); } - /* Set a timeout in case qemu hangs during launch (RHBZ#505329). */ - alarm (600); - /* Cancel previous alarm. */ alarm (0); @@ -6820,7 +7007,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = | Bool _, _ | FileIn _, _ | FileOut _, _ -> () | StringList n, "" | DeviceList n, "" -> - pr " const char *const %s[1] = { NULL };\n" n + pr " const char *const %s[1] = { NULL };\n" n | StringList n, arg | DeviceList n, arg -> let strs = string_split " " arg in iteri ( @@ -7223,7 +7410,7 @@ and generate_fish_cmds () = and comment = "The Int type in the generator is a signed 31 bit int." in Some (min, max, comment) in - parse_integer "xstrtol" "long" "int" range name i + parse_integer "xstrtoll" "long long" "int" range name i | Int64 name -> parse_integer "xstrtoll" "long long" "int64_t" None name i ) (snd style); @@ -7329,6 +7516,8 @@ and generate_fish_cmds () = ) all_functions; pr " {\n"; pr " fprintf (stderr, _(\"%%s: unknown command\\n\"), cmd);\n"; + pr " if (command_num == 1)\n"; + pr " extended_help_message ();\n"; pr " return -1;\n"; pr " }\n"; pr " return 0;\n"; @@ -7407,7 +7596,16 @@ generator (const char *text, int state) #endif /* HAVE_LIBREADLINE */ -char **do_completion (const char *text, int start, int end) +#ifdef HAVE_RL_COMPLETION_MATCHES +#define RL_COMPLETION_MATCHES rl_completion_matches +#else +#ifdef HAVE_COMPLETION_MATCHES +#define RL_COMPLETION_MATCHES completion_matches +#endif +#endif /* else just fail if we don't have either symbol */ + +char ** +do_completion (const char *text, int start, int end) { char **matches = NULL; @@ -7415,9 +7613,9 @@ char **do_completion (const char *text, int start, int end) rl_completion_append_character = ' '; if (start == 0) - matches = rl_completion_matches (text, generator); + matches = RL_COMPLETION_MATCHES (text, generator); else if (complete_dest_paths) - matches = rl_completion_matches (text, complete_dest_paths_generator); + matches = RL_COMPLETION_MATCHES (text, complete_dest_paths_generator); #endif return matches; @@ -8149,7 +8347,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (r == -1)\n"; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; | RInt n | RBool n -> pr "PREINIT:\n"; @@ -8160,7 +8358,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == -1)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSViv (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8173,7 +8371,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == -1)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = my_newSVll (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8186,7 +8384,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSVpv (%s, 0);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8213,7 +8411,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSVpv (%s, 0);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; @@ -8228,7 +8426,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " for (n = 0; %s[n] != NULL; ++n) /**/;\n" n; pr " EXTEND (SP, n);\n"; pr " for (i = 0; i < n; ++i) {\n"; @@ -8252,8 +8450,8 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; - pr " RETVAL = newSVpv (%s, size);\n" n; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; + pr " RETVAL = newSVpvn (%s, size);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8273,7 +8471,7 @@ and generate_perl_struct_list_code typ cols name style n do_cleanups = pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " EXTEND (SP, %s->len);\n" n; pr " for (i = 0; i < %s->len; ++i) {\n" n; pr " hv = newHV ();\n"; @@ -8286,7 +8484,7 @@ and generate_perl_struct_list_code typ cols name style n do_cleanups = pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, 32), 0);\n" name (String.length name) n name | name, FBuffer -> - pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, %s->val[i].%s_len), 0);\n" + pr " (void) hv_store (hv, \"%s\", %d, newSVpvn (%s->val[i].%s, %s->val[i].%s_len), 0);\n" name (String.length name) n name n name | name, (FBytes|FUInt64) -> pr " (void) hv_store (hv, \"%s\", %d, my_newSVull (%s->val[i].%s), 0);\n" @@ -8317,7 +8515,7 @@ and generate_perl_struct_code typ cols name style n do_cleanups = pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " EXTEND (SP, 2 * %d);\n" (List.length cols); List.iter ( fun ((name, _) as col) -> @@ -8328,7 +8526,7 @@ and generate_perl_struct_code typ cols name style n do_cleanups = pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 0)));\n" n name | name, FBuffer -> - pr " PUSHs (sv_2mortal (newSVpv (%s->%s, %s->%s_len)));\n" + pr " PUSHs (sv_2mortal (newSVpvn (%s->%s, %s->%s_len)));\n" n name n name | name, FUUID -> pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 32)));\n" @@ -8393,7 +8591,8 @@ schemes, qcow, qcow2, vmdk. Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, what filesystem is in each LV, etc.). It can also run commands -in the context of the guest. Also you can access filesystems over FTP. +in the context of the guest. Also you can access filesystems over +FUSE. See also L for a set of useful library functions for using libguestfs from Perl, including integration @@ -8930,7 +9129,8 @@ schemes, qcow, qcow2, vmdk. Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, what filesystem is in each LV, etc.). It can also run commands -in the context of the guest. Also you can access filesystems over FTP. +in the context of the guest. Also you can access filesystems over +FUSE. Errors which happen while using the API are turned into Python RuntimeError exceptions. @@ -10223,96 +10423,96 @@ namespace Guestfs List.iter ( fun (name, style, _, _, _, shortdesc, _) -> let rec csharp_return_type () = - match fst style with - | RErr -> "void" - | RBool n -> "bool" - | RInt n -> "int" - | RInt64 n -> "long" - | RConstString n - | RConstOptString n - | RString n - | RBufferOut n -> "string" - | RStruct (_,n) -> "_" ^ n - | RHashtable n -> "Hashtable" - | RStringList n -> "string[]" - | RStructList (_,n) -> sprintf "_%s[]" n + match fst style with + | RErr -> "void" + | RBool n -> "bool" + | RInt n -> "int" + | RInt64 n -> "long" + | RConstString n + | RConstOptString n + | RString n + | RBufferOut n -> "string" + | RStruct (_,n) -> "_" ^ n + | RHashtable n -> "Hashtable" + | RStringList n -> "string[]" + | RStructList (_,n) -> sprintf "_%s[]" n and c_return_type () = - match fst style with - | RErr - | RBool _ - | RInt _ -> "int" - | RInt64 _ -> "long" - | RConstString _ - | RConstOptString _ - | RString _ - | RBufferOut _ -> "string" - | RStruct (_,n) -> "_" ^ n - | RHashtable _ - | RStringList _ -> "string[]" - | RStructList (_,n) -> sprintf "_%s[]" n - + match fst style with + | RErr + | RBool _ + | RInt _ -> "int" + | RInt64 _ -> "long" + | RConstString _ + | RConstOptString _ + | RString _ + | RBufferOut _ -> "string" + | RStruct (_,n) -> "_" ^ n + | RHashtable _ + | RStringList _ -> "string[]" + | RStructList (_,n) -> sprintf "_%s[]" n + and c_error_comparison () = - match fst style with - | RErr - | RBool _ - | RInt _ - | RInt64 _ -> "== -1" - | RConstString _ - | RConstOptString _ - | RString _ - | RBufferOut _ - | RStruct (_,_) - | RHashtable _ - | RStringList _ - | RStructList (_,_) -> "== null" - + match fst style with + | RErr + | RBool _ + | RInt _ + | RInt64 _ -> "== -1" + | RConstString _ + | RConstOptString _ + | RString _ + | RBufferOut _ + | RStruct (_,_) + | RHashtable _ + | RStringList _ + | RStructList (_,_) -> "== null" + and generate_extern_prototype () = - pr " static extern %s guestfs_%s (IntPtr h" - (c_return_type ()) name; - List.iter ( - function - | Pathname n | Device n | Dev_or_Path n | String n | OptString n - | FileIn n | FileOut n -> + pr " static extern %s guestfs_%s (IntPtr h" + (c_return_type ()) name; + List.iter ( + function + | Pathname n | Device n | Dev_or_Path n | String n | OptString n + | FileIn n | FileOut n -> pr ", [In] string %s" n - | StringList n | DeviceList n -> + | StringList n | DeviceList n -> pr ", [In] string[] %s" n - | Bool n -> - pr ", bool %s" n - | Int n -> - pr ", int %s" n - | Int64 n -> - pr ", long %s" n - ) (snd style); - pr ");\n" + | Bool n -> + pr ", bool %s" n + | Int n -> + pr ", int %s" n + | Int64 n -> + pr ", long %s" n + ) (snd style); + pr ");\n" and generate_public_prototype () = - pr " public %s %s (" (csharp_return_type ()) name; - let comma = ref false in - let next () = - if !comma then pr ", "; - comma := true - in - List.iter ( - function - | Pathname n | Device n | Dev_or_Path n | String n | OptString n - | FileIn n | FileOut n -> + pr " public %s %s (" (csharp_return_type ()) name; + let comma = ref false in + let next () = + if !comma then pr ", "; + comma := true + in + List.iter ( + function + | Pathname n | Device n | Dev_or_Path n | String n | OptString n + | FileIn n | FileOut n -> next (); pr "string %s" n - | StringList n | DeviceList n -> + | StringList n | DeviceList n -> next (); pr "string[] %s" n - | Bool n -> - next (); pr "bool %s" n - | Int n -> - next (); pr "int %s" n - | Int64 n -> - next (); pr "long %s" n - ) (snd style); - pr ")\n" + | Bool n -> + next (); pr "bool %s" n + | Int n -> + next (); pr "int %s" n + | Int64 n -> + next (); pr "long %s" n + ) (snd style); + pr ")\n" and generate_call () = - pr "guestfs_%s (_handle" name; - List.iter (fun arg -> pr ", %s" (name_of_argt arg)) (snd style); - pr ");\n"; + pr "guestfs_%s (_handle" name; + List.iter (fun arg -> pr ", %s" (name_of_argt arg)) (snd style); + pr ");\n"; in pr " [DllImport (\"%s\")]\n" library; @@ -10327,8 +10527,7 @@ namespace Guestfs pr " r = "; generate_call (); pr " if (r %s)\n" (c_error_comparison ()); - pr " throw new Error (\"%s: \" + guestfs_last_error (_handle));\n" - name; + pr " throw new Error (guestfs_last_error (_handle));\n"; (match fst style with | RErr -> () | RBool _ ->