We can now use the Guestfs.c_pointer method to access the underlying
guestfs_h *. So no need to use internal APIs for this.
---
customize/perl_edit-c.c | 12 +++---------
customize/perl_edit.ml | 5 +++--
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/customize/perl_edit-c.c b/customize/perl_edit-c.c
index 753d990..dd92b5a 100644
--- a/customize/perl_edit-c.c
+++ b/customize/perl_edit-c.c
@@ -25,16 +25,10 @@
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
+#include <caml/fail.h>
#include "file-edit.h"
-/**
- * We try to reuse the internals of the OCaml binding (for extracting
- * the guestfs handle, and raising errors); hopefully this should be safe,
- * as long as it's kept internal within the libguestfs sources.
- */
-#include "../ocaml/guestfs-c.h"
-
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
value
@@ -43,12 +37,12 @@ virt_customize_edit_file_perl (value verbosev, value gv, value filev,
{
CAMLparam4 (verbosev, gv, filev, exprv);
int r;
- guestfs_h *g = Guestfs_val (gv);
+ guestfs_h *g = (guestfs_h *) Int64_val (gv);
r = edit_file_perl (g, String_val (filev), String_val (exprv), NULL,
Bool_val (verbosev));
if (r == -1)
- guestfs_int_ocaml_raise_error (g, "edit_file_perl");
+ caml_failwith (guestfs_last_error (g) ? : "edit_file_perl: unknown
error");
CAMLreturn (Val_unit);
}
diff --git a/customize/perl_edit.ml b/customize/perl_edit.ml
index f1f06cc..992a001 100644
--- a/customize/perl_edit.ml
+++ b/customize/perl_edit.ml
@@ -18,6 +18,7 @@
open Common_utils
-external c_edit_file : verbose:bool -> Guestfs.t -> string -> string -> unit
+external c_edit_file : verbose:bool -> int64 -> string -> string -> unit
= "virt_customize_edit_file_perl"
-let edit_file g file expr = c_edit_file (verbose ()) g file expr
+let edit_file g file expr =
+ c_edit_file (verbose ()) (Guestfs.c_pointer g) file expr
--
2.7.4