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