1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.49 2007/01/20 16:29:38 fabiankeil Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
6 * Purpose : Simple CGIs to get information about Privoxy's
9 * Functions declared include:
12 * Copyright : Written by and Copyright (C) 2001-2007 the SourceForge
13 * Privoxy team. http://www.privoxy.org/
15 * Based on the Internet Junkbuster originally written
16 * by and Copyright (C) 1997 Anonymous Coders and
17 * Junkbusters Corporation. http://www.junkbusters.com
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.
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.
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.
38 * $Log: cgisimple.c,v $
39 * Revision 1.49 2007/01/20 16:29:38 fabiankeil
40 * Suppress edit buttons for action files if Privoxy has
41 * no write access. Suggested by Roland in PR 1564026.
43 * Revision 1.48 2007/01/20 15:31:31 fabiankeil
44 * Display warning if show-url-info CGI page
45 * is used while Privoxy is toggled off.
47 * Revision 1.47 2007/01/12 15:07:10 fabiankeil
48 * Use zalloc in cgi_send_user_manual.
50 * Revision 1.46 2007/01/02 12:49:46 fabiankeil
51 * Add FEATURE_ZLIB to the list of conditional
52 * defines at the show-status page.
54 * Revision 1.45 2006/12/28 18:16:41 fabiankeil
55 * Fixed gcc43 compiler warnings, zero out cgi_send_user_manual's
56 * body memory before using it, replaced sprintf calls with snprintf.
58 * Revision 1.44 2006/12/22 14:19:27 fabiankeil
59 * Removed checks whether or not AF_FILES have
60 * data structures associated with them in cgi_show_status.
61 * It doesn't matter as we're only interested in the file names.
63 * For the action files the checks were always true,
64 * but they prevented empty filter files from being
65 * listed. Fixes parts of BR 1619208.
67 * Revision 1.43 2006/12/17 17:57:56 fabiankeil
68 * - Added FEATURE_GRACEFUL_TERMINATION to the
69 * "conditional #defines" section
70 * - Escaped ampersands in generated HTML.
71 * - Renamed re-filter-filename to re-filter-filenames
73 * Revision 1.42 2006/11/21 15:43:12 fabiankeil
74 * Add special treatment for WIN32 to make sure
75 * cgi_send_user_manual opens the files in binary mode.
76 * Fixes BR 1600411 and unbreaks image delivery.
78 * Remove outdated comment.
80 * Revision 1.41 2006/10/09 19:18:28 roro
81 * Redirect http://p.p/user-manual (without trailing slash) to
82 * http://p.p/user-manual/ (with trailing slash), otherwise links will be broken.
84 * Revision 1.40 2006/09/09 13:05:33 fabiankeil
85 * Modified cgi_send_user_manual to serve binary
86 * content without destroying it first. Should also be
87 * faster now. Added ".jpg" check for Content-Type guessing.
89 * Revision 1.39 2006/09/08 09:49:23 fabiankeil
90 * Deliver documents in the user-manual directory
91 * with "Content-Type text/css" if their filename
94 * Revision 1.38 2006/09/06 18:45:03 fabiankeil
95 * Incorporate modified version of Roland Rosenfeld's patch to
96 * optionally access the user-manual via Privoxy. Closes patch 679075.
98 * Formatting changed to Privoxy style, added call to
99 * cgi_error_no_template if the requested file doesn't
100 * exist and modified check whether or not Privoxy itself
101 * should serve the manual. Should work cross-platform now.
103 * Revision 1.37 2006/07/18 14:48:45 david__schmidt
104 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
105 * with what was really the latest development (the v_3_0_branch branch)
107 * Revision 1.35.2.7 2006/01/29 23:10:56 david__schmidt
108 * Multiple filter file support
110 * Revision 1.35.2.6 2005/07/04 03:13:43 david__schmidt
111 * Undo some damaging memory leak patches
113 * Revision 1.35.2.5 2005/05/07 21:50:55 david__schmidt
114 * A few memory leaks plugged (mostly on error paths)
116 * Revision 1.35.2.4 2005/04/04 02:21:24 david__schmidt
117 * Another instance of:
118 * Don't show "Edit" buttons #ifndef FEATURE_CGI_EDIT_ACTIONS
119 * Thanks to Magnus Holmgren for the patch
121 * Revision 1.35.2.3 2003/12/17 16:34:15 oes
122 * - Prevent line wrap beween "View/Edit" link buttons on status page
123 * - Some (mostly irrelevant) fixes for Out-of-mem-case handling
125 * Revision 1.35.2.2 2003/04/03 13:48:28 oes
126 * Don't show "Edit" buttons #ifndef FEATURE_CGI_EDIT_ACTIONS
128 * Revision 1.35.2.1 2002/07/04 15:02:38 oes
129 * Added ability to send redirects to send-banner CGI, so that it can completely mimic the image blocking action if called with type=auto
131 * Revision 1.35.2.1 2002/07/01 17:32:04 morcego
132 * Applying patch from Andreas as provided by Hal on the list.
133 * Message-ID: <20020701121218.V1606@feenix.burgiss.net>
135 * Revision 1.35 2002/05/12 21:44:44 jongfoster
136 * Adding amiga.[ch] revision information, if on an amiga.
138 * Revision 1.34 2002/04/30 12:06:12 oes
139 * Deleted unused code from default_cgi
141 * Revision 1.33 2002/04/30 11:14:52 oes
142 * Made csp the first parameter in *action_to_html
144 * Revision 1.32 2002/04/26 18:29:13 jongfoster
145 * Fixing this Visual C++ warning:
146 * cgisimple.c(775) : warning C4018: '<' : signed/unsigned mismatch
148 * Revision 1.31 2002/04/26 12:54:36 oes
149 * - Kill obsolete REDIRECT_URL code
150 * - Error handling fixes
151 * - Style sheet related HTML snipplet changes
152 * - cgi_show_url_info:
153 * - Matches now in table, actions on single lines,
155 * - standard.action suppressed
156 * - Buttons to View and Edit AFs
158 * Revision 1.30 2002/04/24 02:18:08 oes
159 * - show-status is now the starting point for editing
160 * the actions files, generate list of all AFs with buttons
161 * for viewing and editing, new look for file list (Jon:
162 * buttons now aligned ;-P ), view mode now supports multiple
163 * AFs, name changes, no view links for unspecified files,
164 * no edit link for standard.action.
166 * - Jon's multiple AF patch: cgi_show_url_info now uses all
167 * AFs and marks the output accordingly
169 * Revision 1.29 2002/04/10 13:38:35 oes
170 * load_template signature changed
172 * Revision 1.28 2002/04/07 15:42:12 jongfoster
173 * Fixing send-banner?type=auto when the image-blocker is
174 * a redirect to send-banner
176 * Revision 1.27 2002/04/05 15:50:48 oes
177 * added send-stylesheet CGI
179 * Revision 1.26 2002/04/04 00:36:36 gliptak
180 * always use pcre for matching
182 * Revision 1.25 2002/04/03 22:28:03 gliptak
183 * Removed references to gnu_regex
185 * Revision 1.24 2002/04/02 16:12:47 oes
186 * Fix: moving misplaced lines into #ifdef FEATURE_FORCE
188 * Revision 1.23 2002/03/26 22:29:54 swa
189 * we have a new homepage!
191 * Revision 1.22 2002/03/24 16:18:15 jongfoster
194 * Revision 1.21 2002/03/24 15:23:33 jongfoster
197 * Revision 1.20 2002/03/24 13:25:43 swa
198 * name change related issues
200 * Revision 1.19 2002/03/16 23:54:06 jongfoster
201 * Adding graceful termination feature, to help look for memory leaks.
202 * If you enable this (which, by design, has to be done by hand
203 * editing config.h) and then go to http://i.j.b/die, then the program
204 * will exit cleanly after the *next* request. It should free all the
205 * memory that was used.
207 * Revision 1.18 2002/03/12 01:44:49 oes
208 * Changed default for "blocked" image from jb logo to checkboard pattern
210 * Revision 1.17 2002/03/08 16:43:18 oes
211 * Added choice beween GIF and PNG built-in images
213 * Revision 1.16 2002/03/07 03:48:38 oes
214 * - Changed built-in images from GIF to PNG
215 * (with regard to Unisys patent issue)
216 * - Added a 4x4 pattern PNG which is less intrusive
217 * than the logo but also clearly marks the deleted banners
219 * Revision 1.15 2002/03/06 22:54:35 jongfoster
220 * Automated function-comment nitpicking.
222 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
223 * Clean up a little CRLF unpleasantness that suddenly appeared
225 * Revision 1.13 2002/02/21 00:10:37 jongfoster
226 * Adding send-banner?type=auto option
228 * Revision 1.12 2002/01/23 01:03:32 jongfoster
229 * Fixing gcc [CygWin] compiler warnings
231 * Revision 1.11 2002/01/23 00:01:04 jongfoster
232 * Adding cgi_transparent_gif() for http://i.j.b/t
233 * Adding missing html_encode() to many CGI functions.
234 * Adding urlmatch.[ch] to http://i.j.b/show-version
236 * Revision 1.10 2002/01/17 21:10:37 jongfoster
237 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
238 * Also fixing a problem in the same function with improperly quoted URLs
239 * in output HTML, and adding code to handle https:// URLs correctly.
241 * Revision 1.9 2001/11/30 23:09:15 jongfoster
242 * Now reports on FEATURE_CGI_EDIT_ACTIONS
243 * Removing FEATURE_DENY_GZIP from template
245 * Revision 1.8 2001/11/13 00:14:07 jongfoster
246 * Fixing stupid bug now I've figured out what || means.
247 * (It always returns 0 or 1, not one of it's paramaters.)
249 * Revision 1.7 2001/10/23 21:48:19 jongfoster
250 * Cleaning up error handling in CGI functions - they now send back
251 * a HTML error page and should never cause a FATAL error. (Fixes one
252 * potential source of "denial of service" attacks).
254 * CGI actions file editor that works and is actually useful.
256 * Ability to toggle JunkBuster remotely using a CGI call.
258 * You can turn off both the above features in the main configuration
259 * file, e.g. if you are running a multi-user proxy.
261 * Revision 1.6 2001/10/14 22:00:32 jongfoster
262 * Adding support for a 404 error when an invalid CGI page is requested.
264 * Revision 1.5 2001/10/07 15:30:41 oes
265 * Removed FEATURE_DENY_GZIP
267 * Revision 1.4 2001/10/02 15:31:12 oes
268 * Introduced show-request cgi
270 * Revision 1.3 2001/09/22 16:34:44 jongfoster
271 * Removing unneeded #includes
273 * Revision 1.2 2001/09/19 18:01:11 oes
274 * Fixed comments; cosmetics
276 * Revision 1.1 2001/09/16 17:08:54 jongfoster
277 * Moving simple CGI functions from cgi.c to new file cgisimple.c
280 **********************************************************************/
286 #include <sys/types.h>
294 #endif /* def HAVE_ACCESS */
297 #define snprintf _snprintf
298 #endif /* def _WIN32 */
302 #include "cgisimple.h"
308 #include "miscutil.h"
311 #include "urlmatch.h"
314 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
317 static char *show_rcs(void);
318 static jb_err show_defines(struct map *exports);
321 * 16x16 ico blobs for favicon delivery functions.
323 const char default_favicon_data[] =
324 "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
325 "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
326 "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
327 "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
328 "\000\000\377\377\377\000\377\000\052\000\017\360\000\000\077"
329 "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
330 "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
331 "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
332 "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
333 "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
334 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
335 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
336 "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
338 const char error_favicon_data[] =
339 "\000\000\001\000\001\000\020\020\002\000\000\000\000\000\260"
340 "\000\000\000\026\000\000\000\050\000\000\000\020\000\000\000"
341 "\040\000\000\000\001\000\001\000\000\000\000\000\100\000\000"
342 "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000"
343 "\000\000\377\377\377\000\000\000\377\000\017\360\000\000\077"
344 "\374\000\000\161\376\000\000\161\376\000\000\361\377\000\000"
345 "\361\377\000\000\360\017\000\000\360\007\000\000\361\307\000"
346 "\000\361\307\000\000\361\307\000\000\360\007\000\000\160\036"
347 "\000\000\177\376\000\000\077\374\000\000\017\360\000\000\360"
348 "\017\000\000\300\003\000\000\200\001\000\000\200\001\000\000"
349 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
350 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
351 "\000\000\200\001\000\000\200\001\000\000\300\003\000\000\360"
353 const size_t default_favicon_length = sizeof(default_favicon_data) - 1;
354 const size_t error_favicon_length = sizeof(error_favicon_data) - 1;
356 /*********************************************************************
358 * Function : cgi_default
360 * Description : CGI function that is called for the CGI_SITE_1_HOST
361 * and CGI_SITE_2_HOST/CGI_SITE_2_PATH base URLs.
362 * Boring - only exports the default exports.
365 * 1 : csp = Current client state (buffers, headers, etc...)
366 * 2 : rsp = http_response data structure for output
367 * 3 : parameters = map of cgi parameters
369 * CGI Parameters : none
371 * Returns : JB_ERR_OK on success
372 * JB_ERR_MEMORY on out-of-memory
374 *********************************************************************/
375 jb_err cgi_default(struct client_state *csp,
376 struct http_response *rsp,
377 const struct map *parameters)
384 if (NULL == (exports = default_exports(csp, "")))
386 return JB_ERR_MEMORY;
389 return template_fill_for_cgi(csp, "default", exports, rsp);
393 /*********************************************************************
395 * Function : cgi_error_404
397 * Description : CGI function that is called if an unknown action was
401 * 1 : csp = Current client state (buffers, headers, etc...)
402 * 2 : rsp = http_response data structure for output
403 * 3 : parameters = map of cgi parameters
405 * CGI Parameters : none
407 * Returns : JB_ERR_OK on success
408 * JB_ERR_MEMORY on out-of-memory error.
410 *********************************************************************/
411 jb_err cgi_error_404(struct client_state *csp,
412 struct http_response *rsp,
413 const struct map *parameters)
421 if (NULL == (exports = default_exports(csp, NULL)))
423 return JB_ERR_MEMORY;
426 rsp->status = strdup("404 Privoxy configuration page not found");
427 if (rsp->status == NULL)
430 return JB_ERR_MEMORY;
433 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
437 #ifdef FEATURE_GRACEFUL_TERMINATION
438 /*********************************************************************
442 * Description : CGI function to shut down Privoxy.
443 * NOTE: Turning this on in a production build
444 * would be a BAD idea. An EXTREMELY BAD idea.
445 * In short, don't do it.
448 * 1 : csp = Current client state (buffers, headers, etc...)
449 * 2 : rsp = http_response data structure for output
450 * 3 : parameters = map of cgi parameters
452 * CGI Parameters : none
454 * Returns : JB_ERR_OK on success
455 * JB_ERR_MEMORY on out-of-memory error.
457 *********************************************************************/
458 jb_err cgi_die (struct client_state *csp,
459 struct http_response *rsp,
460 const struct map *parameters)
470 * I don't really care what gets sent back to the browser.
471 * Take the easy option - "out of memory" page.
474 return JB_ERR_MEMORY;
476 #endif /* def FEATURE_GRACEFUL_TERMINATION */
479 /*********************************************************************
481 * Function : cgi_show_request
483 * Description : Show the client's request and what sed() would have
487 * 1 : csp = Current client state (buffers, headers, etc...)
488 * 2 : rsp = http_response data structure for output
489 * 3 : parameters = map of cgi parameters
491 * CGI Parameters : none
493 * Returns : JB_ERR_OK on success
494 * JB_ERR_MEMORY on out-of-memory error.
496 *********************************************************************/
497 jb_err cgi_show_request(struct client_state *csp,
498 struct http_response *rsp,
499 const struct map *parameters)
508 if (NULL == (exports = default_exports(csp, "show-request")))
510 return JB_ERR_MEMORY;
514 * Repair the damage done to the IOB by get_header()
516 for (p = csp->iob->buf; p < csp->iob->eod; p++)
518 if (*p == '\0') *p = '\n';
522 * Export the original client's request and the one we would
523 * be sending to the server if this wasn't a CGI call
526 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
529 return JB_ERR_MEMORY;
532 if (map(exports, "processed-request", 1, html_encode_and_free_original(
533 sed(client_patterns, add_client_headers, csp)), 0))
536 return JB_ERR_MEMORY;
539 return template_fill_for_cgi(csp, "show-request", exports, rsp);
543 /*********************************************************************
545 * Function : cgi_send_banner
547 * Description : CGI function that returns a banner.
550 * 1 : csp = Current client state (buffers, headers, etc...)
551 * 2 : rsp = http_response data structure for output
552 * 3 : parameters = map of cgi parameters
555 * type : Selects the type of banner between "trans", "logo",
556 * and "auto". Defaults to "logo" if absent or invalid.
557 * "auto" means to select as if we were image-blocking.
558 * (Only the first character really counts; b and t are
561 * Returns : JB_ERR_OK on success
562 * JB_ERR_MEMORY on out-of-memory error.
564 *********************************************************************/
565 jb_err cgi_send_banner(struct client_state *csp,
566 struct http_response *rsp,
567 const struct map *parameters)
569 char imagetype = lookup(parameters, "type")[0];
572 * If type is auto, then determine the right thing
573 * to do from the set-image-blocker action
575 if (imagetype == 'a')
582 #ifdef FEATURE_IMAGE_BLOCKING
583 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
585 static const char prefix1[] = CGI_PREFIX "send-banner?type=";
586 static const char prefix2[] = "http://" CGI_SITE_1_HOST "/send-banner?type=";
587 const char *p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
591 /* Use default - nothing to do here. */
593 else if (0 == strcmpic(p, "blank"))
597 else if (0 == strcmpic(p, "pattern"))
603 * If the action is to call this CGI, determine
606 else if (0 == strncmpic(p, prefix1, sizeof(prefix1) - 1))
608 imagetype = p[sizeof(prefix1) - 1];
610 else if (0 == strncmpic(p, prefix2, sizeof(prefix2) - 1))
612 imagetype = p[sizeof(prefix2) - 1];
616 * Everything else must (should) be a URL to
624 #endif /* def FEATURE_IMAGE_BLOCKING */
628 * Now imagetype is either the non-auto type we were called with,
629 * or it was auto and has since been determined. In any case, we
630 * can proceed to actually answering the request by sending a redirect
631 * or an image as appropriate:
633 if (imagetype == 'r')
635 rsp->status = strdup("302 Local Redirect from Privoxy");
636 if (rsp->status == NULL)
638 return JB_ERR_MEMORY;
640 if (enlist_unique_header(rsp->headers, "Location",
641 csp->action->string[ACTION_STRING_IMAGE_BLOCKER]))
643 return JB_ERR_MEMORY;
648 if ((imagetype == 'b') || (imagetype == 't'))
650 rsp->body = bindup(image_blank_data, image_blank_length);
651 rsp->content_length = image_blank_length;
655 rsp->body = bindup(image_pattern_data, image_pattern_length);
656 rsp->content_length = image_pattern_length;
659 if (rsp->body == NULL)
661 return JB_ERR_MEMORY;
663 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
665 return JB_ERR_MEMORY;
676 /*********************************************************************
678 * Function : cgi_transparent_image
680 * Description : CGI function that sends a 1x1 transparent image.
683 * 1 : csp = Current client state (buffers, headers, etc...)
684 * 2 : rsp = http_response data structure for output
685 * 3 : parameters = map of cgi parameters
687 * CGI Parameters : None
689 * Returns : JB_ERR_OK on success
690 * JB_ERR_MEMORY on out-of-memory error.
692 *********************************************************************/
693 jb_err cgi_transparent_image(struct client_state *csp,
694 struct http_response *rsp,
695 const struct map *parameters)
697 rsp->body = bindup(image_blank_data, image_blank_length);
698 rsp->content_length = image_blank_length;
700 if (rsp->body == NULL)
702 return JB_ERR_MEMORY;
705 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
707 return JB_ERR_MEMORY;
717 /*********************************************************************
719 * Function : cgi_send_default_favicon
721 * Description : CGI function that sends the standard favicon.
724 * 1 : csp = Current client state (buffers, headers, etc...)
725 * 2 : rsp = http_response data structure for output
726 * 3 : parameters = map of cgi parameters
728 * CGI Parameters : None
730 * Returns : JB_ERR_OK on success
731 * JB_ERR_MEMORY on out-of-memory error.
733 *********************************************************************/
734 jb_err cgi_send_default_favicon(struct client_state *csp,
735 struct http_response *rsp,
736 const struct map *parameters)
738 rsp->body = bindup(default_favicon_data, default_favicon_length);
739 rsp->content_length = default_favicon_length;
741 if (rsp->body == NULL)
743 return JB_ERR_MEMORY;
746 if (enlist(rsp->headers, "Content-Type: image/x-icon"))
748 return JB_ERR_MEMORY;
758 /*********************************************************************
760 * Function : cgi_send_error_favicon
762 * Description : CGI function that sends the favicon for error pages.
765 * 1 : csp = Current client state (buffers, headers, etc...)
766 * 2 : rsp = http_response data structure for output
767 * 3 : parameters = map of cgi parameters
769 * CGI Parameters : None
771 * Returns : JB_ERR_OK on success
772 * JB_ERR_MEMORY on out-of-memory error.
774 *********************************************************************/
775 jb_err cgi_send_error_favicon(struct client_state *csp,
776 struct http_response *rsp,
777 const struct map *parameters)
779 rsp->body = bindup(error_favicon_data, error_favicon_length);
780 rsp->content_length = error_favicon_length;
782 if (rsp->body == NULL)
784 return JB_ERR_MEMORY;
787 if (enlist(rsp->headers, "Content-Type: image/x-icon"))
789 return JB_ERR_MEMORY;
799 /*********************************************************************
801 * Function : cgi_send_stylesheet
803 * Description : CGI function that sends a css stylesheet found
804 * in the cgi-style.css template
807 * 1 : csp = Current client state (buffers, headers, etc...)
808 * 2 : rsp = http_response data structure for output
809 * 3 : parameters = map of cgi parameters
811 * CGI Parameters : None
813 * Returns : JB_ERR_OK on success
814 * JB_ERR_MEMORY on out-of-memory error.
816 *********************************************************************/
817 jb_err cgi_send_stylesheet(struct client_state *csp,
818 struct http_response *rsp,
819 const struct map *parameters)
826 err = template_load(csp, &rsp->body, "cgi-style.css", 0);
828 if (err == JB_ERR_FILE)
831 * No way to tell user; send empty stylesheet
833 log_error(LOG_LEVEL_ERROR, "Could not find cgi-style.css template");
837 return err; /* JB_ERR_MEMORY */
840 if (enlist(rsp->headers, "Content-Type: text/css"))
842 return JB_ERR_MEMORY;
848 /*********************************************************************
850 * Function : cgi_send_user_manual
852 * Description : CGI function that sends a file in the user
856 * 1 : csp = Current client state (buffers, headers, etc...)
857 * 2 : rsp = http_response data structure for output
858 * 3 : parameters = map of cgi parameters
860 * CGI Parameters : file=name.html, the name of the HTML file
861 * (relative to user-manual from config)
863 * Returns : JB_ERR_OK on success
864 * JB_ERR_MEMORY on out-of-memory error.
866 *********************************************************************/
867 jb_err cgi_send_user_manual(struct client_state *csp,
868 struct http_response *rsp,
869 const struct map *parameters)
871 const char * filename;
874 jb_err err = JB_ERR_OK;
881 if (!parameters->first)
883 /* requested http://p.p/user-manual (without trailing slash) */
884 return cgi_redirect(rsp, CGI_PREFIX "user-manual/");
887 get_string_param(parameters, "file", &filename);
888 /* Check paramter for hack attempts */
889 if (filename && strchr(filename, '/'))
891 return JB_ERR_CGI_PARAMS;
893 if (filename && strstr(filename, ".."))
895 return JB_ERR_CGI_PARAMS;
898 full_path = make_path(csp->config->usermanual, filename ? filename : "index.html");
899 if (full_path == NULL)
901 return JB_ERR_MEMORY;
904 /* Open user-manual file */
907 * XXX: Do we support other operating systems that
908 * require special treatment to fopen in binary mode?
910 if (NULL == (fp = fopen(full_path, "rb")))
912 if (NULL == (fp = fopen(full_path, "r")))
913 #endif /* def WIN32 */
915 log_error(LOG_LEVEL_ERROR, "Cannot open user-manual file %s: %E", full_path);
916 err = cgi_error_no_template(csp, rsp, full_path);
921 /* Get file length */
922 fseek(fp, 0, SEEK_END);
923 length = (size_t)ftell(fp);
924 fseek(fp, 0, SEEK_SET);
926 /* Allocate memory and load the file directly into the body */
927 rsp->body = (char *)zalloc(length+1);
932 return JB_ERR_MEMORY;
934 if (!fread(rsp->body, length, 1, fp))
937 * This happens if we didn't fopen in binary mode.
938 * If it does, we just log it and serve what we got.
940 log_error(LOG_LEVEL_ERROR, "Couldn't completely read user-manual file %s.", full_path);
945 rsp->content_length = length;
947 /* Guess correct Content-Type based on the filename's ending */
950 length = strlen(filename);
956 if((length>=4) && !strcmp(&filename[length-4], ".css"))
958 err = enlist(rsp->headers, "Content-Type: text/css");
960 else if((length>=4) && !strcmp(&filename[length-4], ".jpg"))
962 err = enlist(rsp->headers, "Content-Type: image/jpeg");
966 err = enlist(rsp->headers, "Content-Type: text/html");
973 /*********************************************************************
975 * Function : cgi_show_version
977 * Description : CGI function that returns a a web page describing the
978 * file versions of Privoxy.
981 * 1 : csp = Current client state (buffers, headers, etc...)
982 * 2 : rsp = http_response data structure for output
983 * 3 : parameters = map of cgi parameters
985 * CGI Parameters : none
987 * Returns : JB_ERR_OK on success
988 * JB_ERR_MEMORY on out-of-memory error.
990 *********************************************************************/
991 jb_err cgi_show_version(struct client_state *csp,
992 struct http_response *rsp,
993 const struct map *parameters)
1001 if (NULL == (exports = default_exports(csp, "show-version")))
1003 return JB_ERR_MEMORY;
1006 if (map(exports, "sourceversions", 1, show_rcs(), 0))
1009 return JB_ERR_MEMORY;
1012 return template_fill_for_cgi(csp, "show-version", exports, rsp);
1016 /*********************************************************************
1018 * Function : cgi_show_status
1020 * Description : CGI function that returns a web page describing the
1021 * current status of Privoxy.
1024 * 1 : csp = Current client state (buffers, headers, etc...)
1025 * 2 : rsp = http_response data structure for output
1026 * 3 : parameters = map of cgi parameters
1029 * file : Which file to show. Only first letter is checked,
1031 * - "p"ermissions (actions) file
1034 * Default is to show menu and other information.
1036 * Returns : JB_ERR_OK on success
1037 * JB_ERR_MEMORY on out-of-memory error.
1039 *********************************************************************/
1040 jb_err cgi_show_status(struct client_state *csp,
1041 struct http_response *rsp,
1042 const struct map *parameters)
1049 char buf[BUFFER_SIZE];
1050 const char * filename = NULL;
1051 char * file_description = NULL;
1052 #ifdef FEATURE_STATISTICS
1053 float perc_rej; /* Percentage of http requests rejected */
1054 int local_urls_read;
1055 int local_urls_rejected;
1056 #endif /* ndef FEATURE_STATISTICS */
1057 jb_err err = JB_ERR_OK;
1059 struct map *exports;
1065 if (NULL == (exports = default_exports(csp, "show-status")))
1067 return JB_ERR_MEMORY;
1070 switch (*(lookup(parameters, "file")))
1073 if (!get_number_param(csp, parameters, "index", &i) && i < MAX_AF_FILES && csp->actions_list[i])
1075 filename = csp->actions_list[i]->filename;
1076 file_description = "Actions File";
1081 if (!get_number_param(csp, parameters, "index", &i) && i < MAX_AF_FILES && csp->rlist[i])
1083 filename = csp->rlist[i]->filename;
1084 file_description = "Filter File";
1088 #ifdef FEATURE_TRUST
1092 filename = csp->tlist->filename;
1093 file_description = "Trust File";
1096 #endif /* def FEATURE_TRUST */
1099 if (NULL != filename)
1101 if ( map(exports, "file-description", 1, file_description, 1)
1102 || map(exports, "filepath", 1, html_encode(filename), 0) )
1105 return JB_ERR_MEMORY;
1108 if ((fp = fopen(filename, "r")) == NULL)
1110 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
1113 return JB_ERR_MEMORY;
1119 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
1121 string_join (&s, html_encode(buf));
1125 if (map(exports, "contents", 1, s, 0))
1128 return JB_ERR_MEMORY;
1132 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
1136 for (j = 0; (s != NULL) && (j < Argc); j++)
1138 if (!err) err = string_join (&s, html_encode(Argv[j]));
1139 if (!err) err = string_append(&s, " ");
1141 if (!err) err = map(exports, "invocation", 1, s, 0);
1143 if (!err) err = map(exports, "options", 1, csp->config->proxy_args, 1);
1144 if (!err) err = show_defines(exports);
1149 return JB_ERR_MEMORY;
1152 #ifdef FEATURE_STATISTICS
1153 local_urls_read = urls_read;
1154 local_urls_rejected = urls_rejected;
1157 * Need to alter the stats not to include the fetch of this
1160 * Can't do following thread safely! doh!
1163 * urls_rejected--; * This will be incremented subsequently *
1166 if (local_urls_read == 0)
1168 if (!err) err = map_block_killer(exports, "have-stats");
1172 if (!err) err = map_block_killer(exports, "have-no-stats");
1174 perc_rej = (float)local_urls_rejected * 100.0F /
1175 (float)local_urls_read;
1177 snprintf(buf, sizeof(buf), "%d", local_urls_read);
1178 if (!err) err = map(exports, "requests-received", 1, buf, 1);
1180 snprintf(buf, sizeof(buf), "%d", local_urls_rejected);
1181 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
1183 snprintf(buf, sizeof(buf), "%6.2f", perc_rej);
1184 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
1187 #else /* ndef FEATURE_STATISTICS */
1188 err = err || map_block_killer(exports, "statistics");
1189 #endif /* ndef FEATURE_STATISTICS */
1192 * List all action files in use, together with view and edit links,
1193 * except for standard.action, which should only be viewable. (Not
1194 * enforced in the editor itself)
1195 * FIXME: Shouldn't include hardwired HTML here, use line template instead!
1198 for (i = 0; i < MAX_AF_FILES; i++)
1200 if (csp->actions_list[i] != NULL)
1202 if (!err) err = string_append(&s, "<tr><td>");
1203 if (!err) err = string_join(&s, html_encode(csp->actions_list[i]->filename));
1204 snprintf(buf, 100, "</td><td class=\"buttons\"><a href=\"/show-status?file=actions&index=%d\">View</a>", i);
1205 if (!err) err = string_append(&s, buf);
1207 #ifdef FEATURE_CGI_EDIT_ACTIONS
1208 if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
1211 if (access(csp->config->actions_file[i], W_OK) == 0)
1213 #endif /* def HAVE_ACCESS */
1214 snprintf(buf, 100, " <a href=\"/edit-actions-list?f=%s\">Edit</a>",
1215 csp->config->actions_file_short[i]);
1216 if (!err) err = string_append(&s, buf);
1221 if (!err) err = string_append(&s, " <strong>No write access.</strong>");
1223 #endif /* def HAVE_ACCESS */
1227 if (!err) err = string_append(&s, "</td></tr>\n");
1232 if (!err) err = map(exports, "actions-filenames", 1, s, 0);
1236 if (!err) err = map(exports, "actions-filenames", 1, "<tr><td>None specified</td></tr>", 1);
1240 * List all re_filterfiles in use, together with view options.
1241 * FIXME: Shouldn't include hardwired HTML here, use line template instead!
1244 for (i = 0; i < MAX_AF_FILES; i++)
1246 if (csp->rlist[i] != NULL)
1248 if (!err) err = string_append(&s, "<tr><td>");
1249 if (!err) err = string_join(&s, html_encode(csp->rlist[i]->filename));
1251 "</td><td class=\"buttons\"><a href=\"/show-status?file=filter&index=%d\">View</a>", i);
1252 if (!err) err = string_append(&s, buf);
1253 if (!err) err = string_append(&s, "</td></tr>\n");
1258 if (!err) err = map(exports, "re-filter-filenames", 1, s, 0);
1262 if (!err) err = map(exports, "re-filter-filenames", 1, "<tr><td>None specified</td></tr>", 1);
1263 if (!err) err = map_block_killer(exports, "have-filterfile");
1266 #ifdef FEATURE_TRUST
1269 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
1273 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
1274 if (!err) err = map_block_killer(exports, "have-trustfile");
1277 if (!err) err = map_block_killer(exports, "trust-support");
1278 #endif /* ndef FEATURE_TRUST */
1283 return JB_ERR_MEMORY;
1286 return template_fill_for_cgi(csp, "show-status", exports, rsp);
1290 /*********************************************************************
1292 * Function : cgi_show_url_info
1294 * Description : CGI function that determines and shows which actions
1295 * Privoxy will perform for a given url, and which
1296 * matches starting from the defaults have lead to that.
1299 * 1 : csp = Current client state (buffers, headers, etc...)
1300 * 2 : rsp = http_response data structure for output
1301 * 3 : parameters = map of cgi parameters
1304 * url : The url whose actions are to be determined.
1305 * If url is unset, the url-given conditional will be
1306 * set, so that all but the form can be suppressed in
1309 * Returns : JB_ERR_OK on success
1310 * JB_ERR_MEMORY on out-of-memory error.
1312 *********************************************************************/
1313 jb_err cgi_show_url_info(struct client_state *csp,
1314 struct http_response *rsp,
1315 const struct map *parameters)
1318 struct map *exports;
1325 if (NULL == (exports = default_exports(csp, "show-url-info")))
1327 return JB_ERR_MEMORY;
1331 * Get the url= parameter (if present) and remove any leading/trailing spaces.
1333 url_param = strdup(lookup(parameters, "url"));
1334 if (url_param == NULL)
1337 return JB_ERR_MEMORY;
1342 * Handle prefixes. 4 possibilities:
1343 * 1) "http://" or "https://" prefix present and followed by URL - OK
1344 * 2) Only the "http://" or "https://" part is present, no URL - change
1345 * to empty string so it will be detected later as "no URL".
1346 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
1348 * 4) Parameter not specified or is empty string - let this fall through
1349 * for now, next block of code will handle it.
1351 if (0 == strncmp(url_param, "http://", 7))
1353 if (url_param[7] == '\0')
1356 * Empty URL (just prefix).
1357 * Make it totally empty so it's caught by the next if()
1359 url_param[0] = '\0';
1362 else if (0 == strncmp(url_param, "https://", 8))
1364 if (url_param[8] == '\0')
1367 * Empty URL (just prefix).
1368 * Make it totally empty so it's caught by the next if()
1370 url_param[0] = '\0';
1373 else if (url_param[0] != '\0')
1376 * Unknown prefix - assume http://
1378 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
1379 if (NULL == url_param_prefixed)
1383 return JB_ERR_MEMORY;
1385 strcpy(url_param_prefixed, "http://");
1386 strcpy(url_param_prefixed + 7, url_param);
1388 url_param = url_param_prefixed;
1392 * Hide "toggle off" warning if Privoxy is toggled on.
1395 #ifdef FEATURE_TOGGLE
1396 (global_toggle_state == 1) &&
1397 #endif /* def FEATURE_TOGGLE */
1398 map_block_killer(exports, "privoxy-is-toggled-off")
1402 return JB_ERR_MEMORY;
1405 if (url_param[0] == '\0')
1407 /* URL paramater not specified, display query form only. */
1409 if (map_block_killer(exports, "url-given")
1410 || map(exports, "url", 1, "", 1))
1413 return JB_ERR_MEMORY;
1418 /* Given a URL, so query it. */
1423 struct file_list *fl;
1424 struct url_actions *b;
1425 struct http_request url_to_query[1];
1426 struct current_action_spec action[1];
1429 if (map(exports, "url", 1, html_encode(url_param), 0))
1433 return JB_ERR_MEMORY;
1436 init_current_action(action);
1438 if (map(exports, "default", 1, current_action_to_html(csp, action), 0))
1440 free_current_action(action);
1443 return JB_ERR_MEMORY;
1446 err = parse_http_url(url_param, url_to_query, csp);
1450 if (err == JB_ERR_MEMORY)
1452 free_http_request(url_to_query);
1453 free_current_action(action);
1455 return JB_ERR_MEMORY;
1461 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
1462 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
1464 free_current_action(action);
1465 free_http_request(url_to_query);
1470 return JB_ERR_MEMORY;
1473 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1477 * We have a warning about SSL paths. Hide it for insecure sites.
1479 if (!url_to_query->ssl)
1481 if (map_block_killer(exports, "https"))
1483 free_current_action(action);
1485 free_http_request(url_to_query);
1486 return JB_ERR_MEMORY;
1490 matches = strdup("<table class=\"transparent\">");
1492 for (i = 0; i < MAX_AF_FILES; i++)
1494 if (NULL == csp->config->actions_file_short[i]
1495 || !strcmp(csp->config->actions_file_short[i], "standard")) continue;
1499 if ((fl = csp->actions_list[i]) != NULL)
1501 if ((b = fl->f) != NULL)
1503 /* FIXME: Hardcoded HTML! */
1504 string_append(&matches, "<tr><th>In file: ");
1505 string_join (&matches, html_encode(csp->config->actions_file_short[i]));
1506 snprintf(buf, 150, ".action <a class=\"cmd\" href=\"/show-status?file=actions&index=%d\">", i);
1507 string_append(&matches, buf);
1508 string_append(&matches, "View</a>");
1509 #ifdef FEATURE_CGI_EDIT_ACTIONS
1510 string_append(&matches, " <a class=\"cmd\" href=\"/edit-actions-list?f=");
1511 string_join (&matches, html_encode(csp->config->actions_file_short[i]));
1512 string_append(&matches, "\">Edit</a>");
1514 string_append(&matches, "</th></tr>\n");
1521 for (; (b != NULL) && (matches != NULL); b = b->next)
1523 if (url_match(b->url, url_to_query))
1525 string_append(&matches, "<tr><td>{");
1526 string_join (&matches, actions_to_html(csp, b->action));
1527 string_append(&matches, " }</b><br>\n<code>");
1528 string_join (&matches, html_encode(b->url->spec));
1529 string_append(&matches, "</code></td></tr>\n");
1531 if (merge_current_action(action, b->action))
1534 free_http_request(url_to_query);
1535 free_current_action(action);
1537 return JB_ERR_MEMORY;
1545 string_append(&matches, "<tr><td>(no matches in this file)</td></tr>\n");
1548 string_append(&matches, "</table>\n");
1550 free_http_request(url_to_query);
1552 if (matches == NULL)
1554 free_current_action(action);
1556 return JB_ERR_MEMORY;
1559 if (map(exports, "matches", 1, matches , 0))
1561 free_current_action(action);
1563 return JB_ERR_MEMORY;
1566 s = current_action_to_html(csp, action);
1568 free_current_action(action);
1570 if (map(exports, "final", 1, s, 0))
1573 return JB_ERR_MEMORY;
1577 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1581 /*********************************************************************
1583 * Function : cgi_robots_txt
1585 * Description : CGI function to return "/robots.txt".
1588 * 1 : csp = Current client state (buffers, headers, etc...)
1589 * 2 : rsp = http_response data structure for output
1590 * 3 : parameters = map of cgi parameters
1592 * CGI Parameters : None
1594 * Returns : JB_ERR_OK on success
1595 * JB_ERR_MEMORY on out-of-memory error.
1597 *********************************************************************/
1598 jb_err cgi_robots_txt(struct client_state *csp,
1599 struct http_response *rsp,
1600 const struct map *parameters)
1606 "# This is the Privoxy control interface.\n"
1607 "# It isn't very useful to index it, and you're likely to break stuff.\n"
1613 if (rsp->body == NULL)
1615 return JB_ERR_MEMORY;
1618 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1622 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1623 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1625 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1629 /*********************************************************************
1631 * Function : show_defines
1633 * Description : Add to a map the state od all conditional #defines
1634 * used when building
1637 * 1 : exports = map to extend
1639 * Returns : JB_ERR_OK on success
1640 * JB_ERR_MEMORY on out-of-memory error.
1642 *********************************************************************/
1643 static jb_err show_defines(struct map *exports)
1645 jb_err err = JB_ERR_OK;
1648 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1649 #else /* ifndef FEATURE_ACL */
1650 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1651 #endif /* ndef FEATURE_ACL */
1653 #ifdef FEATURE_CGI_EDIT_ACTIONS
1654 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1655 #else /* ifndef FEATURE_COOKIE_JAR */
1656 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1657 #endif /* ndef FEATURE_COOKIE_JAR */
1659 #ifdef FEATURE_COOKIE_JAR
1660 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1661 #else /* ifndef FEATURE_COOKIE_JAR */
1662 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1663 #endif /* ndef FEATURE_COOKIE_JAR */
1665 #ifdef FEATURE_FAST_REDIRECTS
1666 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1667 #else /* ifndef FEATURE_FAST_REDIRECTS */
1668 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1669 #endif /* ndef FEATURE_FAST_REDIRECTS */
1671 #ifdef FEATURE_FORCE_LOAD
1672 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1673 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1674 #else /* ifndef FEATURE_FORCE_LOAD */
1675 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1676 if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
1677 #endif /* ndef FEATURE_FORCE_LOAD */
1679 #ifdef FEATURE_GRACEFUL_TERMINATION
1680 if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 1);
1681 #else /* ifndef FEATURE_GRACEFUL_TERMINATION */
1682 if (!err) err = map_conditional(exports, "FEATURE_GRACEFUL_TERMINATION", 0);
1683 #endif /* ndef FEATURE_GRACEFUL_TERMINATION */
1685 #ifdef FEATURE_IMAGE_BLOCKING
1686 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1687 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1688 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1689 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1691 #ifdef FEATURE_IMAGE_DETECT_MSIE
1692 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1693 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1694 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1695 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1697 #ifdef FEATURE_KILL_POPUPS
1698 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1699 #else /* ifndef FEATURE_KILL_POPUPS */
1700 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1701 #endif /* ndef FEATURE_KILL_POPUPS */
1703 #ifdef FEATURE_NO_GIFS
1704 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1705 #else /* ifndef FEATURE_NO_GIFS */
1706 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1707 #endif /* ndef FEATURE_NO_GIFS */
1709 #ifdef FEATURE_PTHREAD
1710 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1711 #else /* ifndef FEATURE_PTHREAD */
1712 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1713 #endif /* ndef FEATURE_PTHREAD */
1715 #ifdef FEATURE_STATISTICS
1716 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1717 #else /* ifndef FEATURE_STATISTICS */
1718 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1719 #endif /* ndef FEATURE_STATISTICS */
1721 #ifdef FEATURE_TOGGLE
1722 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1723 #else /* ifndef FEATURE_TOGGLE */
1724 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1725 #endif /* ndef FEATURE_TOGGLE */
1727 #ifdef FEATURE_TRUST
1728 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1729 #else /* ifndef FEATURE_TRUST */
1730 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1731 #endif /* ndef FEATURE_TRUST */
1734 if (!err) err = map_conditional(exports, "FEATURE_ZLIB", 1);
1735 #else /* ifndef FEATURE_ZLIB */
1736 if (!err) err = map_conditional(exports, "FEATURE_ZLIB", 0);
1737 #endif /* ndef FEATURE_ZLIB */
1740 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1741 #else /* ifndef STATIC_PCRE */
1742 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1743 #endif /* ndef STATIC_PCRE */
1746 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1747 #else /* ifndef STATIC_PCRS */
1748 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1749 #endif /* ndef STATIC_PCRS */
1755 /*********************************************************************
1757 * Function : show_rcs
1759 * Description : Create a string with the rcs info for all sourcefiles
1763 * Returns : A string, or NULL on out-of-memory.
1765 *********************************************************************/
1766 static char *show_rcs(void)
1768 char *result = strdup("");
1769 char buf[BUFFER_SIZE];
1771 /* Instead of including *all* dot h's in the project (thus creating a
1772 * tremendous amount of dependencies), I will concede to declaring them
1773 * as extern's. This forces the developer to add to this list, but oh well.
1776 #define SHOW_RCS(__x) \
1778 extern const char __x[]; \
1779 snprintf(buf, sizeof(buf), " %s\n", __x); \
1780 string_append(&result, buf); \
1783 /* In alphabetical order */
1784 SHOW_RCS(actions_h_rcs)
1785 SHOW_RCS(actions_rcs)
1787 SHOW_RCS(amiga_h_rcs)
1789 #endif /* def AMIGA */
1792 #ifdef FEATURE_CGI_EDIT_ACTIONS
1793 SHOW_RCS(cgiedit_h_rcs)
1794 SHOW_RCS(cgiedit_rcs)
1795 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1796 SHOW_RCS(cgisimple_h_rcs)
1797 SHOW_RCS(cgisimple_rcs)
1799 SHOW_RCS(cygwin_h_rcs)
1801 SHOW_RCS(deanimate_h_rcs)
1802 SHOW_RCS(deanimate_rcs)
1803 SHOW_RCS(encode_h_rcs)
1804 SHOW_RCS(encode_rcs)
1805 SHOW_RCS(errlog_h_rcs)
1806 SHOW_RCS(errlog_rcs)
1807 SHOW_RCS(filters_h_rcs)
1808 SHOW_RCS(filters_rcs)
1809 SHOW_RCS(gateway_h_rcs)
1810 SHOW_RCS(gateway_rcs)
1811 SHOW_RCS(jbsockets_h_rcs)
1812 SHOW_RCS(jbsockets_rcs)
1815 #ifdef FEATURE_KILL_POPUPS
1816 SHOW_RCS(killpopup_h_rcs)
1817 SHOW_RCS(killpopup_rcs)
1818 #endif /* def FEATURE_KILL_POPUPS */
1819 SHOW_RCS(list_h_rcs)
1821 SHOW_RCS(loadcfg_h_rcs)
1822 SHOW_RCS(loadcfg_rcs)
1823 SHOW_RCS(loaders_h_rcs)
1824 SHOW_RCS(loaders_rcs)
1825 SHOW_RCS(miscutil_h_rcs)
1826 SHOW_RCS(miscutil_rcs)
1827 SHOW_RCS(parsers_h_rcs)
1828 SHOW_RCS(parsers_rcs)
1830 SHOW_RCS(pcrs_h_rcs)
1831 SHOW_RCS(project_h_rcs)
1832 SHOW_RCS(ssplit_h_rcs)
1833 SHOW_RCS(ssplit_rcs)
1834 SHOW_RCS(urlmatch_h_rcs)
1835 SHOW_RCS(urlmatch_rcs)
1837 #ifndef _WIN_CONSOLE
1838 SHOW_RCS(w32log_h_rcs)
1839 SHOW_RCS(w32log_rcs)
1840 SHOW_RCS(w32res_h_rcs)
1841 SHOW_RCS(w32taskbar_h_rcs)
1842 SHOW_RCS(w32taskbar_rcs)
1843 #endif /* ndef _WIN_CONSOLE */
1844 SHOW_RCS(win32_h_rcs)
1846 #endif /* def _WIN32 */