+static int checkdir(struct hthead *req, int fd, char *path, char *rest)
+{
+ 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, "."))) {
+ cpath = sprintf2("%s/", path);
+ if((ch = findchild(cpath, cf->capture, &ccf)) == NULL) {
+ free(cpath);
+ flog(LOG_ERR, "child %s requested for capture, but was not declared", cf->capture);
+ simpleerror(fd, 500, "Configuration Error", "The server is erroneously configured. Handler %s was requested, but not declared.", cf->capture);
+ return(1);
+ }
+ free(cpath);
+ if(*rest == '/')
+ rest++;
+ replrest(req, rest);
+ if(childhandle(ch, req, fd, chinit, ccf?ccf->path:NULL))
+ 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);
+}
+
+static int checkpath(struct hthead *req, int fd, char *path, char *rest, int final)