diff options
author | Richard Jones <rjones@redhat.com> | 2009-05-08 14:28:03 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-05-08 14:28:03 +0100 |
commit | 0faa5dde7b992ba11bb88f77b3424676c7c492e4 (patch) | |
tree | 14948be793fca09223d7ca3022b9ac7e1fbebd81 /ocaml | |
parent | fa7c8bb79b45aecdf65ed93635a42f3fdf301134 (diff) | |
download | libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.tar.gz libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.tar.xz libguestfs-0faa5dde7b992ba11bb88f77b3424676c7c492e4.zip |
Generated code to support previous 2 commits.
Diffstat (limited to 'ocaml')
-rw-r--r-- | ocaml/guestfs.ml | 3 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 9 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 77 |
3 files changed, 89 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 99d59037..ab958b70 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -229,3 +229,6 @@ external drop_caches : t -> int -> unit = "ocaml_guestfs_drop_caches" external dmesg : t -> string = "ocaml_guestfs_dmesg" external ping_daemon : t -> unit = "ocaml_guestfs_ping_daemon" external equal : t -> string -> string -> bool = "ocaml_guestfs_equal" +external strings : t -> string -> string array = "ocaml_guestfs_strings" +external strings_e : t -> string -> string -> string array = "ocaml_guestfs_strings_e" +external hexdump : t -> string -> string = "ocaml_guestfs_hexdump" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 40d1d2a4..d44fb060 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -466,3 +466,12 @@ val ping_daemon : t -> unit val equal : t -> string -> string -> bool (** test if two files have equal contents *) +val strings : t -> string -> string array +(** print the printable strings in a file *) + +val strings_e : t -> string -> string -> string array +(** print the printable strings in a file *) + +val hexdump : t -> string -> string +(** dump a file in hexadecimal *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 7732e1c6..a707897a 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -3034,3 +3034,80 @@ ocaml_guestfs_equal (value gv, value file1v, value file2v) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_strings (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("strings: used handle after closing it"); + + const char *path = String_val (pathv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_strings (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "strings"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_strings_e (value gv, value encodingv, value pathv) +{ + CAMLparam3 (gv, encodingv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("strings_e: used handle after closing it"); + + const char *encoding = String_val (encodingv); + const char *path = String_val (pathv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_strings_e (g, encoding, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "strings_e"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_hexdump (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("hexdump: used handle after closing it"); + + const char *path = String_val (pathv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_hexdump (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "hexdump"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + |