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