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