Adding comments
[privoxy.git] / src / filters.h
1 #ifndef FILTERS_H_INCLUDED
2 #define FILTERS_H_INCLUDED
3 #define FILTERS_H_VERSION "$Id: filters.h,v 1.20 2002/04/02 14:56:16 oes Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/filters.h,v $
7  *
8  * Purpose     :  Declares functions to parse/crunch headers and pages.
9  *                Functions declared include:
10  *                   `acl_addr', `add_stats', `block_acl', `block_imageurl',
11  *                   `block_url', `url_actions', `filter_popups', `forward_url'
12  *                   `ij_untrusted_url', `intercept_url', `re_process_buffer',
13  *                   `show_proxy_args', and `trust_url'
14  *
15  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
16  *                Privoxy team. http://www.privoxy.org/
17  *
18  *                Based on the Internet Junkbuster originally written
19  *                by and Copyright (C) 1997 Anonymous Coders and 
20  *                Junkbusters Corporation.  http://www.junkbusters.com
21  *
22  *                This program is free software; you can redistribute it 
23  *                and/or modify it under the terms of the GNU General
24  *                Public License as published by the Free Software
25  *                Foundation; either version 2 of the License, or (at
26  *                your option) any later version.
27  *
28  *                This program is distributed in the hope that it will
29  *                be useful, but WITHOUT ANY WARRANTY; without even the
30  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
31  *                PARTICULAR PURPOSE.  See the GNU General Public
32  *                License for more details.
33  *
34  *                The GNU General Public License should be included with
35  *                this file.  If not, you can view it at
36  *                http://www.gnu.org/copyleft/gpl.html
37  *                or write to the Free Software Foundation, Inc., 59
38  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
39  *
40  * Revisions   :
41  *    $Log: filters.h,v $
42  *    Revision 1.20  2002/04/02 14:56:16  oes
43  *    Bugfix: is_untrusted_url() and trust_url() now depend on FEATURE_TRUST, not FEATURE_COOKIE_JAR
44  *
45  *    Revision 1.19  2002/03/26 22:29:54  swa
46  *    we have a new homepage!
47  *
48  *    Revision 1.18  2002/03/25 22:12:45  oes
49  *    Added fix for undefined INADDR_NONE on Solaris by Bart Schelstraete
50  *
51  *    Revision 1.17  2002/03/24 13:25:43  swa
52  *    name change related issues
53  *
54  *    Revision 1.16  2002/01/17 21:01:02  jongfoster
55  *    Moving all our URL and URL pattern parsing code to urlmatch.c.
56  *
57  *    Revision 1.15  2001/10/10 16:44:16  oes
58  *    Added match_portlist function
59  *
60  *    Revision 1.14  2001/10/07 15:41:40  oes
61  *    Added prototype for remove_chunked_transfer_coding
62  *
63  *    Revision 1.13  2001/07/30 22:08:36  jongfoster
64  *    Tidying up #defines:
65  *    - All feature #defines are now of the form FEATURE_xxx
66  *    - Permanently turned off WIN_GUI_EDIT
67  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
68  *
69  *    Revision 1.12  2001/07/29 19:01:11  jongfoster
70  *    Changed _FILENAME_H to FILENAME_H_INCLUDED.
71  *    Added forward declarations for needed structures.
72  *
73  *    Revision 1.11  2001/07/13 14:00:18  oes
74  *     - Introduced gif_deanimate_response
75  *     - Renamed re_process_buffer to pcrs_filter_response
76  *     - Removed all #ifdef PCRS
77  *
78  *    Revision 1.10  2001/06/29 13:29:01  oes
79  *    Cleaned up and updated to reflect the changesin
80  *    filters.c
81  *
82  *    Revision 1.9  2001/06/07 23:10:53  jongfoster
83  *    Replacing struct gateway with struct forward_spec
84  *
85  *    Revision 1.8  2001/06/03 19:12:00  oes
86  *    extracted-CGI relevant stuff
87  *
88  *    Revision 1.7  2001/05/31 21:21:30  jongfoster
89  *    Permissionsfile / actions file changes:
90  *    - Changed "permission" to "action" throughout
91  *    - changes to file format to allow string parameters
92  *    - Moved helper functions to actions.c
93  *
94  *    Revision 1.6  2001/05/29 09:50:24  jongfoster
95  *    Unified blocklist/imagelist/permissionslist.
96  *    File format is still under discussion, but the internal changes
97  *    are (mostly) done.
98  *
99  *    Also modified interceptor behaviour:
100  *    - We now intercept all URLs beginning with one of the following
101  *      prefixes (and *only* these prefixes):
102  *        * http://i.j.b/
103  *        * http://ijbswa.sf.net/config/
104  *        * http://ijbswa.sourceforge.net/config/
105  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
106  *    - Internal changes so that intercepted and fast redirect pages
107  *      are not replaced with an image.
108  *    - Interceptors now have the option to send a binary page direct
109  *      to the client. (i.e. ijb-send-banner uses this)
110  *    - Implemented show-url-info interceptor.  (Which is why I needed
111  *      the above interceptors changes - a typical URL is
112  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
113  *      The previous mechanism would not have intercepted that, and
114  *      if it had been intercepted then it then it would have replaced
115  *      it with an image.)
116  *
117  *    Revision 1.5  2001/05/27 22:17:04  oes
118  *
119  *    - re_process_buffer no longer writes the modified buffer
120  *      to the client, which was very ugly. It now returns the
121  *      buffer, which it is then written by chat.
122  *
123  *    - content_length now adjusts the Content-Length: header
124  *      for modified documents rather than crunch()ing it.
125  *      (Length info in csp->content_length, which is 0 for
126  *      unmodified documents)
127  *
128  *    - For this to work, sed() is called twice when filtering.
129  *
130  *    Revision 1.4  2001/05/26 15:26:15  jongfoster
131  *    ACL feature now provides more security by immediately dropping
132  *    connections from untrusted hosts.
133  *
134  *    Revision 1.3  2001/05/22 18:46:04  oes
135  *
136  *    - Enabled filtering banners by size rather than URL
137  *      by adding patterns that replace all standard banner
138  *      sizes with the "Junkbuster" gif to the re_filterfile
139  *
140  *    - Enabled filtering WebBugs by providing a pattern
141  *      which kills all 1x1 images
142  *
143  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
144  *      which is selected by the (nonstandard and therefore
145  *      capital) letter 'U' in the option string.
146  *      It causes the quantifiers to be ungreedy by default.
147  *      Appending a ? turns back to greedy (!).
148  *
149  *    - Added a new interceptor ijb-send-banner, which
150  *      sends back the "Junkbuster" gif. Without imagelist or
151  *      MSIE detection support, or if tinygif = 1, or the
152  *      URL isn't recognized as an imageurl, a lame HTML
153  *      explanation is sent instead.
154  *
155  *    - Added new feature, which permits blocking remote
156  *      script redirects and firing back a local redirect
157  *      to the browser.
158  *      The feature is conditionally compiled, i.e. it
159  *      can be disabled with --disable-fast-redirects,
160  *      plus it must be activated by a "fast-redirects"
161  *      line in the config file, has its own log level
162  *      and of course wants to be displayed by show-proxy-args
163  *      Note: Boy, all the #ifdefs in 1001 locations and
164  *      all the fumbling with configure.in and acconfig.h
165  *      were *way* more work than the feature itself :-(
166  *
167  *    - Because a generic redirect template was needed for
168  *      this, tinygif = 3 now uses the same.
169  *
170  *    - Moved GIFs, and other static HTTP response templates
171  *      to project.h
172  *
173  *    - Some minor fixes
174  *
175  *    - Removed some >400 CRs again (Jon, you really worked
176  *      a lot! ;-)
177  *
178  *    Revision 1.2  2001/05/20 01:21:20  jongfoster
179  *    Version 2.9.4 checkin.
180  *    - Merged popupfile and cookiefile, and added control over PCRS
181  *      filtering, in new "permissionsfile".
182  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
183  *      file error you now get a message box (in the Win32 GUI) rather
184  *      than the program exiting with no explanation.
185  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
186  *      skipping.
187  *    - Removed tabs from "config"
188  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
189  *    - Bumped up version number.
190  *
191  *    Revision 1.1.1.1  2001/05/15 13:58:52  oes
192  *    Initial import of version 2.9.3 source tree
193  *
194  *
195  *********************************************************************/
196 \f
197
198 #include "project.h"
199
200 #ifdef __cplusplus
201 extern "C" {
202 #endif
203
204
205 struct access_control_addr;
206 struct client_state;
207 struct http_request;
208 struct http_response;
209 struct current_action_spec;
210 struct url_actions;
211 struct url_spec;
212
213
214 /*
215  * ACL checking
216  */
217 #ifdef FEATURE_ACL
218 extern int block_acl(struct access_control_addr *dst, struct client_state *csp);
219 extern int acl_addr(char *aspec, struct access_control_addr *aca);
220 #endif /* def FEATURE_ACL */
221 extern int match_portlist(const char *portlist, int port);
222
223 /*
224  * Interceptors
225  */
226 extern struct http_response *block_url(struct client_state *csp);
227 extern struct http_response *redirect_url(struct client_state *csp);
228 #ifdef FEATURE_TRUST
229 extern struct http_response *trust_url(struct client_state *csp);
230 #endif /* def FEATURE_TRUST */
231
232 /*
233  * Request inspectors
234  */
235 #ifdef FEATURE_TRUST
236 extern int is_untrusted_url(struct client_state *csp);
237 #endif /* def FEATURE_TRUST */
238 #ifdef FEATURE_IMAGE_BLOCKING
239 extern int is_imageurl(struct client_state *csp);
240 #endif /* def FEATURE_IMAGE_BLOCKING */
241
242 /*
243  * Determining applicable actions
244  */
245 extern void url_actions(struct http_request *http, 
246                         struct client_state *csp);
247 extern void apply_url_actions(struct current_action_spec *action, 
248                               struct http_request *http, 
249                               struct url_actions *b);
250 /*
251  * Determining parent proxies
252  */
253 extern const struct forward_spec *forward_url(struct http_request *http, struct client_state *csp);
254
255 /*
256  * Content modification
257  */
258 extern char *pcrs_filter_response(struct client_state *csp);
259 extern char *gif_deanimate_response(struct client_state *csp);
260 extern int remove_chunked_transfer_coding(char *buffer, const size_t size);
261
262 /*
263  * Solaris fix:
264  */
265 #ifndef INADDR_NONE
266 #define INADDR_NONE -1
267 #endif     
268
269 /* 
270  * Revision control strings from this header and associated .c file
271  */
272 extern const char filters_rcs[];
273 extern const char filters_h_rcs[];
274
275 #ifdef __cplusplus
276 } /* extern "C" */
277 #endif
278
279 #endif /* ndef FILTERS_H_INCLUDED */
280
281 /*
282   Local Variables:
283   tab-width: 3
284   end:
285 */