diff options
-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); } |