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