implemented support for SKIP (~) files
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 6 Apr 2004 08:43:20 +0000 (08:43 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 6 Apr 2004 08:43:20 +0000 (08:43 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1423 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib_internal/matchlist-appendfiles.c
util-vserver/lib_internal/matchlist-compare.c
util-vserver/lib_internal/matchlist.h

index de2393a..73af1a0 100644 (file)
@@ -51,6 +51,7 @@ MatchList_appendFiles(struct MatchList *list, size_t idx,
       char     *file = files[i];
       switch (file[0]) {
        case '+'        :  ptr->type = stINCLUDE; ++file; break;
+       case '~'        :  ptr->type = stSKIP;    ++file; break;
        case '-'        :  ++file; /*@fallthrough@*/
        default         :  ptr->type = stEXCLUDE; break;
       }
index 7f15ec5..2cff7e2 100644 (file)
 #include "matchlist.h"
 #include <string.h>
 
-bool
+MatchType
 MatchList_compare(struct MatchList const *list, char const *path)
 {
-  bool                                 res = true;
   struct MatchItem const *             ptr = list->data;
   struct MatchItem const * const       end_ptr = list->data + list->count;
   
@@ -34,15 +33,9 @@ MatchList_compare(struct MatchList const *list, char const *path)
   //write(1, "\n", 1);
   for (; ptr<end_ptr; ++ptr) {
     if ((ptr->cmp==0 && strcmp(ptr->name, path)==0) ||
-       (ptr->cmp!=0 && (ptr->cmp)(ptr->name, path)==0)) {
-      switch (ptr->type) {
-       case stINCLUDE  :  res = true;  break;
-       case stEXCLUDE  :  res = false; break;
-       default         :  abort();
-      }
-      break;
-    }
+       (ptr->cmp!=0 && (ptr->cmp)(ptr->name, path)==0))
+      return ptr->type;
   }
 
-  return res;
+  return stINCLUDE;
 }
index 0e31517..d06e7bd 100644 (file)
 #include <stdbool.h>
 
 typedef int    (*MatchItemCompareFunc)(char const *, char const *);
+typedef enum { stINCLUDE,stEXCLUDE,stSKIP }    MatchType;
 
 struct MatchItem
 {
-    enum { stINCLUDE, stEXCLUDE }      type;
-    char const *                       name;
-    MatchItemCompareFunc               cmp;
+    MatchType                  type;
+    char const *               name;
+    MatchItemCompareFunc       cmp;
 };
 
 struct MatchList
@@ -62,7 +63,7 @@ void          MatchList_appendFiles(struct MatchList *, size_t idx,
                                      char **files, size_t count,
                                      bool auto_type) NONNULL((1,3));
 
-bool           MatchList_compare(struct MatchList const *,
+MatchType      MatchList_compare(struct MatchList const *,
                                  char const *path) NONNULL((1,2));
 struct MatchItem
 const *                MatchList_find(struct MatchList const *,