Add Augeas.transform
[ocaml-augeas.git] / augeas-c.c
index b81c2b1..160fe34 100644 (file)
@@ -369,3 +369,19 @@ ocaml_augeas_set (value tv, value pathv, value valuev)
 
   CAMLreturn (Val_unit);
 }
+
+/* val transform : t -> string -> string -> transform_mode -> unit */
+CAMLprim value
+ocaml_augeas_transform (value tv, value lensv, value filev, value modev)
+{
+  CAMLparam4 (tv, lensv, filev, modev);
+  augeas_t t = Augeas_t_val (tv);
+  const char *lens = String_val (lensv);
+  const char *file = String_val (filev);
+  const int excl = Int_val (modev) == 1 ? 1 : 0;
+
+  if (aug_transform (t, lens, file, excl) == -1)
+    raise_error (t, "Augeas.transform");
+
+  CAMLreturn (Val_unit);
+}