]> www.dolda2000.com Git - ashd.git/commitdiff
dirplex: Added a capture option to ignore captures of the root directory.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 15 Aug 2012 23:51:11 +0000 (01:51 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 15 Aug 2012 23:51:11 +0000 (01:51 +0200)
doc/dirplex.doc
src/dirplex/conf.c
src/dirplex/dirplex.c
src/dirplex/dirplex.h

index 9d2240d449063bae9a040e2c3ea7f452efc3cc43..a2dd61cdbb66500f0477b1edf87441020fe337c3 100644 (file)
@@ -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
 --------
 
index 84c035d204957e10e4d8650d3042760783c376c4..dec84b57287dba25f267c7d740864e1b303f8e87 100644 (file)
@@ -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 {
index 55b464801f3a28b0c3fc8f0101b6845f32ccac69..d6879573cd397d4be6152ba13a7ea06d5479b6c4 100644 (file)
@@ -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);
index d3011f56c0ae3788b0f82a374fc17d4e271470d9..14b5454a75200f4515bc8f337c0887406543a968 100644 (file)
@@ -18,6 +18,7 @@ struct config {
     struct pattern *patterns;
     char **index;
     char *capture;
+    int caproot;
 };
 
 struct rule {