X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex%2Fconf.c;h=8494050adecb658330055bd5e43302436ece5bd4;hb=7711283ce85263a4177b9d27762fd5a4bc5cee41;hp=ffa43138d6db56ed4c44c0a9dc6571fc6f497c60;hpb=a756e349cf57ac9468161439a1452490dc009c94;p=ashd.git diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index ffa4313..8494050 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 { @@ -329,7 +341,7 @@ struct config **getconfigs(char *file) return(ret = buf.b); } -struct child *findchild(char *file, char *name) +struct child *findchild(char *file, char *name, struct config **cf) { int i; struct config **cfs; @@ -337,10 +349,13 @@ struct child *findchild(char *file, char *name) cfs = getconfigs(file); for(i = 0; cfs[i] != NULL; i++) { - if((ch = getchild(cfs[i], name)) != NULL) - break; + if((ch = getchild(cfs[i], name)) != NULL) { + if(cf != NULL) + *cf = cfs[i]; + return(ch); + } } - return(ch); + return(NULL); } struct pattern *findmatch(char *file, int trydefault, int dir) @@ -350,6 +365,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++; @@ -381,6 +397,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)