X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/fdf98378d2d8c8550661f657d30ec5186ff642f1..5e34540b562f91c7b383a307c32e1a159266dd11:/server/cgimain.c diff --git a/server/cgimain.c b/server/cgimain.c index 61f808f..b377c8e 100644 --- a/server/cgimain.c +++ b/server/cgimain.c @@ -33,13 +33,15 @@ #include "client.h" #include "sink.h" #include "cgi.h" -#include "dcgi.h" #include "mem.h" #include "log.h" #include "configuration.h" #include "disorder.h" #include "api-client.h" #include "mime.h" +#include "printf.h" +#include "dcgi.h" +#include "url.h" int main(int argc, char **argv) { const char *cookie_env, *conf; @@ -54,12 +56,14 @@ int main(int argc, char **argv) { if((conf = getenv("DISORDER_CONFIG"))) configfile = xstrdup(conf); if(getenv("DISORDER_DEBUG")) debugging = 1; if(config_read(0)) exit(EXIT_FAILURE); + if(!config->url) + config->url = infer_url(); memset(&g, 0, sizeof g); memset(&s, 0, sizeof s); s.g = &g; g.client = disorder_get_client(); output.quote = 1; - output.sink = sink_stdio("stdout", stdout); + output.sink = sink_stdio("stdout", stdout); /* See if there's a cookie */ cookie_env = getenv("HTTP_COOKIE"); if(cookie_env) { @@ -72,11 +76,8 @@ int main(int argc, char **argv) { login_cookie = cd.cookies[n].value; } } - /* Log in with the cookie if possible otherwise as guest */ - if(disorder_connect_cookie(g.client, login_cookie)) { - disorder_cgi_error(&output, &s, "connect"); - return 0; - } + disorder_cgi_login(&s, &output); + /* TODO RFC 3875 s8.2 recommendations e.g. concerning PATH_INFO */ disorder_cgi(&output, &s); if(fclose(stdout) < 0) fatal(errno, "error closing stdout"); return 0;