Now uses _snprintf() in place of snprintf() under Win32.
[privoxy.git] / cgi.h
1 #ifndef _CGI_H
2 #define _CGI_H
3 #define CGI_H_VERSION "$Id: cgi.h,v 1.1 2001/06/03 11:04:49 oes 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 the SourceForge
15  *                IJBSWA team.  http://ijbswa.sourceforge.net
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.1  2001/06/03 11:04:49  oes
42  *    Makefile/in
43  *
44  *    introduced cgi.c
45  *
46  *    actions.c:
47  *
48  *    adapted to new enlist_unique arg format
49  *
50  *    conf loadcfg.c
51  *
52  *    introduced confdir option
53  *
54  *    filters.c filtrers.h
55  *
56  *     extracted-CGI relevant stuff
57  *
58  *    jbsockets.c
59  *
60  *     filled comment
61  *
62  *    jcc.c
63  *
64  *     support for new cgi mechansim
65  *
66  *    list.c list.h
67  *
68  *    functions for new list type: "map"
69  *    extended enlist_unique
70  *
71  *    miscutil.c .h
72  *    introduced bindup()
73  *
74  *    parsers.c parsers.h
75  *
76  *    deleted const struct interceptors
77  *
78  *    pcrs.c
79  *    added FIXME
80  *
81  *    project.h
82  *
83  *    added struct map
84  *    added struct http_response
85  *    changes struct interceptors to struct cgi_dispatcher
86  *    moved HTML stuff to cgi.h
87  *
88  *    re_filterfile:
89  *
90  *    changed
91  *
92  *    showargs.c
93  *    NO TIME LEFT
94  *
95  *
96  *
97  **********************************************************************/
98 \f
99
100 #include "project.h"
101
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105
106 extern struct http_response *cgi_dispatch(struct client_state *csp);
107 extern int make_http_response(struct http_response *rsp);
108 extern void free_http_response(struct http_response *rsp);
109
110 extern struct map *parse_cgi(char *argstring);
111 char *dump_map(struct map *map);
112
113 extern int cgi_default(struct client_state *csp, struct http_response *rsp,
114                        struct map *parameters);
115 int cgi_show_status(struct client_state *csp, struct http_response *rsp,
116                     struct map *parameters);
117
118 extern char *ijb_show_url_info(struct http_request *http, struct client_state *csp);
119
120 extern char *redirect_url(struct http_request *http, struct client_state *csp);
121 extern int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
122                            struct map *parameters);
123
124
125
126 #ifdef TRUST_FILES
127 extern char *ij_untrusted_url(struct http_request *http, struct client_state *csp);
128 #endif /* def TRUST_FILES */
129
130
131
132 #ifdef STATISTICS
133 extern char *add_stats(char *s);
134 #endif /* def STATISTICS */
135
136 static const char CJBGIF[] =
137    "GIF89aD\000\013\000\360\000\000\000\000\000\377\377\377!"
138    "\371\004\001\000\000\001\000,\000\000\000\000D\000\013\000"
139    "\000\002a\214\217\251\313\355\277\000\200G&K\025\316hC\037"
140    "\200\234\230Y\2309\235S\230\266\206\372J\253<\3131\253\271"
141    "\270\215\342\254\013\203\371\202\264\334P\207\332\020o\266"
142    "N\215I\332=\211\312\3513\266:\026AK)\364\370\365aobr\305"
143    "\372\003S\275\274k2\354\254z\347?\335\274x\306^9\374\276"
144    "\037Q\000\000;";
145
146 static const char CBLANKGIF[] =
147    "GIF89a\001\000\001\000\200\000\000\377\377\377\000\000"
148    "\000!\371\004\001\000\000\000\000,\000\000\000\000\001"
149    "\000\001\000\000\002\002D\001\000;";
150
151 static const char CBLOCK[] = 
152 #ifdef AMIGA 
153        "HTTP/1.0 403 Request for blocked URL\n" 
154 #else /* ifndef AMIGA */
155        "HTTP/1.0 202 Request for blocked URL\n"
156 #endif /* ndef AMIGA */
157        "Pragma: no-cache\n"
158        "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\n"
159        "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\n"
160        "Content-Type: text/html\n\n"
161        "<html>\n"
162        "<head>\n"
163        "<title>Internet Junkbuster: Request for blocked URL</title>\n"
164        "</head>\n"
165        WHITEBG
166        "<center><h1>"
167        BANNER
168        "</h1></center>\n"
169       "<p align=center>Your request for <b>%s%s</b>\n"
170       "was blocked.<br><a href=\"http://i.j.b/show-url-info?url=%s%s\">See why</a>"
171 #ifdef FORCE_LOAD
172        " or <a href=\"http://%s" FORCE_PREFIX "%s\">"
173        "go there anyway.</a>"
174 #endif /* def FORCE_LOAD */
175       "</p>\n"
176       "</body>\n"
177       "</html>\n";
178
179 #ifdef TRUST_FILES
180 static const char CTRUST[] =
181 #ifdef AMIGA 
182        "HTTP/1.0 403 Request for untrusted URL\n"
183 #else /* ifndef AMIGA */
184        "HTTP/1.0 202 Request for untrusted URL\n"
185 #endif /* ndef AMIGA */
186        "Pragma: no-cache\n"
187        "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT\n"
188        "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\n"
189        "Content-Type: text/html\n\n"
190        "<html>\n"
191        "<head>\n"
192        "<title>Internet Junkbuster: Request for untrusted URL</title>\n"
193        "</head>\n"
194        WHITEBG
195        "<center>"
196        "<a href=http://i.j.b/ij-untrusted-url?%s+%s+%s>"
197        BANNER
198        "</a>"
199        "</center>"
200        "</body>\n"
201        "</html>\n";
202 #endif /* def TRUST_FILES */
203
204
205 static const char C_HOME_PAGE[] =
206    "<html>\n"
207    "<head>\n"
208    "<title>Internet Junkbuster: Information</title>\n"
209    "</head>\n"
210    BODY
211    "<h1><center>"
212    BANNER
213    "</h1></center>\n"
214    "<p><a href=\"" HOME_PAGE_URL "\">JunkBuster web site</a></p>\n"
215    "<p><a href=\"http://i.j.b/show-proxy-arg\">Proxy configuration</a></p>\n"
216    "<p><a href=\"http://i.j.b/show-url-info\">Look up a URL</a></p>\n"
217    "</body>\n"
218    "</html>\n";
219
220 static const char C_URL_INFO_HEADER[] =
221    "HTTP/1.0 200 OK\n"
222    "Pragma: no-cache\n"
223    "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\n"
224    "Content-Type: text/html\n\n"
225    "<html>\n"
226    "<head>\n"
227    "<title>Internet Junkbuster: URL Info</title>\n"
228    "</head>\n"
229    BODY
230    "<h1><center>"
231    BANNER
232    "</h1></center>\n"
233    "<p>Information for: <a href=\"http://%s\">http://%s</a></p>\n";
234 static const char C_URL_INFO_FOOTER[] =
235    "\n</p>\n"
236    "</body>\n"
237    "</html>\n";
238
239 static const char C_URL_INFO_FORM[] =
240    "HTTP/1.0 200 OK\n"
241    "Pragma: no-cache\n"
242    "Expires:       Thu Jul 31, 1997 07:42:22 pm GMT\n"
243    "Content-Type: text/html\n\n"
244    "<html>\n"
245    "<head>\n"
246    "<title>Internet Junkbuster: URL Info</title>\n"
247    "</head>\n"
248    BODY
249    "<h1><center>"
250    BANNER
251    "</h1></center>\n"
252    "<form method=\"GET\" action=\"http://i.j.b/show-url-info\">\n"
253    "<p>Please enter a URL, without the leading &quot;http://&quot;:</p>"
254    "<p><input type=\"text\" name=\"url\" size=\"80\">"
255    "<input type=\"submit\" value=\"Info\"></p>\n"
256    "</form>\n"
257    "</body>\n"
258    "</html>\n";
259
260 static const char CFAIL[] =
261    "HTTP/1.0 503 Connect failed\n"
262    "Content-Type: text/html\n\n"
263    "<html>\n"
264    "<head>\n"
265    "<title>Internet Junkbuster: Connect failed</title>\n"
266    "</head>\n"
267    BODY
268    "<h1><center>"
269    BANNER
270    "</center></h1>"
271    "TCP connection to '%s' failed: %s.\n<br>"
272    "</body>\n"
273    "</html>\n";
274
275 static const char CNXDOM[] =
276    "HTTP/1.0 404 Non-existent domain\n"
277    "Content-Type: text/html\n\n"
278    "<html>\n"
279    "<head>\n"
280    "<title>Internet Junkbuster: Non-existent domain</title>\n"
281    "</head>\n"
282    BODY
283    "<h1><center>"
284    BANNER
285    "</center></h1>"
286    "No such domain: %s\n"
287    "</body>\n"
288    "</html>\n";
289
290 static const char CNOBANNER[] =
291    "HTTP/1.0 200 No Banner\n"
292    "Content-Type: text/html\n\n"
293    "<html>\n"
294    "<head>\n"
295    "<title>Internet Junkbuster: No Banner</title>\n"
296    "</head>\n"
297    BODY
298    "<h1><center>"
299    BANNER
300    "</h1>"
301    "You asked for a banner that this proxy can't produce because either configuration does not permit.\n<br>"
302    "or the URL didn't end with .gif\n"
303    "</center></body>\n"
304    "</html>\n";
305
306
307 /* Revision control strings from this header and associated .c file */
308 extern const char cgi_rcs[];
309 extern const char cgi_h_rcs[];
310
311 #ifdef __cplusplus
312 } /* extern "C" */
313 #endif
314
315 #endif /* ndef _CGI_H */
316
317 /*
318   Local Variables:
319   tab-width: 3
320   end:
321 */