X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgi.c;h=c8aa40272ae44cbd7e5253efe76d08df052f4b7c;hp=b101b2cdd16628b5cc46bc796e0e24f56a89856f;hb=1f641e69a8cb9402126c1031f71424527d669dff;hpb=fef47f1318a4147305d5645290a8f4d72cdddf5c diff --git a/cgi.c b/cgi.c index b101b2cd..c8aa4027 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -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 $ @@ -36,6 +36,9 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.5 2001/06/05 19:59:16 jongfoster Exp $"; * * 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++). * @@ -135,9 +138,9 @@ const struct cgi_dispatcher cgi_dispatchers[] = { { "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" }, @@ -257,7 +260,7 @@ struct http_response *cgi_dispatch(struct client_state *csp) struct map *parse_cgi(char *argstring) { char *tmp, *p; - char *vector[BUFSIZ]; + char *vector[BUFFER_SIZE]; int pairs, i; struct map *cgi_params = NULL; @@ -296,7 +299,7 @@ struct map *parse_cgi(char *argstring) *********************************************************************/ 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"); @@ -378,7 +381,7 @@ char *fill_template(struct client_state *csp, char *template, struct map *answer { struct map *m; pcrs_job *job, *joblist = NULL; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; char *new, *old = NULL; int size; FILE *fp; @@ -386,7 +389,7 @@ char *fill_template(struct client_state *csp, char *template, struct map *answer /* * 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"))) { @@ -401,7 +404,7 @@ char *fill_template(struct client_state *csp, char *template, struct map *answer { 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))) { @@ -420,7 +423,7 @@ char *fill_template(struct client_state *csp, char *template, struct map *answer /* * Read the file, ignoring comments */ - while (fgets(buf, BUFSIZ, fp)) + while (fgets(buf, BUFFER_SIZE, fp)) { /* skip lines starting with '#' */ if(*buf == '#') continue; @@ -505,7 +508,7 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, struct map *parameters) { char *p, *tmp = NULL; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; const struct cgi_dispatcher *d; struct map *exports = NULL; @@ -514,7 +517,7 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, { if (strncmp(d->description, "HIDE", 4)) { - snprintf(buf, BUFSIZ, "
{"); - result = strsav(result, s); - result = strsav(result, " }
\n\n");
- freez(s);
-
+ exports = map(exports, "default", 1, s , 0);
+
+ if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
+ {
+ exports = map(exports, "matches", 1, "" , 1);
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+ freez(host);
+ free_current_action(action);
+
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
+
+ return 0;
+ }
+
s = strchr(host, '/');
if (s != NULL)
{
@@ -875,14 +885,7 @@ char *cgi_show_url_info(struct http_request *http, struct client_state *csp)
{
*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;
}
*url = dsplit(host);
@@ -890,10 +893,17 @@ char *cgi_show_url_info(struct http_request *http, struct client_state *csp)
/* 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);
+ exports = map(exports, "final", 1, lookup(exports, "default"), 1);
+
+ freez(host);
+ freez(path);
+ free_current_action(action);
+
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
+
+ return 0;
}
for (b = b->next; NULL != b; b = b->next)
@@ -911,11 +921,11 @@ char *cgi_show_url_info(struct http_request *http, struct client_state *csp)
)
{
s = actions_to_text(b->action);
- result = strsav(result, "{");
- result = strsav(result, s);
- result = strsav(result, " }
\n");
- result = strsav(result, b->url->spec);
- result = strsav(result, "
\n
\n");
+ matches = strsav(matches, "{");
+ matches = strsav(matches, s);
+ matches = strsav(matches, " }
\n");
+ matches = strsav(matches, b->url->spec);
+ matches = strsav(matches, "
\n
\n");
freez(s);
merge_current_action(action, b->action);
@@ -924,26 +934,31 @@ char *cgi_show_url_info(struct http_request *http, struct client_state *csp)
}
}
+ exports = map(exports, "matches", 1, matches , 0);
+ matches = NULL;
+
freez(url->dbuf);
freez(url->dvec);
freez(host);
freez(path);
-
+
s = current_action_to_text(action);
- result = strsav(result, "
{");
- result = strsav(result, s);
- result = strsav(result, " }
\n
\n");
- freez(s);
+ exports = map(exports, "final", 1, s, 0);
+ s = NULL;
free_current_action(action);
- result = strsav(result, C_URL_INFO_FOOTER);
- return result;
+ rsp->body = fill_template(csp, "show-url-info", exports);
+ free_map(exports);
+
+ return 0;
}
else
{
- return strdup(C_URL_INFO_FORM);
+ rsp->body = fill_template(csp, "show-url-info-form", NULL);
+
+ return 0;
}
}
@@ -968,7 +983,7 @@ char *ij_untrusted_url(struct http_request *http, struct client_state *csp)
{
int n;
char *hostport, *path, *refer, *p, *v[9];
- char buf[BUFSIZ];
+ char buf[BUFFER_SIZE];
struct url_spec **tl, *t;