X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex%2Fconf.c;h=0bfa6f4b8fe454d042cf1b1981ed5722551c5bff;hb=HEAD;hp=3f9f9e88529650ae7baa167803da37a4028edc81;hpb=8cc893f5a55ad27a6971524b41e99589576eade5;p=ashd.git diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index 3f9f9e8..0bfa6f4 100644 --- a/src/dirplex/conf.c +++ b/src/dirplex/conf.c @@ -84,8 +84,11 @@ static void freeconfig(struct config *cf) freepattern(pat); } freeca(cf->index); + freeca(cf->dotallow); if(cf->capture != NULL) free(cf->capture); + if(cf->reparse != NULL) + free(cf->reparse); free(cf); } @@ -150,6 +153,10 @@ static struct pattern *parsepattern(struct cfstate *s) if((s->argc > 1) && !strcmp(s->argv[1], "directory")) pat->type = PT_DIR; + else if((s->argc > 1) && !strcmp(s->argv[1], "notfound")) + pat->type = PT_NOTFOUND; + else + pat->type = PT_FILE; sl = s->lno; while(1) { getcfline(s); @@ -251,9 +258,10 @@ struct config *readconfig(char *file) cf->patterns = pat; } else if(!strcmp(s->argv[0], "index-file")) { freeca(cf->index); - cf->index = NULL; - if(s->argc > 1) - cf->index = cadup(s->argv + 1); + cf->index = cadup(s->argv + 1); + } else if(!strcmp(s->argv[0], "dot-allow")) { + freeca(cf->dotallow); + cf->dotallow = 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); @@ -262,6 +270,20 @@ struct config *readconfig(char *file) if(cf->capture != NULL) free(cf->capture); cf->capture = sstrdup(s->argv[1]); + cf->caproot = 0; + if((s->argc > 2) && strchr(s->argv[2], 'D')) + cf->caproot = 1; + } else if(!strcmp(s->argv[0], "reparse")) { + if(s->argc < 2) { + flog(LOG_WARNING, "%s:%i: missing argument to reparse declaration", s->file, s->lno); + continue; + } + if(cf->reparse != NULL) + free(cf->reparse); + cf->reparse = sstrdup(s->argv[1]); + cf->parsecomb = 0; + if((s->argc > 2) && strchr(s->argv[2], 'c')) + cf->parsecomb = 1; } else if(!strcmp(s->argv[0], "eof")) { break; } else { @@ -329,6 +351,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,10 +393,10 @@ struct child *findchild(char *file, char *name, struct config **cf) return(NULL); } -struct pattern *findmatch(char *file, int trydefault, int dir) +struct pattern *findmatch(char *file, int trydefault, int type) { int i, o, c; - char *bn; + char *bn, *ln; struct config **cfs; struct pattern *pat; struct rule *rule; @@ -384,10 +408,17 @@ 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; - if(dir && (pat->type != PT_DIR)) + if(pat->type != type) continue; for(i = 0; (rule = pat->rules[i]) != NULL; i++) { if(rule->type == PAT_BASENAME) { @@ -399,7 +430,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) @@ -409,10 +440,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; } } @@ -421,7 +449,7 @@ struct pattern *findmatch(char *file, int trydefault, int dir) } } if(!trydefault) - return(findmatch(file, 1, dir)); + return(findmatch(file, 1, type)); return(NULL); }