+ /* Parse CGI arguments */
+ cgi_init();
+ /* We allow various things to be overridden from the environment. This is
+ * intended for debugging and is not a documented feature. */
+ if((conf = getenv("DISORDER_CONFIG")))
+ configfile = xstrdup(conf);
+ if(getenv("DISORDER_DEBUG"))
+ debugging = 1;
+ if(config_read(0))
+ exit(EXIT_FAILURE);
+ /* Figure out our URL. This can still be overridden from the config file if
+ * necessary but it shouldn't be necessary in ordinary installations. */
+ if(!config->url)
+ config->url = infer_url();
+ /* Pick up the cookie, if there is one */
+ dcgi_get_cookie();
+ /* Register expansions */
+ mx_register_builtin();
+ dcgi_expansions();
+ /* Update search path. We look in the config directory first and the data
+ * directory second, so that the latter overrides the former. */
+ mx_search_path(pkgconfdir);
+ mx_search_path(pkgdatadir);
+ /* Never cache anythging */
+ if(printf("Cache-Control: no-cache\n") < 0)
+ fatal(errno, "error writing to stdout");
+ /* Create the initial connection, trying the cookie if we found a suitable
+ * one. */
+ dcgi_login();
+ /* The main program... */
+ dcgi_action(NULL);
+ /* In practice if a write fails that probably means the web server went away,
+ * but we log it anyway. */
+ if(fclose(stdout) < 0)
+ fatal(errno, "error closing stdout");