X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=cgisimple.c;h=fcf71e7e205b56bae18dc993f6dbded4250bd4d5;hb=b17b1b1723a431c5414bf454d12fbd0dfb2345c6;hp=058faa11e3760f7102d41756181d9f04c1393346;hpb=83a36343155a2f17d29ff1c706809bf56382a9ec;p=privoxy.git diff --git a/cgisimple.c b/cgisimple.c index 058faa11..fcf71e7e 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,7 +1,7 @@ -const char cgisimple_rcs[] = "$Id: cgi.c,v 1.26 2001/09/16 15:47:37 jongfoster Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.5 2001/10/07 15:30:41 oes Exp $"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ + * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ * * Purpose : Simple CGIs to get information about JunkBuster's * status. @@ -35,7 +35,22 @@ const char cgisimple_rcs[] = "$Id: cgi.c,v 1.26 2001/09/16 15:47:37 jongfoster E * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Revisions : - * $Log: cgi.c,v $ + * $Log: cgisimple.c,v $ + * Revision 1.5 2001/10/07 15:30:41 oes + * Removed FEATURE_DENY_GZIP + * + * Revision 1.4 2001/10/02 15:31:12 oes + * Introduced show-request cgi + * + * Revision 1.3 2001/09/22 16:34:44 jongfoster + * Removing unneeded #includes + * + * Revision 1.2 2001/09/19 18:01:11 oes + * Fixed comments; cosmetics + * + * Revision 1.1 2001/09/16 17:08:54 jongfoster + * Moving simple CGI functions from cgi.c to new file cgisimple.c + * * **********************************************************************/ @@ -58,13 +73,12 @@ const char cgisimple_rcs[] = "$Id: cgi.c,v 1.26 2001/09/16 15:47:37 jongfoster E #include "cgisimple.h" #include "list.h" #include "encode.h" -#include "ssplit.h" #include "jcc.h" #include "filters.h" #include "actions.h" -#include "errlog.h" #include "miscutil.h" #include "loadcfg.h" +#include "parsers.h" const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION; @@ -93,7 +107,7 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, { char *p; char *tmp = NULL; - struct map * exports = default_exports(csp, ""); + struct map *exports = default_exports(csp, ""); /* If there were other parameters, export a dump as "cgi-parameters" */ if(parameters) @@ -118,6 +132,81 @@ int cgi_default(struct client_state *csp, struct http_response *rsp, } + + +/********************************************************************* + * + * Function : cgi_error_404 + * + * Description : CGI function that is called if an unknow action was + * given. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * 2 : rsp = http_response data structure for output + * 3 : parameters = map of cgi parameters + * + * Returns : 0 + * + *********************************************************************/ +int cgi_error_404(struct client_state *csp, + struct http_response *rsp, + struct map *parameters) +{ + struct map *exports = default_exports(csp, NULL); + + rsp->status = strdup("404 JunkBuster configuration page not found"); + rsp->body = template_load(csp, "cgi-error-404"); + template_fill(&rsp->body, exports); + free_map(exports); + return 0; +} + + +/********************************************************************* + * + * Function : cgi_show_request + * + * Description : Show the client's request and what sed() would have + * made of it. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * 2 : rsp = http_response data structure for output + * 3 : parameters = map of cgi parameters + * + * Returns : 0 + * + *********************************************************************/ +int cgi_show_request(struct client_state *csp, struct http_response *rsp, + struct map *parameters) +{ + char *p; + struct map *exports = default_exports(csp, "show-request"); + + /* + * Repair the damage done to the IOB by get_header() + */ + for (p = csp->iob->buf; p < csp->iob->eod; p++) + { + if (*p == '\0') *p = '\n'; + } + + /* + * Export the original client's request and the one we would + * be sending to the server if this wasn't a CGI call + */ + map(exports, "client-request", 1, csp->iob->buf, 1); + map(exports, "processed-request", 1, sed(client_patterns, add_client_headers, csp), 0); + + rsp->body = template_load(csp, "show-request"); + template_fill(&rsp->body, exports); + free_map(exports); + return(0); + +} + + /********************************************************************* * * Function : cgi_send_banner @@ -170,9 +259,7 @@ int cgi_send_banner(struct client_state *csp, struct http_response *rsp, * 2 : rsp = http_response data structure for output * 3 : parameters = map of cgi parameters * - * CGI Parameters : - * type : Selects the type of banner between "trans" and "jb". - * Defaults to "jb" if absent or != "trans". + * CGI Parameters : none * * Returns : 0 * @@ -187,6 +274,7 @@ int cgi_show_version(struct client_state *csp, struct http_response *rsp, rsp->body = template_load(csp, "show-version"); template_fill(&rsp->body, exports); free_map(exports); + return(0); } @@ -204,9 +292,7 @@ int cgi_show_version(struct client_state *csp, struct http_response *rsp, * 2 : rsp = http_response data structure for output * 3 : parameters = map of cgi parameters * - * CGI Parameters : - * type : Selects the type of banner between "trans" and "jb". - * Defaults to "jb" if absent or != "trans". + * CGI Parameters : none * * Returns : 0 * @@ -588,6 +674,7 @@ int cgi_robots_txt(struct client_state *csp, struct http_response *rsp, enlist_unique_header(rsp->headers, "Expires", buf); return 0; + } @@ -618,12 +705,6 @@ static void show_defines(struct map *exports) map_conditional(exports, "FEATURE_COOKIE_JAR", 0); #endif /* ndef FEATURE_COOKIE_JAR */ -#ifdef FEATURE_DENY_GZIP - map_conditional(exports, "FEATURE_DENY_GZIP", 1); -#else /* ifndef FEATURE_DENY_GZIP */ - map_conditional(exports, "FEATURE_DENY_GZIP", 0); -#endif /* ndef FEATURE_DENY_GZIP */ - #ifdef FEATURE_FAST_REDIRECTS map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1); #else /* ifndef FEATURE_FAST_REDIRECTS */ @@ -703,6 +784,7 @@ static void show_defines(struct map *exports) #endif /* ndef STATIC_PCRS */ map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1); + } @@ -800,6 +882,7 @@ static char *show_rcs(void) #undef SHOW_RCS return(b); + }