Fix 'make dist' rule.
[ocaml-augeas.git] / augeas_c.c
index e070bc4..0b535d6 100644 (file)
@@ -1,5 +1,5 @@
 /* Augeas OCaml bindings
- * Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
+ * Copyright (C) 2008-2012 Red Hat Inc., Richard W.M. Jones
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -216,13 +216,13 @@ ocaml_augeas_match (value tv, value pathv)
   CAMLparam2 (tv, pathv);
   CAMLlocal3 (rv, v, cons);
   augeas_t t = Augeas_t_val (tv);
-  char *path = String_val (path);
+  char *path = String_val (pathv);
   char **matches;
   int r, i;
 
   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)