extern CAMLprim value ocaml_augeas_create (value rootv, value loadpathv, value flagsv);
extern CAMLprim value ocaml_augeas_close (value tv);
+extern CAMLprim value ocaml_augeas_defnode (value tv, value namev, value exprv, value valv);
extern CAMLprim value ocaml_augeas_defvar (value tv, value namev, value exprv);
extern CAMLprim value ocaml_augeas_get (value tv, value pathv);
extern CAMLprim value ocaml_augeas_exists (value tv, value pathv);
CAMLreturn (Val_unit);
}
+/* val defnode : t -> string -> string -> string option -> int * bool */
+CAMLprim value
+ocaml_augeas_defnode (value tv, value namev, value exprv, value valv)
+{
+ CAMLparam4 (tv, namev, exprv, valv);
+ CAMLlocal2 (optv, v);
+ augeas_t t = Augeas_t_val (tv);
+ const char *name = String_val (namev);
+ const char *expr = String_val (exprv);
+ const char *val = Optstring_val (valv);
+ int r, created;
+
+ r = aug_defnode (t, name, expr, val, &created);
+ if (r == -1) {
+ raise_error (t, "Augeas.defnode");
+ }
+
+ v = caml_alloc (2, 0);
+ Store_field (v, 0, Val_int (r));
+ Store_field (v, 1, Val_bool (created));
+
+ CAMLreturn (v);
+}
+
/* val defvar : t -> string -> string option -> int option */
CAMLprim value
ocaml_augeas_defvar (value tv, value namev, value exprv)
= "ocaml_augeas_create"
external close : t -> unit
= "ocaml_augeas_close"
+external defnode : t -> string -> string -> string option -> int * bool
+ = "ocaml_augeas_defnode"
external defvar : t -> string -> string option -> int option
= "ocaml_augeas_defvar"
external get : t -> path -> value option
Do not use the handle after closing it. *)
+val defnode : t -> string -> string -> string option -> int * bool
+ (** [defnode t name expr value] defines [name] whose value is the
+ result of evaluating [expr], which is a nodeset. *)
+
val defvar : t -> string -> string option -> int option
(** [defvar t name expr] defines [name] whose value is the result
of evaluating [expr], replacing the old value if existing.