diff options
author | the little girl <yui@blekksprut.net> | 2014-01-10 10:40:59 +0100 |
---|---|---|
committer | the little girl <yui@blekksprut.net> | 2014-01-10 10:40:59 +0100 |
commit | 2efa92385562b68a61f71ebed2dd734ce4895073 (patch) | |
tree | f7b1d944cbadea5557733c0acd4ccae0262cb8dd | |
parent | abfb23091bd2306c87ebdc8ac31e1d72329d668e (diff) | |
download | ukulele-2efa92385562b68a61f71ebed2dd734ce4895073.tar.xz |
vaske vaske
-rw-r--r-- | wiki.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -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); } |