X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fvunify-matchlist.c;h=1c52b0ccd9cafa43099d34e68c29e6a3a572e6c3;hb=4fc0d7c31dd9fb6bae2e77ba37d8a08ab26dd65c;hp=99454421584e2dc17ef77683545d2720abd6fb56;hpb=c3fec66a494a6b744a706700859b826da2f8bc4d;p=util-vserver.git diff --git a/util-vserver/src/vunify-matchlist.c b/util-vserver/src/vunify-matchlist.c index 9945442..1c52b0c 100644 --- a/util-vserver/src/vunify-matchlist.c +++ b/util-vserver/src/vunify-matchlist.c @@ -21,6 +21,9 @@ #endif #include "vunify-matchlist.h" +#include "wrappers.h" + +#include #include bool @@ -33,8 +36,8 @@ MatchList_compare(struct MatchList const *list, char const *path) //write(1, path, strlen(path)); //write(1, "\n", 1); for (; ptrcmp!=0); - if ((ptr->cmp)(ptr->name, path)==0) { + 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; @@ -53,8 +56,58 @@ MatchList_init(struct MatchList *list, char const *root, size_t count) list->skip_depth = 0; list->root.d = root; list->root.l = strlen(root); - list->data = malloc(sizeof(struct MatchItem) * count); + list->data = Emalloc(sizeof(struct MatchItem) * count); list->count = count; + list->buf = 0; + list->buf_count = 0; + + String_init(&list->id); +} + +static int +fnmatchWrap(char const *a, char const *b) +{ + return fnmatch(a, b, 0); +} + + +static MatchItemCompareFunc +determineCompareFunc(char const UNUSED *fname) +{ + return fnmatchWrap; +} + +void +MatchList_appendFiles(struct MatchList *list, size_t idx, + char **files, size_t count, + bool auto_type) +{ + struct MatchItem *ptr = list->data + idx; + size_t i; + + assert(idx+count <= list->count); + + if (auto_type) { + for (i=0; itype = stINCLUDE; ++file; break; + case '-' : ++file; /*@fallthrough@*/ + default : ptr->type = stEXCLUDE; break; + } + ptr->cmp = determineCompareFunc(file); + ptr->name = file; + ++ptr; + } + } + else { + for (i=0; itype = stEXCLUDE; + ptr->name = files[i]; + ptr->cmp = 0; + ++ptr; + } + } } @@ -88,6 +141,12 @@ PathInfo_append(PathInfo * restrict lhs, lhs->l = ptr-buf-1; } +void +String_init(String *str) +{ + str->d = 0; + str->l = 0; +} #ifdef ENSC_TESTSUITE #define CHECK(LHS,RHS, EXP) \