Lines Matching refs:CGI
29 #include "cgi.h"
218 static NEOERR *_add_cgi_env_var (CGI *cgi, char *env, char *name)
227 err = hdf_set_buf (cgi->hdf, name, s);
288 static NEOERR *_parse_query (CGI *cgi, char *query)
325 if (!(cgi->ignore_empty_form_vars && (*v == '\0')))
330 obj = hdf_get_obj (cgi->hdf, buf);
357 err = hdf_set_value (cgi->hdf, buf, v);
376 static NEOERR *_parse_post_form (CGI *cgi)
382 l = hdf_get_value (cgi->hdf, "CGI.ContentLength", NULL);
387 cgi->data_expected = len;
405 return nerr_raise_errno (NERR_IO, "Short read on CGI POST input (%d < %d)",
411 return nerr_raise (NERR_IO, "Short read on CGI POST input (%d < %d)",
415 err = _parse_query (cgi, query);
420 static NEOERR *_parse_cookie (CGI *cgi)
427 err = hdf_get_copy (cgi->hdf, "HTTP.Cookie", &cookie, NULL);
431 err = hdf_set_value (cgi->hdf, "Cookie", cookie);
437 obj = hdf_get_obj (cgi->hdf, "Cookie");
482 static void _launch_debugger (CGI *cgi, char *display)
491 for (obj = hdf_get_child (cgi->hdf, "Config.Displays");
504 if ((debugger = hdf_get_value (cgi->hdf, "Config.Debugger", NULL)) == NULL)
522 static NEOERR *cgi_pre_parse (CGI *cgi)
531 snprintf (buf, sizeof(buf), "CGI.%s", CGIVars[x].hdf_name);
532 err = _add_cgi_env_var(cgi, CGIVars[x].env_name, buf);
540 err = _add_cgi_env_var(cgi, HTTPVars[x].env_name, buf);
544 err = _parse_cookie(cgi);
547 err = hdf_get_copy (cgi->hdf, "CGI.QueryString", &query, NULL);
551 err = _parse_query(cgi, query);
557 char *d = hdf_get_value(cgi->hdf, "Query.debug_pause", NULL);
558 char *d_p = hdf_get_value(cgi->hdf, "Config.DebugPassword", NULL);
560 if (hdf_get_int_value(cgi->hdf, "Config.DebugEnabled", 0) &&
570 display = hdf_get_value (cgi->hdf, "Query.xdisplay", NULL);
574 _launch_debugger(cgi, display);
582 NEOERR *cgi_register_parse_cb(CGI *cgi, const char *method, const char *ctype,
611 my_pcb->next = cgi->parse_callbacks;
612 cgi->parse_callbacks = my_pcb;
616 NEOERR *cgi_parse (CGI *cgi)
623 method = hdf_get_value (cgi->hdf, "CGI.RequestMethod", "GET");
624 type = hdf_get_value (cgi->hdf, "CGI.ContentType", NULL);
626 pcb = cgi->parse_callbacks;
632 err = pcb->parse_cb(cgi, method, type, pcb->rock);
645 err = _parse_post_form(cgi);
650 err = parse_rfc2388 (cgi);
663 l = hdf_get_value (cgi->hdf, "CGI.ContentLength", NULL);
688 int unlink_files = hdf_get_int_value(cgi->hdf, "Config.Upload.Unlink", 1);
690 err = open_upload(cgi, unlink_files, &fp);
693 l = hdf_get_value (cgi->hdf, "CGI.ContentLength", NULL);
715 l = hdf_get_value(cgi->hdf, "CGI.PathInfo", NULL);
716 if (l) err = hdf_set_value (cgi->hdf, "PUT", l);
718 if (type) err = hdf_set_value (cgi->hdf, "PUT.Type", type);
720 err = hdf_set_int_value (cgi->hdf, "PUT.FileHandle", uListLength(cgi->files));
725 err = uListGet(cgi->filenames, uListLength(cgi->filenames)-1,
728 err = hdf_set_value (cgi->hdf, "PUT.FileName", name);
735 NEOERR *cgi_init (CGI **cgi, HDF *hdf)
738 CGI *mycgi;
753 *cgi = NULL;
754 mycgi = (CGI *) calloc (1, sizeof(CGI));
756 return nerr_raise(NERR_NOMEM, "Unable to allocate space for CGI");
779 *cgi = mycgi;
793 void cgi_destroy (CGI **cgi)
795 CGI *my_cgi;
797 if (!cgi || !*cgi)
799 my_cgi = *cgi;
808 free (*cgi);
809 *cgi = NULL;
821 static NEOERR *cgi_headers (CGI *cgi)
827 if (hdf_get_int_value (cgi->hdf, "Config.NoCache", 0))
838 obj = hdf_get_obj (cgi->hdf, "cgiout");
849 child = hdf_get_obj (cgi->hdf, "cgiout.other");
1056 NEOERR *cgi_output (CGI *cgi, STRING *str)
1068 s = hdf_get_value (cgi->hdf, "Query.debug", NULL);
1069 e = hdf_get_value (cgi->hdf, "Config.DebugPassword", NULL);
1070 if (hdf_get_int_value(cgi->hdf, "Config.DebugEnabled", 0) &&
1072 do_timefooter = hdf_get_int_value (cgi->hdf, "Config.TimeFooter", 1);
1073 ws_strip_level = hdf_get_int_value (cgi->hdf, "Config.WhiteSpaceStrip", 1);
1076 s = hdf_get_value (cgi->hdf, "cgiout.ContentType", "text/html");
1082 if (is_html && hdf_get_int_value (cgi->hdf, "Config.CompressionEnabled", 0))
1084 err = hdf_get_copy (cgi->hdf, "HTTP.AcceptEncoding", &s, NULL);
1104 s = hdf_get_value (cgi->hdf, "HTTP.UserAgent", NULL);
1109 e = hdf_get_value (cgi->hdf, "HTTP.Accept", NULL);
1132 err = hdf_set_value (cgi->hdf, "cgiout.other.encoding",
1137 err = hdf_set_value (cgi->hdf, "cgiout.other.encoding",
1144 err = cgi_headers(cgi);
1155 dis - cgi->time_start, use_deflate || use_gzip);
1184 err = hdf_dump_str (cgi->hdf, NULL, 0, str);
1298 NEOERR *cgi_cs_init(CGI *cgi, CSPARSE **cs)
1306 err = cs_init (cs, cgi->hdf);
1316 NEOERR *cgi_display (CGI *cgi, const char *cs_file)
1327 debug = hdf_get_value (cgi->hdf, "Query.debug", NULL);
1328 t = hdf_get_value (cgi->hdf, "Config.DumpPassword", NULL);
1329 if (hdf_get_int_value(cgi->hdf, "Config.DebugEnabled", 0) &&
1334 err = cs_init (&cs, cgi->hdf);
1343 hdf_dump_str(cgi->hdf, "", 0, &str);
1353 err = cgi_output(cgi, &str);
1362 void cgi_neo_error (CGI *cgi, NEOERR *err)
1376 void cgi_error (CGI *cgi, const char *fmt, ...)
1418 void cgi_vredirect (CGI *cgi, int uri, const char *fmt, va_list ap)
1435 if (!strcmp(hdf_get_value(cgi->hdf, "CGI.HTTPS", "off"), "on"))
1440 host = hdf_get_value (cgi->hdf, "HTTP.Host", NULL);
1442 host = hdf_get_value (cgi->hdf, "CGI.ServerName", "localhost");
1447 int port = hdf_get_int_value(cgi->hdf, "CGI.ServerPort", 80);
1471 void cgi_redirect (CGI *cgi, const char *fmt, ...)
1476 cgi_vredirect (cgi, 0, fmt, ap);
1481 void cgi_redirect_uri (CGI *cgi, const char *fmt, ...)
1486 cgi_vredirect (cgi, 1, fmt, ap);
1491 char *cgi_cookie_authority (CGI *cgi, const char *host)
1499 host = hdf_get_value (cgi->hdf, "HTTP.Host", NULL);
1505 obj = hdf_get_obj (cgi->hdf, "CookieAuthority");
1531 NEOERR *cgi_cookie_set (CGI *cgi, const char *name, const char *value,
1584 NEOERR *cgi_cookie_clear (CGI *cgi, const char *name, const char *domain,