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