-const char cgi_rcs[] = "$Id: cgi.c,v 1.5 2001/06/05 19:59:16 jongfoster Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.6 2001/06/07 23:05:19 jongfoster Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
*
* Revisions :
* $Log: cgi.c,v $
+ * Revision 1.6 2001/06/07 23:05:19 jongfoster
+ * Removing code related to old forward and ACL files.
+ *
* Revision 1.5 2001/06/05 19:59:16 jongfoster
* Fixing multiline character string (a GCC-only "feature"), and snprintf (it's _snprintf under VC++).
*
{ "show-status",
11, cgi_show_status,
"Show information about the version and configuration" },
-/* { "show-url-info",
+ { "show-url-info",
13, cgi_show_url_info,
- "Show which actions apply to a URL and why" },*/
+ "Show which actions apply to a URL and why" },
{ "send-banner",
11, cgi_send_banner,
"HIDE Send the transparent or \"Junkbuster\" gif" },
struct map *parse_cgi(char *argstring)
{
char *tmp, *p;
- char *vector[BUFSIZ];
+ char *vector[BUFFER_SIZE];
int pairs, i;
struct map *cgi_params = NULL;
*********************************************************************/
int make_http_response(struct http_response *rsp)
{
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
/* Fill in the HTTP Status */
sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
{
struct map *m;
pcrs_job *job, *joblist = NULL;
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
char *new, *old = NULL;
int size;
FILE *fp;
/*
* Open template file or fail
*/
- snprintf(buf, BUFSIZ, "%s/templates/%s", csp->config->confdir, template);
+ snprintf(buf, BUFFER_SIZE, "%s/templates/%s", csp->config->confdir, template);
if(NULL == (fp = fopen(buf, "r")))
{
{
int error;
- snprintf(buf, BUFSIZ, "s°@%s@°%s°ig", m->name, m->value);
+ snprintf(buf, BUFFER_SIZE, "s°@%s@°%s°ig", m->name, m->value);
if(NULL == (job = pcrs_make_job(buf, &error)))
{
/*
* Read the file, ignoring comments
*/
- while (fgets(buf, BUFSIZ, fp))
+ while (fgets(buf, BUFFER_SIZE, fp))
{
/* skip lines starting with '#' */
if(*buf == '#') continue;
struct map *parameters)
{
char *p, *tmp = NULL;
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
const struct cgi_dispatcher *d;
struct map *exports = NULL;
{
if (strncmp(d->description, "HIDE", 4))
{
- snprintf(buf, BUFSIZ, "<li><a href=%s/config/%s>%s</a></li>",
+ snprintf(buf, BUFFER_SIZE, "<li><a href=%s/config/%s>%s</a></li>",
HOME_PAGE_URL, d->name, d->description);
tmp = strsav(tmp, buf);
}
#ifdef SPLIT_PROXY_ARGS
FILE * fp;
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
char * p;
const char * filename = NULL;
char * file_description = NULL;
}
fclose(fp);
exports = map(exports, "contents", 1, s, 0);
- }
- rsp->body = fill_template(csp, "show-status-file", exports);;
- free_map(exports);
- return(0);
+ }
+ rsp->body = fill_template(csp, "show-status-file", exports);;
+ free_map(exports);
+ return(0);
}
* Returns : ???FIXME
*
*********************************************************************/
-char *cgi_show_url_info(struct http_request *http, struct client_state *csp)
+int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,\r
+ struct map *parameters)\r
{
- char * query_string = strchr(http->path, '?');
- char * host = NULL;
-
- if (query_string != NULL)
+ const char * host_param = lookup(parameters, "url");\r
+ char * host = NULL;\r
+
+ if (*host_param != '\0')\r
{
- query_string = url_decode(query_string + 1);
- if (strncmpic(query_string, "url=", 4) == 0)
- {
- host = strdup(query_string + 4);
- }
- freez(query_string);
+ host = strdup(host_param);
}
if (host != NULL)
{
- char * result;
+ char * matches = NULL;
char * path;
char * s;
int port = 80;
struct url_actions *b;
struct url_spec url[1];
struct current_action_spec action[1];
+ struct map *exports = NULL;\r
+ exports = map(exports, "url", 1, html_encode(host), 0);\r
+\r
init_current_action(action);
- result = (char *)malloc(sizeof(C_URL_INFO_HEADER) + 2 * strlen(host));
- sprintf(result, C_URL_INFO_HEADER, host, host);
-
s = current_action_to_text(action);
- result = strsav(result, "<h3>Defaults:</h3>\n<p><b>{");
- result = strsav(result, s);
- result = strsav(result, " }</b></p>\n<h3>Patterns affecting the URL:</h3>\n<p>\n");
- freez(s);
-
+ exports = map(exports, "default", 1, s , 0);\r
+
+ if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))\r
+ {\r
+ exports = map(exports, "matches", 1, "" , 1);\r
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
+\r
+ freez(host);\r
+ free_current_action(action);\r
+\r
+ rsp->body = fill_template(csp, "show-url-info", exports);\r
+ free_map(exports);\r
+\r
+ return 0;\r
+ }\r
+\r
s = strchr(host, '/');
if (s != NULL)
{
{
*s++ = '\0';
port = atoi(s);
- }
-
- if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
- {
- freez(host);
- freez(path);
- result = strsav(result, C_URL_INFO_FOOTER);
- return result;
+ s = NULL;\r
}
*url = dsplit(host);
/* if splitting the domain fails, punt */
if (url->dbuf == NULL)
{
- freez(host);
- freez(path);
- result = strsav(result, C_URL_INFO_FOOTER);
- return result;
+ exports = map(exports, "matches", 1, "" , 1);\r
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);\r
+\r
+ freez(host);\r
+ freez(path);\r
+ free_current_action(action);\r
+\r
+ rsp->body = fill_template(csp, "show-url-info", exports);\r
+ free_map(exports);\r
+\r
+ return 0;\r
}
for (b = b->next; NULL != b; b = b->next)
)
{
s = actions_to_text(b->action);
- result = strsav(result, "<b>{");
- result = strsav(result, s);
- result = strsav(result, " }</b><br>\n<code>");
- result = strsav(result, b->url->spec);
- result = strsav(result, "</code><br>\n<br>\n");
+ matches = strsav(matches, "<b>{");
+ matches = strsav(matches, s);
+ matches = strsav(matches, " }</b><br>\n<code>");
+ matches = strsav(matches, b->url->spec);
+ matches = strsav(matches, "</code><br>\n<br>\n");
freez(s);
merge_current_action(action, b->action);
}
}
+ exports = map(exports, "matches", 1, matches , 0);\r
+ matches = NULL;\r
+\r
freez(url->dbuf);
freez(url->dvec);
freez(host);
freez(path);
-
+\r
s = current_action_to_text(action);
- result = strsav(result, "</p>\n<h2>Final Results:</h2>\n<p><b>{");
- result = strsav(result, s);
- result = strsav(result, " }</b><br>\n<br>\n");
- freez(s);
+ exports = map(exports, "final", 1, s, 0);\r
+ s = NULL;\r
free_current_action(action);
- result = strsav(result, C_URL_INFO_FOOTER);
- return result;
+ rsp->body = fill_template(csp, "show-url-info", exports);\r
+ free_map(exports);\r
+\r
+ return 0;\r
}
else
{
- return strdup(C_URL_INFO_FORM);
+ rsp->body = fill_template(csp, "show-url-info-form", NULL);\r
+\r
+ return 0;
}
}
{
int n;
char *hostport, *path, *refer, *p, *v[9];
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
struct url_spec **tl, *t;