60e9b501ac36039cd5c9731ef657132beb8e95a1
[privoxy.git] / actionlist.h
1 /*********************************************************************
2  *
3  * File        :  $Source: /cvsroot/ijbswa/current/actionlist.h,v $
4  *
5  * Purpose     :  Master list of supported actions.
6  *                Not really a header, since it generates code.
7  *                This is included (3 times!) from actions.c
8  *                Each time, the following macros are defined to
9  *                suitable values beforehand:
10  *                    DEFINE_ACTION_MULTI()
11  *                    DEFINE_ACTION_STRING()
12  *                    DEFINE_ACTION_BOOL()
13  *                    DEFINE_ACTION_ALIAS
14  *
15  * Copyright   :  Written by and Copyright (C) 2001-2008 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: actionlist.h,v $
42  *    Revision 1.34  2008/09/19 15:26:28  fabiankeil
43  *    Add change-x-forwarded-for{} action to block or add
44  *    X-Forwarded-For headers. Mostly based on code removed
45  *    before 3.0.7.
46  *
47  *    Revision 1.33  2008/03/29 12:13:45  fabiankeil
48  *    Remove send-wafer and send-vanilla-wafer actions.
49  *
50  *    Revision 1.32  2008/03/28 15:13:42  fabiankeil
51  *    Remove inspect-jpegs action.
52  *
53  *    Revision 1.31  2008/03/27 18:27:20  fabiankeil
54  *    Remove kill-popups action.
55  *
56  *    Revision 1.30  2008/03/04 18:30:34  fabiankeil
57  *    Remove the treat-forbidden-connects-like-blocks action. We now
58  *    use the "blocked" page for forbidden CONNECT requests by default.
59  *
60  *    Revision 1.29  2008/03/01 14:00:43  fabiankeil
61  *    Let the block action take the reason for the block
62  *    as argument and show it on the "blocked" page.
63  *
64  *    Revision 1.28  2007/12/11 21:08:29  fabiankeil
65  *    Let the CGI editor suggest a forward-override
66  *    parameter whose syntax is actually valid.
67  *
68  *    Revision 1.27  2007/11/10 15:04:08  fabiankeil
69  *    Tell the CGI editor about +hide-referrer{conditional-forge}.
70  *
71  *    Revision 1.26  2007/06/01 16:54:28  fabiankeil
72  *    Add forward-override{} to change the forwarding settings through
73  *    action sections. This is mainly interesting to forward different
74  *    clients differently (for example based on User-Agent or request
75  *    origin).
76  *
77  *    Revision 1.25  2007/04/15 16:39:20  fabiankeil
78  *    Introduce tags as alternative way to specify which
79  *    actions apply to a request. At the moment tags can be
80  *    created based on client and server headers.
81  *
82  *    Revision 1.24  2007/03/20 15:16:34  fabiankeil
83  *    Use dedicated header filter actions instead of abusing "filter".
84  *    Replace "filter-client-headers" and "filter-client-headers"
85  *    with "server-header-filter" and "client-header-filter".
86  *
87  *    Revision 1.23  2006/10/09 10:26:18  fabiankeil
88  *    Changed the path in set-image-blocker's redirection default to
89  *    "send-banner?type=pattern" instead of "show-banner?type=pattern"
90  *    which isn't caught by Privoxy. Fixes BR 1573468.
91  *
92  *    Changed hide-user-agent's default value to "Privoxy VERSION".
93  *
94  *    Changed hide-referrer's default fake value to "http://www.privoxy.org/".
95  *    A static referrer is obviously fake anyway, so we might as well
96  *    advertise ourselves.
97  *
98  *    Revision 1.22  2006/09/01 17:14:18  hal9
99  *    Re-ordered the actions list so that they display in the actions editor in
100  *    alphabetical order. Some of the new actions were "out of order".
101  *
102  *    Revision 1.21  2006/08/14 08:25:19  fabiankeil
103  *    Split filter-headers{} into filter-client-headers{}
104  *    and filter-server-headers{}.
105  *    Added parse_header_time() to share some code.
106  *    Replaced timegm() with mktime().
107  *
108  *    Revision 1.20  2006/08/03 02:46:41  david__schmidt
109  *    Incorporate Fabian Keil's patch work:\rhttp://www.fabiankeil.de/sourcecode/privoxy/
110  *
111  *    Revision 1.19  2006/07/18 14:48:45  david__schmidt
112  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
113  *    with what was really the latest development (the v_3_0_branch branch)
114  *
115  *    Revision 1.17.2.3  2004/10/03 12:53:32  david__schmidt
116  *    Add the ability to check jpeg images for invalid
117  *    lengths of comment blocks.  Defensive strategy
118  *    against the exploit:
119  *       Microsoft Security Bulletin MS04-028
120  *       Buffer Overrun in JPEG Processing (GDI+) Could
121  *       Allow Code Execution (833987)
122  *    Enabled with +inspect-jpegs in actions files.
123  *
124  *    Revision 1.17.2.2  2002/09/25 15:25:25  oes
125  *    Added more aliases for prehistoric action names
126  *
127  *    Revision 1.17.2.1  2002/08/02 12:50:47  oes
128  *    Consistency with docs: Change default name for action from hide-referer to hide-referrer
129  *
130  *    Revision 1.17  2002/05/14 21:25:55  oes
131  *    Renamed prevent-(setting/reading)-cookies to crunch-(incoming/outgoing)-cookies
132  *
133  *    Revision 1.16  2002/04/24 02:15:18  oes
134  *    Renamed actions as discussed, Aliased old action names to new ones.
135  *
136  *    Revision 1.15  2002/03/26 22:29:54  swa
137  *    we have a new homepage!
138  *
139  *    Revision 1.14  2002/03/24 16:32:08  jongfoster
140  *    Removing logo option
141  *
142  *    Revision 1.13  2002/03/24 15:23:33  jongfoster
143  *    Name changes
144  *
145  *    Revision 1.12  2002/03/24 13:25:43  swa
146  *    name change related issues
147  *
148  *    Revision 1.11  2002/03/12 01:42:49  oes
149  *    Introduced modular filters
150  *
151  *    Revision 1.10  2002/03/08 18:19:14  jongfoster
152  *    Adding +image-blocker{pattern} option to edit interface
153  *
154  *    Revision 1.9  2001/11/22 21:58:41  jongfoster
155  *    Adding action +no-cookies-keep
156  *
157  *    Revision 1.8  2001/10/10 16:42:52  oes
158  *    Fixed a bug, Added +limit-connect string action
159  *
160  *    Revision 1.7  2001/10/07 15:33:59  oes
161  *    Introduced a +no-compression action
162  *    Introduced a +downgrade action
163  *
164  *    Revision 1.6  2001/09/16 15:47:37  jongfoster
165  *    First version of CGI-based edit interface.  This is very much a
166  *    work-in-progress, and you can't actually use it to edit anything
167  *    yet.  You must #define FEATURE_CGI_EDIT_ACTIONS for these changes
168  *    to have any effect.
169  *
170  *    Revision 1.5  2001/07/18 12:27:03  oes
171  *    Changed deanimate-gifs to string action
172  *
173  *    Revision 1.4  2001/07/13 13:52:12  oes
174  *     - Formatting
175  *     - Introduced new action ACTION_DEANIMATE
176  *
177  *    Revision 1.3  2001/06/07 23:03:56  jongfoster
178  *    Added standard comment at top of file.
179  *
180  *
181  *********************************************************************/
182 \f
183
184 #if !(defined(DEFINE_ACTION_BOOL) && defined(DEFINE_ACTION_MULTI) && defined(DEFINE_ACTION_STRING))
185 #error Please define lots of macros before including "actionlist.h".
186 #endif /* !defined(all the DEFINE_ACTION_xxx macros) */
187
188 #ifndef DEFINE_CGI_PARAM_RADIO
189 #define DEFINE_CGI_PARAM_RADIO(name, bit, index, value, is_default)
190 #define DEFINE_CGI_PARAM_CUSTOM(name, bit, index, default_val)
191 #define DEFINE_CGI_PARAM_NO_RADIO(name, bit, index, default_val)
192 #endif /* ndef DEFINE_CGI_PARAM_RADIO */
193
194 DEFINE_ACTION_MULTI      ("add-header",                 ACTION_MULTI_ADD_HEADER)
195 DEFINE_ACTION_STRING     ("block",                      ACTION_BLOCK, ACTION_STRING_BLOCK)
196 DEFINE_CGI_PARAM_NO_RADIO("block",                      ACTION_BLOCK, ACTION_STRING_BLOCK, "No reason specified.")
197 DEFINE_ACTION_STRING     ("change-x-forwarded-for",     ACTION_CHANGE_X_FORWARDED_FOR,  ACTION_STRING_CHANGE_X_FORWARDED_FOR)
198 DEFINE_CGI_PARAM_RADIO   ("change-x-forwarded-for",     ACTION_CHANGE_X_FORWARDED_FOR,  ACTION_STRING_CHANGE_X_FORWARDED_FOR, "block", 0)
199 DEFINE_CGI_PARAM_RADIO   ("change-x-forwarded-for",     ACTION_CHANGE_X_FORWARDED_FOR,  ACTION_STRING_CHANGE_X_FORWARDED_FOR, "add", 1)
200 DEFINE_ACTION_MULTI      ("client-header-filter",       ACTION_MULTI_CLIENT_HEADER_FILTER)
201 DEFINE_ACTION_MULTI      ("client-header-tagger",       ACTION_MULTI_CLIENT_HEADER_TAGGER)
202 DEFINE_ACTION_STRING     ("content-type-overwrite",     ACTION_CONTENT_TYPE_OVERWRITE, ACTION_STRING_CONTENT_TYPE)
203 DEFINE_CGI_PARAM_NO_RADIO("content-type-overwrite",     ACTION_CONTENT_TYPE_OVERWRITE, ACTION_STRING_CONTENT_TYPE,    "text/html")
204 DEFINE_ACTION_STRING     ("crunch-client-header",       ACTION_CRUNCH_CLIENT_HEADER, ACTION_STRING_CLIENT_HEADER)
205 DEFINE_CGI_PARAM_NO_RADIO("crunch-client-header",       ACTION_CRUNCH_CLIENT_HEADER, ACTION_STRING_CLIENT_HEADER,          "X-Whatever:")
206 DEFINE_ACTION_BOOL       ("crunch-if-none-match",       ACTION_CRUNCH_IF_NONE_MATCH)
207 DEFINE_ACTION_BOOL       ("crunch-incoming-cookies",    ACTION_NO_COOKIE_SET)
208 DEFINE_ACTION_BOOL       ("crunch-outgoing-cookies",    ACTION_NO_COOKIE_READ)
209 DEFINE_ACTION_STRING     ("crunch-server-header",       ACTION_CRUNCH_SERVER_HEADER, ACTION_STRING_SERVER_HEADER)
210 DEFINE_CGI_PARAM_NO_RADIO("crunch-server-header",       ACTION_CRUNCH_SERVER_HEADER, ACTION_STRING_SERVER_HEADER,          "X-Whatever:")
211 DEFINE_ACTION_STRING     ("deanimate-gifs",             ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE)
212 DEFINE_CGI_PARAM_RADIO   ("deanimate-gifs",             ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE,     "first", 0)
213 DEFINE_CGI_PARAM_RADIO   ("deanimate-gifs",             ACTION_DEANIMATE,       ACTION_STRING_DEANIMATE,     "last",  1)
214 DEFINE_ACTION_BOOL       ("downgrade-http-version",     ACTION_DOWNGRADE)
215 DEFINE_ACTION_STRING     ("fast-redirects",             ACTION_FAST_REDIRECTS,  ACTION_STRING_FAST_REDIRECTS)
216 DEFINE_CGI_PARAM_RADIO   ("fast-redirects",             ACTION_FAST_REDIRECTS,  ACTION_STRING_FAST_REDIRECTS, "simple-check",  0)
217 DEFINE_CGI_PARAM_RADIO   ("fast-redirects",             ACTION_FAST_REDIRECTS,  ACTION_STRING_FAST_REDIRECTS, "check-decoded-url",  1)
218 DEFINE_ACTION_MULTI      ("filter",                     ACTION_MULTI_FILTER)
219 DEFINE_ACTION_BOOL       ("force-text-mode",            ACTION_FORCE_TEXT_MODE)
220 DEFINE_ACTION_STRING     ("forward-override",           ACTION_FORWARD_OVERRIDE, ACTION_STRING_FORWARD_OVERRIDE)
221 DEFINE_CGI_PARAM_CUSTOM  ("forward-override",           ACTION_FORWARD_OVERRIDE, ACTION_STRING_FORWARD_OVERRIDE, "forward .")
222 DEFINE_ACTION_BOOL       ("handle-as-empty-document",   ACTION_HANDLE_AS_EMPTY_DOCUMENT)
223 DEFINE_ACTION_BOOL       ("handle-as-image",            ACTION_IMAGE)
224 DEFINE_ACTION_STRING     ("hide-accept-language",       ACTION_HIDE_ACCEPT_LANGUAGE, ACTION_STRING_LANGUAGE)
225 DEFINE_CGI_PARAM_RADIO   ("hide-accept-language",       ACTION_HIDE_ACCEPT_LANGUAGE, ACTION_STRING_LANGUAGE, "block", 0)
226 DEFINE_CGI_PARAM_CUSTOM  ("hide-accept-language",       ACTION_HIDE_ACCEPT_LANGUAGE, ACTION_STRING_LANGUAGE, "de-de")
227 DEFINE_ACTION_STRING     ("hide-content-disposition",   ACTION_HIDE_CONTENT_DISPOSITION, ACTION_STRING_CONTENT_DISPOSITION)
228 DEFINE_CGI_PARAM_RADIO   ("hide-content-disposition",   ACTION_HIDE_CONTENT_DISPOSITION, ACTION_STRING_CONTENT_DISPOSITION,    "block", 0)
229 DEFINE_CGI_PARAM_CUSTOM  ("hide-content-disposition",   ACTION_HIDE_CONTENT_DISPOSITION, ACTION_STRING_CONTENT_DISPOSITION,    "attachment; filename=WHATEVER.txt")
230 DEFINE_ACTION_BOOL       ("hide-forwarded-for-headers", ACTION_HIDE_FORWARDED)
231 DEFINE_ACTION_STRING     ("hide-from-header",           ACTION_HIDE_FROM,       ACTION_STRING_FROM)
232 DEFINE_CGI_PARAM_RADIO   ("hide-from-header",           ACTION_HIDE_FROM,       ACTION_STRING_FROM,          "block", 1)
233 DEFINE_CGI_PARAM_CUSTOM  ("hide-from-header",           ACTION_HIDE_FROM,       ACTION_STRING_FROM,          "spam_me_senseless@sittingduck.xyz")
234 DEFINE_ACTION_STRING     ("hide-if-modified-since",     ACTION_HIDE_IF_MODIFIED_SINCE, ACTION_STRING_IF_MODIFIED_SINCE)
235 DEFINE_CGI_PARAM_RADIO   ("hide-if-modified-since",     ACTION_HIDE_IF_MODIFIED_SINCE, ACTION_STRING_IF_MODIFIED_SINCE, "block", 0)
236 DEFINE_CGI_PARAM_CUSTOM  ("hide-if-modified-since",     ACTION_HIDE_IF_MODIFIED_SINCE, ACTION_STRING_IF_MODIFIED_SINCE, "-1")
237 DEFINE_ACTION_STRING     ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
238 DEFINE_CGI_PARAM_RADIO   ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "conditional-forge", 3)
239 DEFINE_CGI_PARAM_RADIO   ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "conditional-block", 2)
240 DEFINE_CGI_PARAM_RADIO   ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "forge", 1)
241 DEFINE_CGI_PARAM_RADIO   ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "block", 0)
242 DEFINE_CGI_PARAM_CUSTOM  ("hide-referrer",              ACTION_HIDE_REFERER,    ACTION_STRING_REFERER,       "http://www.privoxy.org/")
243 DEFINE_ACTION_STRING     ("hide-user-agent",            ACTION_HIDE_USER_AGENT, ACTION_STRING_USER_AGENT)
244 DEFINE_CGI_PARAM_NO_RADIO("hide-user-agent",            ACTION_HIDE_USER_AGENT, ACTION_STRING_USER_AGENT,    "Privoxy " VERSION)
245 DEFINE_ACTION_STRING     ("limit-connect",              ACTION_LIMIT_CONNECT,   ACTION_STRING_LIMIT_CONNECT)
246 DEFINE_CGI_PARAM_NO_RADIO("limit-connect",              ACTION_LIMIT_CONNECT,   ACTION_STRING_LIMIT_CONNECT,  "443")
247 DEFINE_ACTION_STRING     ("overwrite-last-modified",    ACTION_OVERWRITE_LAST_MODIFIED, ACTION_STRING_LAST_MODIFIED)
248 DEFINE_CGI_PARAM_RADIO   ("overwrite-last-modified",    ACTION_OVERWRITE_LAST_MODIFIED, ACTION_STRING_LAST_MODIFIED, "block", 0)
249 DEFINE_CGI_PARAM_RADIO   ("overwrite-last-modified",    ACTION_OVERWRITE_LAST_MODIFIED, ACTION_STRING_LAST_MODIFIED, "reset-to-request-time", 1)
250 DEFINE_CGI_PARAM_RADIO   ("overwrite-last-modified",    ACTION_OVERWRITE_LAST_MODIFIED, ACTION_STRING_LAST_MODIFIED, "randomize", 2)
251 DEFINE_ACTION_BOOL       ("prevent-compression",        ACTION_NO_COMPRESSION)
252 DEFINE_ACTION_STRING     ("redirect",                   ACTION_REDIRECT,        ACTION_STRING_REDIRECT)
253 DEFINE_CGI_PARAM_NO_RADIO("redirect",                   ACTION_REDIRECT,        ACTION_STRING_REDIRECT,  "http://localhost/")
254 DEFINE_ACTION_MULTI      ("server-header-filter",       ACTION_MULTI_SERVER_HEADER_FILTER)
255 DEFINE_ACTION_MULTI      ("server-header-tagger",       ACTION_MULTI_SERVER_HEADER_TAGGER)
256 DEFINE_ACTION_BOOL       ("session-cookies-only",       ACTION_NO_COOKIE_KEEP)
257 DEFINE_ACTION_STRING     ("set-image-blocker",          ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER)
258 DEFINE_CGI_PARAM_RADIO   ("set-image-blocker",          ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER, "pattern", 1)
259 DEFINE_CGI_PARAM_RADIO   ("set-image-blocker",          ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER, "blank", 0)
260 DEFINE_CGI_PARAM_CUSTOM  ("set-image-blocker",          ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER,  CGI_PREFIX "send-banner?type=pattern")
261
262 #if DEFINE_ACTION_ALIAS
263
264 /* 
265  * Alternative spellings
266  */
267 DEFINE_ACTION_STRING     ("hide-referer",   ACTION_HIDE_REFERER,    ACTION_STRING_REFERER)
268 DEFINE_ACTION_BOOL       ("prevent-keeping-cookies", ACTION_NO_COOKIE_KEEP)
269
270 /* 
271  * Pre-3.0.7 (pseudo) compatibility
272  */
273 DEFINE_ACTION_MULTI      ("filter-client-headers",       ACTION_MULTI_CLIENT_HEADER_FILTER)
274 DEFINE_ACTION_MULTI      ("filter-server-headers",       ACTION_MULTI_SERVER_HEADER_FILTER)
275
276 /* 
277  * Pre-3.0 compatibility
278  */
279 DEFINE_ACTION_BOOL       ("no-cookie-read",          ACTION_NO_COOKIE_READ)
280 DEFINE_ACTION_BOOL       ("no-cookie-set",           ACTION_NO_COOKIE_SET)
281 DEFINE_ACTION_BOOL       ("prevent-reading-cookies", ACTION_NO_COOKIE_READ)
282 DEFINE_ACTION_BOOL       ("prevent-setting-cookies", ACTION_NO_COOKIE_SET)
283 DEFINE_ACTION_BOOL       ("downgrade",               ACTION_DOWNGRADE)
284 DEFINE_ACTION_BOOL       ("hide-forwarded",          ACTION_HIDE_FORWARDED)
285 DEFINE_ACTION_STRING     ("hide-from",               ACTION_HIDE_FROM,       ACTION_STRING_FROM)
286 DEFINE_ACTION_BOOL       ("image",                   ACTION_IMAGE)
287 DEFINE_ACTION_STRING     ("image-blocker",           ACTION_IMAGE_BLOCKER,   ACTION_STRING_IMAGE_BLOCKER)
288 DEFINE_ACTION_BOOL       ("no-compression",          ACTION_NO_COMPRESSION)
289 DEFINE_ACTION_BOOL       ("no-cookies-keep",         ACTION_NO_COOKIE_KEEP)
290 DEFINE_ACTION_BOOL       ("no-cookies-read",         ACTION_NO_COOKIE_READ)
291 DEFINE_ACTION_BOOL       ("no-cookies-set",          ACTION_NO_COOKIE_SET)
292 #endif /* if DEFINE_ACTION_ALIAS */
293
294 #undef DEFINE_ACTION_MULTI
295 #undef DEFINE_ACTION_STRING
296 #undef DEFINE_ACTION_BOOL
297 #undef DEFINE_ACTION_ALIAS
298 #undef DEFINE_CGI_PARAM_CUSTOM
299 #undef DEFINE_CGI_PARAM_RADIO
300 #undef DEFINE_CGI_PARAM_NO_RADIO
301