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