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