X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex%2Fconf.c;h=b90163a20a1d391130d3b7669bc777012d086673;hb=1924fe8c26de2861744fd576631ad15da2759f51;hp=e40a44542043648f1919904049022d28c674f3c1;hpb=da75c835b71b9ed9cf1d2c8fcbcfb7631dd24a05;p=ashd.git diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index e40a445..b90163a 100644 --- a/src/dirplex/conf.c +++ b/src/dirplex/conf.c @@ -76,6 +76,8 @@ static void freeconfig(struct config *cf) freepattern(pat); } freeca(cf->index); + if(cf->capture != NULL) + free(cf->capture); free(cf); } @@ -162,6 +164,8 @@ static struct pattern *parsepattern(struct cfstate *s) newrule(pat)->type = PAT_ALL; } else if(!strcmp(s->argv[0], "default")) { newrule(pat)->type = PAT_DEFAULT; + } else if(!strcmp(s->argv[0], "local")) { + newrule(pat)->type = PAT_LOCAL; } else if(!strcmp(s->argv[0], "handler")) { if(s->argc < 2) { flog(LOG_WARNING, "%s:%i: missing child name for `handler' directive", s->file, s->lno); @@ -228,6 +232,14 @@ struct config *readconfig(char *file) cf->index = NULL; if(s->argc > 1) cf->index = cadup(s->argv + 1); + } else if(!strcmp(s->argv[0], "capture")) { + if(s->argc < 2) { + flog(LOG_WARNING, "%s:%i: missing argument to capture declaration", s->file, s->lno); + continue; + } + if(cf->capture != NULL) + free(cf->capture); + cf->capture = sstrdup(s->argv[1]); } else if(!strcmp(s->argv[0], "eof")) { break; } else { @@ -240,21 +252,6 @@ struct config *readconfig(char *file) return(cf); } -static void mergechildren(struct config *dst, struct config *src) -{ - struct child *ch1, *ch2; - - for(ch1 = dst->children; ch1 != NULL; ch1 = ch1->next) { - for(ch2 = src->children; ch2 != NULL; ch2 = ch2->next) { - if(!strcmp(ch1->name, ch2->name)) { - ch1->fd = ch2->fd; - ch2->fd = -1; - break; - } - } - } -} - struct config *getconfig(char *path) { struct config *cf, *ocf; @@ -283,7 +280,7 @@ struct config *getconfig(char *path) mtime = sb.st_mtime; } if(ocf != NULL) { - mergechildren(cf, ocf); + mergechildren(cf->children, ocf->children); freeconfig(ocf); } cf->path = sstrdup(path); @@ -353,6 +350,7 @@ struct pattern *findmatch(char *file, int trydefault, int dir) struct config **cfs; struct pattern *pat; struct rule *rule; + size_t pl; if((bn = strrchr(file, '/')) != NULL) bn++; @@ -384,6 +382,12 @@ struct pattern *findmatch(char *file, int trydefault, int dir) } else if(rule->type == PAT_DEFAULT) { if(!trydefault) break; + } else if(rule->type == PAT_LOCAL) { + if(cfs[c]->path == NULL) + break; + pl = strlen(cfs[c]->path); + if(!((strlen(file) > pl) && !strncmp(file, cfs[c]->path, pl) && (file[pl] == '/') && !strchr(file + pl + 1, '/'))) + break; } } if(!rule)