Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

filters.h

Go to the documentation of this file.
00001 #ifndef FILTERS_H_INCLUDED
00002 #define FILTERS_H_INCLUDED
00003 #define FILTERS_H_VERSION "$Id: filters.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
00004 /* ******************************************************************
00005  * $Source: /cvsroot/ijbswa/current/src/filters.h,v $
00006  * ******************************************************************
00007  *
00008  * Written by and Copyright (C) 2001 the SourceForge
00009  * Privoxy team. http://www.privoxy.org/
00010  * 
00011  * Based on the Internet Junkbuster originally written
00012  * by and Copyright (C) 1997 Anonymous Coders and
00013  * Junkbusters Corporation.  http://www.junkbusters.com
00014  * 
00015  * This program is free software; you can redistribute it
00016  * and/or modify it under the terms of the GNU General
00017  * Public License as published by the Free Software
00018  * Foundation; either version 2 of the License, or (at
00019  * your option) any later version.
00020  * 
00021  * This program is distributed in the hope that it will
00022  * be useful, but WITHOUT ANY WARRANTY; without even the
00023  * implied warranty of MERCHANTABILITY or FITNESS FOR A
00024  * PARTICULAR PURPOSE.  See the GNU General Public
00025  * License for more details.
00026  * 
00027  * The GNU General Public License should be included with
00028  * this file.  If not, you can view it at
00029  * http://www.gnu.org/copyleft/gpl.html
00030  * or write to the Free Software Foundation, Inc., 59
00031  * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00032  * 
00033  * *****************************************************************/
00034 /**
00035  * @file
00036  *
00037  * Declares functions to parse/crunch headers and pages.
00038  * Functions declared include:
00039  * `acl_addr', `add_stats', `block_acl', `block_imageurl',
00040  * `block_url', `url_actions', `filter_popups', `forward_url'
00041  * `ij_untrusted_url', `intercept_url', `re_process_buffer',
00042  * `show_proxy_args', and `trust_url'
00043  * 
00044  *
00045  * $Log: filters.h,v $
00046  * Revision 2.0  2002/06/04 14:34:21  jongfoster
00047  * Moving source files to src/
00048  * 
00049  * Revision 1.20  2002/04/02 14:56:16  oes
00050  * Bugfix: is_untrusted_url() and trust_url() now depend on FEATURE_TRUST, not FEATURE_COOKIE_JAR
00051  * 
00052  * Revision 1.19  2002/03/26 22:29:54  swa
00053  * we have a new homepage!
00054  * 
00055  * Revision 1.18  2002/03/25 22:12:45  oes
00056  * Added fix for undefined INADDR_NONE on Solaris by Bart Schelstraete
00057  * 
00058  * Revision 1.17  2002/03/24 13:25:43  swa
00059  * name change related issues
00060  * 
00061  * Revision 1.16  2002/01/17 21:01:02  jongfoster
00062  * Moving all our URL and URL pattern parsing code to urlmatch.c.
00063  * 
00064  * Revision 1.15  2001/10/10 16:44:16  oes
00065  * Added match_portlist function
00066  * 
00067  * Revision 1.14  2001/10/07 15:41:40  oes
00068  * Added prototype for remove_chunked_transfer_coding
00069  * 
00070  * Revision 1.13  2001/07/30 22:08:36  jongfoster
00071  * Tidying up #defines:
00072  * - All feature #defines are now of the form FEATURE_xxx
00073  * - Permanently turned off WIN_GUI_EDIT
00074  * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
00075  * 
00076  * Revision 1.12  2001/07/29 19:01:11  jongfoster
00077  * Changed _FILENAME_H to FILENAME_H_INCLUDED.
00078  * Added forward declarations for needed structures.
00079  * 
00080  * Revision 1.11  2001/07/13 14:00:18  oes
00081  *  - Introduced gif_deanimate_response
00082  *  - Renamed re_process_buffer to pcrs_filter_response
00083  *  - Removed all #ifdef PCRS
00084  * 
00085  * Revision 1.10  2001/06/29 13:29:01  oes
00086  * Cleaned up and updated to reflect the changesin
00087  * filters.c
00088  * 
00089  * Revision 1.9  2001/06/07 23:10:53  jongfoster
00090  * Replacing struct gateway with struct forward_spec
00091  * 
00092  * Revision 1.8  2001/06/03 19:12:00  oes
00093  * extracted-CGI relevant stuff
00094  * 
00095  * Revision 1.7  2001/05/31 21:21:30  jongfoster
00096  * Permissionsfile / actions file changes:
00097  * - Changed "permission" to "action" throughout
00098  * - changes to file format to allow string parameters
00099  * - Moved helper functions to actions.c
00100  * 
00101  * Revision 1.6  2001/05/29 09:50:24  jongfoster
00102  * Unified blocklist/imagelist/permissionslist.
00103  * File format is still under discussion, but the internal changes
00104  * are (mostly) done.
00105  * 
00106  * Also modified interceptor behaviour:
00107  * - We now intercept all URLs beginning with one of the following
00108  *   prefixes (and *only* these prefixes):
00109  *     * http://i.j.b/
00110  *     * http://ijbswa.sf.net/config/
00111  *     * http://ijbswa.sourceforge.net/config/
00112  * - New interceptors "home page" - go to http://i.j.b/ to see it.
00113  * - Internal changes so that intercepted and fast redirect pages
00114  *   are not replaced with an image.
00115  * - Interceptors now have the option to send a binary page direct
00116  *   to the client. (i.e. ijb-send-banner uses this)
00117  * - Implemented show-url-info interceptor.  (Which is why I needed
00118  *   the above interceptors changes - a typical URL is
00119  *   "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
00120  *   The previous mechanism would not have intercepted that, and
00121  *   if it had been intercepted then it then it would have replaced
00122  *   it with an image.)
00123  * 
00124  * Revision 1.5  2001/05/27 22:17:04  oes
00125  * 
00126  * - re_process_buffer no longer writes the modified buffer
00127  *   to the client, which was very ugly. It now returns the
00128  *   buffer, which it is then written by chat.
00129  * 
00130  * - content_length now adjusts the Content-Length: header
00131  *   for modified documents rather than crunch()ing it.
00132  *   (Length info in csp->content_length, which is 0 for
00133  *   unmodified documents)
00134  * 
00135  * - For this to work, sed() is called twice when filtering.
00136  * 
00137  * Revision 1.4  2001/05/26 15:26:15  jongfoster
00138  * ACL feature now provides more security by immediately dropping
00139  * connections from untrusted hosts.
00140  * 
00141  * Revision 1.3  2001/05/22 18:46:04  oes
00142  * 
00143  * - Enabled filtering banners by size rather than URL
00144  *   by adding patterns that replace all standard banner
00145  *   sizes with the "Junkbuster" gif to the re_filterfile
00146  * 
00147  * - Enabled filtering WebBugs by providing a pattern
00148  *   which kills all 1x1 images
00149  * 
00150  * - Added support for PCRE_UNGREEDY behaviour to pcrs,
00151  *   which is selected by the (nonstandard and therefore
00152  *   capital) letter 'U' in the option string.
00153  *   It causes the quantifiers to be ungreedy by default.
00154  *   Appending a ? turns back to greedy (!).
00155  * 
00156  * - Added a new interceptor ijb-send-banner, which
00157  *   sends back the "Junkbuster" gif. Without imagelist or
00158  *   MSIE detection support, or if tinygif = 1, or the
00159  *   URL isn't recognized as an imageurl, a lame HTML
00160  *   explanation is sent instead.
00161  * 
00162  * - Added new feature, which permits blocking remote
00163  *   script redirects and firing back a local redirect
00164  *   to the browser.
00165  *   The feature is conditionally compiled, i.e. it
00166  *   can be disabled with --disable-fast-redirects,
00167  *   plus it must be activated by a "fast-redirects"
00168  *   line in the config file, has its own log level
00169  *   and of course wants to be displayed by show-proxy-args
00170  *   Note: Boy, all the #ifdefs in 1001 locations and
00171  *   all the fumbling with configure.in and acconfig.h
00172  *   were *way* more work than the feature itself :-(
00173  * 
00174  * - Because a generic redirect template was needed for
00175  *   this, tinygif = 3 now uses the same.
00176  * 
00177  * - Moved GIFs, and other static HTTP response templates
00178  *   to project.h
00179  * 
00180  * - Some minor fixes
00181  * 
00182  * - Removed some >400 CRs again (Jon, you really worked
00183  *   a lot! ;-)
00184  * 
00185  * Revision 1.2  2001/05/20 01:21:20  jongfoster
00186  * Version 2.9.4 checkin.
00187  * - Merged popupfile and cookiefile, and added control over PCRS
00188  *   filtering, in new "permissionsfile".
00189  * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
00190  *   file error you now get a message box (in the Win32 GUI) rather
00191  *   than the program exiting with no explanation.
00192  * - Made killpopup use the PCRS MIME-type checking and HTTP-header
00193  *   skipping.
00194  * - Removed tabs from "config"
00195  * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
00196  * - Bumped up version number.
00197  * 
00198  * Revision 1.1.1.1  2001/05/15 13:58:52  oes
00199  * Initial import of version 2.9.3 source tree
00200  * 
00201  * 
00202  */
00203 /* *****************************************************************/
00204 
00205 
00206 #include "project.h"
00207 
00208 #ifdef __cplusplus
00209 extern "C" {
00210 #endif
00211 
00212 
00213 struct access_control_addr;
00214 struct client_state;
00215 struct http_request;
00216 struct http_response;
00217 struct current_action_spec;
00218 struct url_actions;
00219 struct url_spec;
00220 
00221 
00222 /*
00223  * ACL checking
00224  */
00225 #ifdef FEATURE_ACL
00226 extern int block_acl(struct access_control_addr *dst, struct client_state *csp);
00227 extern int acl_addr(char *aspec, struct access_control_addr *aca);
00228 #endif /* def FEATURE_ACL */
00229 extern int match_portlist(const char *portlist, int port);
00230 
00231 /*
00232  * Interceptors
00233  */
00234 extern struct http_response *block_url(struct client_state *csp);
00235 extern struct http_response *redirect_url(struct client_state *csp);
00236 #ifdef FEATURE_TRUST
00237 extern struct http_response *trust_url(struct client_state *csp);
00238 #endif /* def FEATURE_TRUST */
00239 
00240 /*
00241  * Request inspectors
00242  */
00243 #ifdef FEATURE_TRUST
00244 extern int is_untrusted_url(struct client_state *csp);
00245 #endif /* def FEATURE_TRUST */
00246 #ifdef FEATURE_IMAGE_BLOCKING
00247 extern int is_imageurl(struct client_state *csp);
00248 #endif /* def FEATURE_IMAGE_BLOCKING */
00249 
00250 /*
00251  * Determining applicable actions
00252  */
00253 extern void url_actions(struct http_request *http, 
00254                         struct client_state *csp);
00255 extern void apply_url_actions(struct current_action_spec *action, 
00256                               struct http_request *http, 
00257                               struct url_actions *b);
00258 /*
00259  * Determining parent proxies
00260  */
00261 extern const struct forward_spec *forward_url(struct http_request *http, struct client_state *csp);
00262 
00263 /*
00264  * Content modification
00265  */
00266 extern char *pcrs_filter_response(struct client_state *csp);
00267 extern char *gif_deanimate_response(struct client_state *csp);
00268 extern int remove_chunked_transfer_coding(char *buffer, const size_t size);
00269 
00270 /*
00271  * Solaris fix:
00272  */
00273 #ifndef INADDR_NONE
00274 #define INADDR_NONE -1
00275 #endif     
00276 
00277 /* 
00278  * Revision control strings from this header and associated .c file
00279  */
00280 
00281 /** Version information about filters.c. */
00282 extern const char filters_rcs[];
00283 
00284 /** Version information about filters.h. */
00285 extern const char filters_h_rcs[];
00286 
00287 #ifdef __cplusplus
00288 } /* extern "C" */
00289 #endif
00290 
00291 #endif /* ndef FILTERS_H_INCLUDED */
00292 
00293 /*
00294   Local Variables:
00295   tab-width: 3
00296   end:
00297 */

Generated on Tue Jun 4 18:54:48 2002 for Privoxy 3.1.1 by doxygen1.2.15