1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.17 2002/03/08 16:43:18 oes Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
6 * Purpose : Simple CGIs to get information about JunkBuster's
9 * Functions declared include:
12 * Copyright : Written by and Copyright (C) 2001 the SourceForge
13 * IJBSWA team. http://ijbswa.sourceforge.net
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.17 2002/03/08 16:43:18 oes
40 * Added choice beween GIF and PNG built-in images
42 * Revision 1.16 2002/03/07 03:48:38 oes
43 * - Changed built-in images from GIF to PNG
44 * (with regard to Unisys patent issue)
45 * - Added a 4x4 pattern PNG which is less intrusive
46 * than the logo but also clearly marks the deleted banners
48 * Revision 1.15 2002/03/06 22:54:35 jongfoster
49 * Automated function-comment nitpicking.
51 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
52 * Clean up a little CRLF unpleasantness that suddenly appeared
54 * Revision 1.13 2002/02/21 00:10:37 jongfoster
55 * Adding send-banner?type=auto option
57 * Revision 1.12 2002/01/23 01:03:32 jongfoster
58 * Fixing gcc [CygWin] compiler warnings
60 * Revision 1.11 2002/01/23 00:01:04 jongfoster
61 * Adding cgi_transparent_gif() for http://i.j.b/t
62 * Adding missing html_encode() to many CGI functions.
63 * Adding urlmatch.[ch] to http://i.j.b/show-version
65 * Revision 1.10 2002/01/17 21:10:37 jongfoster
66 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
67 * Also fixing a problem in the same function with improperly quoted URLs
68 * in output HTML, and adding code to handle https:// URLs correctly.
70 * Revision 1.9 2001/11/30 23:09:15 jongfoster
71 * Now reports on FEATURE_CGI_EDIT_ACTIONS
72 * Removing FEATURE_DENY_GZIP from template
74 * Revision 1.8 2001/11/13 00:14:07 jongfoster
75 * Fixing stupid bug now I've figured out what || means.
76 * (It always returns 0 or 1, not one of it's paramaters.)
78 * Revision 1.7 2001/10/23 21:48:19 jongfoster
79 * Cleaning up error handling in CGI functions - they now send back
80 * a HTML error page and should never cause a FATAL error. (Fixes one
81 * potential source of "denial of service" attacks).
83 * CGI actions file editor that works and is actually useful.
85 * Ability to toggle JunkBuster remotely using a CGI call.
87 * You can turn off both the above features in the main configuration
88 * file, e.g. if you are running a multi-user proxy.
90 * Revision 1.6 2001/10/14 22:00:32 jongfoster
91 * Adding support for a 404 error when an invalid CGI page is requested.
93 * Revision 1.5 2001/10/07 15:30:41 oes
94 * Removed FEATURE_DENY_GZIP
96 * Revision 1.4 2001/10/02 15:31:12 oes
97 * Introduced show-request cgi
99 * Revision 1.3 2001/09/22 16:34:44 jongfoster
100 * Removing unneeded #includes
102 * Revision 1.2 2001/09/19 18:01:11 oes
103 * Fixed comments; cosmetics
105 * Revision 1.1 2001/09/16 17:08:54 jongfoster
106 * Moving simple CGI functions from cgi.c to new file cgisimple.c
109 **********************************************************************/
115 #include <sys/types.h>
122 #define snprintf _snprintf
123 #endif /* def _WIN32 */
127 #include "cgisimple.h"
133 #include "miscutil.h"
136 #include "urlmatch.h"
138 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
141 static char *show_rcs(void);
142 static jb_err show_defines(struct map *exports);
145 /*********************************************************************
147 * Function : cgi_default
149 * Description : CGI function that is called if no action was given.
150 * Lists menu of available unhidden CGIs.
153 * 1 : csp = Current client state (buffers, headers, etc...)
154 * 2 : rsp = http_response data structure for output
155 * 3 : parameters = map of cgi parameters
157 * CGI Parameters : none
159 * Returns : JB_ERR_OK on success
160 * JB_ERR_MEMORY on out-of-memory
161 * (Problems other than out-of-memory should be
162 * handled by this routine - it should set the
163 * rsp appropriately and return "success")
165 *********************************************************************/
166 jb_err cgi_default(struct client_state *csp,
167 struct http_response *rsp,
168 const struct map *parameters)
177 if (NULL == (exports = default_exports(csp, "")))
179 return JB_ERR_MEMORY;
182 /* If there were other parameters, export a dump as "cgi-parameters" */
183 if (parameters->first)
185 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
186 "Anyway, here they are, in case you're interested:</p>\n");
187 string_join(&tmp, dump_map(parameters));
191 return JB_ERR_MEMORY;
193 if (map(exports, "cgi-parameters", 1, tmp, 0))
195 return JB_ERR_MEMORY;
200 if (map(exports, "cgi-parameters", 1, "", 1))
202 return JB_ERR_MEMORY;
206 return template_fill_for_cgi(csp, "default", exports, rsp);
212 /*********************************************************************
214 * Function : cgi_error_404
216 * Description : CGI function that is called if an unknown action was
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
224 * CGI Parameters : none
226 * Returns : JB_ERR_OK on success
227 * JB_ERR_MEMORY on out-of-memory error.
229 *********************************************************************/
230 jb_err cgi_error_404(struct client_state *csp,
231 struct http_response *rsp,
232 const struct map *parameters)
240 if (NULL == (exports = default_exports(csp, NULL)))
242 return JB_ERR_MEMORY;
245 rsp->status = strdup("404 JunkBuster configuration page not found");
246 if (rsp->status == NULL)
249 return JB_ERR_MEMORY;
252 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
256 /*********************************************************************
258 * Function : cgi_show_request
260 * Description : Show the client's request and what sed() would have
264 * 1 : csp = Current client state (buffers, headers, etc...)
265 * 2 : rsp = http_response data structure for output
266 * 3 : parameters = map of cgi parameters
268 * CGI Parameters : none
270 * Returns : JB_ERR_OK on success
271 * JB_ERR_MEMORY on out-of-memory error.
273 *********************************************************************/
274 jb_err cgi_show_request(struct client_state *csp,
275 struct http_response *rsp,
276 const struct map *parameters)
285 if (NULL == (exports = default_exports(csp, "show-request")))
287 return JB_ERR_MEMORY;
291 * Repair the damage done to the IOB by get_header()
293 for (p = csp->iob->buf; p < csp->iob->eod; p++)
295 if (*p == '\0') *p = '\n';
299 * Export the original client's request and the one we would
300 * be sending to the server if this wasn't a CGI call
303 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
306 return JB_ERR_MEMORY;
309 if (map(exports, "processed-request", 1, html_encode_and_free_original(
310 sed(client_patterns, add_client_headers, csp)), 0))
313 return JB_ERR_MEMORY;
316 return template_fill_for_cgi(csp, "show-request", exports, rsp);
320 /*********************************************************************
322 * Function : cgi_send_banner
324 * Description : CGI function that returns a banner.
327 * 1 : csp = Current client state (buffers, headers, etc...)
328 * 2 : rsp = http_response data structure for output
329 * 3 : parameters = map of cgi parameters
332 * type : Selects the type of banner between "trans", "logo",
333 * and "auto". Defaults to "logo" if absent or invalid.
334 * "auto" means to select as if we were image-blocking.
335 * (Only the first character really counts).
337 * Returns : JB_ERR_OK on success
338 * JB_ERR_MEMORY on out-of-memory error.
340 *********************************************************************/
341 jb_err cgi_send_banner(struct client_state *csp,
342 struct http_response *rsp,
343 const struct map *parameters)
345 char imagetype = lookup(parameters, "type")[0];
347 if (imagetype == 'a') /* auto */
349 /* Default to logo */
351 #ifdef FEATURE_IMAGE_BLOCKING
352 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
354 /* determine HOW images should be blocked */
355 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
357 /* and handle accordingly: */
358 if ((p != NULL) && (0 == strcmpic(p, "blank")))
362 else if ((p != NULL) && (0 == strcmpic(p, "pattern")))
367 #endif /* def FEATURE_IMAGE_BLOCKING */
370 if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
372 rsp->body = bindup(image_blank_data, image_blank_length);
373 rsp->content_length = image_blank_length;
376 else if (imagetype == 'l') /* logo */
378 rsp->body = bindup(image_logo_data, image_logo_length);
379 rsp->content_length = image_logo_length;
383 rsp->body = bindup(image_pattern_data, image_pattern_length);
384 rsp->content_length = image_pattern_length;
387 if (rsp->body == NULL)
389 return JB_ERR_MEMORY;
392 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
394 return JB_ERR_MEMORY;
404 /*********************************************************************
406 * Function : cgi_transparent_image
408 * Description : CGI function that sends a 1x1 transparent image.
411 * 1 : csp = Current client state (buffers, headers, etc...)
412 * 2 : rsp = http_response data structure for output
413 * 3 : parameters = map of cgi parameters
415 * CGI Parameters : None
417 * Returns : JB_ERR_OK on success
418 * JB_ERR_MEMORY on out-of-memory error.
420 *********************************************************************/
421 jb_err cgi_transparent_image(struct client_state *csp,
422 struct http_response *rsp,
423 const struct map *parameters)
425 rsp->body = bindup(image_blank_data, image_blank_length);
426 rsp->content_length = image_blank_length;
428 if (rsp->body == NULL)
430 return JB_ERR_MEMORY;
433 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
435 return JB_ERR_MEMORY;
445 /*********************************************************************
447 * Function : cgi_show_version
449 * Description : CGI function that returns a a web page describing the
450 * file versions of IJB.
453 * 1 : csp = Current client state (buffers, headers, etc...)
454 * 2 : rsp = http_response data structure for output
455 * 3 : parameters = map of cgi parameters
457 * CGI Parameters : none
459 * Returns : JB_ERR_OK on success
460 * JB_ERR_MEMORY on out-of-memory error.
462 *********************************************************************/
463 jb_err cgi_show_version(struct client_state *csp,
464 struct http_response *rsp,
465 const struct map *parameters)
473 if (NULL == (exports = default_exports(csp, "show-version")))
475 return JB_ERR_MEMORY;
478 if (map(exports, "sourceversions", 1, show_rcs(), 0))
481 return JB_ERR_MEMORY;
484 return template_fill_for_cgi(csp, "show-version", exports, rsp);
488 /*********************************************************************
490 * Function : cgi_show_status
492 * Description : CGI function that returns a a web page describing the
493 * current status of IJB.
496 * 1 : csp = Current client state (buffers, headers, etc...)
497 * 2 : rsp = http_response data structure for output
498 * 3 : parameters = map of cgi parameters
501 * file : Which file to show. Only first letter is checked,
503 * - "p"ermissions (actions) file
506 * Default is to show menu and other information.
508 * Returns : JB_ERR_OK on success
509 * JB_ERR_MEMORY on out-of-memory error.
511 *********************************************************************/
512 jb_err cgi_show_status(struct client_state *csp,
513 struct http_response *rsp,
514 const struct map *parameters)
520 char buf[BUFFER_SIZE];
521 const char * filename = NULL;
522 char * file_description = NULL;
523 #ifdef FEATURE_STATISTICS
524 float perc_rej; /* Percentage of http requests rejected */
526 int local_urls_rejected;
527 #endif /* ndef FEATURE_STATISTICS */
536 if (NULL == (exports = default_exports(csp, "show-status")))
538 return JB_ERR_MEMORY;
541 switch (*(lookup(parameters, "file")))
544 if (csp->actions_list)
546 filename = csp->actions_list->filename;
547 file_description = "Actions List";
554 filename = csp->rlist->filename;
555 file_description = "Regex Filter List";
563 filename = csp->tlist->filename;
564 file_description = "Trust List";
567 #endif /* def FEATURE_TRUST */
570 if (NULL != filename)
572 if ( map(exports, "file-description", 1, file_description, 1)
573 || map(exports, "filepath", 1, html_encode(filename), 0) )
576 return JB_ERR_MEMORY;
579 if ((fp = fopen(filename, "r")) == NULL)
581 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
584 return JB_ERR_MEMORY;
590 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
592 string_join (&s, html_encode(buf));
593 string_append(&s, "<br>");
597 if (map(exports, "contents", 1, s, 0))
600 return JB_ERR_MEMORY;
604 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
607 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
610 return JB_ERR_MEMORY;
614 for (i = 0; (s != NULL) && (i < Argc); i++)
616 string_join (&s, html_encode(Argv[i]));
617 string_append(&s, " ");
619 if (map(exports, "invocation", 1, s, 0))
622 return JB_ERR_MEMORY;
625 err = map(exports, "options", 1, csp->config->proxy_args, 1);
626 if (!err) err = show_defines(exports);
628 #ifdef FEATURE_STATISTICS
629 local_urls_read = urls_read;
630 local_urls_rejected = urls_rejected;
633 * Need to alter the stats not to include the fetch of this
636 * Can't do following thread safely! doh!
639 * urls_rejected--; * This will be incremented subsequently *
642 if (local_urls_read == 0)
644 if (!err) err = map_block_killer(exports, "have-stats");
648 if (!err) err = map_block_killer(exports, "have-no-stats");
650 perc_rej = (float)local_urls_rejected * 100.0F /
651 (float)local_urls_read;
653 sprintf(buf, "%d", local_urls_read);
654 if (!err) err = map(exports, "requests-received", 1, buf, 1);
656 sprintf(buf, "%d", local_urls_rejected);
657 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
659 sprintf(buf, "%6.2f", perc_rej);
660 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
663 #else /* ndef FEATURE_STATISTICS */
664 err = err || map_block_killer(exports, "statistics");
665 #endif /* ndef FEATURE_STATISTICS */
667 if (csp->actions_list)
669 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
673 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
678 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
682 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
688 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
692 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
695 if (!err) err = map_block_killer(exports, "trust-support");
696 #endif /* ndef FEATURE_TRUST */
701 return JB_ERR_MEMORY;
704 return template_fill_for_cgi(csp, "show-status", exports, rsp);
708 /*********************************************************************
710 * Function : cgi_show_url_info
712 * Description : CGI function that determines and shows which actions
713 * junkbuster will perform for a given url, and which
714 * matches starting from the defaults have lead to that.
717 * 1 : csp = Current client state (buffers, headers, etc...)
718 * 2 : rsp = http_response data structure for output
719 * 3 : parameters = map of cgi parameters
722 * url : The url whose actions are to be determined.
723 * If url is unset, the url-given conditional will be
724 * set, so that all but the form can be suppressed in
727 * Returns : JB_ERR_OK on success
728 * JB_ERR_MEMORY on out-of-memory error.
730 *********************************************************************/
731 jb_err cgi_show_url_info(struct client_state *csp,
732 struct http_response *rsp,
733 const struct map *parameters)
742 if (NULL == (exports = default_exports(csp, "show-url-info")))
744 return JB_ERR_MEMORY;
748 * Get the url= parameter (if present) and remove any leading/trailing spaces.
750 url_param = strdup(lookup(parameters, "url"));
751 if (url_param == NULL)
754 return JB_ERR_MEMORY;
759 * Handle prefixes. 4 possibilities:
760 * 1) "http://" or "https://" prefix present and followed by URL - OK
761 * 2) Only the "http://" or "https://" part is present, no URL - change
762 * to empty string so it will be detected later as "no URL".
763 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
765 * 4) Parameter not specified or is empty string - let this fall through
766 * for now, next block of code will handle it.
768 if (0 == strncmp(url_param, "http://", 7))
770 if (url_param[7] == '\0')
773 * Empty URL (just prefix).
774 * Make it totally empty so it's caught by the next if()
779 else if (0 == strncmp(url_param, "https://", 8))
781 if (url_param[8] == '\0')
784 * Empty URL (just prefix).
785 * Make it totally empty so it's caught by the next if()
790 else if (url_param[0] != '\0')
793 * Unknown prefix - assume http://
795 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
796 if (NULL == url_param_prefixed)
800 return JB_ERR_MEMORY;
802 strcpy(url_param_prefixed, "http://");
803 strcpy(url_param_prefixed + 7, url_param);
805 url_param = url_param_prefixed;
809 if (url_param[0] == '\0')
811 /* URL paramater not specified, display query form only. */
813 if (map_block_killer(exports, "url-given")
814 || map(exports, "url", 1, "", 1))
817 return JB_ERR_MEMORY;
822 /* Given a URL, so query it. */
827 struct file_list *fl;
828 struct url_actions *b;
829 struct http_request url_to_query[1];
830 struct current_action_spec action[1];
832 if (map(exports, "url", 1, html_encode(url_param), 0))
836 return JB_ERR_MEMORY;
839 init_current_action(action);
841 if (map(exports, "default", 1, html_encode_and_free_original(
842 current_action_to_text(action)), 0))
844 free_current_action(action);
847 return JB_ERR_MEMORY;
850 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
852 err = map(exports, "matches", 1, "none" , 1);
853 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
855 free_current_action(action);
861 return JB_ERR_MEMORY;
864 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
867 err = parse_http_url(url_param, url_to_query, csp);
871 if (err == JB_ERR_MEMORY)
873 free_current_action(action);
875 return JB_ERR_MEMORY;
881 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
882 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
884 free_current_action(action);
889 return JB_ERR_MEMORY;
892 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
896 * We have a warning about SSL paths. Hide it for insecure sites.
898 if (!url_to_query->ssl)
900 if (map_block_killer(exports, "https"))
902 free_current_action(action);
904 return JB_ERR_MEMORY;
908 matches = strdup("");
910 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
912 if (url_match(b->url, url_to_query))
914 string_append(&matches, "<b>{");
915 string_join (&matches, html_encode_and_free_original(
916 actions_to_text(b->action)));
917 string_append(&matches, " }</b><br>\n<code>");
918 string_join (&matches, html_encode(b->url->spec));
919 string_append(&matches, "</code><br>\n<br>\n");
921 if (merge_current_action(action, b->action))
924 free_http_request(url_to_query);
925 free_current_action(action);
927 return JB_ERR_MEMORY;
933 free_http_request(url_to_query);
937 free_current_action(action);
939 return JB_ERR_MEMORY;
945 matches = strdup("none");
947 if (map(exports, "matches", 1, matches , 0))
949 free_current_action(action);
951 return JB_ERR_MEMORY;
954 s = html_encode_and_free_original(current_action_to_text(action));
956 free_current_action(action);
958 if (map(exports, "final", 1, s, 0))
961 return JB_ERR_MEMORY;
965 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
969 /*********************************************************************
971 * Function : cgi_robots_txt
973 * Description : CGI function to return "/robots.txt".
976 * 1 : csp = Current client state (buffers, headers, etc...)
977 * 2 : rsp = http_response data structure for output
978 * 3 : parameters = map of cgi parameters
980 * CGI Parameters : None
982 * Returns : JB_ERR_OK on success
983 * JB_ERR_MEMORY on out-of-memory error.
985 *********************************************************************/
986 jb_err cgi_robots_txt(struct client_state *csp,
987 struct http_response *rsp,
988 const struct map *parameters)
994 "# This is the Internet Junkbuster control interface.\n"
995 "# It isn't very useful to index it, and you're likely to break stuff.\n"
1001 if (rsp->body == NULL)
1003 return JB_ERR_MEMORY;
1006 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1010 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1011 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1013 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1017 /*********************************************************************
1019 * Function : show_defines
1021 * Description : Add to a map the state od all conditional #defines
1022 * used when building
1025 * 1 : exports = map to extend
1027 * Returns : JB_ERR_OK on success
1028 * JB_ERR_MEMORY on out-of-memory error.
1030 *********************************************************************/
1031 static jb_err show_defines(struct map *exports)
1033 jb_err err = JB_ERR_OK;
1036 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1037 #else /* ifndef FEATURE_ACL */
1038 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1039 #endif /* ndef FEATURE_ACL */
1041 #ifdef FEATURE_CGI_EDIT_ACTIONS
1042 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1043 #else /* ifndef FEATURE_COOKIE_JAR */
1044 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1045 #endif /* ndef FEATURE_COOKIE_JAR */
1047 #ifdef FEATURE_COOKIE_JAR
1048 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1049 #else /* ifndef FEATURE_COOKIE_JAR */
1050 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1051 #endif /* ndef FEATURE_COOKIE_JAR */
1053 #ifdef FEATURE_FAST_REDIRECTS
1054 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1055 #else /* ifndef FEATURE_FAST_REDIRECTS */
1056 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1057 #endif /* ndef FEATURE_FAST_REDIRECTS */
1059 #ifdef FEATURE_FORCE_LOAD
1060 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1061 #else /* ifndef FEATURE_FORCE_LOAD */
1062 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1063 #endif /* ndef FEATURE_FORCE_LOAD */
1065 #ifdef FEATURE_IMAGE_BLOCKING
1066 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1067 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1068 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1069 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1071 #ifdef FEATURE_IMAGE_DETECT_MSIE
1072 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1073 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1074 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1075 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1077 #ifdef FEATURE_KILL_POPUPS
1078 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1079 #else /* ifndef FEATURE_KILL_POPUPS */
1080 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1081 #endif /* ndef FEATURE_KILL_POPUPS */
1083 #ifdef FEATURE_NO_GIFS
1084 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1085 #else /* ifndef FEATURE_NO_GIFS */
1086 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1087 #endif /* ndef FEATURE_NO_GIFS */
1089 #ifdef FEATURE_PTHREAD
1090 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1091 #else /* ifndef FEATURE_PTHREAD */
1092 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1093 #endif /* ndef FEATURE_PTHREAD */
1095 #ifdef FEATURE_STATISTICS
1096 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1097 #else /* ifndef FEATURE_STATISTICS */
1098 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1099 #endif /* ndef FEATURE_STATISTICS */
1101 #ifdef FEATURE_TOGGLE
1102 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1103 #else /* ifndef FEATURE_TOGGLE */
1104 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1105 #endif /* ndef FEATURE_TOGGLE */
1107 #ifdef FEATURE_TRUST
1108 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1109 #else /* ifndef FEATURE_TRUST */
1110 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1111 #endif /* ndef FEATURE_TRUST */
1114 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1115 #else /* ifndef REGEX_GNU */
1116 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1117 #endif /* def REGEX_GNU */
1120 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1121 #else /* ifndef REGEX_PCRE */
1122 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1123 #endif /* def REGEX_PCRE */
1126 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1127 #else /* ifndef STATIC_PCRE */
1128 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1129 #endif /* ndef STATIC_PCRE */
1132 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1133 #else /* ifndef STATIC_PCRS */
1134 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1135 #endif /* ndef STATIC_PCRS */
1137 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1143 /*********************************************************************
1145 * Function : show_rcs
1147 * Description : Create a string with the rcs info for all sourcefiles
1151 * Returns : A string, or NULL on out-of-memory.
1153 *********************************************************************/
1154 static char *show_rcs(void)
1156 char *result = strdup("");
1157 char buf[BUFFER_SIZE];
1159 /* Instead of including *all* dot h's in the project (thus creating a
1160 * tremendous amount of dependencies), I will concede to declaring them
1161 * as extern's. This forces the developer to add to this list, but oh well.
1164 #define SHOW_RCS(__x) \
1166 extern const char __x[]; \
1167 sprintf(buf, "%s\n", __x); \
1168 string_append(&result, buf); \
1171 /* In alphabetical order */
1172 SHOW_RCS(actions_h_rcs)
1173 SHOW_RCS(actions_rcs)
1176 #ifdef FEATURE_CGI_EDIT_ACTIONS
1177 SHOW_RCS(cgiedit_h_rcs)
1178 SHOW_RCS(cgiedit_rcs)
1179 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1180 SHOW_RCS(cgisimple_h_rcs)
1181 SHOW_RCS(cgisimple_rcs)
1183 SHOW_RCS(cygwin_h_rcs)
1185 SHOW_RCS(deanimate_h_rcs)
1186 SHOW_RCS(deanimate_rcs)
1187 SHOW_RCS(encode_h_rcs)
1188 SHOW_RCS(encode_rcs)
1189 SHOW_RCS(errlog_h_rcs)
1190 SHOW_RCS(errlog_rcs)
1191 SHOW_RCS(filters_h_rcs)
1192 SHOW_RCS(filters_rcs)
1193 SHOW_RCS(gateway_h_rcs)
1194 SHOW_RCS(gateway_rcs)
1196 SHOW_RCS(gnu_regex_h_rcs)
1197 SHOW_RCS(gnu_regex_rcs)
1198 #endif /* def GNU_REGEX */
1199 SHOW_RCS(jbsockets_h_rcs)
1200 SHOW_RCS(jbsockets_rcs)
1203 #ifdef FEATURE_KILL_POPUPS
1204 SHOW_RCS(killpopup_h_rcs)
1205 SHOW_RCS(killpopup_rcs)
1206 #endif /* def FEATURE_KILL_POPUPS */
1207 SHOW_RCS(list_h_rcs)
1209 SHOW_RCS(loadcfg_h_rcs)
1210 SHOW_RCS(loadcfg_rcs)
1211 SHOW_RCS(loaders_h_rcs)
1212 SHOW_RCS(loaders_rcs)
1213 SHOW_RCS(miscutil_h_rcs)
1214 SHOW_RCS(miscutil_rcs)
1215 SHOW_RCS(parsers_h_rcs)
1216 SHOW_RCS(parsers_rcs)
1218 SHOW_RCS(pcrs_h_rcs)
1219 SHOW_RCS(project_h_rcs)
1220 SHOW_RCS(ssplit_h_rcs)
1221 SHOW_RCS(ssplit_rcs)
1222 SHOW_RCS(urlmatch_h_rcs)
1223 SHOW_RCS(urlmatch_rcs)
1225 #ifndef _WIN_CONSOLE
1226 SHOW_RCS(w32log_h_rcs)
1227 SHOW_RCS(w32log_rcs)
1228 SHOW_RCS(w32res_h_rcs)
1229 SHOW_RCS(w32taskbar_h_rcs)
1230 SHOW_RCS(w32taskbar_rcs)
1231 #endif /* ndef _WIN_CONSOLE */
1232 SHOW_RCS(win32_h_rcs)
1234 #endif /* def _WIN32 */