summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-20 10:19:45 +0100
committerRichard Jones <rjones@redhat.com>2009-04-20 10:19:45 +0100
commit24ccbb29ac475187f51a27dcd318db2b4824a0c1 (patch)
treeecb06a1b2985b33b7bdd8dad6e222a380b274ac5 /ocaml
parentaef3d2013fee188c9607f35657c45df88503cd64 (diff)
downloadlibguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.gz
libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.xz
libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.zip
Generated code for 'checksum' command.
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c25
3 files changed, 29 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 09b12b1c..337555c9 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -201,3 +201,4 @@ external blockdev_flushbufs : t -> string -> unit = "ocaml_guestfs_blockdev_flus
external blockdev_rereadpt : t -> string -> unit = "ocaml_guestfs_blockdev_rereadpt"
external upload : t -> string -> string -> unit = "ocaml_guestfs_upload"
external download : t -> string -> string -> unit = "ocaml_guestfs_download"
+external checksum : t -> string -> string -> string = "ocaml_guestfs_checksum"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index dfc17842..4fd05dad 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -382,3 +382,6 @@ val upload : t -> string -> string -> unit
val download : t -> string -> string -> unit
(** download a file to the local machine *)
+val checksum : t -> string -> string -> string
+(** compute MD5, SHAx or CRC checksum of file *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 138f0fd1..882d5052 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -2367,3 +2367,28 @@ ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_checksum (value gv, value csumtypev, value pathv)
+{
+ CAMLparam3 (gv, csumtypev, pathv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("checksum: used handle after closing it");
+
+ const char *csumtype = String_val (csumtypev);
+ const char *path = String_val (pathv);
+ char *r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_checksum (g, csumtype, path);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "checksum");
+
+ rv = caml_copy_string (r);
+ free (r);
+ CAMLreturn (rv);
+}
+