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