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