X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=filters.c;h=9ba16058c4b87196511d2d6059b2c166e2f07074;hb=28b7a0e2c74ce13c5e3fb72a44da1fa5f8ba6e38;hp=4851dff27cc1ead26a0ceca0295aafbdf4bb263f;hpb=cf0ec9e8474462c26b7416b417dad9a8fd7be75c;p=privoxy.git diff --git a/filters.c b/filters.c index 4851dff2..9ba16058 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.28 2001/09/10 10:18:51 oes Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.33 2001/09/16 17:05:14 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,28 @@ const char filters_rcs[] = "$Id: filters.c,v 1.28 2001/09/10 10:18:51 oes Exp $" * * Revisions : * $Log: filters.c,v $ + * Revision 1.33 2001/09/16 17:05:14 jongfoster + * Removing unused #include showarg.h + * + * Revision 1.32 2001/09/16 13:21:27 jongfoster + * Changes to use new list functions. + * + * Revision 1.31 2001/09/16 11:38:02 jongfoster + * Splitting fill_template() into 2 functions: + * template_load() loads the file + * template_fill() performs the PCRS regexps. + * This is because the CGI edit interface has a "table row" + * template which is used many times in the page - this + * change means it's only loaded from disk once. + * + * Revision 1.30 2001/09/16 11:00:10 jongfoster + * New function alloc_http_response, for symmetry with free_http_response + * + * Revision 1.29 2001/09/13 23:32:40 jongfoster + * Moving image data to cgi.c rather than cgi.h + * Fixing a GPF under Win32 (and any other OS that protects global + * constants from being written to). + * * Revision 1.28 2001/09/10 10:18:51 oes * Silenced compiler warnings * @@ -275,12 +297,8 @@ const char filters_rcs[] = "$Id: filters.c,v 1.28 2001/09/10 10:18:51 oes Exp $" #include "project.h" #include "filters.h" #include "encode.h" -#include "jcc.h" -#include "showargs.h" #include "parsers.h" #include "ssplit.h" -#include "gateway.h" -#include "jbsockets.h" #include "errlog.h" #include "jbsockets.h" #include "miscutil.h" @@ -472,7 +490,7 @@ struct http_response *block_url(struct client_state *csp) /* * Else, prepare a response */ - if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -528,7 +546,8 @@ struct http_response *block_url(struct client_state *csp) map(exports, "path", 1, csp->http->path, 1); map(exports, "path-html", 1, html_encode(csp->http->path), 0); - rsp->body = fill_template(csp, "blocked", exports); + rsp->body = template_load(csp, "blocked"); + template_fill(&rsp->body, exports); free_map(exports); /* @@ -588,7 +607,7 @@ struct http_response *trust_url(struct client_state *csp) /* * Else, prepare a response: */ - if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -628,11 +647,11 @@ struct http_response *trust_url(struct client_state *csp) /* * Export the trust info, if available */ - if (csp->config->trust_info->next) + if (csp->config->trust_info->first) { - struct list *l; + struct list_entry *l; - for (l = csp->config->trust_info->next; l ; l = l->next) + for (l = csp->config->trust_info->first; l ; l = l->next) { sprintf(buf, "
  • %s
    \n",l->str, l->str); p = strsav(p, buf); @@ -656,7 +675,8 @@ struct http_response *trust_url(struct client_state *csp) /* * Build the response */ - rsp->body = fill_template(csp, "untrusted", exports); + rsp->body = template_load(csp, "untrusted"); + template_fill(&rsp->body, exports); free_map(exports); return(finish_http_response(rsp)); @@ -702,7 +722,7 @@ struct http_response *redirect_url(struct client_state *csp) { log_error(LOG_LEVEL_REDIRECTS, "redirecting to: %s", q); - if (NULL == ( rsp = zalloc(sizeof(*rsp)))) + if (NULL == (rsp = alloc_http_response())) { return NULL; } @@ -945,7 +965,7 @@ int is_untrusted_url(struct client_state *csp) char *pcrs_filter_response(struct client_state *csp) { int hits=0; - int size = csp->iob->eod - csp->iob->cur; + size_t size; char *old = csp->iob->cur, *new = NULL; pcrs_job *job; @@ -954,10 +974,11 @@ char *pcrs_filter_response(struct client_state *csp) struct re_filterfile_spec *b; /* Sanity first ;-) */ - if (size <= 0) + if (csp->iob->cur >= csp->iob->eod) { return(NULL); } + size = csp->iob->eod - csp->iob->cur; if ( ( NULL == (fl = csp->rlist) ) || ( NULL == (b = fl->f) ) ) {