]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - stra.c
Add extended wildcard matching
[repo_shell.git] / stra.c
diff --git a/stra.c b/stra.c
index 4e2f04b8395075c8fd6d978b99fb3f1ee0437003..232419af91fe7a39d9a6ec977147fd3629d44f36 100644 (file)
--- a/stra.c
+++ b/stra.c
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include "utility.h"
 #include "stra.h"
+#include "match.h"
 
 void stra_init(stra_t *stra, size_t size)
 {
@@ -61,6 +62,21 @@ int stra_add(stra_t *stra, const char *item)
   return stra->count++;
 }
 
+int stra_match(stra_t *stra, const char *item)
+{
+  unsigned i;
+
+  if (!stra)
+    die("stra_in: stra NULL reference");
+  if (!item)
+    die("stra_in: item is NULL");
+  for (i = 0; i < stra->count; i++) {
+    if (match(item, stra->items[i]))
+      return i;
+  }
+  return -1;
+}
+
 int stra_find(stra_t *stra, const char *item)
 {
   unsigned i;