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