Added Augeas.count_matches
[ocaml-augeas.git] / augeas_c.c
index e070bc4..3cc1021 100644 (file)
@@ -222,7 +222,7 @@ ocaml_augeas_match (value tv, value pathv)
 
   r = aug_match (t, path, &matches);
   if (r == -1)
-    raise_error ("Augeas.match");
+    raise_error ("Augeas.matches");
 
   /* Copy the paths to a list. */
   rv = Val_int (0);
@@ -240,6 +240,22 @@ ocaml_augeas_match (value tv, value pathv)
   CAMLreturn (rv);
 }
 
+/* val count_matches : t -> path -> int */
+CAMLprim value
+ocaml_augeas_count_matches (value tv, value pathv)
+{
+  CAMLparam2 (tv, pathv);
+  augeas_t t = Augeas_t_val (tv);
+  char *path = String_val (path);
+  int r;
+
+  r = aug_match (t, path, NULL);
+  if (r == -1)
+    raise_error ("Augeas.count_matches");
+
+  CAMLreturn (Val_int (r));
+}
+
 /* val save : t -> unit */
 CAMLprim value
 ocaml_augeas_save (value tv)