dirplex, patplex: Added a cosmetical `xset' directive to supplant `set'.
authorFredrik Tolf <fredrik@dolda2000.com>
Tue, 13 Dec 2011 18:50:52 +0000 (19:50 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Tue, 13 Dec 2011 18:50:52 +0000 (19:50 +0100)
doc/dirplex.doc
doc/patplex.doc
src/dirplex/conf.c
src/patplex.c

index 9f3aab2..fe21c7e 100644 (file)
@@ -261,8 +261,8 @@ following actions are recognized:
        by a *fchild* stanza. This action exists mostly for
        convenience.
 
-A *match* stanza may also contain any number of *set* lines, as
-follows:
+A *match* stanza may also contain any number of the following,
+optional directives:
 
 *set* 'HEADER' 'VALUE'::
 
@@ -270,6 +270,13 @@ follows:
        named HTTP 'HEADER' in the request is set to 'VALUE' before
        passing the request on to the specified handler.
 
+*xset* 'HEADER' 'VALUE'::
+
+       *xset* does exactly the same thing as *set*, except the
+         'HEADER' is automatically prepended with the `X-Ash-`
+         prefix. The intention is only to make configuration files
+         look nicer in this very common case.
+
 404 RESPONSES
 -------------
 
index d2ee009..f567d56 100644 (file)
@@ -111,6 +111,13 @@ optional lines:
        request on to the specified handler. A *match* stanza may
        contain any number of *set* lines.
 
+*xset* 'HEADER' 'VALUE'::
+
+       *xset* does exactly the same thing as *set*, except the
+         'HEADER' is automatically prepended with the `X-Ash-`
+         prefix. The intention is only to make configuration files
+         look nicer in this very common case.
+
 *restpat* 'TEMPLATE'::
 
        If the *match* stanza as a whole matches, 'TEMPLATE' is
index e2b1481..3f9f9e8 100644 (file)
@@ -185,13 +185,16 @@ static struct pattern *parsepattern(struct cfstate *s)
            pat->childnm = sstrdup(s->argv[1]);
        } else if(!strcmp(s->argv[0], "fork")) {
            pat->fchild = cadup(s->argv + 1);
-       } else if(!strcmp(s->argv[0], "set")) {
+       } else if(!strcmp(s->argv[0], "set") || !strcmp(s->argv[0], "xset")) {
            if(s->argc < 3) {
-               flog(LOG_WARNING, "%s:%i: missing header name or pattern for `set' directive", s->file, s->lno);
+               flog(LOG_WARNING, "%s:%i: missing header name or pattern for `%s' directive", s->file, s->lno, s->argv[0]);
                continue;
            }
            omalloc(head);
-           head->name = sstrdup(s->argv[1]);
+           if(!strcmp(s->argv[0], "xset"))
+               head->name = sprintf2("X-Ash-%s", s->argv[1]);
+           else
+               head->name = sstrdup(s->argv[1]);
            head->value = sstrdup(s->argv[2]);
            head->next = pat->headers;
            pat->headers = head;
index b03b626..5506386 100644 (file)
@@ -249,13 +249,16 @@ static struct pattern *parsepattern(struct cfstate *s)
            if(pat->restpat != NULL)
                free(pat->restpat);
            pat->restpat = sstrdup(s->argv[1]);
-       } else if(!strcmp(s->argv[0], "set")) {
+       } else if(!strcmp(s->argv[0], "set") || !strcmp(s->argv[0], "xset")) {
            if(s->argc < 3) {
-               flog(LOG_WARNING, "%s:%i: missing header name or pattern for `set' directive", s->file, s->lno);
+               flog(LOG_WARNING, "%s:%i: missing header name or pattern for `%s' directive", s->file, s->lno, s->argv[0]);
                continue;
            }
            omalloc(head);
-           head->name = sstrdup(s->argv[1]);
+           if(!strcmp(s->argv[0], "xset"))
+               head->name = sprintf2("X-Ash-%s", s->argv[1]);
+           else
+               head->name = sstrdup(s->argv[1]);
            head->value = sstrdup(s->argv[2]);
            head->next = pat->headers;
            pat->headers = head;