Fix macro name in cgi_show_file() error path.
[privoxy.git] / cgi.h
1 #ifndef CGI_H_INCLUDED
2 #define CGI_H_INCLUDED
3 #define CGI_H_VERSION "$Id: cgi.h,v 1.33 2007/01/28 13:41:17 fabiankeil Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/cgi.h,v $
7  *
8  * Purpose     :  Declares functions to intercept request, generate
9  *                html or gif answers, and to compose HTTP resonses.
10  *                
11  *                Functions declared include:
12  * 
13  *
14  * Copyright   :  Written by and Copyright (C) 2001-2007 the SourceForge
15  *                Privoxy team. http://www.privoxy.org/
16  *
17  *                Based on the Internet Junkbuster originally written
18  *                by and Copyright (C) 1997 Anonymous Coders and 
19  *                Junkbusters Corporation.  http://www.junkbusters.com
20  *
21  *                This program is free software; you can redistribute it 
22  *                and/or modify it under the terms of the GNU General
23  *                Public License as published by the Free Software
24  *                Foundation; either version 2 of the License, or (at
25  *                your option) any later version.
26  *
27  *                This program is distributed in the hope that it will
28  *                be useful, but WITHOUT ANY WARRANTY; without even the
29  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
30  *                PARTICULAR PURPOSE.  See the GNU General Public
31  *                License for more details.
32  *
33  *                The GNU General Public License should be included with
34  *                this file.  If not, you can view it at
35  *                http://www.gnu.org/copyleft/gpl.html
36  *                or write to the Free Software Foundation, Inc., 59
37  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
38  *
39  * Revisions   :
40  *    $Log: cgi.h,v $
41  *    Revision 1.33  2007/01/28 13:41:17  fabiankeil
42  *    - Add HEAD support to finish_http_response.
43  *    - Add error favicon to internal HTML error messages.
44  *
45  *    Revision 1.32  2006/12/17 17:53:39  fabiankeil
46  *    Suppress the toggle link if remote toggling is disabled.
47  *
48  *    Revision 1.31  2006/07/18 14:48:45  david__schmidt
49  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
50  *    with what was really the latest development (the v_3_0_branch branch)
51  *
52  *    Revision 1.29.2.2  2004/02/17 13:30:23  oes
53  *    Moved cgi_error_disabled() from cgiedit.c to
54  *    cgi.c to re-enable build with --disable-editor.
55  *    Fixes Bug #892744. Thanks to Matthew Fischer
56  *    for spotting.
57  *
58  *    Revision 1.29.2.1  2003/12/17 16:33:28  oes
59  *    Added prototype of new function cgi_redirect
60  *
61  *    Revision 1.29  2002/05/19 11:33:21  jongfoster
62  *    If a CGI error was not handled, and propogated back to
63  *    dispatch_known_cgi(), then it was assumed to be "out of memory".
64  *    This gave a very misleading error message.
65  *
66  *    Now other errors will cause a simple message giving the error
67  *    number and asking the user to report a bug.
68  *
69  *    Bug report:
70  *    http://sourceforge.net/tracker/index.php?func=detail
71  *    &aid=557905&group_id=11118&atid=111118
72  *
73  *    Revision 1.28  2002/04/26 12:54:03  oes
74  *    New function add_help_link
75  *
76  *    Revision 1.27  2002/04/24 02:16:51  oes
77  *    Moved get_char_param, get_string_param and get_number_param here from cgiedit.c
78  *
79  *    Revision 1.26  2002/04/10 13:38:35  oes
80  *    load_template signature changed
81  *
82  *    Revision 1.25  2002/04/08 20:50:25  swa
83  *    fixed JB spelling
84  *
85  *    Revision 1.24  2002/03/26 22:29:54  swa
86  *    we have a new homepage!
87  *
88  *    Revision 1.23  2002/03/24 16:18:15  jongfoster
89  *    Removing old logo
90  *
91  *    Revision 1.22  2002/03/24 13:25:43  swa
92  *    name change related issues
93  *
94  *    Revision 1.21  2002/03/07 03:48:38  oes
95  *     - Changed built-in images from GIF to PNG
96  *       (with regard to Unisys patent issue)
97  *     - Added a 4x4 pattern PNG which is less intrusive
98  *       than the logo but also clearly marks the deleted banners
99  *
100  *    Revision 1.20  2002/03/04 17:53:22  oes
101  *    Fixed compiled warning
102  *
103  *    Revision 1.19  2002/01/21 00:33:52  jongfoster
104  *    Adding map_block_keep() to save a few bytes in the edit-actions-list HTML.
105  *
106  *    Revision 1.18  2001/11/16 00:46:31  jongfoster
107  *    Fixing compiler warnings
108  *
109  *    Revision 1.17  2001/10/23 21:48:19  jongfoster
110  *    Cleaning up error handling in CGI functions - they now send back
111  *    a HTML error page and should never cause a FATAL error.  (Fixes one
112  *    potential source of "denial of service" attacks).
113  *
114  *    CGI actions file editor that works and is actually useful.
115  *
116  *    Ability to toggle Junkbuster remotely using a CGI call.
117  *
118  *    You can turn off both the above features in the main configuration
119  *    file, e.g. if you are running a multi-user proxy.
120  *
121  *    Revision 1.16  2001/09/16 17:08:54  jongfoster
122  *    Moving simple CGI functions from cgi.c to new file cgisimple.c
123  *
124  *    Revision 1.15  2001/09/16 15:02:35  jongfoster
125  *    Adding i.j.b/robots.txt.
126  *    Inlining add_stats() since it's only ever called from one place.
127  *
128  *    Revision 1.14  2001/09/16 11:38:02  jongfoster
129  *    Splitting fill_template() into 2 functions:
130  *    template_load() loads the file
131  *    template_fill() performs the PCRS regexps.
132  *    This is because the CGI edit interface has a "table row"
133  *    template which is used many times in the page - this
134  *    change means it's only loaded from disk once.
135  *
136  *    Revision 1.13  2001/09/16 11:00:10  jongfoster
137  *    New function alloc_http_response, for symmetry with free_http_response
138  *
139  *    Revision 1.12  2001/09/13 23:31:25  jongfoster
140  *    Moving image data to cgi.c rather than cgi.h.
141  *
142  *    Revision 1.11  2001/08/05 16:06:20  jongfoster
143  *    Modifiying "struct map" so that there are now separate header and
144  *    "map_entry" structures.  This means that functions which modify a
145  *    map no longer need to return a pointer to the modified map.
146  *    Also, it no longer reverses the order of the entries (which may be
147  *    important with some advanced template substitutions).
148  *
149  *    Revision 1.10  2001/08/01 21:19:22  jongfoster
150  *    Moving file version information to a separate CGI page.
151  *
152  *    Revision 1.9  2001/08/01 00:17:54  jongfoster
153  *    Adding prototype for map_conditional
154  *
155  *    Revision 1.8  2001/07/30 22:08:36  jongfoster
156  *    Tidying up #defines:
157  *    - All feature #defines are now of the form FEATURE_xxx
158  *    - Permanently turned off WIN_GUI_EDIT
159  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
160  *
161  *    Revision 1.7  2001/07/29 18:43:08  jongfoster
162  *    Changing #ifdef _FILENAME_H to FILENAME_H_INCLUDED, to conform to
163  *    ANSI C rules.
164  *
165  *    Revision 1.6  2001/06/29 21:45:41  oes
166  *    Indentation, CRLF->LF, Tab-> Space
167  *
168  *    Revision 1.5  2001/06/29 13:22:44  oes
169  *    - Cleaned up
170  *    - Added new functions: default_exports(), make_menu(),
171  *      error_response() etc, ranamed others and changed
172  *      param and return types.
173  *    - Removed HTTP/HTML snipplets
174  *    - Removed logentry from cancelled commit
175  *
176  *    Revision 1.4  2001/06/09 10:50:58  jongfoster
177  *    Changing "show URL info" handler to new style.
178  *    Adding "extern" to some function prototypes.
179  *
180  *    Revision 1.3  2001/06/03 19:12:16  oes
181  *    introduced new cgi handling
182  *
183  *    No revisions before 1.3
184  *
185  **********************************************************************/
186 \f
187
188 #include "project.h"
189
190 #ifdef __cplusplus
191 extern "C" {
192 #endif
193
194 /*
195  * Main dispatch function
196  */
197 extern struct http_response *dispatch_cgi(struct client_state *csp);
198
199 /* Not exactly a CGI */
200 extern struct http_response * error_response(struct client_state *csp,
201                                              const char *templatename,
202                                              int err);
203
204 /*
205  * CGI support functions
206  */
207 extern struct http_response * alloc_http_response(void);
208 extern void free_http_response(struct http_response *rsp);
209
210 extern struct http_response *finish_http_response(const struct client_state *csp,
211                                                   struct http_response *rsp);
212
213 extern struct map * default_exports(const struct client_state *csp, const char *caller);
214
215 extern jb_err map_block_killer (struct map *exports, const char *name);
216 extern jb_err map_block_keep   (struct map *exports, const char *name);
217 extern jb_err map_conditional  (struct map *exports, const char *name, int choose_first);
218
219 extern jb_err template_load(struct client_state *csp, char ** template_ptr, 
220                             const char *templatename, int recursive);
221 extern jb_err template_fill(char ** template_ptr, const struct map *exports);
222 extern jb_err template_fill_for_cgi(struct client_state *csp,
223                                     const char *templatename,
224                                     struct map *exports,
225                                     struct http_response *rsp);
226
227 extern void cgi_init_error_messages(void);
228 extern struct http_response *cgi_error_memory(void);
229 extern jb_err cgi_redirect (struct http_response * rsp, const char *target);
230
231 extern jb_err cgi_error_no_template(struct client_state *csp,
232                                     struct http_response *rsp,
233                                     const char *template_name);
234 extern jb_err cgi_error_bad_param(struct client_state *csp,
235                                   struct http_response *rsp);
236 extern jb_err cgi_error_disabled(struct client_state *csp,
237                                  struct http_response *rsp);
238 extern jb_err cgi_error_unknown(struct client_state *csp,
239                          struct http_response *rsp,
240                          jb_err error_to_report);
241
242 extern jb_err get_number_param(struct client_state *csp,
243                                const struct map *parameters,
244                                char *name,
245                                unsigned *pvalue);
246 extern jb_err get_string_param(const struct map *parameters,
247                                const char *param_name,
248                                const char **pparam);
249 extern char   get_char_param(const struct map *parameters,
250                              const char *param_name);
251
252 /*
253  * Text generators
254  */
255 extern void get_http_time(int time_offset, char *buf, size_t buffer_size);
256 extern char *add_help_link(const char *item, struct configuration_spec *config);
257 extern char *make_menu(const char *self, const unsigned feature_flags);
258 extern char *dump_map(const struct map *the_map);
259
260 /*
261  * Ad replacement images
262  */
263 extern const char image_pattern_data[];
264 extern const size_t  image_pattern_length;
265 extern const char image_blank_data[];
266 extern const size_t  image_blank_length;
267
268 /* Revision control strings from this header and associated .c file */
269 extern const char cgi_rcs[];
270 extern const char cgi_h_rcs[];
271
272 #ifdef __cplusplus
273 } /* extern "C" */
274 #endif
275
276 #endif /* ndef CGI_H_INCLUDED */
277
278 /*
279   Local Variables:
280   tab-width: 3
281   end:
282 */