aboutsummaryrefslogtreecommitdiff
path: root/wiki.c
diff options
context:
space:
mode:
authorthe little girl <yui@blekksprut.net>2014-01-10 10:40:59 +0100
committerthe little girl <yui@blekksprut.net>2014-01-10 10:40:59 +0100
commit2efa92385562b68a61f71ebed2dd734ce4895073 (patch)
treef7b1d944cbadea5557733c0acd4ccae0262cb8dd /wiki.c
parentabfb23091bd2306c87ebdc8ac31e1d72329d668e (diff)
downloadukulele-2efa92385562b68a61f71ebed2dd734ce4895073.tar.xz
vaske vaske
Diffstat (limited to 'wiki.c')
-rw-r--r--wiki.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/wiki.c b/wiki.c
index d788e91..d554a17 100644
--- a/wiki.c
+++ b/wiki.c
@@ -211,16 +211,15 @@ int view(char *path) {
}
int main(int argc, char **argv) {
- char *method = getenv("REQUEST_METHOD");
- char *page = getenv("PATH_INFO");
- char *query = getenv("QUERY_STRING");
+ char *page = getenv("PATH_INFO");
+ char *qstr = getenv("QUERY_STRING");
+ char *verb = getenv("REQUEST_METHOD");
- if(!page && argc > 1)
- page = argv[1];
- if(!query && argc > 2)
- query = argv[2];
+ if(!page && argc > 1) page = argv[1];
+ if(!qstr && argc > 2) qstr = argv[2];
+
+ if(!verb) verb = "GET";
- if(!method) method = "GET";
if(!script) script = getenv("SCRIPT_NAME");
if(!script) script = "";
if(!base) base = strdup(dirname(strdup(script)));
@@ -232,19 +231,20 @@ int main(int argc, char **argv) {
setenv("MARXUP_PREFIX", base, 1);
if(chdir("pages"))
- return problem(404, "Not found");
+ return problem(503, "Service unavailable");
- if(!strncmp(method, "POST", 4)) return post(page);
- while(query && *query) {
- switch(*query) {
+ if(!strncmp(verb, "POST", 4)) return post(page);
+ if(strchr(page, '*'))
+ return list(page, 0);
+
+ while(qstr && *qstr) {
+ switch(*qstr) {
case 'e': return edit(page);
case 't': return text(page);
// case 'p': return
}
- query++;
+ qstr++;
}
- if(strchr(page, '*'))
- return list(page, 0);
return view(page);
}