X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=src%2Fdirplex%2Fconf.c;h=dec84b57287dba25f267c7d740864e1b303f8e87;hp=e2b1481c4d3881898e8ec58747e5627542096008;hb=54490135194e0474e753ce7d4cb60f935dad1dd4;hpb=acc2d159e6f946ed6abc7c0e843a483d6478bee3 diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index e2b1481..dec84b5 100644 --- a/src/dirplex/conf.c +++ b/src/dirplex/conf.c @@ -185,13 +185,16 @@ static struct pattern *parsepattern(struct cfstate *s) pat->childnm = sstrdup(s->argv[1]); } else if(!strcmp(s->argv[0], "fork")) { pat->fchild = cadup(s->argv + 1); - } else if(!strcmp(s->argv[0], "set")) { + } else if(!strcmp(s->argv[0], "set") || !strcmp(s->argv[0], "xset")) { if(s->argc < 3) { - flog(LOG_WARNING, "%s:%i: missing header name or pattern for `set' directive", s->file, s->lno); + flog(LOG_WARNING, "%s:%i: missing header name or pattern for `%s' directive", s->file, s->lno, s->argv[0]); continue; } omalloc(head); - head->name = sstrdup(s->argv[1]); + if(!strcmp(s->argv[0], "xset")) + head->name = sprintf2("X-Ash-%s", s->argv[1]); + else + head->name = sstrdup(s->argv[1]); head->value = sstrdup(s->argv[2]); head->next = pat->headers; pat->headers = head; @@ -259,6 +262,9 @@ struct config *readconfig(char *file) if(cf->capture != NULL) free(cf->capture); cf->capture = sstrdup(s->argv[1]); + cf->caproot = 1; + if((s->argc > 2) && strchr(s->argv[2], 'R')) + cf->caproot = 0; } else if(!strcmp(s->argv[0], "eof")) { break; } else { @@ -326,6 +332,8 @@ struct config **getconfigs(char *file) if(ret != NULL) free(ret); bufinit(buf); + if(!strncmp(file, "./", 2)) + file += 2; tmp = sstrdup(file); while(1) { if((p = strrchr(tmp, '/')) == NULL) @@ -369,7 +377,7 @@ struct child *findchild(char *file, char *name, struct config **cf) struct pattern *findmatch(char *file, int trydefault, int dir) { int i, o, c; - char *bn; + char *bn, *ln; struct config **cfs; struct pattern *pat; struct rule *rule; @@ -381,6 +389,15 @@ struct pattern *findmatch(char *file, int trydefault, int dir) bn = file; cfs = getconfigs(file); for(c = 0; cfs[c] != NULL; c++) { + if(cfs[c]->path == NULL) { + ln = file; + } else { + pl = strlen(cfs[c]->path); + if((strlen(file) > pl) && !strncmp(file, cfs[c]->path, pl) && (file[pl] == '/')) + ln = file + pl + 1; + else + ln = file; /* This should only happen in the base directory. */ + } for(pat = cfs[c]->patterns; pat != NULL; pat = pat->next) { if(!dir && (pat->type == PT_DIR)) continue; @@ -396,7 +413,7 @@ struct pattern *findmatch(char *file, int trydefault, int dir) break; } else if(rule->type == PAT_PATHNAME) { for(o = 0; rule->patterns[o] != NULL; o++) { - if(!fnmatch(rule->patterns[o], file, FNM_PATHNAME)) + if(!fnmatch(rule->patterns[o], ln, FNM_PATHNAME)) break; } if(rule->patterns[o] == NULL) @@ -406,10 +423,7 @@ struct pattern *findmatch(char *file, int trydefault, int dir) 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, '/'))) + if(strchr(ln, '/')) break; } }