From 2efa92385562b68a61f71ebed2dd734ce4895073 Mon Sep 17 00:00:00 2001 From: the little girl Date: Fri, 10 Jan 2014 10:40:59 +0100 Subject: vaske vaske --- wiki.c | 30 +++++++++++++++--------------- 1 file 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); } -- cgit v1.0