diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-14 13:51:12 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-14 13:51:12 +0100 |
commit | 5365ebd501850ea10d9a5b28fc6480ea34dbe16d (patch) | |
tree | 3c3bedf7581ea8485db6f039f2633ee07361b031 /ocaml/guestfs_c_actions.c | |
parent | 161018ed1e90c796e6e099859979da02d5f3e410 (diff) | |
download | libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.tar.gz libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.tar.xz libguestfs-5365ebd501850ea10d9a5b28fc6480ea34dbe16d.zip |
Add 'command' and 'command-lines'. Fix args freeing in Perl bindings.
Diffstat (limited to 'ocaml/guestfs_c_actions.c')
-rw-r--r-- | ocaml/guestfs_c_actions.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index decb8383..356965dc 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -1689,3 +1689,55 @@ ocaml_guestfs_file (value gv, value pathv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_command (value gv, value argumentsv) +{ + CAMLparam2 (gv, argumentsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("command: used handle after closing it"); + + char **arguments = ocaml_guestfs_strings_val (argumentsv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_command (g, arguments); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (arguments); + if (r == NULL) + ocaml_guestfs_raise_error (g, "command"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_command_lines (value gv, value argumentsv) +{ + CAMLparam2 (gv, argumentsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("command_lines: used handle after closing it"); + + char **arguments = ocaml_guestfs_strings_val (argumentsv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_command_lines (g, arguments); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (arguments); + if (r == NULL) + ocaml_guestfs_raise_error (g, "command_lines"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + |