X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fvunify-matchlist.c;h=2801aa3c96207d8d79fc338e9ffc1120bd39c280;hb=71f059c02b443b53f1e08143a03b13513fb63bbd;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..2801aa3 100644 --- a/util-vserver/src/vunify-matchlist.c +++ b/util-vserver/src/vunify-matchlist.c @@ -21,8 +21,13 @@ #endif #include "vunify-matchlist.h" + +#include #include +#define ENSC_WRAPPERS_STDLIB 1 +#include + bool MatchList_compare(struct MatchList const *list, char const *path) { @@ -33,8 +38,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 +58,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 +143,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) \