freeca(cf->index);
if(cf->capture != NULL)
free(cf->capture);
+ if(cf->reparse != NULL)
+ free(cf->reparse);
free(cf);
}
cf->caproot = 0;
if((s->argc > 2) && strchr(s->argv[2], 'D'))
cf->caproot = 1;
+ } else if(!strcmp(s->argv[0], "reparse")) {
+ if(s->argc < 2) {
+ flog(LOG_WARNING, "%s:%i: missing argument to reparse declaration", s->file, s->lno);
+ continue;
+ }
+ if(cf->reparse != NULL)
+ free(cf->reparse);
+ cf->reparse = sstrdup(s->argv[1]);
+ cf->parsecomb = 0;
+ if((s->argc > 2) && strchr(s->argv[2], 'c'))
+ cf->parsecomb = 1;
} else if(!strcmp(s->argv[0], "eof")) {
break;
} else {
static int checkdir(struct hthead *req, int fd, char *path, char *rest)
{
- char *cpath;
+ char *cpath, *newpath;
struct config *cf, *ccf;
struct child *ch;
+ struct stat sb;
+ int rv;
cf = getconfig(path);
if((cf->capture != NULL) && (cf->caproot || !cf->path || strcmp(cf->path, "."))) {
childerror(req, fd);
return(1);
}
+ if(cf->reparse != NULL) {
+ newpath = (cf->reparse[0] == '/')?sstrdup(cf->reparse):sprintf2("%s/%s", path, cf->reparse);
+ rv = stat(newpath, &sb);
+ if(!rv && S_ISDIR(sb.st_mode)) {
+ rv = checkpath(req, fd, newpath, rest, !cf->parsecomb);
+ } else if(!rv && S_ISREG(sb.st_mode)) {
+ replrest(req, rest);
+ handlefile(req, fd, newpath);
+ rv = 1;
+ } else {
+ rv = !cf->parsecomb;
+ }
+ free(newpath);
+ if(rv)
+ return(rv);
+ }
return(0);
}
struct child *children;
struct pattern *patterns;
char **index;
- char *capture;
- int caproot;
+ char *capture, *reparse;
+ int caproot, parsecomb;
};
struct rule {