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