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