Remove the treat-forbidden-connects-like-blocks action. We now
[privoxy.git] / cgisimple.c
1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.65 2008/02/23 16:33:43 fabiankeil Exp $";
2 /*********************************************************************
3  *
4  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
5  *
6  * Purpose     :  Simple CGIs to get information about Privoxy's
7  *                status.
8  *                
9  *                Functions declared include:
10  * 
11  *
12  * Copyright   :  Written by and Copyright (C) 2001-2007 the SourceForge
13  *                Privoxy team. http://www.privoxy.org/
14  *
15  *                Based on the Internet Junkbuster originally written
16  *                by and Copyright (C) 1997 Anonymous Coders and 
17  *                Junkbusters Corporation.  http://www.junkbusters.com
18  *
19  *                This program is free software; you can redistribute it 
20  *                and/or modify it under the terms of the GNU General
21  *                Public License as published by the Free Software
22  *                Foundation; either version 2 of the License, or (at
23  *                your option) any later version.
24  *
25  *                This program is distributed in the hope that it will
26  *                be useful, but WITHOUT ANY WARRANTY; without even the
27  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
28  *                PARTICULAR PURPOSE.  See the GNU General Public
29  *                License for more details.
30  *
31  *                The GNU General Public License should be included with
32  *                this file.  If not, you can view it at
33  *                http://www.gnu.org/copyleft/gpl.html
34  *                or write to the Free Software Foundation, Inc., 59
35  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
36  *
37  * Revisions   :
38  *    $Log: cgisimple.c,v $
39  *    Revision 1.65  2008/02/23 16:33:43  fabiankeil
40  *    Let forward_url() use the standard parameter ordering
41  *    and mark its second parameter immutable.
42  *
43  *    Revision 1.64  2008/02/03 13:56:07  fabiankeil
44  *    Add SOCKS5 support for show-url-info CGI page.
45  *
46  *    Revision 1.63  2008/02/01 06:04:31  fabiankeil
47  *    If edit buttons on the show-url-info CGI page are hidden, explain why.
48  *
49  *    Revision 1.62  2008/02/01 05:52:40  fabiankeil
50  *    Hide edit buttons on the show-url-info CGI page if enable-edit-action
51  *    is disabled. Patch by Lee with additional white space adjustments.
52  *
53  *    Revision 1.61  2008/01/26 11:13:25  fabiankeil
54  *    If enable-edit-actions is disabled, hide the edit buttons and explain why.
55  *
56  *    Revision 1.60  2007/10/27 13:12:13  fabiankeil
57  *    Finish 1.49 and check write access before
58  *    showing edit buttons on show-url-info page.
59  *
60  *    Revision 1.59  2007/10/19 16:42:36  fabiankeil
61  *    Plug memory leak I introduced five months ago.
62  *    Yay Valgrind and Privoxy-Regression-Test.
63  *
64  *    Revision 1.58  2007/07/21 12:19:50  fabiankeil
65  *    If show-url-info is called with an URL that Privoxy
66  *    would reject as invalid, don't show unresolved forwarding
67  *    variables, "final matches" or claim the site's secure.
68  *
69  *    Revision 1.57  2007/06/01 16:53:05  fabiankeil
70  *    Adjust cgi_show_url_info() to show what forward-override{}
71  *    would do with the requested URL (instead of showing how the
72  *    request for the CGI page would be forwarded if it wasn't a
73  *    CGI request).
74  *
75  *    Revision 1.56  2007/05/21 10:50:35  fabiankeil
76  *    - Use strlcpy() instead of strcpy().
77  *    - Stop treating actions files special. Expect a complete file name
78  *      (with or without path) like it's done for the rest of the files.
79  *      Closes FR#588084.
80  *    - Don't rerun sed() in cgi_show_request().
81  *
82  *    Revision 1.55  2007/04/13 13:36:46  fabiankeil
83  *    Reference action files in CGI URLs by id instead
84  *    of using the first part of the file name.
85  *    Fixes BR 1694250 and BR 1590556.
86  *
87  *    Revision 1.54  2007/04/09 18:11:35  fabiankeil
88  *    Don't mistake VC++'s _snprintf() for a snprintf() replacement.
89  *
90  *    Revision 1.53  2007/04/08 13:21:04  fabiankeil
91  *    Reference action files in CGI URLs by id instead
92  *    of using the first part of the file name.
93  *    Fixes BR 1694250 and BR 1590556.
94  *
95  *    Revision 1.52  2007/02/13 15:10:26  fabiankeil
96  *    Apparently fopen()ing in "binary" mode doesn't require
97  *    #ifdefs, it's already done without them in cgiedit.c.
98  *
99  *    Revision 1.51  2007/02/10 16:55:22  fabiankeil
100  *    - Show forwarding settings on the show-url-info page
101  *    - Fix some HTML syntax errors.
102  *
103  *    Revision 1.50  2007/01/23 15:51:17  fabiankeil
104  *    Add favicon delivery functions.
105  *
106  *    Revision 1.49  2007/01/20 16:29:38  fabiankeil
107  *    Suppress edit buttons for action files if Privoxy has
108  *    no write access. Suggested by Roland in PR 1564026.
109  *
110  *    Revision 1.48  2007/01/20 15:31:31  fabiankeil
111  *    Display warning if show-url-info CGI page
112  *    is used while Privoxy is toggled off.
113  *
114  *    Revision 1.47  2007/01/12 15:07:10  fabiankeil
115  *    Use zalloc in cgi_send_user_manual.
116  *
117  *    Revision 1.46  2007/01/02 12:49:46  fabiankeil
118  *    Add FEATURE_ZLIB to the list of conditional
119  *    defines at the show-status page.
120  *
121  *    Revision 1.45  2006/12/28 18:16:41  fabiankeil
122  *    Fixed gcc43 compiler warnings, zero out cgi_send_user_manual's
123  *    body memory before using it, replaced sprintf calls with snprintf.
124  *
125  *    Revision 1.44  2006/12/22 14:19:27  fabiankeil
126  *    Removed checks whether or not AF_FILES have
127  *    data structures associated with them in cgi_show_status.
128  *    It doesn't matter as we're only interested in the file names.
129  *
130  *    For the action files the checks were always true,
131  *    but they prevented empty filter files from being
132  *    listed. Fixes parts of BR 1619208.
133  *
134  *    Revision 1.43  2006/12/17 17:57:56  fabiankeil
135  *    - Added FEATURE_GRACEFUL_TERMINATION to the
136  *      "conditional #defines" section
137  *    - Escaped ampersands in generated HTML.
138  *    - Renamed re-filter-filename to re-filter-filenames
139  *
140  *    Revision 1.42  2006/11/21 15:43:12  fabiankeil
141  *    Add special treatment for WIN32 to make sure
142  *    cgi_send_user_manual opens the files in binary mode.
143  *    Fixes BR 1600411 and unbreaks image delivery.
144  *
145  *    Remove outdated comment.
146  *
147  *    Revision 1.41  2006/10/09 19:18:28  roro
148  *    Redirect http://p.p/user-manual (without trailing slash) to
149  *    http://p.p/user-manual/ (with trailing slash), otherwise links will be broken.
150  *
151  *    Revision 1.40  2006/09/09 13:05:33  fabiankeil
152  *    Modified cgi_send_user_manual to serve binary
153  *    content without destroying it first. Should also be
154  *    faster now. Added ".jpg" check for Content-Type guessing.
155  *
156  *    Revision 1.39  2006/09/08 09:49:23  fabiankeil
157  *    Deliver documents in the user-manual directory
158  *    with "Content-Type text/css" if their filename
159  *    ends with ".css".
160  *
161  *    Revision 1.38  2006/09/06 18:45:03  fabiankeil
162  *    Incorporate modified version of Roland Rosenfeld's patch to
163  *    optionally access the user-manual via Privoxy. Closes patch 679075.
164  *
165  *    Formatting changed to Privoxy style, added call to
166  *    cgi_error_no_template if the requested file doesn't
167  *    exist and modified check whether or not Privoxy itself
168  *    should serve the manual. Should work cross-platform now.
169  *
170  *    Revision 1.37  2006/07/18 14:48:45  david__schmidt
171  *    Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
172  *    with what was really the latest development (the v_3_0_branch branch)
173  *
174  *    Revision 1.35.2.7  2006/01/29 23:10:56  david__schmidt
175  *    Multiple filter file support
176  *
177  *    Revision 1.35.2.6  2005/07/04 03:13:43  david__schmidt
178  *    Undo some damaging memory leak patches
179  *
180  *    Revision 1.35.2.5  2005/05/07 21:50:55  david__schmidt
181  *    A few memory leaks plugged (mostly on error paths)
182  *
183  *    Revision 1.35.2.4  2005/04/04 02:21:24  david__schmidt
184  *    Another instance of:
185  *    Don't show "Edit" buttons #ifndef FEATURE_CGI_EDIT_ACTIONS
186  *    Thanks to Magnus Holmgren for the patch
187  *
188  *    Revision 1.35.2.3  2003/12/17 16:34:15  oes
189  *     - Prevent line wrap beween "View/Edit" link buttons on status page
190  *     - Some (mostly irrelevant) fixes for Out-of-mem-case handling
191  *
192  *    Revision 1.35.2.2  2003/04/03 13:48:28  oes
193  *    Don't show "Edit" buttons #ifndef FEATURE_CGI_EDIT_ACTIONS
194  *
195  *    Revision 1.35.2.1  2002/07/04 15:02:38  oes
196  *    Added ability to send redirects to send-banner CGI, so that it can completely mimic the image blocking action if called with type=auto
197  *
198  *    Revision 1.35.2.1  2002/07/01 17:32:04  morcego
199  *    Applying patch from Andreas as provided by Hal on the list.
200  *    Message-ID: <20020701121218.V1606@feenix.burgiss.net>
201  *
202  *    Revision 1.35  2002/05/12 21:44:44  jongfoster
203  *    Adding amiga.[ch] revision information, if on an amiga.
204  *
205  *    Revision 1.34  2002/04/30 12:06:12  oes
206  *    Deleted unused code from default_cgi
207  *
208  *    Revision 1.33  2002/04/30 11:14:52  oes
209  *    Made csp the first parameter in *action_to_html
210  *
211  *    Revision 1.32  2002/04/26 18:29:13  jongfoster
212  *    Fixing this Visual C++ warning:
213  *    cgisimple.c(775) : warning C4018: '<' : signed/unsigned mismatch
214  *
215  *    Revision 1.31  2002/04/26 12:54:36  oes
216  *     - Kill obsolete REDIRECT_URL code
217  *     - Error handling fixes
218  *     - Style sheet related HTML snipplet changes
219  *     - cgi_show_url_info:
220  *       - Matches now in table, actions on single lines,
221  *         linked to help
222  *       - standard.action suppressed
223  *       - Buttons to View and Edit AFs
224  *
225  *    Revision 1.30  2002/04/24 02:18:08  oes
226  *     - show-status is now the starting point for editing
227  *       the actions files, generate list of all AFs with buttons
228  *       for viewing and editing, new look for file list (Jon:
229  *       buttons now aligned ;-P ), view mode now supports multiple
230  *       AFs, name changes, no view links for unspecified files,
231  *       no edit link for standard.action.
232  *
233  *     - Jon's multiple AF patch: cgi_show_url_info now uses all
234  *       AFs and marks the output accordingly
235  *
236  *    Revision 1.29  2002/04/10 13:38:35  oes
237  *    load_template signature changed
238  *
239  *    Revision 1.28  2002/04/07 15:42:12  jongfoster
240  *    Fixing send-banner?type=auto when the image-blocker is
241  *    a redirect to send-banner
242  *
243  *    Revision 1.27  2002/04/05 15:50:48  oes
244  *    added send-stylesheet CGI
245  *
246  *    Revision 1.26  2002/04/04 00:36:36  gliptak
247  *    always use pcre for matching
248  *
249  *    Revision 1.25  2002/04/03 22:28:03  gliptak
250  *    Removed references to gnu_regex
251  *
252  *    Revision 1.24  2002/04/02 16:12:47  oes
253  *    Fix: moving misplaced lines into #ifdef FEATURE_FORCE
254  *
255  *    Revision 1.23  2002/03/26 22:29:54  swa
256  *    we have a new homepage!
257  *
258  *    Revision 1.22  2002/03/24 16:18:15  jongfoster
259  *    Removing old logo
260  *
261  *    Revision 1.21  2002/03/24 15:23:33  jongfoster
262  *    Name changes
263  *
264  *    Revision 1.20  2002/03/24 13:25:43  swa
265  *    name change related issues
266  *
267  *    Revision 1.19  2002/03/16 23:54:06  jongfoster
268  *    Adding graceful termination feature, to help look for memory leaks.
269  *    If you enable this (which, by design, has to be done by hand
270  *    editing config.h) and then go to http://i.j.b/die, then the program
271  *    will exit cleanly after the *next* request.  It should free all the
272  *    memory that was used.
273  *
274  *    Revision 1.18  2002/03/12 01:44:49  oes
275  *    Changed default for "blocked" image from jb logo to checkboard pattern
276  *
277  *    Revision 1.17  2002/03/08 16:43:18  oes
278  *    Added choice beween GIF and PNG built-in images
279  *
280  *    Revision 1.16  2002/03/07 03:48:38  oes
281  *     - Changed built-in images from GIF to PNG
282  *       (with regard to Unisys patent issue)
283  *     - Added a 4x4 pattern PNG which is less intrusive
284  *       than the logo but also clearly marks the deleted banners
285  *
286  *    Revision 1.15  2002/03/06 22:54:35  jongfoster
287  *    Automated function-comment nitpicking.
288  *
289  *    Revision 1.14  2002/03/02 04:14:50  david__schmidt
290  *    Clean up a little CRLF unpleasantness that suddenly appeared
291  *
292  *    Revision 1.13  2002/02/21 00:10:37  jongfoster
293  *    Adding send-banner?type=auto option
294  *
295  *    Revision 1.12  2002/01/23 01:03:32  jongfoster
296  *    Fixing gcc [CygWin] compiler warnings
297  *
298  *    Revision 1.11  2002/01/23 00:01:04  jongfoster
299  *    Adding cgi_transparent_gif() for http://i.j.b/t
300  *    Adding missing html_encode() to many CGI functions.
301  *    Adding urlmatch.[ch] to http://i.j.b/show-version
302  *
303  *    Revision 1.10  2002/01/17 21:10:37  jongfoster
304  *    Changes to cgi_show_url_info to use new matching code from urlmatch.c.
305  *    Also fixing a problem in the same function with improperly quoted URLs
306  *    in output HTML, and adding code to handle https:// URLs correctly.
307  *
308  *    Revision 1.9  2001/11/30 23:09:15  jongfoster
309  *    Now reports on FEATURE_CGI_EDIT_ACTIONS
310  *    Removing FEATURE_DENY_GZIP from template
311  *
312  *    Revision 1.8  2001/11/13 00:14:07  jongfoster
313  *    Fixing stupid bug now I've figured out what || means.
314  *    (It always returns 0 or 1, not one of it's paramaters.)
315  *
316  *    Revision 1.7  2001/10/23 21:48:19  jongfoster
317  *    Cleaning up error handling in CGI functions - they now send back
318  *    a HTML error page and should never cause a FATAL error.  (Fixes one
319  *    potential source of "denial of service" attacks).
320  *
321  *    CGI actions file editor that works and is actually useful.
322  *
323  *    Ability to toggle JunkBuster remotely using a CGI call.
324  *
325  *    You can turn off both the above features in the main configuration
326  *    file, e.g. if you are running a multi-user proxy.
327  *
328  *    Revision 1.6  2001/10/14 22:00:32  jongfoster
329  *    Adding support for a 404 error when an invalid CGI page is requested.
330  *
331  *    Revision 1.5  2001/10/07 15:30:41  oes
332  *    Removed FEATURE_DENY_GZIP
333  *
334  *    Revision 1.4  2001/10/02 15:31:12  oes
335  *    Introduced show-request cgi
336  *
337  *    Revision 1.3  2001/09/22 16:34:44  jongfoster
338  *    Removing unneeded #includes
339  *
340  *    Revision 1.2  2001/09/19 18:01:11  oes
341  *    Fixed comments; cosmetics
342  *
343  *    Revision 1.1  2001/09/16 17:08:54  jongfoster
344  *    Moving simple CGI functions from cgi.c to new file cgisimple.c
345  *
346  *
347  **********************************************************************/
348 \f
349
350 #include "config.h"
351
352 #include <stdio.h>
353 #include <sys/types.h>
354 #include <stdlib.h>
355 #include <ctype.h>
356 #include <string.h>
357 #include <assert.h>
358
359 #ifdef HAVE_ACCESS
360 #include <unistd.h>
361 #endif /* def HAVE_ACCESS */
362
363 #include "project.h"
364 #include "cgi.h"
365 #include "cgisimple.h"
366 #include "list.h"
367 #include "encode.h"
368 #include "jcc.h"
369 #include "filters.h"
370 #include "actions.h"
371 #include "miscutil.h"
372 #include "loadcfg.h"
373 #include "parsers.h"
374 #include "urlmatch.h"
375 #include "errlog.h"
376
377 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
378
379
380 static char *show_rcs(void);
381 static jb_err show_defines(struct map *exports);
382
383 /*
384  * 16x16 ico blobs for favicon delivery functions.
385  */
386 const char default_favicon_data[] =
387    "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
388    "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
389    "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
390    "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
391    "\000\000\377\377\377\000\377\000\052\000\017\360\000\000\077"
392    "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
393    "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
394    "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
395    "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
396    "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
397    "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
398    "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
399    "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
400    "\017\000\000";
401 const char error_favicon_data[] =
402    "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
403    "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
404    "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
405    "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
406    "\000\000\377\377\377\000\000\000\377\000\017\360\000\000\077"
407    "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
408    "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
409    "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
410    "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
411    "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
412    "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
413    "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
414    "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
415    "\017\000\000";
416 const size_t default_favicon_length  = sizeof(default_favicon_data) - 1;
417 const size_t error_favicon_length  = sizeof(error_favicon_data) - 1;
418
419 /*********************************************************************
420  *
421  * Function    :  cgi_default
422  *
423  * Description :  CGI function that is called for the CGI_SITE_1_HOST
424  *                and CGI_SITE_2_HOST/CGI_SITE_2_PATH base URLs.
425  *                Boring - only exports the default exports.
426  *               
427  * Parameters  :
428  *          1  :  csp = Current client state (buffers, headers, etc...)
429  *          2  :  rsp = http_response data structure for output
430  *          3  :  parameters = map of cgi parameters
431  *
432  * CGI Parameters : none
433  *
434  * Returns     :  JB_ERR_OK on success
435  *                JB_ERR_MEMORY on out-of-memory
436  *
437  *********************************************************************/
438 jb_err cgi_default(struct client_state *csp,
439                    struct http_response *rsp,
440                    const struct map *parameters)
441 {
442    struct map *exports;
443
444    assert(csp);
445    assert(rsp);
446
447    if (NULL == (exports = default_exports(csp, "")))
448    {
449       return JB_ERR_MEMORY;
450    }
451
452    return template_fill_for_cgi(csp, "default", exports, rsp);
453 }
454
455
456 /*********************************************************************
457  *
458  * Function    :  cgi_error_404
459  *
460  * Description :  CGI function that is called if an unknown action was
461  *                given.
462  *               
463  * Parameters  :
464  *          1  :  csp = Current client state (buffers, headers, etc...)
465  *          2  :  rsp = http_response data structure for output
466  *          3  :  parameters = map of cgi parameters
467  *
468  * CGI Parameters : none
469  *
470  * Returns     :  JB_ERR_OK on success
471  *                JB_ERR_MEMORY on out-of-memory error.  
472  *
473  *********************************************************************/
474 jb_err cgi_error_404(struct client_state *csp,
475                      struct http_response *rsp,
476                      const struct map *parameters)
477 {
478    struct map *exports;
479
480    assert(csp);
481    assert(rsp);
482    assert(parameters);
483
484    if (NULL == (exports = default_exports(csp, NULL)))
485    {
486       return JB_ERR_MEMORY;
487    }
488
489    rsp->status = strdup("404 Privoxy configuration page not found");
490    if (rsp->status == NULL)
491    {
492       free_map(exports);
493       return JB_ERR_MEMORY;
494    }
495
496    return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
497 }
498
499
500 #ifdef FEATURE_GRACEFUL_TERMINATION
501 /*********************************************************************
502  *
503  * Function    :  cgi_die
504  *
505  * Description :  CGI function to shut down Privoxy.
506  *                NOTE: Turning this on in a production build
507  *                would be a BAD idea.  An EXTREMELY BAD idea.
508  *                In short, don't do it.
509  *               
510  * Parameters  :
511  *          1  :  csp = Current client state (buffers, headers, etc...)
512  *          2  :  rsp = http_response data structure for output
513  *          3  :  parameters = map of cgi parameters
514  *
515  * CGI Parameters : none
516  *
517  * Returns     :  JB_ERR_OK on success
518  *                JB_ERR_MEMORY on out-of-memory error.  
519  *
520  *********************************************************************/
521 jb_err cgi_die (struct client_state *csp,
522                 struct http_response *rsp,
523                 const struct map *parameters)
524 {
525    assert(csp);
526    assert(rsp);
527    assert(parameters);
528
529    /* quit */
530    g_terminate = 1;
531
532    /*
533     * I don't really care what gets sent back to the browser.
534     * Take the easy option - "out of memory" page.
535     */
536
537    return JB_ERR_MEMORY;
538 }
539 #endif /* def FEATURE_GRACEFUL_TERMINATION */
540
541
542 /*********************************************************************
543  *
544  * Function    :  cgi_show_request
545  *
546  * Description :  Show the client's request and what sed() would have
547  *                made of it.
548  *               
549  * Parameters  :
550  *          1  :  csp = Current client state (buffers, headers, etc...)
551  *          2  :  rsp = http_response data structure for output
552  *          3  :  parameters = map of cgi parameters
553  *
554  * CGI Parameters : none
555  *
556  * Returns     :  JB_ERR_OK on success
557  *                JB_ERR_MEMORY on out-of-memory error.  
558  *
559  *********************************************************************/
560 jb_err cgi_show_request(struct client_state *csp,
561                         struct http_response *rsp,
562                         const struct map *parameters)
563 {
564    char *p;
565    struct map *exports;
566
567    assert(csp);
568    assert(rsp);
569    assert(parameters);
570
571    if (NULL == (exports = default_exports(csp, "show-request")))
572    {
573       return JB_ERR_MEMORY;
574    }
575    
576    /*
577     * Repair the damage done to the IOB by get_header()
578     */
579    for (p = csp->iob->buf; p < csp->iob->eod; p++)
580    {
581       if (*p == '\0') *p = '\n';
582    }
583
584    /*
585     * Export the original client's request and the one we would
586     * be sending to the server if this wasn't a CGI call
587     */
588
589    if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
590    {
591       free_map(exports);
592       return JB_ERR_MEMORY;
593    }
594
595    if (map(exports, "processed-request", 1,
596          html_encode_and_free_original(list_to_text(csp->headers)), 0))
597    {
598       free_map(exports);
599       return JB_ERR_MEMORY;
600    }
601
602    return template_fill_for_cgi(csp, "show-request", exports, rsp);
603 }
604
605
606 /*********************************************************************
607  *
608  * Function    :  cgi_send_banner
609  *
610  * Description :  CGI function that returns a banner. 
611  *
612  * Parameters  :
613  *          1  :  csp = Current client state (buffers, headers, etc...)
614  *          2  :  rsp = http_response data structure for output
615  *          3  :  parameters = map of cgi parameters
616  *
617  * CGI Parameters :
618  *           type : Selects the type of banner between "trans", "logo",
619  *                  and "auto". Defaults to "logo" if absent or invalid.
620  *                  "auto" means to select as if we were image-blocking.
621  *                  (Only the first character really counts; b and t are
622  *                  equivalent).
623  *
624  * Returns     :  JB_ERR_OK on success
625  *                JB_ERR_MEMORY on out-of-memory error.  
626  *
627  *********************************************************************/
628 jb_err cgi_send_banner(struct client_state *csp,
629                        struct http_response *rsp,
630                        const struct map *parameters)
631 {
632    char imagetype = lookup(parameters, "type")[0];
633
634    /*
635     * If type is auto, then determine the right thing
636     * to do from the set-image-blocker action
637     */
638    if (imagetype == 'a') 
639    {
640       /*
641        * Default to pattern
642        */
643       imagetype = 'p';
644
645 #ifdef FEATURE_IMAGE_BLOCKING
646       if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
647       {
648          static const char prefix1[] = CGI_PREFIX "send-banner?type=";
649          static const char prefix2[] = "http://" CGI_SITE_1_HOST "/send-banner?type=";
650          const char *p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
651
652          if (p == NULL)
653          {
654             /* Use default - nothing to do here. */
655          }
656          else if (0 == strcmpic(p, "blank"))
657          {
658             imagetype = 'b';
659          }
660          else if (0 == strcmpic(p, "pattern"))
661          {
662             imagetype = 'p';
663          }
664
665          /*
666           * If the action is to call this CGI, determine
667           * the argument:
668           */
669          else if (0 == strncmpic(p, prefix1, sizeof(prefix1) - 1))
670          {
671             imagetype = p[sizeof(prefix1) - 1];
672          }
673          else if (0 == strncmpic(p, prefix2, sizeof(prefix2) - 1))
674          {
675             imagetype = p[sizeof(prefix2) - 1];
676          }
677
678          /*
679           * Everything else must (should) be a URL to
680           * redirect to.
681           */
682          else
683          {
684             imagetype = 'r';
685          }
686       }
687 #endif /* def FEATURE_IMAGE_BLOCKING */
688    }
689       
690    /*
691     * Now imagetype is either the non-auto type we were called with,
692     * or it was auto and has since been determined. In any case, we
693     * can proceed to actually answering the request by sending a redirect
694     * or an image as appropriate:
695     */
696    if (imagetype == 'r') 
697    {
698       rsp->status = strdup("302 Local Redirect from Privoxy");
699       if (rsp->status == NULL)
700       {
701          return JB_ERR_MEMORY;
702       }
703       if (enlist_unique_header(rsp->headers, "Location",
704                                csp->action->string[ACTION_STRING_IMAGE_BLOCKER]))
705       {
706          return JB_ERR_MEMORY;
707       }
708    }
709    else
710    {
711       if ((imagetype == 'b') || (imagetype == 't')) 
712       {
713          rsp->body = bindup(image_blank_data, image_blank_length);
714          rsp->content_length = image_blank_length;
715       }
716       else
717       {
718          rsp->body = bindup(image_pattern_data, image_pattern_length);
719          rsp->content_length = image_pattern_length;
720       }
721
722       if (rsp->body == NULL)
723       {
724          return JB_ERR_MEMORY;
725       }
726       if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
727       {
728          return JB_ERR_MEMORY;
729       }
730
731       rsp->is_static = 1;
732    }
733
734    return JB_ERR_OK;
735
736 }
737
738
739 /*********************************************************************
740  *
741  * Function    :  cgi_transparent_image
742  *
743  * Description :  CGI function that sends a 1x1 transparent image.
744  *
745  * Parameters  :
746  *          1  :  csp = Current client state (buffers, headers, etc...)
747  *          2  :  rsp = http_response data structure for output
748  *          3  :  parameters = map of cgi parameters
749  *
750  * CGI Parameters : None
751  *
752  * Returns     :  JB_ERR_OK on success
753  *                JB_ERR_MEMORY on out-of-memory error.  
754  *
755  *********************************************************************/
756 jb_err cgi_transparent_image(struct client_state *csp,
757                              struct http_response *rsp,
758                              const struct map *parameters)
759 {
760    rsp->body = bindup(image_blank_data, image_blank_length);
761    rsp->content_length = image_blank_length;
762
763    if (rsp->body == NULL)
764    {
765       return JB_ERR_MEMORY;
766    }
767
768    if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
769    {
770       return JB_ERR_MEMORY;
771    }
772
773    rsp->is_static = 1;
774
775    return JB_ERR_OK;
776
777 }
778
779
780 /*********************************************************************
781  *
782  * Function    :  cgi_send_default_favicon
783  *
784  * Description :  CGI function that sends the standard favicon.
785  *
786  * Parameters  :
787  *          1  :  csp = Current client state (buffers, headers, etc...)
788  *          2  :  rsp = http_response data structure for output
789  *          3  :  parameters = map of cgi parameters
790  *
791  * CGI Parameters : None
792  *
793  * Returns     :  JB_ERR_OK on success
794  *                JB_ERR_MEMORY on out-of-memory error.  
795  *
796  *********************************************************************/
797 jb_err cgi_send_default_favicon(struct client_state *csp,
798                                 struct http_response *rsp,
799                                 const struct map *parameters)
800 {
801    rsp->body = bindup(default_favicon_data, default_favicon_length);
802    rsp->content_length = default_favicon_length;
803
804    if (rsp->body == NULL)
805    {
806       return JB_ERR_MEMORY;
807    }
808
809    if (enlist(rsp->headers, "Content-Type: image/x-icon"))
810    {
811       return JB_ERR_MEMORY;
812    }
813
814    rsp->is_static = 1;
815
816    return JB_ERR_OK;
817
818 }
819
820
821 /*********************************************************************
822  *
823  * Function    :  cgi_send_error_favicon
824  *
825  * Description :  CGI function that sends the favicon for error pages.
826  *
827  * Parameters  :
828  *          1  :  csp = Current client state (buffers, headers, etc...)
829  *          2  :  rsp = http_response data structure for output
830  *          3  :  parameters = map of cgi parameters
831  *
832  * CGI Parameters : None
833  *
834  * Returns     :  JB_ERR_OK on success
835  *                JB_ERR_MEMORY on out-of-memory error.  
836  *
837  *********************************************************************/
838 jb_err cgi_send_error_favicon(struct client_state *csp,
839                               struct http_response *rsp,
840                               const struct map *parameters)
841 {
842    rsp->body = bindup(error_favicon_data, error_favicon_length);
843    rsp->content_length = error_favicon_length;
844
845    if (rsp->body == NULL)
846    {
847       return JB_ERR_MEMORY;
848    }
849
850    if (enlist(rsp->headers, "Content-Type: image/x-icon"))
851    {
852       return JB_ERR_MEMORY;
853    }
854
855    rsp->is_static = 1;
856
857    return JB_ERR_OK;
858
859 }
860
861
862 /*********************************************************************
863  *
864  * Function    :  cgi_send_stylesheet
865  *
866  * Description :  CGI function that sends a css stylesheet found
867  *                in the cgi-style.css template
868  *
869  * Parameters  :
870  *          1  :  csp = Current client state (buffers, headers, etc...)
871  *          2  :  rsp = http_response data structure for output
872  *          3  :  parameters = map of cgi parameters
873  *
874  * CGI Parameters : None
875  *
876  * Returns     :  JB_ERR_OK on success
877  *                JB_ERR_MEMORY on out-of-memory error.  
878  *
879  *********************************************************************/
880 jb_err cgi_send_stylesheet(struct client_state *csp,
881                            struct http_response *rsp,
882                            const struct map *parameters)
883 {
884    jb_err err;
885    
886    assert(csp);
887    assert(rsp);
888
889    err = template_load(csp, &rsp->body, "cgi-style.css", 0);
890
891    if (err == JB_ERR_FILE)
892    {
893       /*
894        * No way to tell user; send empty stylesheet
895        */
896       log_error(LOG_LEVEL_ERROR, "Could not find cgi-style.css template");
897    }
898    else if (err)
899    {
900       return err; /* JB_ERR_MEMORY */
901    }
902
903    if (enlist(rsp->headers, "Content-Type: text/css"))
904    {
905       return JB_ERR_MEMORY;
906    }
907
908    return JB_ERR_OK;
909
910 }
911 /*********************************************************************
912  *
913  * Function    :  cgi_send_user_manual
914  *
915  * Description :  CGI function that sends a file in the user
916  *                manual directory.
917  *
918  * Parameters  :
919  *          1  :  csp = Current client state (buffers, headers, etc...)
920  *          2  :  rsp = http_response data structure for output
921  *          3  :  parameters = map of cgi parameters
922  *
923  * CGI Parameters : file=name.html, the name of the HTML file
924  *                  (relative to user-manual from config)
925  *
926  * Returns     :  JB_ERR_OK on success
927  *                JB_ERR_MEMORY on out-of-memory error.  
928  *
929  *********************************************************************/
930 jb_err cgi_send_user_manual(struct client_state *csp,
931                             struct http_response *rsp,
932                             const struct map *parameters)
933 {
934    const char * filename;
935    char *full_path;
936    FILE *fp;
937    jb_err err = JB_ERR_OK;
938    size_t length;
939
940    assert(csp);
941    assert(rsp);
942    assert(parameters);
943
944    if (!parameters->first)
945    {
946       /* requested http://p.p/user-manual (without trailing slash) */
947       return cgi_redirect(rsp, CGI_PREFIX "user-manual/");
948    }
949
950    get_string_param(parameters, "file", &filename);
951    /* Check paramter for hack attempts */
952    if (filename && strchr(filename, '/'))
953    {
954       return JB_ERR_CGI_PARAMS;
955    }
956    if (filename && strstr(filename, ".."))
957    {
958       return JB_ERR_CGI_PARAMS;
959    }
960
961    full_path = make_path(csp->config->usermanual, filename ? filename : "index.html");
962    if (full_path == NULL)
963    {
964       return JB_ERR_MEMORY;
965    }
966
967    /* Open user-manual file */
968    if (NULL == (fp = fopen(full_path, "rb")))
969    {
970       log_error(LOG_LEVEL_ERROR, "Cannot open user-manual file %s: %E", full_path);
971       err = cgi_error_no_template(csp, rsp, full_path);
972       free(full_path);
973       return err;
974    }
975
976    /* Get file length */
977    fseek(fp, 0, SEEK_END);
978    length = (size_t)ftell(fp);
979    fseek(fp, 0, SEEK_SET);
980
981    /* Allocate memory and load the file directly into the body */
982    rsp->body = (char *)zalloc(length+1);
983    if (!rsp->body)
984    {
985       fclose(fp);
986       free(full_path);
987       return JB_ERR_MEMORY;
988    }
989    if (!fread(rsp->body, length, 1, fp))
990    {
991       /*
992        * May happen if the file size changes between fseek() and fread().
993        * If it does, we just log it and serve what we got.
994        */
995       log_error(LOG_LEVEL_ERROR, "Couldn't completely read user-manual file %s.", full_path);
996    }
997    fclose(fp);
998    free(full_path);
999
1000    rsp->content_length = length;
1001
1002    /* Guess correct Content-Type based on the filename's ending */
1003    if (filename)
1004    {
1005       length = strlen(filename);
1006    }
1007    else
1008    {
1009       length = 0;
1010    } 
1011    if((length>=4) && !strcmp(&filename[length-4], ".css"))
1012    {
1013       err = enlist(rsp->headers, "Content-Type: text/css");
1014    }
1015    else if((length>=4) && !strcmp(&filename[length-4], ".jpg"))
1016    {
1017       err = enlist(rsp->headers, "Content-Type: image/jpeg");
1018    }
1019    else
1020    {
1021       err = enlist(rsp->headers, "Content-Type: text/html");
1022    }
1023
1024    return err;
1025 }
1026
1027
1028 /*********************************************************************
1029  *
1030  * Function    :  cgi_show_version
1031  *
1032  * Description :  CGI function that returns a a web page describing the
1033  *                file versions of Privoxy.
1034  *
1035  * Parameters  :
1036  *          1  :  csp = Current client state (buffers, headers, etc...)
1037  *          2  :  rsp = http_response data structure for output
1038  *          3  :  parameters = map of cgi parameters
1039  *
1040  * CGI Parameters : none
1041  *
1042  * Returns     :  JB_ERR_OK on success
1043  *                JB_ERR_MEMORY on out-of-memory error.  
1044  *
1045  *********************************************************************/
1046 jb_err cgi_show_version(struct client_state *csp,
1047                         struct http_response *rsp,
1048                         const struct map *parameters)
1049 {
1050    struct map *exports;
1051
1052    assert(csp);
1053    assert(rsp);
1054    assert(parameters);
1055
1056    if (NULL == (exports = default_exports(csp, "show-version")))
1057    {
1058       return JB_ERR_MEMORY;
1059    }
1060
1061    if (map(exports, "sourceversions", 1, show_rcs(), 0))
1062    {
1063       free_map(exports);
1064       return JB_ERR_MEMORY;
1065    }
1066
1067    return template_fill_for_cgi(csp, "show-version", exports, rsp);
1068 }
1069
1070  
1071 /*********************************************************************
1072  *
1073  * Function    :  cgi_show_status
1074  *
1075  * Description :  CGI function that returns a web page describing the
1076  *                current status of Privoxy.
1077  *
1078  * Parameters  :
1079  *          1  :  csp = Current client state (buffers, headers, etc...)
1080  *          2  :  rsp = http_response data structure for output
1081  *          3  :  parameters = map of cgi parameters
1082  *
1083  * CGI Parameters :
1084  *        file :  Which file to show.  Only first letter is checked,
1085  *                valid values are:
1086  *                - "p"ermissions (actions) file
1087  *                - "r"egex
1088  *                - "t"rust
1089  *                Default is to show menu and other information.
1090  *
1091  * Returns     :  JB_ERR_OK on success
1092  *                JB_ERR_MEMORY on out-of-memory error.  
1093  *
1094  *********************************************************************/
1095 jb_err cgi_show_status(struct client_state *csp,
1096                        struct http_response *rsp,
1097                        const struct map *parameters)
1098 {
1099    char *s = NULL;
1100    unsigned i;
1101    int j;
1102
1103    FILE * fp;
1104    char buf[BUFFER_SIZE];
1105    const char * filename = NULL;
1106    char * file_description = NULL;
1107 #ifdef FEATURE_STATISTICS
1108    float perc_rej;   /* Percentage of http requests rejected */
1109    int local_urls_read;
1110    int local_urls_rejected;
1111 #endif /* ndef FEATURE_STATISTICS */
1112    jb_err err = JB_ERR_OK;
1113
1114    struct map *exports;
1115
1116    assert(csp);
1117    assert(rsp);
1118    assert(parameters);
1119
1120    if (NULL == (exports = default_exports(csp, "show-status")))
1121    {
1122       return JB_ERR_MEMORY;
1123    }
1124
1125    switch (*(lookup(parameters, "file")))
1126    {
1127    case 'a':
1128       if (!get_number_param(csp, parameters, "index", &i) && i < MAX_AF_FILES && csp->actions_list[i])
1129       {
1130          filename = csp->actions_list[i]->filename;
1131          file_description = "Actions File";
1132       }
1133       break;
1134
1135    case 'f':
1136       if (!get_number_param(csp, parameters, "index", &i) && i < MAX_AF_FILES && csp->rlist[i])
1137       {
1138          filename = csp->rlist[i]->filename;
1139          file_description = "Filter File";
1140       }
1141       break;
1142
1143 #ifdef FEATURE_TRUST
1144    case 't':
1145       if (csp->tlist)
1146       {
1147          filename = csp->tlist->filename;
1148          file_description = "Trust File";
1149       }
1150       break;
1151 #endif /* def FEATURE_TRUST */
1152    }
1153
1154    if (NULL != filename)
1155    {
1156       if ( map(exports, "file-description", 1, file_description, 1)
1157         || map(exports, "filepath", 1, html_encode(filename), 0) )
1158       {
1159          free_map(exports);
1160          return JB_ERR_MEMORY;
1161       }
1162
1163       if ((fp = fopen(filename, "r")) == NULL)
1164       {
1165          if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
1166          {
1167             free_map(exports);
1168             return JB_ERR_MEMORY;
1169          }
1170       }
1171       else
1172       {
1173          s = strdup("");
1174          while ((s != NULL) && fgets(buf, sizeof(buf), fp))
1175          {
1176             string_join  (&s, html_encode(buf));
1177          }
1178          fclose(fp);
1179
1180          if (map(exports, "contents", 1, s, 0))
1181          {
1182             free_map(exports);
1183             return JB_ERR_MEMORY;
1184          }
1185       }
1186
1187       return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
1188    }
1189
1190    s = strdup("");
1191    for (j = 0; (s != NULL) && (j < Argc); j++)
1192    {
1193       if (!err) err = string_join  (&s, html_encode(Argv[j]));
1194       if (!err) err = string_append(&s, " ");
1195    }
1196    if (!err) err = map(exports, "invocation", 1, s, 0);
1197
1198    if (!err) err = map(exports, "options", 1, csp->config->proxy_args, 1);
1199    if (!err) err = show_defines(exports);
1200
1201    if (err) 
1202    {
1203       free_map(exports);
1204       return JB_ERR_MEMORY;
1205    }
1206
1207 #ifdef FEATURE_STATISTICS
1208    local_urls_read     = urls_read;
1209    local_urls_rejected = urls_rejected;
1210
1211    /*
1212     * Need to alter the stats not to include the fetch of this
1213     * page.
1214     *
1215     * Can't do following thread safely! doh!
1216     *
1217     * urls_read--;
1218     * urls_rejected--; * This will be incremented subsequently *
1219     */
1220
1221    if (local_urls_read == 0)
1222    {
1223       if (!err) err = map_block_killer(exports, "have-stats");
1224    }
1225    else
1226    {
1227       if (!err) err = map_block_killer(exports, "have-no-stats");
1228
1229       perc_rej = (float)local_urls_rejected * 100.0F /
1230             (float)local_urls_read;
1231
1232       snprintf(buf, sizeof(buf), "%d", local_urls_read);
1233       if (!err) err = map(exports, "requests-received", 1, buf, 1);
1234
1235       snprintf(buf, sizeof(buf), "%d", local_urls_rejected);
1236       if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
1237
1238       snprintf(buf, sizeof(buf), "%6.2f", perc_rej);
1239       if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
1240    }
1241
1242 #else /* ndef FEATURE_STATISTICS */
1243    err = err || map_block_killer(exports, "statistics");
1244 #endif /* ndef FEATURE_STATISTICS */
1245    
1246    /* 
1247     * List all action files in use, together with view and edit links,
1248     * except for standard.action, which should only be viewable. (Not
1249     * enforced in the editor itself)
1250     * FIXME: Shouldn't include hardwired HTML here, use line template instead!
1251     */
1252    s = strdup("");
1253    for (i = 0; i < MAX_AF_FILES; i++)
1254    {
1255       if (csp->actions_list[i] != NULL)
1256       {
1257          if (!err) err = string_append(&s, "<tr><td>");
1258          if (!err) err = string_join(&s, html_encode(csp->actions_list[i]->filename));
1259          snprintf(buf, sizeof(buf),
1260             "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&amp;index=%d\">View</a>", i);
1261          if (!err) err = string_append(&s, buf);
1262
1263 #ifdef FEATURE_CGI_EDIT_ACTIONS
1264          if ((csp->config->feature_flags & RUNTIME_FEATURE_CGI_EDIT_ACTIONS)
1265             && (NULL == strstr(csp->actions_list[i]->filename, "standard.action"))
1266             && (NULL != csp->config->actions_file_short[i]))
1267          {
1268 #ifdef HAVE_ACCESS
1269             if (access(csp->config->actions_file[i], W_OK) == 0)
1270             {
1271 #endif /* def HAVE_ACCESS */
1272                snprintf(buf, sizeof(buf), "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%d\">Edit</a>", i);
1273                if (!err) err = string_append(&s, buf);
1274 #ifdef HAVE_ACCESS
1275             }
1276             else
1277             {
1278                if (!err) err = string_append(&s, "&nbsp;&nbsp;<strong>No write access.</strong>");
1279             }
1280 #endif /* def HAVE_ACCESS */
1281          }
1282 #endif
1283
1284          if (!err) err = string_append(&s, "</td></tr>\n");
1285       }
1286    }
1287    if (*s != '\0')   
1288    {
1289       if (!err) err = map(exports, "actions-filenames", 1, s, 0);
1290    }
1291    else
1292    {
1293       if (!err) err = map(exports, "actions-filenames", 1, "<tr><td>None specified</td></tr>", 1);
1294    }
1295
1296    /* 
1297     * List all re_filterfiles in use, together with view options.
1298     * FIXME: Shouldn't include hardwired HTML here, use line template instead!
1299     */
1300    s = strdup("");
1301    for (i = 0; i < MAX_AF_FILES; i++)
1302    {
1303       if (csp->rlist[i] != NULL)
1304       {
1305          if (!err) err = string_append(&s, "<tr><td>");
1306          if (!err) err = string_join(&s, html_encode(csp->rlist[i]->filename));
1307          snprintf(buf, 100,
1308             "</td><td class=\"buttons\"><a href=\"/show-status?file=filter&amp;index=%d\">View</a>", i);
1309          if (!err) err = string_append(&s, buf);
1310          if (!err) err = string_append(&s, "</td></tr>\n");
1311       }
1312    }
1313    if (*s != '\0')   
1314    {
1315       if (!err) err = map(exports, "re-filter-filenames", 1, s, 0);
1316    }
1317    else
1318    {
1319       if (!err) err = map(exports, "re-filter-filenames", 1, "<tr><td>None specified</td></tr>", 1);
1320       if (!err) err = map_block_killer(exports, "have-filterfile");
1321    }
1322
1323 #ifdef FEATURE_TRUST
1324    if (csp->tlist)
1325    {
1326       if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
1327    }
1328    else
1329    {
1330       if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
1331       if (!err) err = map_block_killer(exports, "have-trustfile");
1332    }
1333 #else
1334    if (!err) err = map_block_killer(exports, "trust-support");
1335 #endif /* ndef FEATURE_TRUST */
1336
1337 #ifdef FEATURE_CGI_EDIT_ACTIONS
1338    if (!err && (csp->config->feature_flags & RUNTIME_FEATURE_CGI_EDIT_ACTIONS))
1339    {
1340       err = map_block_killer(exports, "cgi-editor-is-disabled");
1341    }
1342 #endif /* ndef CGI_EDIT_ACTIONS */
1343
1344    if (err)
1345    {
1346       free_map(exports);
1347       return JB_ERR_MEMORY;
1348    }
1349
1350    return template_fill_for_cgi(csp, "show-status", exports, rsp);
1351 }
1352
1353  
1354 /*********************************************************************
1355  *
1356  * Function    :  cgi_show_url_info
1357  *
1358  * Description :  CGI function that determines and shows which actions
1359  *                Privoxy will perform for a given url, and which
1360  *                matches starting from the defaults have lead to that.
1361  *
1362  * Parameters  :
1363  *          1  :  csp = Current client state (buffers, headers, etc...)
1364  *          2  :  rsp = http_response data structure for output
1365  *          3  :  parameters = map of cgi parameters
1366  *
1367  * CGI Parameters :
1368  *            url : The url whose actions are to be determined.
1369  *                  If url is unset, the url-given conditional will be
1370  *                  set, so that all but the form can be suppressed in
1371  *                  the template.
1372  *
1373  * Returns     :  JB_ERR_OK on success
1374  *                JB_ERR_MEMORY on out-of-memory error.  
1375  *
1376  *********************************************************************/
1377 jb_err cgi_show_url_info(struct client_state *csp,
1378                          struct http_response *rsp,
1379                          const struct map *parameters)
1380 {
1381    char *url_param;
1382    struct map *exports;
1383    char buf[150];
1384
1385    assert(csp);
1386    assert(rsp);
1387    assert(parameters);
1388
1389    if (NULL == (exports = default_exports(csp, "show-url-info")))
1390    {
1391       return JB_ERR_MEMORY;
1392    }
1393
1394    /*
1395     * Get the url= parameter (if present) and remove any leading/trailing spaces.
1396     */
1397    url_param = strdup(lookup(parameters, "url"));
1398    if (url_param == NULL)
1399    {
1400       free_map(exports);
1401       return JB_ERR_MEMORY;
1402    }
1403    chomp(url_param);
1404
1405    /*
1406     * Handle prefixes.  4 possibilities:
1407     * 1) "http://" or "https://" prefix present and followed by URL - OK
1408     * 2) Only the "http://" or "https://" part is present, no URL - change
1409     *    to empty string so it will be detected later as "no URL".
1410     * 3) Parameter specified but doesn't contain "http(s?)://" - add a
1411     *    "http://" prefix.
1412     * 4) Parameter not specified or is empty string - let this fall through
1413     *    for now, next block of code will handle it.
1414     */
1415    if (0 == strncmp(url_param, "http://", 7))
1416    {
1417       if (url_param[7] == '\0')
1418       {
1419          /*
1420           * Empty URL (just prefix).
1421           * Make it totally empty so it's caught by the next if()
1422           */
1423          url_param[0] = '\0';
1424       }
1425    }
1426    else if (0 == strncmp(url_param, "https://", 8))
1427    {
1428       if (url_param[8] == '\0')
1429       {
1430          /*
1431           * Empty URL (just prefix).
1432           * Make it totally empty so it's caught by the next if()
1433           */
1434          url_param[0] = '\0';
1435       }
1436    }
1437    else if (url_param[0] != '\0')
1438    {
1439       /*
1440        * Unknown prefix - assume http://
1441        */
1442       const size_t url_param_prefixed_size = 7 + 1 + strlen(url_param);
1443       char * url_param_prefixed = malloc(url_param_prefixed_size);
1444       if (NULL == url_param_prefixed)
1445       {
1446          free(url_param);
1447          free_map(exports);
1448          return JB_ERR_MEMORY;
1449       }
1450       strlcpy(url_param_prefixed, "http://", url_param_prefixed_size);
1451       strlcat(url_param_prefixed, url_param, url_param_prefixed_size);
1452       free(url_param);
1453       url_param = url_param_prefixed;
1454    }
1455
1456    /*
1457     * Hide "toggle off" warning if Privoxy is toggled on.
1458     */
1459    if (
1460 #ifdef FEATURE_TOGGLE
1461        (global_toggle_state == 1) &&
1462 #endif /* def FEATURE_TOGGLE */
1463        map_block_killer(exports, "privoxy-is-toggled-off")
1464       )
1465    {
1466       free_map(exports);
1467       return JB_ERR_MEMORY;
1468    }
1469
1470    if (url_param[0] == '\0')
1471    {
1472       /* URL paramater not specified, display query form only. */
1473       free(url_param);
1474       if (map_block_killer(exports, "url-given")
1475         || map(exports, "url", 1, "", 1))
1476       {
1477          free_map(exports);
1478          return JB_ERR_MEMORY;
1479       }
1480    }
1481    else
1482    {
1483       /* Given a URL, so query it. */
1484       jb_err err;
1485       char *matches;
1486       char *s;
1487       int hits = 0;
1488       struct file_list *fl;
1489       struct url_actions *b;
1490       struct http_request url_to_query[1];
1491       struct current_action_spec action[1];
1492       int i;
1493       
1494       if (map(exports, "url", 1, html_encode(url_param), 0))
1495       {
1496          free(url_param);
1497          free_map(exports);
1498          return JB_ERR_MEMORY;
1499       }
1500
1501       init_current_action(action);
1502
1503       if (map(exports, "default", 1, current_action_to_html(csp, action), 0))
1504       {
1505          free_current_action(action);
1506          free(url_param);
1507          free_map(exports);
1508          return JB_ERR_MEMORY;
1509       }
1510
1511       err = parse_http_url(url_param, url_to_query, csp);
1512
1513       free(url_param);
1514
1515       if (err == JB_ERR_MEMORY)
1516       {
1517          free_http_request(url_to_query);
1518          free_current_action(action);
1519          free_map(exports);
1520          return JB_ERR_MEMORY;
1521       }
1522       else if (err)
1523       {
1524          /* Invalid URL */
1525
1526          err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
1527          if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
1528          if (!err) err = map_block_killer(exports, "valid-url");
1529
1530          free_current_action(action);
1531          free_http_request(url_to_query);
1532
1533          if (err)
1534          {
1535             free_map(exports);
1536             return JB_ERR_MEMORY;
1537          }
1538
1539          return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1540       }
1541
1542       /*
1543        * We have a warning about SSL paths.  Hide it for unencrypted sites.
1544        */
1545       if (!url_to_query->ssl)
1546       {
1547          if (map_block_killer(exports, "https"))
1548          {
1549             free_current_action(action);
1550             free_map(exports);
1551             free_http_request(url_to_query);
1552             return JB_ERR_MEMORY;
1553          }
1554       }
1555
1556       matches = strdup("<table summary=\"\" class=\"transparent\">");
1557
1558       for (i = 0; i < MAX_AF_FILES; i++)
1559       {
1560          if (NULL == csp->config->actions_file_short[i]
1561              || !strcmp(csp->config->actions_file_short[i], "standard.action")) continue;
1562
1563          b = NULL;
1564          hits = 1;
1565          if ((fl = csp->actions_list[i]) != NULL)
1566          {
1567             if ((b = fl->f) != NULL)
1568             {
1569                /* FIXME: Hardcoded HTML! */
1570                string_append(&matches, "<tr><th>In file: ");
1571                string_join  (&matches, html_encode(csp->config->actions_file_short[i]));
1572                snprintf(buf, sizeof(buf), " <a class=\"cmd\" href=\"/show-status?file=actions&amp;index=%d\">", i);
1573                string_append(&matches, buf);
1574                string_append(&matches, "View</a>");
1575 #ifdef FEATURE_CGI_EDIT_ACTIONS
1576                if (csp->config->feature_flags & RUNTIME_FEATURE_CGI_EDIT_ACTIONS)
1577                {
1578 #ifdef HAVE_ACCESS
1579                   if (access(csp->config->actions_file[i], W_OK) == 0)
1580                   {
1581 #endif /* def HAVE_ACCESS */
1582                      snprintf(buf, sizeof(buf),
1583                         " <a class=\"cmd\" href=\"/edit-actions-list?f=%d\">", i);
1584                      string_append(&matches, buf);
1585                      string_append(&matches, "Edit</a>");
1586 #ifdef HAVE_ACCESS
1587                   }
1588                   else
1589                   {
1590                      string_append(&matches, " <strong>No write access.</strong>");
1591                   }
1592 #endif /* def HAVE_ACCESS */
1593                }
1594 #endif /* FEATURE_CGI_EDIT_ACTIONS */
1595
1596                string_append(&matches, "</th></tr>\n");
1597
1598                hits = 0;
1599                b = b->next;
1600             }
1601          }
1602
1603          for (; (b != NULL) && (matches != NULL); b = b->next)
1604          {
1605             if (url_match(b->url, url_to_query))
1606             {
1607                string_append(&matches, "<tr><td>{");
1608                string_join  (&matches, actions_to_html(csp, b->action));
1609                string_append(&matches, " }<br>\n<code>");
1610                string_join  (&matches, html_encode(b->url->spec));
1611                string_append(&matches, "</code></td></tr>\n");
1612
1613                if (merge_current_action(action, b->action))
1614                {
1615                   freez(matches);
1616                   free_http_request(url_to_query);
1617                   free_current_action(action);
1618                   free_map(exports);
1619                   return JB_ERR_MEMORY;
1620                }
1621                hits++;
1622             }
1623          }
1624
1625          if (!hits)
1626          {
1627             string_append(&matches, "<tr><td>(no matches in this file)</td></tr>\n");
1628          }
1629       }
1630       string_append(&matches, "</table>\n");
1631
1632       /*
1633        * XXX: Kludge to make sure the "Forward settings" section
1634        * shows what forward-override{} would do with the requested URL.
1635        * No one really cares how the CGI request would be forwarded
1636        * if it wasn't intercepted as CGI request in the first place.
1637        *
1638        * From here on the action bitmask will no longer reflect
1639        * the real url (http://config.privoxy.org/show-url-info?url=.*),
1640        * but luckily it's no longer required later on anyway.
1641        */
1642       free_current_action(csp->action);
1643       get_url_actions(csp, url_to_query);
1644
1645       /*
1646        * Fill in forwarding settings.
1647        *
1648        * The possibilities are:
1649        *  - no forwarding
1650        *  - http forwarding only
1651        *  - socks4(a) forwarding only
1652        *  - socks4(a) and http forwarding.
1653        *
1654        * XXX: Parts of this code could be reused for the
1655        * "forwarding-failed" template which currently doesn't
1656        * display the proxy port and an eventual second forwarder.
1657        */
1658       {
1659          const struct forward_spec *fwd = forward_url(csp, url_to_query);
1660
1661          if ((fwd->gateway_host == NULL) && (fwd->forward_host == NULL))
1662          {
1663             if (!err) err = map_block_killer(exports, "socks-forwarder");
1664             if (!err) err = map_block_killer(exports, "http-forwarder");
1665          }
1666          else
1667          {
1668             char port[10]; /* We save proxy ports as int but need a string here */
1669
1670             if (!err) err = map_block_killer(exports, "no-forwarder");
1671
1672             if (fwd->gateway_host != NULL)
1673             {
1674                char *socks_type = NULL;
1675
1676                switch (fwd->type)
1677                {
1678                   case SOCKS_4:
1679                      socks_type = "socks4";
1680                      break;
1681                   case SOCKS_4A:
1682                      socks_type = "socks4a";
1683                      break;
1684                   case SOCKS_5:
1685                      socks_type = "socks5";
1686                      break;
1687                   default:
1688                      log_error(LOG_LEVEL_FATAL, "Unknown socks type: %d.", fwd->type);
1689                }
1690
1691                if (!err) err = map(exports, "socks-type", 1, socks_type, 1);
1692                if (!err) err = map(exports, "gateway-host", 1, fwd->gateway_host, 1);
1693                snprintf(port, sizeof(port), "%d", fwd->gateway_port);
1694                if (!err) err = map(exports, "gateway-port", 1, port, 1);
1695             }
1696             else
1697             {
1698                if (!err) err = map_block_killer(exports, "socks-forwarder");
1699             }
1700
1701             if (fwd->forward_host != NULL)
1702             {
1703                if (!err) err = map(exports, "forward-host", 1, fwd->forward_host, 1);
1704                snprintf(port, sizeof(port), "%d", fwd->forward_port);
1705                if (!err) err = map(exports, "forward-port", 1, port, 1);
1706             }
1707             else
1708             {
1709                if (!err) err = map_block_killer(exports, "http-forwarder");
1710             }
1711          }
1712       }
1713
1714       free_http_request(url_to_query);
1715
1716       if (err || matches == NULL)
1717       {
1718          free_current_action(action);
1719          free_map(exports);
1720          return JB_ERR_MEMORY;
1721       }
1722
1723 #ifdef FEATURE_CGI_EDIT_ACTIONS
1724       if ((csp->config->feature_flags & RUNTIME_FEATURE_CGI_EDIT_ACTIONS))
1725       {
1726          err = map_block_killer(exports, "cgi-editor-is-disabled");
1727       }
1728 #endif /* FEATURE_CGI_EDIT_ACTIONS */
1729
1730       if (err || map(exports, "matches", 1, matches , 0))
1731       {
1732          free_current_action(action);
1733          free_map(exports);
1734          return JB_ERR_MEMORY;
1735       }
1736
1737       s = current_action_to_html(csp, action);
1738
1739       free_current_action(action);
1740
1741       if (map(exports, "final", 1, s, 0))
1742       {
1743          free_map(exports);
1744          return JB_ERR_MEMORY;
1745       }
1746    }
1747
1748    return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1749 }
1750
1751
1752 /*********************************************************************
1753  *
1754  * Function    :  cgi_robots_txt
1755  *
1756  * Description :  CGI function to return "/robots.txt".
1757  *
1758  * Parameters  :
1759  *          1  :  csp = Current client state (buffers, headers, etc...)
1760  *          2  :  rsp = http_response data structure for output
1761  *          3  :  parameters = map of cgi parameters
1762  *
1763  * CGI Parameters : None
1764  *
1765  * Returns     :  JB_ERR_OK on success
1766  *                JB_ERR_MEMORY on out-of-memory error.  
1767  *
1768  *********************************************************************/
1769 jb_err cgi_robots_txt(struct client_state *csp,
1770                       struct http_response *rsp,
1771                       const struct map *parameters)
1772 {
1773    char buf[100];
1774    jb_err err;
1775
1776    rsp->body = strdup(
1777       "# This is the Privoxy control interface.\n"
1778       "# It isn't very useful to index it, and you're likely to break stuff.\n"
1779       "# So go away!\n"
1780       "\n"
1781       "User-agent: *\n"
1782       "Disallow: /\n"
1783       "\n");
1784    if (rsp->body == NULL)
1785    {
1786       return JB_ERR_MEMORY;
1787    }
1788
1789    err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1790
1791    rsp->is_static = 1;
1792
1793    get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1794    if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1795
1796    return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1797 }
1798
1799
1800 /*********************************************************************
1801  *
1802  * Function    :  show_defines
1803  *
1804  * Description :  Add to a map the state od all conditional #defines
1805  *                used when building
1806  *
1807  * Parameters  :
1808  *          1  :  exports = map to extend
1809  *
1810  * Returns     :  JB_ERR_OK on success
1811  *                JB_ERR_MEMORY on out-of-memory error.  
1812  *
1813  *********************************************************************/
1814 static jb_err show_defines(struct map *exports)
1815 {
1816    jb_err err = JB_ERR_OK;
1817
1818 #ifdef FEATURE_ACL
1819    if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1820 #else /* ifndef FEATURE_ACL */
1821    if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1822 #endif /* ndef FEATURE_ACL */
1823
1824 #ifdef FEATURE_CGI_EDIT_ACTIONS
1825    if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1826 #else /* ifndef FEATURE_COOKIE_JAR */
1827    if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1828 #endif /* ndef FEATURE_COOKIE_JAR */
1829
1830 #ifdef FEATURE_COOKIE_JAR
1831    if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1832 #else /* ifndef FEATURE_COOKIE_JAR */
1833    if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1834 #endif /* ndef FEATURE_COOKIE_JAR */
1835
1836 #ifdef FEATURE_FAST_REDIRECTS
1837    if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1838 #else /* ifndef FEATURE_FAST_REDIRECTS */
1839    if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1840 #endif /* ndef FEATURE_FAST_REDIRECTS */
1841
1842 #ifdef FEATURE_FORCE_LOAD
1843    if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1844    if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1845 #else /* ifndef FEATURE_FORCE_LOAD */
1846    if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1847    if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
1848 #endif /* ndef FEATURE_FORCE_LOAD */
1849
1850 #ifdef FEATURE_GRACEFUL_TERMINATION
1851    if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 1);
1852 #else /* ifndef FEATURE_GRACEFUL_TERMINATION */
1853    if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 0);
1854 #endif /* ndef FEATURE_GRACEFUL_TERMINATION */
1855
1856 #ifdef FEATURE_IMAGE_BLOCKING
1857    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1858 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1859    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1860 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1861
1862 #ifdef FEATURE_IMAGE_DETECT_MSIE
1863    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1864 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1865    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1866 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1867
1868 #ifdef FEATURE_KILL_POPUPS
1869    if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1870 #else /* ifndef FEATURE_KILL_POPUPS */
1871    if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1872 #endif /* ndef FEATURE_KILL_POPUPS */
1873
1874 #ifdef FEATURE_NO_GIFS
1875    if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1876 #else /* ifndef FEATURE_NO_GIFS */
1877    if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1878 #endif /* ndef FEATURE_NO_GIFS */
1879
1880 #ifdef FEATURE_PTHREAD
1881    if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1882 #else /* ifndef FEATURE_PTHREAD */
1883    if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1884 #endif /* ndef FEATURE_PTHREAD */
1885
1886 #ifdef FEATURE_STATISTICS
1887    if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1888 #else /* ifndef FEATURE_STATISTICS */
1889    if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1890 #endif /* ndef FEATURE_STATISTICS */
1891
1892 #ifdef FEATURE_TOGGLE
1893    if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1894 #else /* ifndef FEATURE_TOGGLE */
1895    if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1896 #endif /* ndef FEATURE_TOGGLE */
1897
1898 #ifdef FEATURE_TRUST
1899    if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1900 #else /* ifndef FEATURE_TRUST */
1901    if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1902 #endif /* ndef FEATURE_TRUST */
1903
1904 #ifdef FEATURE_ZLIB
1905    if (!err) err = map_conditional(exports, "FEATURE_ZLIB", 1);
1906 #else /* ifndef FEATURE_ZLIB */
1907    if (!err) err = map_conditional(exports, "FEATURE_ZLIB", 0);
1908 #endif /* ndef FEATURE_ZLIB */
1909
1910 #ifdef STATIC_PCRE
1911    if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1912 #else /* ifndef STATIC_PCRE */
1913    if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1914 #endif /* ndef STATIC_PCRE */
1915
1916 #ifdef STATIC_PCRS
1917    if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1918 #else /* ifndef STATIC_PCRS */
1919    if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1920 #endif /* ndef STATIC_PCRS */
1921
1922    return err;
1923 }
1924
1925
1926 /*********************************************************************
1927  *
1928  * Function    :  show_rcs
1929  *
1930  * Description :  Create a string with the rcs info for all sourcefiles
1931  *
1932  * Parameters  :  None
1933  *
1934  * Returns     :  A string, or NULL on out-of-memory.
1935  *
1936  *********************************************************************/
1937 static char *show_rcs(void)
1938 {
1939    char *result = strdup("");
1940    char buf[BUFFER_SIZE];
1941
1942    /* Instead of including *all* dot h's in the project (thus creating a
1943     * tremendous amount of dependencies), I will concede to declaring them
1944     * as extern's.  This forces the developer to add to this list, but oh well.
1945     */
1946
1947 #define SHOW_RCS(__x)              \
1948    {                               \
1949       extern const char __x[];     \
1950       snprintf(buf, sizeof(buf), " %s\n", __x);   \
1951       string_append(&result, buf); \
1952    }
1953
1954    /* In alphabetical order */
1955    SHOW_RCS(actions_h_rcs)
1956    SHOW_RCS(actions_rcs)
1957 #ifdef AMIGA
1958    SHOW_RCS(amiga_h_rcs)
1959    SHOW_RCS(amiga_rcs)
1960 #endif /* def AMIGA */
1961    SHOW_RCS(cgi_h_rcs)
1962    SHOW_RCS(cgi_rcs)
1963 #ifdef FEATURE_CGI_EDIT_ACTIONS
1964    SHOW_RCS(cgiedit_h_rcs)
1965    SHOW_RCS(cgiedit_rcs)
1966 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1967    SHOW_RCS(cgisimple_h_rcs)
1968    SHOW_RCS(cgisimple_rcs)
1969 #ifdef __MINGW32__
1970    SHOW_RCS(cygwin_h_rcs)
1971 #endif
1972    SHOW_RCS(deanimate_h_rcs)
1973    SHOW_RCS(deanimate_rcs)
1974    SHOW_RCS(encode_h_rcs)
1975    SHOW_RCS(encode_rcs)
1976    SHOW_RCS(errlog_h_rcs)
1977    SHOW_RCS(errlog_rcs)
1978    SHOW_RCS(filters_h_rcs)
1979    SHOW_RCS(filters_rcs)
1980    SHOW_RCS(gateway_h_rcs)
1981    SHOW_RCS(gateway_rcs)
1982    SHOW_RCS(jbsockets_h_rcs)
1983    SHOW_RCS(jbsockets_rcs)
1984    SHOW_RCS(jcc_h_rcs)
1985    SHOW_RCS(jcc_rcs)
1986 #ifdef FEATURE_KILL_POPUPS
1987    SHOW_RCS(killpopup_h_rcs)
1988    SHOW_RCS(killpopup_rcs)
1989 #endif /* def FEATURE_KILL_POPUPS */
1990    SHOW_RCS(list_h_rcs)
1991    SHOW_RCS(list_rcs)
1992    SHOW_RCS(loadcfg_h_rcs)
1993    SHOW_RCS(loadcfg_rcs)
1994    SHOW_RCS(loaders_h_rcs)
1995    SHOW_RCS(loaders_rcs)
1996    SHOW_RCS(miscutil_h_rcs)
1997    SHOW_RCS(miscutil_rcs)
1998    SHOW_RCS(parsers_h_rcs)
1999    SHOW_RCS(parsers_rcs)
2000    SHOW_RCS(pcrs_rcs)
2001    SHOW_RCS(pcrs_h_rcs)
2002    SHOW_RCS(project_h_rcs)
2003    SHOW_RCS(ssplit_h_rcs)
2004    SHOW_RCS(ssplit_rcs)
2005    SHOW_RCS(urlmatch_h_rcs)
2006    SHOW_RCS(urlmatch_rcs)
2007 #ifdef _WIN32
2008 #ifndef _WIN_CONSOLE
2009    SHOW_RCS(w32log_h_rcs)
2010    SHOW_RCS(w32log_rcs)
2011    SHOW_RCS(w32res_h_rcs)
2012    SHOW_RCS(w32taskbar_h_rcs)
2013    SHOW_RCS(w32taskbar_rcs)
2014 #endif /* ndef _WIN_CONSOLE */
2015    SHOW_RCS(win32_h_rcs)
2016    SHOW_RCS(win32_rcs)
2017 #endif /* def _WIN32 */
2018
2019 #undef SHOW_RCS
2020
2021    return result;
2022
2023 }
2024
2025
2026 /*
2027   Local Variables:
2028   tab-width: 3
2029   end:
2030 */