From: Fredrik Tolf Date: Wed, 15 Aug 2012 23:51:11 +0000 (+0200) Subject: dirplex: Added a capture option to ignore captures of the root directory. X-Git-Tag: 0.11~2 X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=commitdiff_plain;h=54490135194e0474e753ce7d4cb60f935dad1dd4 dirplex: Added a capture option to ignore captures of the root directory. --- diff --git a/doc/dirplex.doc b/doc/dirplex.doc index 9d2240d..a2dd61c 100644 --- a/doc/dirplex.doc +++ b/doc/dirplex.doc @@ -182,7 +182,7 @@ The following configuration directives are recognized: pattern-matching procedure and the follow-up lines accepted by this stanza are described below, under MATCHING. -*capture* 'HANDLER':: +*capture* 'HANDLER' ['FLAGS']:: Only meaningful in `.htrc` files. If a *capture* directive is specified, then the URL-to-file mapping procedure as described @@ -194,6 +194,10 @@ The following configuration directives are recognized: follow-up lines. Note that the `X-Ash-File` header is not added to requests passed via *capture* directives. + If 'FLAGS' contain the character `R`, this *capture* directive + will be ignored if it is in the root directory that *dirplex* + serves. + MATCHING -------- diff --git a/src/dirplex/conf.c b/src/dirplex/conf.c index 84c035d..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 { diff --git a/src/dirplex/dirplex.c b/src/dirplex/dirplex.c index 55b4648..d687957 100644 --- a/src/dirplex/dirplex.c +++ b/src/dirplex/dirplex.c @@ -244,7 +244,7 @@ static int checkdir(struct hthead *req, int fd, char *path, char *rest) struct child *ch; cf = getconfig(path); - if(cf->capture != NULL) { + if((cf->capture != NULL) && (cf->caproot || !cf->path || strcmp(cf->path, "."))) { cpath = sprintf2("%s/", path); if((ch = findchild(cpath, cf->capture, &ccf)) == NULL) { free(cpath); diff --git a/src/dirplex/dirplex.h b/src/dirplex/dirplex.h index d3011f5..14b5454 100644 --- a/src/dirplex/dirplex.h +++ b/src/dirplex/dirplex.h @@ -18,6 +18,7 @@ struct config { struct pattern *patterns; char **index; char *capture; + int caproot; }; struct rule {