Generated code for new guestfs_read_lines API call.
[libguestfs.git] / ocaml / guestfs_c_actions.c
index 64a590f..80a891e 100644 (file)
@@ -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);
+}
+