Added the developer manual
[privoxy.git] / cgisimple.c
1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.34 2002/04/30 12:06:12 oes 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 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.34  2002/04/30 12:06:12  oes
40  *    Deleted unused code from default_cgi
41  *
42  *    Revision 1.33  2002/04/30 11:14:52  oes
43  *    Made csp the first parameter in *action_to_html
44  *
45  *    Revision 1.32  2002/04/26 18:29:13  jongfoster
46  *    Fixing this Visual C++ warning:
47  *    cgisimple.c(775) : warning C4018: '<' : signed/unsigned mismatch
48  *
49  *    Revision 1.31  2002/04/26 12:54:36  oes
50  *     - Kill obsolete REDIRECT_URL code
51  *     - Error handling fixes
52  *     - Style sheet related HTML snipplet changes
53  *     - cgi_show_url_info:
54  *       - Matches now in table, actions on single lines,
55  *         linked to help
56  *       - standard.action suppressed
57  *       - Buttons to View and Edit AFs
58  *
59  *    Revision 1.30  2002/04/24 02:18:08  oes
60  *     - show-status is now the starting point for editing
61  *       the actions files, generate list of all AFs with buttons
62  *       for viewing and editing, new look for file list (Jon:
63  *       buttons now aligned ;-P ), view mode now supports multiple
64  *       AFs, name changes, no view links for unspecified files,
65  *       no edit link for standard.action.
66  *
67  *     - Jon's multiple AF patch: cgi_show_url_info now uses all
68  *       AFs and marks the output accordingly
69  *
70  *    Revision 1.29  2002/04/10 13:38:35  oes
71  *    load_template signature changed
72  *
73  *    Revision 1.28  2002/04/07 15:42:12  jongfoster
74  *    Fixing send-banner?type=auto when the image-blocker is
75  *    a redirect to send-banner
76  *
77  *    Revision 1.27  2002/04/05 15:50:48  oes
78  *    added send-stylesheet CGI
79  *
80  *    Revision 1.26  2002/04/04 00:36:36  gliptak
81  *    always use pcre for matching
82  *
83  *    Revision 1.25  2002/04/03 22:28:03  gliptak
84  *    Removed references to gnu_regex
85  *
86  *    Revision 1.24  2002/04/02 16:12:47  oes
87  *    Fix: moving misplaced lines into #ifdef FEATURE_FORCE
88  *
89  *    Revision 1.23  2002/03/26 22:29:54  swa
90  *    we have a new homepage!
91  *
92  *    Revision 1.22  2002/03/24 16:18:15  jongfoster
93  *    Removing old logo
94  *
95  *    Revision 1.21  2002/03/24 15:23:33  jongfoster
96  *    Name changes
97  *
98  *    Revision 1.20  2002/03/24 13:25:43  swa
99  *    name change related issues
100  *
101  *    Revision 1.19  2002/03/16 23:54:06  jongfoster
102  *    Adding graceful termination feature, to help look for memory leaks.
103  *    If you enable this (which, by design, has to be done by hand
104  *    editing config.h) and then go to http://i.j.b/die, then the program
105  *    will exit cleanly after the *next* request.  It should free all the
106  *    memory that was used.
107  *
108  *    Revision 1.18  2002/03/12 01:44:49  oes
109  *    Changed default for "blocked" image from jb logo to checkboard pattern
110  *
111  *    Revision 1.17  2002/03/08 16:43:18  oes
112  *    Added choice beween GIF and PNG built-in images
113  *
114  *    Revision 1.16  2002/03/07 03:48:38  oes
115  *     - Changed built-in images from GIF to PNG
116  *       (with regard to Unisys patent issue)
117  *     - Added a 4x4 pattern PNG which is less intrusive
118  *       than the logo but also clearly marks the deleted banners
119  *
120  *    Revision 1.15  2002/03/06 22:54:35  jongfoster
121  *    Automated function-comment nitpicking.
122  *
123  *    Revision 1.14  2002/03/02 04:14:50  david__schmidt
124  *    Clean up a little CRLF unpleasantness that suddenly appeared
125  *
126  *    Revision 1.13  2002/02/21 00:10:37  jongfoster
127  *    Adding send-banner?type=auto option
128  *
129  *    Revision 1.12  2002/01/23 01:03:32  jongfoster
130  *    Fixing gcc [CygWin] compiler warnings
131  *
132  *    Revision 1.11  2002/01/23 00:01:04  jongfoster
133  *    Adding cgi_transparent_gif() for http://i.j.b/t
134  *    Adding missing html_encode() to many CGI functions.
135  *    Adding urlmatch.[ch] to http://i.j.b/show-version
136  *
137  *    Revision 1.10  2002/01/17 21:10:37  jongfoster
138  *    Changes to cgi_show_url_info to use new matching code from urlmatch.c.
139  *    Also fixing a problem in the same function with improperly quoted URLs
140  *    in output HTML, and adding code to handle https:// URLs correctly.
141  *
142  *    Revision 1.9  2001/11/30 23:09:15  jongfoster
143  *    Now reports on FEATURE_CGI_EDIT_ACTIONS
144  *    Removing FEATURE_DENY_GZIP from template
145  *
146  *    Revision 1.8  2001/11/13 00:14:07  jongfoster
147  *    Fixing stupid bug now I've figured out what || means.
148  *    (It always returns 0 or 1, not one of it's paramaters.)
149  *
150  *    Revision 1.7  2001/10/23 21:48:19  jongfoster
151  *    Cleaning up error handling in CGI functions - they now send back
152  *    a HTML error page and should never cause a FATAL error.  (Fixes one
153  *    potential source of "denial of service" attacks).
154  *
155  *    CGI actions file editor that works and is actually useful.
156  *
157  *    Ability to toggle JunkBuster remotely using a CGI call.
158  *
159  *    You can turn off both the above features in the main configuration
160  *    file, e.g. if you are running a multi-user proxy.
161  *
162  *    Revision 1.6  2001/10/14 22:00:32  jongfoster
163  *    Adding support for a 404 error when an invalid CGI page is requested.
164  *
165  *    Revision 1.5  2001/10/07 15:30:41  oes
166  *    Removed FEATURE_DENY_GZIP
167  *
168  *    Revision 1.4  2001/10/02 15:31:12  oes
169  *    Introduced show-request cgi
170  *
171  *    Revision 1.3  2001/09/22 16:34:44  jongfoster
172  *    Removing unneeded #includes
173  *
174  *    Revision 1.2  2001/09/19 18:01:11  oes
175  *    Fixed comments; cosmetics
176  *
177  *    Revision 1.1  2001/09/16 17:08:54  jongfoster
178  *    Moving simple CGI functions from cgi.c to new file cgisimple.c
179  *
180  *
181  **********************************************************************/
182 \f
183
184 #include "config.h"
185
186 #include <stdio.h>
187 #include <sys/types.h>
188 #include <stdlib.h>
189 #include <ctype.h>
190 #include <string.h>
191 #include <assert.h>
192
193 #ifdef _WIN32
194 #define snprintf _snprintf
195 #endif /* def _WIN32 */
196
197 #include "project.h"
198 #include "cgi.h"
199 #include "cgisimple.h"
200 #include "list.h"
201 #include "encode.h"
202 #include "jcc.h"
203 #include "filters.h"
204 #include "actions.h"
205 #include "miscutil.h"
206 #include "loadcfg.h"
207 #include "parsers.h"
208 #include "urlmatch.h"
209 #include "errlog.h"
210
211 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
212
213
214 static char *show_rcs(void);
215 static jb_err show_defines(struct map *exports);
216
217
218 /*********************************************************************
219  *
220  * Function    :  cgi_default
221  *
222  * Description :  CGI function that is called for the CGI_SITE_1_HOST
223  *                and CGI_SITE_2_HOST/CGI_SITE_2_PATH base URLs.
224  *                Boring - only exports the default exports.
225  *               
226  * Parameters  :
227  *          1  :  csp = Current client state (buffers, headers, etc...)
228  *          2  :  rsp = http_response data structure for output
229  *          3  :  parameters = map of cgi parameters
230  *
231  * CGI Parameters : none
232  *
233  * Returns     :  JB_ERR_OK on success
234  *                JB_ERR_MEMORY on out-of-memory
235  *
236  *********************************************************************/
237 jb_err cgi_default(struct client_state *csp,
238                    struct http_response *rsp,
239                    const struct map *parameters)
240 {
241    struct map *exports;
242
243    assert(csp);
244    assert(rsp);
245
246    if (NULL == (exports = default_exports(csp, "")))
247    {
248       return JB_ERR_MEMORY;
249    }
250
251    return template_fill_for_cgi(csp, "default", exports, rsp);
252 }
253
254
255 /*********************************************************************
256  *
257  * Function    :  cgi_error_404
258  *
259  * Description :  CGI function that is called if an unknown action was
260  *                given.
261  *               
262  * Parameters  :
263  *          1  :  csp = Current client state (buffers, headers, etc...)
264  *          2  :  rsp = http_response data structure for output
265  *          3  :  parameters = map of cgi parameters
266  *
267  * CGI Parameters : none
268  *
269  * Returns     :  JB_ERR_OK on success
270  *                JB_ERR_MEMORY on out-of-memory error.  
271  *
272  *********************************************************************/
273 jb_err cgi_error_404(struct client_state *csp,
274                      struct http_response *rsp,
275                      const struct map *parameters)
276 {
277    struct map *exports;
278
279    assert(csp);
280    assert(rsp);
281    assert(parameters);
282
283    if (NULL == (exports = default_exports(csp, NULL)))
284    {
285       return JB_ERR_MEMORY;
286    }
287
288    rsp->status = strdup("404 Privoxy configuration page not found");
289    if (rsp->status == NULL)
290    {
291       free_map(exports);
292       return JB_ERR_MEMORY;
293    }
294
295    return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
296 }
297
298
299 #ifdef FEATURE_GRACEFUL_TERMINATION
300 /*********************************************************************
301  *
302  * Function    :  cgi_die
303  *
304  * Description :  CGI function to shut down Privoxy.
305  *                NOTE: Turning this on in a production build
306  *                would be a BAD idea.  An EXTREMELY BAD idea.
307  *                In short, don't do it.
308  *               
309  * Parameters  :
310  *          1  :  csp = Current client state (buffers, headers, etc...)
311  *          2  :  rsp = http_response data structure for output
312  *          3  :  parameters = map of cgi parameters
313  *
314  * CGI Parameters : none
315  *
316  * Returns     :  JB_ERR_OK on success
317  *                JB_ERR_MEMORY on out-of-memory error.  
318  *
319  *********************************************************************/
320 jb_err cgi_die (struct client_state *csp,
321                 struct http_response *rsp,
322                 const struct map *parameters)
323 {
324    assert(csp);
325    assert(rsp);
326    assert(parameters);
327
328    /* quit */
329    g_terminate = 1;
330
331    /*
332     * I don't really care what gets sent back to the browser.
333     * Take the easy option - "out of memory" page.
334     */
335
336    return JB_ERR_MEMORY;
337 }
338 #endif /* def FEATURE_GRACEFUL_TERMINATION */
339
340
341 /*********************************************************************
342  *
343  * Function    :  cgi_show_request
344  *
345  * Description :  Show the client's request and what sed() would have
346  *                made of it.
347  *               
348  * Parameters  :
349  *          1  :  csp = Current client state (buffers, headers, etc...)
350  *          2  :  rsp = http_response data structure for output
351  *          3  :  parameters = map of cgi parameters
352  *
353  * CGI Parameters : none
354  *
355  * Returns     :  JB_ERR_OK on success
356  *                JB_ERR_MEMORY on out-of-memory error.  
357  *
358  *********************************************************************/
359 jb_err cgi_show_request(struct client_state *csp,
360                         struct http_response *rsp,
361                         const struct map *parameters)
362 {
363    char *p;
364    struct map *exports;
365
366    assert(csp);
367    assert(rsp);
368    assert(parameters);
369
370    if (NULL == (exports = default_exports(csp, "show-request")))
371    {
372       return JB_ERR_MEMORY;
373    }
374    
375    /*
376     * Repair the damage done to the IOB by get_header()
377     */
378    for (p = csp->iob->buf; p < csp->iob->eod; p++)
379    {
380       if (*p == '\0') *p = '\n';
381    }
382
383    /*
384     * Export the original client's request and the one we would
385     * be sending to the server if this wasn't a CGI call
386     */
387
388    if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
389    {
390       free_map(exports);
391       return JB_ERR_MEMORY;
392    }
393
394    if (map(exports, "processed-request", 1, html_encode_and_free_original(
395       sed(client_patterns, add_client_headers, csp)), 0))
396    {
397       free_map(exports);
398       return JB_ERR_MEMORY;
399    }
400
401    return template_fill_for_cgi(csp, "show-request", exports, rsp);
402 }
403
404
405 /*********************************************************************
406  *
407  * Function    :  cgi_send_banner
408  *
409  * Description :  CGI function that returns a banner. 
410  *
411  * Parameters  :
412  *          1  :  csp = Current client state (buffers, headers, etc...)
413  *          2  :  rsp = http_response data structure for output
414  *          3  :  parameters = map of cgi parameters
415  *
416  * CGI Parameters :
417  *           type : Selects the type of banner between "trans", "logo",
418  *                  and "auto". Defaults to "logo" if absent or invalid.
419  *                  "auto" means to select as if we were image-blocking.
420  *                  (Only the first character really counts).
421  *
422  * Returns     :  JB_ERR_OK on success
423  *                JB_ERR_MEMORY on out-of-memory error.  
424  *
425  *********************************************************************/
426 jb_err cgi_send_banner(struct client_state *csp,
427                        struct http_response *rsp,
428                        const struct map *parameters)
429 {
430    char imagetype = lookup(parameters, "type")[0];
431
432    if (imagetype == 'a') /* auto */
433    {
434       /* Default to pattern */
435       imagetype = 'p';
436 #ifdef FEATURE_IMAGE_BLOCKING
437       if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
438       {
439          static const char prefix1[] = CGI_PREFIX "send-banner?type=";
440          static const char prefix2[] = "http://" CGI_SITE_1_HOST "/send-banner?type=";
441
442          /* determine HOW images should be blocked */
443          const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
444
445          /* and handle accordingly: */
446          if (p == NULL)
447          {
448             /* Use default - nothing to do here. */
449          }
450          else if (0 == strcmpic(p, "blank"))
451          {
452             imagetype = 'b';
453          }
454          else if (0 == strcmpic(p, "pattern"))
455          {
456             imagetype = 'p';
457          }
458          else if (0 == strncmpic(p, prefix1, sizeof(prefix1) - 1))
459          {
460             imagetype = p[sizeof(prefix1) - 1];
461          }
462          else if (0 == strncmpic(p, prefix2, sizeof(prefix2) - 1))
463          {
464             imagetype = p[sizeof(prefix2) - 1];
465          }
466       }
467 #endif /* def FEATURE_IMAGE_BLOCKING */
468    }
469       
470    if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
471    {
472       rsp->body = bindup(image_blank_data, image_blank_length);
473       rsp->content_length = image_blank_length;
474
475    }
476    else /* pattern */
477    {
478       rsp->body = bindup(image_pattern_data, image_pattern_length);
479       rsp->content_length = image_pattern_length;
480    }   
481
482    if (rsp->body == NULL)
483    {
484       return JB_ERR_MEMORY;
485    }
486
487    if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
488    {
489       return JB_ERR_MEMORY;
490    }
491
492    rsp->is_static = 1;
493
494    return JB_ERR_OK;
495
496 }
497
498
499 /*********************************************************************
500  *
501  * Function    :  cgi_transparent_image
502  *
503  * Description :  CGI function that sends a 1x1 transparent image.
504  *
505  * Parameters  :
506  *          1  :  csp = Current client state (buffers, headers, etc...)
507  *          2  :  rsp = http_response data structure for output
508  *          3  :  parameters = map of cgi parameters
509  *
510  * CGI Parameters : None
511  *
512  * Returns     :  JB_ERR_OK on success
513  *                JB_ERR_MEMORY on out-of-memory error.  
514  *
515  *********************************************************************/
516 jb_err cgi_transparent_image(struct client_state *csp,
517                              struct http_response *rsp,
518                              const struct map *parameters)
519 {
520    rsp->body = bindup(image_blank_data, image_blank_length);
521    rsp->content_length = image_blank_length;
522
523    if (rsp->body == NULL)
524    {
525       return JB_ERR_MEMORY;
526    }
527
528    if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
529    {
530       return JB_ERR_MEMORY;
531    }
532
533    rsp->is_static = 1;
534
535    return JB_ERR_OK;
536
537 }
538
539
540 /*********************************************************************
541  *
542  * Function    :  cgi_send_stylesheet
543  *
544  * Description :  CGI function that sends a css stylesheet found
545  *                in the cgi-style.css template
546  *
547  * Parameters  :
548  *          1  :  csp = Current client state (buffers, headers, etc...)
549  *          2  :  rsp = http_response data structure for output
550  *          3  :  parameters = map of cgi parameters
551  *
552  * CGI Parameters : None
553  *
554  * Returns     :  JB_ERR_OK on success
555  *                JB_ERR_MEMORY on out-of-memory error.  
556  *
557  *********************************************************************/
558 jb_err cgi_send_stylesheet(struct client_state *csp,
559                            struct http_response *rsp,
560                            const struct map *parameters)
561 {
562    jb_err err;
563    
564    assert(csp);
565    assert(rsp);
566
567    err = template_load(csp, &rsp->body, "cgi-style.css", 0);
568
569    if (err == JB_ERR_FILE)
570    {
571       /*
572        * No way to tell user; send empty stylesheet
573        */
574       log_error(LOG_LEVEL_ERROR, "Could not find cgi-style.css template");
575    }
576    else if (err)
577    {
578       return err; /* JB_ERR_MEMORY */
579    }
580
581    if (enlist(rsp->headers, "Content-Type: text/css"))
582    {
583       return JB_ERR_MEMORY;
584    }
585
586    return JB_ERR_OK;
587
588 }
589
590
591 /*********************************************************************
592  *
593  * Function    :  cgi_show_version
594  *
595  * Description :  CGI function that returns a a web page describing the
596  *                file versions of Privoxy.
597  *
598  * Parameters  :
599  *          1  :  csp = Current client state (buffers, headers, etc...)
600  *          2  :  rsp = http_response data structure for output
601  *          3  :  parameters = map of cgi parameters
602  *
603  * CGI Parameters : none
604  *
605  * Returns     :  JB_ERR_OK on success
606  *                JB_ERR_MEMORY on out-of-memory error.  
607  *
608  *********************************************************************/
609 jb_err cgi_show_version(struct client_state *csp,
610                         struct http_response *rsp,
611                         const struct map *parameters)
612 {
613    struct map *exports;
614
615    assert(csp);
616    assert(rsp);
617    assert(parameters);
618
619    if (NULL == (exports = default_exports(csp, "show-version")))
620    {
621       return JB_ERR_MEMORY;
622    }
623
624    if (map(exports, "sourceversions", 1, show_rcs(), 0))
625    {
626       free_map(exports);
627       return JB_ERR_MEMORY;
628    }
629
630    return template_fill_for_cgi(csp, "show-version", exports, rsp);
631 }
632
633  
634 /*********************************************************************
635  *
636  * Function    :  cgi_show_status
637  *
638  * Description :  CGI function that returns a a web page describing the
639  *                current status of Privoxy.
640  *
641  * Parameters  :
642  *          1  :  csp = Current client state (buffers, headers, etc...)
643  *          2  :  rsp = http_response data structure for output
644  *          3  :  parameters = map of cgi parameters
645  *
646  * CGI Parameters :
647  *        file :  Which file to show.  Only first letter is checked,
648  *                valid values are:
649  *                - "p"ermissions (actions) file
650  *                - "r"egex
651  *                - "t"rust
652  *                Default is to show menu and other information.
653  *
654  * Returns     :  JB_ERR_OK on success
655  *                JB_ERR_MEMORY on out-of-memory error.  
656  *
657  *********************************************************************/
658 jb_err cgi_show_status(struct client_state *csp,
659                        struct http_response *rsp,
660                        const struct map *parameters)
661 {
662    char *s = NULL;
663    unsigned i;
664    int j;
665
666    FILE * fp;
667    char buf[BUFFER_SIZE];
668    const char * filename = NULL;
669    char * file_description = NULL;
670 #ifdef FEATURE_STATISTICS
671    float perc_rej;   /* Percentage of http requests rejected */
672    int local_urls_read;
673    int local_urls_rejected;
674 #endif /* ndef FEATURE_STATISTICS */
675    struct file_list * fl;
676    struct url_actions * b;
677    jb_err err = JB_ERR_OK;
678
679    struct map *exports;
680
681    assert(csp);
682    assert(rsp);
683    assert(parameters);
684
685    if (NULL == (exports = default_exports(csp, "show-status")))
686    {
687       return JB_ERR_MEMORY;
688    }
689
690    switch (*(lookup(parameters, "file")))
691    {
692    case 'a':
693       if (!get_number_param(csp, parameters, "index", &i) && i < MAX_ACTION_FILES && csp->actions_list[i])
694       {
695          filename = csp->actions_list[i]->filename;
696          file_description = "Actions File";
697       }
698       break;
699
700    case 'f':
701       if (csp->rlist)
702       {
703          filename = csp->rlist->filename;
704          file_description = "Filter File";
705       }
706       break;
707
708 #ifdef FEATURE_TRUST
709    case 't':
710       if (csp->tlist)
711       {
712          filename = csp->tlist->filename;
713          file_description = "Trust File";
714       }
715       break;
716 #endif /* def FEATURE_TRUST */
717    }
718
719    if (NULL != filename)
720    {
721       if ( map(exports, "file-description", 1, file_description, 1)
722         || map(exports, "filepath", 1, html_encode(filename), 0) )
723       {
724          free_map(exports);
725          return JB_ERR_MEMORY;
726       }
727
728       if ((fp = fopen(filename, "r")) == NULL)
729       {
730          if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
731          {
732             free_map(exports);
733             return JB_ERR_MEMORY;
734          }
735       }
736       else
737       {
738          s = strdup("");
739          while ((s != NULL) && fgets(buf, sizeof(buf), fp))
740          {
741             string_join  (&s, html_encode(buf));
742          }
743          fclose(fp);
744
745          if (map(exports, "contents", 1, s, 0))
746          {
747             free_map(exports);
748             return JB_ERR_MEMORY;
749          }
750       }
751
752       return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
753    }
754
755    s = strdup("");
756    for (j = 0; (s != NULL) && (j < Argc); j++)
757    {
758       if (!err) err = string_join  (&s, html_encode(Argv[j]));
759       if (!err) err = string_append(&s, " ");
760    }
761    if (!err) err = map(exports, "invocation", 1, s, 0);
762
763    if (!err) err = map(exports, "options", 1, csp->config->proxy_args, 1);
764    if (!err) err = show_defines(exports);
765
766    if (err) 
767    {
768       free_map(exports);
769       return JB_ERR_MEMORY;
770    }
771
772 #ifdef FEATURE_STATISTICS
773    local_urls_read     = urls_read;
774    local_urls_rejected = urls_rejected;
775
776    /*
777     * Need to alter the stats not to include the fetch of this
778     * page.
779     *
780     * Can't do following thread safely! doh!
781     *
782     * urls_read--;
783     * urls_rejected--; * This will be incremented subsequently *
784     */
785
786    if (local_urls_read == 0)
787    {
788       if (!err) err = map_block_killer(exports, "have-stats");
789    }
790    else
791    {
792       if (!err) err = map_block_killer(exports, "have-no-stats");
793
794       perc_rej = (float)local_urls_rejected * 100.0F /
795             (float)local_urls_read;
796
797       sprintf(buf, "%d", local_urls_read);
798       if (!err) err = map(exports, "requests-received", 1, buf, 1);
799
800       sprintf(buf, "%d", local_urls_rejected);
801       if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
802
803       sprintf(buf, "%6.2f", perc_rej);
804       if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
805    }
806
807 #else /* ndef FEATURE_STATISTICS */
808    err = err || map_block_killer(exports, "statistics");
809 #endif /* ndef FEATURE_STATISTICS */
810    
811    /* 
812     * List all action files in use, together with view and edit links,
813     * except for standard.action, which should only be viewable. (Not
814     * enforced in the editor itself)
815     * FIXME: Shouldn't include hardwired HTML here, use line template instead!
816     */
817    s = strdup("");
818    for (i = 0; i < MAX_ACTION_FILES; i++)
819    {
820       if (((fl = csp->actions_list[i]) != NULL) && ((b = fl->f) != NULL))
821       {
822          if (!err) err = string_append(&s, "<tr><td>");
823          if (!err) err = string_join(&s, html_encode(csp->actions_list[i]->filename));
824          snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&index=%d\">View</a> ", i);
825          if (!err) err = string_append(&s, buf);
826
827          if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
828          {
829             snprintf(buf, 100, "<a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
830             if (!err) err = string_append(&s, buf);
831          }
832
833          if (!err) err = string_append(&s, "</td></tr>\n");
834       }
835    }
836    if (*s != '\0')   
837    {
838       if (!err) err = map(exports, "actions-filenames", 1, s, 0);
839    }
840    else
841    {
842       if (!err) err = map(exports, "actions-filenames", 1, "<tr><td>None specified</td></tr>", 1);
843    }
844
845    if (csp->rlist)
846    {
847       if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
848    }
849    else
850    {
851       if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
852       if (!err) err = map_block_killer(exports, "have-filterfile");
853    }
854
855 #ifdef FEATURE_TRUST
856    if (csp->tlist)
857    {
858       if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
859    }
860    else
861    {
862       if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
863       if (!err) err = map_block_killer(exports, "have-trustfile");
864    }
865 #else
866    if (!err) err = map_block_killer(exports, "trust-support");
867 #endif /* ndef FEATURE_TRUST */
868
869    if (err)
870    {
871       free_map(exports);
872       return JB_ERR_MEMORY;
873    }
874
875    return template_fill_for_cgi(csp, "show-status", exports, rsp);
876 }
877
878  
879 /*********************************************************************
880  *
881  * Function    :  cgi_show_url_info
882  *
883  * Description :  CGI function that determines and shows which actions
884  *                Privoxy will perform for a given url, and which
885  *                matches starting from the defaults have lead to that.
886  *
887  * Parameters  :
888  *          1  :  csp = Current client state (buffers, headers, etc...)
889  *          2  :  rsp = http_response data structure for output
890  *          3  :  parameters = map of cgi parameters
891  *
892  * CGI Parameters :
893  *            url : The url whose actions are to be determined.
894  *                  If url is unset, the url-given conditional will be
895  *                  set, so that all but the form can be suppressed in
896  *                  the template.
897  *
898  * Returns     :  JB_ERR_OK on success
899  *                JB_ERR_MEMORY on out-of-memory error.  
900  *
901  *********************************************************************/
902 jb_err cgi_show_url_info(struct client_state *csp,
903                          struct http_response *rsp,
904                          const struct map *parameters)
905 {
906    char *url_param;
907    struct map *exports;
908    char buf[150];
909
910    assert(csp);
911    assert(rsp);
912    assert(parameters);
913
914    if (NULL == (exports = default_exports(csp, "show-url-info")))
915    {
916       return JB_ERR_MEMORY;
917    }
918
919    /*
920     * Get the url= parameter (if present) and remove any leading/trailing spaces.
921     */
922    url_param = strdup(lookup(parameters, "url"));
923    if (url_param == NULL)
924    {
925       free_map(exports);
926       return JB_ERR_MEMORY;
927    }
928    chomp(url_param);
929
930    /*
931     * Handle prefixes.  4 possibilities:
932     * 1) "http://" or "https://" prefix present and followed by URL - OK
933     * 2) Only the "http://" or "https://" part is present, no URL - change
934     *    to empty string so it will be detected later as "no URL".
935     * 3) Parameter specified but doesn't contain "http(s?)://" - add a
936     *    "http://" prefix.
937     * 4) Parameter not specified or is empty string - let this fall through
938     *    for now, next block of code will handle it.
939     */
940    if (0 == strncmp(url_param, "http://", 7))
941    {
942       if (url_param[7] == '\0')
943       {
944          /*
945           * Empty URL (just prefix).
946           * Make it totally empty so it's caught by the next if()
947           */
948          url_param[0] = '\0';
949       }
950    }
951    else if (0 == strncmp(url_param, "https://", 8))
952    {
953       if (url_param[8] == '\0')
954       {
955          /*
956           * Empty URL (just prefix).
957           * Make it totally empty so it's caught by the next if()
958           */
959          url_param[0] = '\0';
960       }
961    }
962    else if (url_param[0] != '\0')
963    {
964       /*
965        * Unknown prefix - assume http://
966        */
967       char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
968       if (NULL == url_param_prefixed)
969       {
970          free(url_param);
971          free_map(exports);
972          return JB_ERR_MEMORY;
973       }
974       strcpy(url_param_prefixed, "http://");
975       strcpy(url_param_prefixed + 7, url_param);
976       free(url_param);
977       url_param = url_param_prefixed;
978    }
979
980
981    if (url_param[0] == '\0')
982    {
983       /* URL paramater not specified, display query form only. */
984       free(url_param);
985       if (map_block_killer(exports, "url-given")
986         || map(exports, "url", 1, "", 1))
987       {
988          free_map(exports);
989          return JB_ERR_MEMORY;
990       }
991    }
992    else
993    {
994       /* Given a URL, so query it. */
995       jb_err err;
996       char *matches;
997       char *s;
998       int hits = 0;
999       struct file_list *fl;
1000       struct url_actions *b;
1001       struct http_request url_to_query[1];
1002       struct current_action_spec action[1];
1003       int i;
1004       
1005       if (map(exports, "url", 1, html_encode(url_param), 0))
1006       {
1007          free(url_param);
1008          free_map(exports);
1009          return JB_ERR_MEMORY;
1010       }
1011
1012       init_current_action(action);
1013
1014       if (map(exports, "default", 1, current_action_to_html(csp, action), 0))
1015       {
1016          free_current_action(action);
1017          free(url_param);
1018          free_map(exports);
1019          return JB_ERR_MEMORY;
1020       }
1021
1022       err = parse_http_url(url_param, url_to_query, csp);
1023
1024       free(url_param);
1025
1026       if (err == JB_ERR_MEMORY)
1027       {
1028          free_current_action(action);
1029          free_map(exports);
1030          return JB_ERR_MEMORY;
1031       }
1032       else if (err)
1033       {
1034          /* Invalid URL */
1035
1036          err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
1037          if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
1038
1039          free_current_action(action);
1040
1041          if (err)
1042          {
1043             free_map(exports);
1044             return JB_ERR_MEMORY;
1045          }
1046
1047          return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1048       }
1049
1050       /*
1051        * We have a warning about SSL paths.  Hide it for insecure sites.
1052        */
1053       if (!url_to_query->ssl)
1054       {
1055          if (map_block_killer(exports, "https"))
1056          {
1057             free_current_action(action);
1058             free_map(exports);
1059             return JB_ERR_MEMORY;
1060          }
1061       }
1062
1063       matches = strdup("<table class=\"transparent\">");
1064
1065       for (i = 0; i < MAX_ACTION_FILES; i++)
1066       {
1067          if (NULL == csp->config->actions_file_short[i]
1068              || !strcmp(csp->config->actions_file_short[i], "standard")) continue;
1069
1070          b = NULL;
1071          hits = 1;
1072          if ((fl = csp->actions_list[i]) != NULL)
1073          {
1074             if ((b = fl->f) != NULL)
1075             {
1076                /* FIXME: Hardcoded HTML! */
1077                string_append(&matches, "<tr><th>In file: ");
1078                string_join  (&matches, html_encode(csp->config->actions_file_short[i]));
1079                snprintf(buf, 150, ".action <a class=\"cmd\" href=\"/show-status?file=actions&index=%d\">", i);
1080                string_append(&matches, buf);
1081                string_append(&matches, "View</a> <a class=\"cmd\" href=\"/edit-actions-list?f=");
1082                string_join  (&matches, html_encode(csp->config->actions_file_short[i]));
1083                string_append(&matches, "\">Edit</a></th></tr>\n");
1084
1085                hits = 0;
1086                b = b->next;
1087             }
1088          }
1089
1090          for (; (b != NULL) && (matches != NULL); b = b->next)
1091          {
1092             if (url_match(b->url, url_to_query))
1093             {
1094                string_append(&matches, "<tr><td>{");
1095                string_join  (&matches, actions_to_html(csp, b->action));
1096                string_append(&matches, " }</b><br>\n<code>");
1097                string_join  (&matches, html_encode(b->url->spec));
1098                string_append(&matches, "</code></td></tr>\n");
1099
1100                if (merge_current_action(action, b->action))
1101                {
1102                   freez(matches);
1103                   free_http_request(url_to_query);
1104                   free_current_action(action);
1105                   free_map(exports);
1106                   return JB_ERR_MEMORY;
1107                }
1108                hits++;
1109             }
1110          }
1111
1112          if (!hits)
1113          {
1114             string_append(&matches, "<tr><td>(no matches in this file)</td></tr>\n");
1115          }
1116       }
1117       string_append(&matches, "</table>\n");
1118
1119       free_http_request(url_to_query);
1120
1121       if (matches == NULL)
1122       {
1123          free_current_action(action);
1124          free_map(exports);
1125          return JB_ERR_MEMORY;
1126       }
1127
1128       if (map(exports, "matches", 1, matches , 0))
1129       {
1130          free_current_action(action);
1131          free_map(exports);
1132          return JB_ERR_MEMORY;
1133       }
1134
1135       s = current_action_to_html(csp, action);
1136
1137       free_current_action(action);
1138
1139       if (map(exports, "final", 1, s, 0))
1140       {
1141          free_map(exports);
1142          return JB_ERR_MEMORY;
1143       }
1144    }
1145
1146    return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1147 }
1148
1149
1150 /*********************************************************************
1151  *
1152  * Function    :  cgi_robots_txt
1153  *
1154  * Description :  CGI function to return "/robots.txt".
1155  *
1156  * Parameters  :
1157  *          1  :  csp = Current client state (buffers, headers, etc...)
1158  *          2  :  rsp = http_response data structure for output
1159  *          3  :  parameters = map of cgi parameters
1160  *
1161  * CGI Parameters : None
1162  *
1163  * Returns     :  JB_ERR_OK on success
1164  *                JB_ERR_MEMORY on out-of-memory error.  
1165  *
1166  *********************************************************************/
1167 jb_err cgi_robots_txt(struct client_state *csp,
1168                       struct http_response *rsp,
1169                       const struct map *parameters)
1170 {
1171    char buf[100];
1172    jb_err err;
1173
1174    rsp->body = strdup(
1175       "# This is the Privoxy control interface.\n"
1176       "# It isn't very useful to index it, and you're likely to break stuff.\n"
1177       "# So go away!\n"
1178       "\n"
1179       "User-agent: *\n"
1180       "Disallow: /\n"
1181       "\n");
1182    if (rsp->body == NULL)
1183    {
1184       return JB_ERR_MEMORY;
1185    }
1186
1187    err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1188
1189    rsp->is_static = 1;
1190
1191    get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1192    if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1193
1194    return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1195 }
1196
1197
1198 /*********************************************************************
1199  *
1200  * Function    :  show_defines
1201  *
1202  * Description :  Add to a map the state od all conditional #defines
1203  *                used when building
1204  *
1205  * Parameters  :
1206  *          1  :  exports = map to extend
1207  *
1208  * Returns     :  JB_ERR_OK on success
1209  *                JB_ERR_MEMORY on out-of-memory error.  
1210  *
1211  *********************************************************************/
1212 static jb_err show_defines(struct map *exports)
1213 {
1214    jb_err err = JB_ERR_OK;
1215
1216 #ifdef FEATURE_ACL
1217    if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1218 #else /* ifndef FEATURE_ACL */
1219    if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1220 #endif /* ndef FEATURE_ACL */
1221
1222 #ifdef FEATURE_CGI_EDIT_ACTIONS
1223    if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1224 #else /* ifndef FEATURE_COOKIE_JAR */
1225    if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1226 #endif /* ndef FEATURE_COOKIE_JAR */
1227
1228 #ifdef FEATURE_COOKIE_JAR
1229    if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1230 #else /* ifndef FEATURE_COOKIE_JAR */
1231    if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1232 #endif /* ndef FEATURE_COOKIE_JAR */
1233
1234 #ifdef FEATURE_FAST_REDIRECTS
1235    if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1236 #else /* ifndef FEATURE_FAST_REDIRECTS */
1237    if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1238 #endif /* ndef FEATURE_FAST_REDIRECTS */
1239
1240 #ifdef FEATURE_FORCE_LOAD
1241    if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1242    if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1243 #else /* ifndef FEATURE_FORCE_LOAD */
1244    if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1245    if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
1246 #endif /* ndef FEATURE_FORCE_LOAD */
1247
1248 #ifdef FEATURE_IMAGE_BLOCKING
1249    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1250 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1251    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1252 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1253
1254 #ifdef FEATURE_IMAGE_DETECT_MSIE
1255    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1256 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1257    if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1258 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1259
1260 #ifdef FEATURE_KILL_POPUPS
1261    if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1262 #else /* ifndef FEATURE_KILL_POPUPS */
1263    if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1264 #endif /* ndef FEATURE_KILL_POPUPS */
1265
1266 #ifdef FEATURE_NO_GIFS
1267    if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1268 #else /* ifndef FEATURE_NO_GIFS */
1269    if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1270 #endif /* ndef FEATURE_NO_GIFS */
1271
1272 #ifdef FEATURE_PTHREAD
1273    if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1274 #else /* ifndef FEATURE_PTHREAD */
1275    if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1276 #endif /* ndef FEATURE_PTHREAD */
1277
1278 #ifdef FEATURE_STATISTICS
1279    if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1280 #else /* ifndef FEATURE_STATISTICS */
1281    if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1282 #endif /* ndef FEATURE_STATISTICS */
1283
1284 #ifdef FEATURE_TOGGLE
1285    if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1286 #else /* ifndef FEATURE_TOGGLE */
1287    if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1288 #endif /* ndef FEATURE_TOGGLE */
1289
1290 #ifdef FEATURE_TRUST
1291    if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1292 #else /* ifndef FEATURE_TRUST */
1293    if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1294 #endif /* ndef FEATURE_TRUST */
1295
1296 #ifdef STATIC_PCRE
1297    if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1298 #else /* ifndef STATIC_PCRE */
1299    if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1300 #endif /* ndef STATIC_PCRE */
1301
1302 #ifdef STATIC_PCRS
1303    if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1304 #else /* ifndef STATIC_PCRS */
1305    if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1306 #endif /* ndef STATIC_PCRS */
1307
1308    return err;
1309 }
1310
1311
1312 /*********************************************************************
1313  *
1314  * Function    :  show_rcs
1315  *
1316  * Description :  Create a string with the rcs info for all sourcefiles
1317  *
1318  * Parameters  :  None
1319  *
1320  * Returns     :  A string, or NULL on out-of-memory.
1321  *
1322  *********************************************************************/
1323 static char *show_rcs(void)
1324 {
1325    char *result = strdup("");
1326    char buf[BUFFER_SIZE];
1327
1328    /* Instead of including *all* dot h's in the project (thus creating a
1329     * tremendous amount of dependencies), I will concede to declaring them
1330     * as extern's.  This forces the developer to add to this list, but oh well.
1331     */
1332
1333 #define SHOW_RCS(__x)              \
1334    {                               \
1335       extern const char __x[];     \
1336       sprintf(buf, "%s\n", __x);   \
1337       string_append(&result, buf); \
1338    }
1339
1340    /* In alphabetical order */
1341    SHOW_RCS(actions_h_rcs)
1342    SHOW_RCS(actions_rcs)
1343 #ifdef AMIGA
1344    SHOW_RCS(amiga_h_rcs)
1345    SHOW_RCS(amiga_rcs)
1346 #endif /* def AMIGA */
1347    SHOW_RCS(cgi_h_rcs)
1348    SHOW_RCS(cgi_rcs)
1349 #ifdef FEATURE_CGI_EDIT_ACTIONS
1350    SHOW_RCS(cgiedit_h_rcs)
1351    SHOW_RCS(cgiedit_rcs)
1352 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1353    SHOW_RCS(cgisimple_h_rcs)
1354    SHOW_RCS(cgisimple_rcs)
1355 #ifdef __MINGW32__
1356    SHOW_RCS(cygwin_h_rcs)
1357 #endif
1358    SHOW_RCS(deanimate_h_rcs)
1359    SHOW_RCS(deanimate_rcs)
1360    SHOW_RCS(encode_h_rcs)
1361    SHOW_RCS(encode_rcs)
1362    SHOW_RCS(errlog_h_rcs)
1363    SHOW_RCS(errlog_rcs)
1364    SHOW_RCS(filters_h_rcs)
1365    SHOW_RCS(filters_rcs)
1366    SHOW_RCS(gateway_h_rcs)
1367    SHOW_RCS(gateway_rcs)
1368    SHOW_RCS(jbsockets_h_rcs)
1369    SHOW_RCS(jbsockets_rcs)
1370    SHOW_RCS(jcc_h_rcs)
1371    SHOW_RCS(jcc_rcs)
1372 #ifdef FEATURE_KILL_POPUPS
1373    SHOW_RCS(killpopup_h_rcs)
1374    SHOW_RCS(killpopup_rcs)
1375 #endif /* def FEATURE_KILL_POPUPS */
1376    SHOW_RCS(list_h_rcs)
1377    SHOW_RCS(list_rcs)
1378    SHOW_RCS(loadcfg_h_rcs)
1379    SHOW_RCS(loadcfg_rcs)
1380    SHOW_RCS(loaders_h_rcs)
1381    SHOW_RCS(loaders_rcs)
1382    SHOW_RCS(miscutil_h_rcs)
1383    SHOW_RCS(miscutil_rcs)
1384    SHOW_RCS(parsers_h_rcs)
1385    SHOW_RCS(parsers_rcs)
1386    SHOW_RCS(pcrs_rcs)
1387    SHOW_RCS(pcrs_h_rcs)
1388    SHOW_RCS(project_h_rcs)
1389    SHOW_RCS(ssplit_h_rcs)
1390    SHOW_RCS(ssplit_rcs)
1391    SHOW_RCS(urlmatch_h_rcs)
1392    SHOW_RCS(urlmatch_rcs)
1393 #ifdef _WIN32
1394 #ifndef _WIN_CONSOLE
1395    SHOW_RCS(w32log_h_rcs)
1396    SHOW_RCS(w32log_rcs)
1397    SHOW_RCS(w32res_h_rcs)
1398    SHOW_RCS(w32taskbar_h_rcs)
1399    SHOW_RCS(w32taskbar_rcs)
1400 #endif /* ndef _WIN_CONSOLE */
1401    SHOW_RCS(win32_h_rcs)
1402    SHOW_RCS(win32_rcs)
1403 #endif /* def _WIN32 */
1404
1405 #undef SHOW_RCS
1406
1407    return result;
1408
1409 }
1410
1411
1412 /*
1413   Local Variables:
1414   tab-width: 3
1415   end:
1416 */