X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=src%2Fdirplex%2Fconf.c;h=dec84b57287dba25f267c7d740864e1b303f8e87;hp=3f9f9e88529650ae7baa167803da37a4028edc81;hb=54490135194e0474e753ce7d4cb60f935dad1dd4;hpb=8cc893f5a55ad27a6971524b41e99589576eade5 diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index 3f9f9e8..dec84b5 100644 --- a/src/dirplex/conf.c +++ b/src/dirplex/conf.c @@ -262,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 { @@ -329,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) @@ -372,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; @@ -384,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; @@ -399,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) @@ -409,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; } }