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 9d2240d..a2dd61c 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 84c035d..dec84b5 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 55b4648..d687957 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 d3011f5..14b5454 100644 (file)
@@ -18,6 +18,7 @@ struct config {
     struct pattern *patterns;
     char **index;
     char *capture;
+    int caproot;
 };
 
 struct rule {