#include <utils.h>
#include <log.h>
#include <cf.h>
+#include <resp.h>
#include "dirplex.h"
return(cf);
}
-static void mergechildren(struct config *dst, struct config *src)
-{
- struct child *ch1, *ch2;
-
- for(ch1 = dst->children; ch1 != NULL; ch1 = ch1->next) {
- for(ch2 = src->children; ch2 != NULL; ch2 = ch2->next) {
- if(!strcmp(ch1->name, ch2->name)) {
- ch1->fd = ch2->fd;
- ch2->fd = -1;
- break;
- }
- }
- }
-}
-
struct config *getconfig(char *path)
{
struct config *cf, *ocf;
mtime = sb.st_mtime;
}
if(ocf != NULL) {
- mergechildren(cf, ocf);
+ mergechildren(cf->children, ocf->children);
freeconfig(ocf);
}
cf->path = sstrdup(path);
struct config **cfs;
struct child *ch;
+ if(cf != NULL)
+ *cf = NULL;
cfs = getconfigs(file);
for(i = 0; cfs[i] != NULL; i++) {
if((ch = getchild(cfs[i], name)) != NULL) {
return(ch);
}
}
+ if(!strcmp(name, ".notfound"))
+ return(notfound);
return(NULL);
}
return(findmatch(file, 1, dir));
return(NULL);
}
+
+static int donotfound(struct child *ch, struct hthead *req, int fd, void (*chinit)(void *), void *idata)
+{
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
+ return(0);
+}
+
+static struct chandler i_notfound = {
+ .handle = donotfound,
+};
+
+static struct child s_notfound = {
+ .name = ".notfound",
+ .iface = &i_notfound,
+};
+struct child *notfound = &s_notfound;