summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-08 23:47:31 +0100
committerRichard Jones <rjones@redhat.com>2009-04-08 23:47:31 +0100
commitc168ce1c91c8f4f615ec53e140970e0017ad750d (patch)
treea4d3c6b3cbf4a42f5fa9cf6fdb33ecda27a2bfd6 /ocaml
parentf4299f7ea55c4bbc9302e102d2fc801829e75ef6 (diff)
downloadlibguestfs-c168ce1c91c8f4f615ec53e140970e0017ad750d.tar.gz
libguestfs-c168ce1c91c8f4f615ec53e140970e0017ad750d.tar.xz
libguestfs-c168ce1c91c8f4f615ec53e140970e0017ad750d.zip
Generated code for new guestfs_read_lines API call.
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c26
3 files changed, 30 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 3e9f172d..2504b45e 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -111,3 +111,4 @@ external lvs : t -> string array = "ocaml_guestfs_lvs"
external pvs_full : t -> lvm_pv array = "ocaml_guestfs_pvs_full"
external vgs_full : t -> lvm_vg array = "ocaml_guestfs_vgs_full"
external lvs_full : t -> lvm_lv array = "ocaml_guestfs_lvs_full"
+external read_lines : t -> string -> string array = "ocaml_guestfs_read_lines"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index d1970ede..177f09e8 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -172,3 +172,6 @@ val vgs_full : t -> lvm_vg array
val lvs_full : t -> lvm_lv array
(** list the LVM logical volumes (LVs) *)
+val read_lines : t -> string -> string array
+(** read file as lines *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 64a590fa..80a891e8 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -842,3 +842,29 @@ ocaml_guestfs_lvs_full (value gv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_read_lines (value gv, value pathv)
+{
+ CAMLparam2 (gv, pathv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("read_lines: used handle after closing it");
+
+ const char *path = String_val (pathv);
+ int i;
+ char **r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_read_lines (g, path);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "read_lines");
+
+ rv = caml_copy_string_array ((const char **) r);
+ for (i = 0; r[i] != NULL; ++i) free (r[i]);
+ free (r);
+ CAMLreturn (rv);
+}
+