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