1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.16 2002/03/07 03:48:38 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.16 2002/03/07 03:48:38 oes
40 * - Changed built-in images from GIF to PNG
41 * (with regard to Unisys patent issue)
42 * - Added a 4x4 pattern PNG which is less intrusive
43 * than the logo but also clearly marks the deleted banners
45 * Revision 1.15 2002/03/06 22:54:35 jongfoster
46 * Automated function-comment nitpicking.
48 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
49 * Clean up a little CRLF unpleasantness that suddenly appeared
51 * Revision 1.13 2002/02/21 00:10:37 jongfoster
52 * Adding send-banner?type=auto option
54 * Revision 1.12 2002/01/23 01:03:32 jongfoster
55 * Fixing gcc [CygWin] compiler warnings
57 * Revision 1.11 2002/01/23 00:01:04 jongfoster
58 * Adding cgi_transparent_gif() for http://i.j.b/t
59 * Adding missing html_encode() to many CGI functions.
60 * Adding urlmatch.[ch] to http://i.j.b/show-version
62 * Revision 1.10 2002/01/17 21:10:37 jongfoster
63 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
64 * Also fixing a problem in the same function with improperly quoted URLs
65 * in output HTML, and adding code to handle https:// URLs correctly.
67 * Revision 1.9 2001/11/30 23:09:15 jongfoster
68 * Now reports on FEATURE_CGI_EDIT_ACTIONS
69 * Removing FEATURE_DENY_GZIP from template
71 * Revision 1.8 2001/11/13 00:14:07 jongfoster
72 * Fixing stupid bug now I've figured out what || means.
73 * (It always returns 0 or 1, not one of it's paramaters.)
75 * Revision 1.7 2001/10/23 21:48:19 jongfoster
76 * Cleaning up error handling in CGI functions - they now send back
77 * a HTML error page and should never cause a FATAL error. (Fixes one
78 * potential source of "denial of service" attacks).
80 * CGI actions file editor that works and is actually useful.
82 * Ability to toggle JunkBuster remotely using a CGI call.
84 * You can turn off both the above features in the main configuration
85 * file, e.g. if you are running a multi-user proxy.
87 * Revision 1.6 2001/10/14 22:00:32 jongfoster
88 * Adding support for a 404 error when an invalid CGI page is requested.
90 * Revision 1.5 2001/10/07 15:30:41 oes
91 * Removed FEATURE_DENY_GZIP
93 * Revision 1.4 2001/10/02 15:31:12 oes
94 * Introduced show-request cgi
96 * Revision 1.3 2001/09/22 16:34:44 jongfoster
97 * Removing unneeded #includes
99 * Revision 1.2 2001/09/19 18:01:11 oes
100 * Fixed comments; cosmetics
102 * Revision 1.1 2001/09/16 17:08:54 jongfoster
103 * Moving simple CGI functions from cgi.c to new file cgisimple.c
106 **********************************************************************/
112 #include <sys/types.h>
119 #define snprintf _snprintf
120 #endif /* def _WIN32 */
124 #include "cgisimple.h"
130 #include "miscutil.h"
133 #include "urlmatch.h"
135 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
138 static char *show_rcs(void);
139 static jb_err show_defines(struct map *exports);
142 /*********************************************************************
144 * Function : cgi_default
146 * Description : CGI function that is called if no action was given.
147 * Lists menu of available unhidden CGIs.
150 * 1 : csp = Current client state (buffers, headers, etc...)
151 * 2 : rsp = http_response data structure for output
152 * 3 : parameters = map of cgi parameters
154 * CGI Parameters : none
156 * Returns : JB_ERR_OK on success
157 * JB_ERR_MEMORY on out-of-memory
158 * (Problems other than out-of-memory should be
159 * handled by this routine - it should set the
160 * rsp appropriately and return "success")
162 *********************************************************************/
163 jb_err cgi_default(struct client_state *csp,
164 struct http_response *rsp,
165 const struct map *parameters)
174 if (NULL == (exports = default_exports(csp, "")))
176 return JB_ERR_MEMORY;
179 /* If there were other parameters, export a dump as "cgi-parameters" */
180 if (parameters->first)
182 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
183 "Anyway, here they are, in case you're interested:</p>\n");
184 string_join(&tmp, dump_map(parameters));
188 return JB_ERR_MEMORY;
190 if (map(exports, "cgi-parameters", 1, tmp, 0))
192 return JB_ERR_MEMORY;
197 if (map(exports, "cgi-parameters", 1, "", 1))
199 return JB_ERR_MEMORY;
203 return template_fill_for_cgi(csp, "default", exports, rsp);
209 /*********************************************************************
211 * Function : cgi_error_404
213 * Description : CGI function that is called if an unknown action was
217 * 1 : csp = Current client state (buffers, headers, etc...)
218 * 2 : rsp = http_response data structure for output
219 * 3 : parameters = map of cgi parameters
221 * CGI Parameters : none
223 * Returns : JB_ERR_OK on success
224 * JB_ERR_MEMORY on out-of-memory error.
226 *********************************************************************/
227 jb_err cgi_error_404(struct client_state *csp,
228 struct http_response *rsp,
229 const struct map *parameters)
237 if (NULL == (exports = default_exports(csp, NULL)))
239 return JB_ERR_MEMORY;
242 rsp->status = strdup("404 JunkBuster configuration page not found");
243 if (rsp->status == NULL)
246 return JB_ERR_MEMORY;
249 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
253 /*********************************************************************
255 * Function : cgi_show_request
257 * Description : Show the client's request and what sed() would have
261 * 1 : csp = Current client state (buffers, headers, etc...)
262 * 2 : rsp = http_response data structure for output
263 * 3 : parameters = map of cgi parameters
265 * CGI Parameters : none
267 * Returns : JB_ERR_OK on success
268 * JB_ERR_MEMORY on out-of-memory error.
270 *********************************************************************/
271 jb_err cgi_show_request(struct client_state *csp,
272 struct http_response *rsp,
273 const struct map *parameters)
282 if (NULL == (exports = default_exports(csp, "show-request")))
284 return JB_ERR_MEMORY;
288 * Repair the damage done to the IOB by get_header()
290 for (p = csp->iob->buf; p < csp->iob->eod; p++)
292 if (*p == '\0') *p = '\n';
296 * Export the original client's request and the one we would
297 * be sending to the server if this wasn't a CGI call
300 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
303 return JB_ERR_MEMORY;
306 if (map(exports, "processed-request", 1, html_encode_and_free_original(
307 sed(client_patterns, add_client_headers, csp)), 0))
310 return JB_ERR_MEMORY;
313 return template_fill_for_cgi(csp, "show-request", exports, rsp);
317 /*********************************************************************
319 * Function : cgi_send_banner
321 * Description : CGI function that returns a banner.
324 * 1 : csp = Current client state (buffers, headers, etc...)
325 * 2 : rsp = http_response data structure for output
326 * 3 : parameters = map of cgi parameters
329 * type : Selects the type of banner between "trans", "logo",
330 * and "auto". Defaults to "logo" if absent or invalid.
331 * "auto" means to select as if we were image-blocking.
332 * (Only the first character really counts).
334 * Returns : JB_ERR_OK on success
335 * JB_ERR_MEMORY on out-of-memory error.
337 *********************************************************************/
338 jb_err cgi_send_banner(struct client_state *csp,
339 struct http_response *rsp,
340 const struct map *parameters)
342 char imagetype = lookup(parameters, "type")[0];
344 if (imagetype == 'a') /* auto */
346 /* Default to logo */
348 #ifdef FEATURE_IMAGE_BLOCKING
349 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
351 /* determine HOW images should be blocked */
352 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
354 /* and handle accordingly: */
355 if ((p != NULL) && (0 == strcmpic(p, "blank")))
359 else if ((p != NULL) && (0 == strcmpic(p, "pattern")))
364 #endif /* def FEATURE_IMAGE_BLOCKING */
367 if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
369 rsp->body = bindup(image_blank_data, image_blank_length);
370 rsp->content_length = image_blank_length;
373 else if (imagetype == 'p') /* pattern */
375 rsp->body = bindup(image_pattern_data, image_pattern_length);
376 rsp->content_length = image_pattern_length;
380 rsp->body = bindup(image_logo_data, image_logo_length);
381 rsp->content_length = image_logo_length;
384 if (rsp->body == NULL)
386 return JB_ERR_MEMORY;
389 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
391 return JB_ERR_MEMORY;
401 /*********************************************************************
403 * Function : cgi_transparent_image
405 * Description : CGI function that sends a 1x1 transparent image.
408 * 1 : csp = Current client state (buffers, headers, etc...)
409 * 2 : rsp = http_response data structure for output
410 * 3 : parameters = map of cgi parameters
412 * CGI Parameters : None
414 * Returns : JB_ERR_OK on success
415 * JB_ERR_MEMORY on out-of-memory error.
417 *********************************************************************/
418 jb_err cgi_transparent_image(struct client_state *csp,
419 struct http_response *rsp,
420 const struct map *parameters)
422 rsp->body = bindup(image_blank_data, image_blank_length);
423 rsp->content_length = image_blank_length;
425 if (rsp->body == NULL)
427 return JB_ERR_MEMORY;
430 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
432 return JB_ERR_MEMORY;
442 /*********************************************************************
444 * Function : cgi_show_version
446 * Description : CGI function that returns a a web page describing the
447 * file versions of IJB.
450 * 1 : csp = Current client state (buffers, headers, etc...)
451 * 2 : rsp = http_response data structure for output
452 * 3 : parameters = map of cgi parameters
454 * CGI Parameters : none
456 * Returns : JB_ERR_OK on success
457 * JB_ERR_MEMORY on out-of-memory error.
459 *********************************************************************/
460 jb_err cgi_show_version(struct client_state *csp,
461 struct http_response *rsp,
462 const struct map *parameters)
470 if (NULL == (exports = default_exports(csp, "show-version")))
472 return JB_ERR_MEMORY;
475 if (map(exports, "sourceversions", 1, show_rcs(), 0))
478 return JB_ERR_MEMORY;
481 return template_fill_for_cgi(csp, "show-version", exports, rsp);
485 /*********************************************************************
487 * Function : cgi_show_status
489 * Description : CGI function that returns a a web page describing the
490 * current status of IJB.
493 * 1 : csp = Current client state (buffers, headers, etc...)
494 * 2 : rsp = http_response data structure for output
495 * 3 : parameters = map of cgi parameters
498 * file : Which file to show. Only first letter is checked,
500 * - "p"ermissions (actions) file
503 * Default is to show menu and other information.
505 * Returns : JB_ERR_OK on success
506 * JB_ERR_MEMORY on out-of-memory error.
508 *********************************************************************/
509 jb_err cgi_show_status(struct client_state *csp,
510 struct http_response *rsp,
511 const struct map *parameters)
517 char buf[BUFFER_SIZE];
518 const char * filename = NULL;
519 char * file_description = NULL;
520 #ifdef FEATURE_STATISTICS
521 float perc_rej; /* Percentage of http requests rejected */
523 int local_urls_rejected;
524 #endif /* ndef FEATURE_STATISTICS */
533 if (NULL == (exports = default_exports(csp, "show-status")))
535 return JB_ERR_MEMORY;
538 switch (*(lookup(parameters, "file")))
541 if (csp->actions_list)
543 filename = csp->actions_list->filename;
544 file_description = "Actions List";
551 filename = csp->rlist->filename;
552 file_description = "Regex Filter List";
560 filename = csp->tlist->filename;
561 file_description = "Trust List";
564 #endif /* def FEATURE_TRUST */
567 if (NULL != filename)
569 if ( map(exports, "file-description", 1, file_description, 1)
570 || map(exports, "filepath", 1, html_encode(filename), 0) )
573 return JB_ERR_MEMORY;
576 if ((fp = fopen(filename, "r")) == NULL)
578 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
581 return JB_ERR_MEMORY;
587 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
589 string_join (&s, html_encode(buf));
590 string_append(&s, "<br>");
594 if (map(exports, "contents", 1, s, 0))
597 return JB_ERR_MEMORY;
601 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
604 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
607 return JB_ERR_MEMORY;
611 for (i = 0; (s != NULL) && (i < Argc); i++)
613 string_join (&s, html_encode(Argv[i]));
614 string_append(&s, " ");
616 if (map(exports, "invocation", 1, s, 0))
619 return JB_ERR_MEMORY;
622 err = map(exports, "options", 1, csp->config->proxy_args, 1);
623 if (!err) err = show_defines(exports);
625 #ifdef FEATURE_STATISTICS
626 local_urls_read = urls_read;
627 local_urls_rejected = urls_rejected;
630 * Need to alter the stats not to include the fetch of this
633 * Can't do following thread safely! doh!
636 * urls_rejected--; * This will be incremented subsequently *
639 if (local_urls_read == 0)
641 if (!err) err = map_block_killer(exports, "have-stats");
645 if (!err) err = map_block_killer(exports, "have-no-stats");
647 perc_rej = (float)local_urls_rejected * 100.0F /
648 (float)local_urls_read;
650 sprintf(buf, "%d", local_urls_read);
651 if (!err) err = map(exports, "requests-received", 1, buf, 1);
653 sprintf(buf, "%d", local_urls_rejected);
654 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
656 sprintf(buf, "%6.2f", perc_rej);
657 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
660 #else /* ndef FEATURE_STATISTICS */
661 err = err || map_block_killer(exports, "statistics");
662 #endif /* ndef FEATURE_STATISTICS */
664 if (csp->actions_list)
666 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
670 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
675 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
679 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
685 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
689 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
692 if (!err) err = map_block_killer(exports, "trust-support");
693 #endif /* ndef FEATURE_TRUST */
698 return JB_ERR_MEMORY;
701 return template_fill_for_cgi(csp, "show-status", exports, rsp);
705 /*********************************************************************
707 * Function : cgi_show_url_info
709 * Description : CGI function that determines and shows which actions
710 * junkbuster will perform for a given url, and which
711 * matches starting from the defaults have lead to that.
714 * 1 : csp = Current client state (buffers, headers, etc...)
715 * 2 : rsp = http_response data structure for output
716 * 3 : parameters = map of cgi parameters
719 * url : The url whose actions are to be determined.
720 * If url is unset, the url-given conditional will be
721 * set, so that all but the form can be suppressed in
724 * Returns : JB_ERR_OK on success
725 * JB_ERR_MEMORY on out-of-memory error.
727 *********************************************************************/
728 jb_err cgi_show_url_info(struct client_state *csp,
729 struct http_response *rsp,
730 const struct map *parameters)
739 if (NULL == (exports = default_exports(csp, "show-url-info")))
741 return JB_ERR_MEMORY;
745 * Get the url= parameter (if present) and remove any leading/trailing spaces.
747 url_param = strdup(lookup(parameters, "url"));
748 if (url_param == NULL)
751 return JB_ERR_MEMORY;
756 * Handle prefixes. 4 possibilities:
757 * 1) "http://" or "https://" prefix present and followed by URL - OK
758 * 2) Only the "http://" or "https://" part is present, no URL - change
759 * to empty string so it will be detected later as "no URL".
760 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
762 * 4) Parameter not specified or is empty string - let this fall through
763 * for now, next block of code will handle it.
765 if (0 == strncmp(url_param, "http://", 7))
767 if (url_param[7] == '\0')
770 * Empty URL (just prefix).
771 * Make it totally empty so it's caught by the next if()
776 else if (0 == strncmp(url_param, "https://", 8))
778 if (url_param[8] == '\0')
781 * Empty URL (just prefix).
782 * Make it totally empty so it's caught by the next if()
787 else if (url_param[0] != '\0')
790 * Unknown prefix - assume http://
792 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
793 if (NULL == url_param_prefixed)
797 return JB_ERR_MEMORY;
799 strcpy(url_param_prefixed, "http://");
800 strcpy(url_param_prefixed + 7, url_param);
802 url_param = url_param_prefixed;
806 if (url_param[0] == '\0')
808 /* URL paramater not specified, display query form only. */
810 if (map_block_killer(exports, "url-given")
811 || map(exports, "url", 1, "", 1))
814 return JB_ERR_MEMORY;
819 /* Given a URL, so query it. */
824 struct file_list *fl;
825 struct url_actions *b;
826 struct http_request url_to_query[1];
827 struct current_action_spec action[1];
829 if (map(exports, "url", 1, html_encode(url_param), 0))
833 return JB_ERR_MEMORY;
836 init_current_action(action);
838 if (map(exports, "default", 1, html_encode_and_free_original(
839 current_action_to_text(action)), 0))
841 free_current_action(action);
844 return JB_ERR_MEMORY;
847 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
849 err = map(exports, "matches", 1, "none" , 1);
850 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
852 free_current_action(action);
858 return JB_ERR_MEMORY;
861 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
864 err = parse_http_url(url_param, url_to_query, csp);
868 if (err == JB_ERR_MEMORY)
870 free_current_action(action);
872 return JB_ERR_MEMORY;
878 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
879 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
881 free_current_action(action);
886 return JB_ERR_MEMORY;
889 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
893 * We have a warning about SSL paths. Hide it for insecure sites.
895 if (!url_to_query->ssl)
897 if (map_block_killer(exports, "https"))
899 free_current_action(action);
901 return JB_ERR_MEMORY;
905 matches = strdup("");
907 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
909 if (url_match(b->url, url_to_query))
911 string_append(&matches, "<b>{");
912 string_join (&matches, html_encode_and_free_original(
913 actions_to_text(b->action)));
914 string_append(&matches, " }</b><br>\n<code>");
915 string_join (&matches, html_encode(b->url->spec));
916 string_append(&matches, "</code><br>\n<br>\n");
918 if (merge_current_action(action, b->action))
921 free_http_request(url_to_query);
922 free_current_action(action);
924 return JB_ERR_MEMORY;
930 free_http_request(url_to_query);
934 free_current_action(action);
936 return JB_ERR_MEMORY;
942 matches = strdup("none");
944 if (map(exports, "matches", 1, matches , 0))
946 free_current_action(action);
948 return JB_ERR_MEMORY;
951 s = html_encode_and_free_original(current_action_to_text(action));
953 free_current_action(action);
955 if (map(exports, "final", 1, s, 0))
958 return JB_ERR_MEMORY;
962 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
966 /*********************************************************************
968 * Function : cgi_robots_txt
970 * Description : CGI function to return "/robots.txt".
973 * 1 : csp = Current client state (buffers, headers, etc...)
974 * 2 : rsp = http_response data structure for output
975 * 3 : parameters = map of cgi parameters
977 * CGI Parameters : None
979 * Returns : JB_ERR_OK on success
980 * JB_ERR_MEMORY on out-of-memory error.
982 *********************************************************************/
983 jb_err cgi_robots_txt(struct client_state *csp,
984 struct http_response *rsp,
985 const struct map *parameters)
991 "# This is the Internet Junkbuster control interface.\n"
992 "# It isn't very useful to index it, and you're likely to break stuff.\n"
998 if (rsp->body == NULL)
1000 return JB_ERR_MEMORY;
1003 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1007 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1008 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1010 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1014 /*********************************************************************
1016 * Function : show_defines
1018 * Description : Add to a map the state od all conditional #defines
1019 * used when building
1022 * 1 : exports = map to extend
1024 * Returns : JB_ERR_OK on success
1025 * JB_ERR_MEMORY on out-of-memory error.
1027 *********************************************************************/
1028 static jb_err show_defines(struct map *exports)
1030 jb_err err = JB_ERR_OK;
1033 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1034 #else /* ifndef FEATURE_ACL */
1035 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1036 #endif /* ndef FEATURE_ACL */
1038 #ifdef FEATURE_CGI_EDIT_ACTIONS
1039 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1040 #else /* ifndef FEATURE_COOKIE_JAR */
1041 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1042 #endif /* ndef FEATURE_COOKIE_JAR */
1044 #ifdef FEATURE_COOKIE_JAR
1045 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1046 #else /* ifndef FEATURE_COOKIE_JAR */
1047 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1048 #endif /* ndef FEATURE_COOKIE_JAR */
1050 #ifdef FEATURE_FAST_REDIRECTS
1051 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1052 #else /* ifndef FEATURE_FAST_REDIRECTS */
1053 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1054 #endif /* ndef FEATURE_FAST_REDIRECTS */
1056 #ifdef FEATURE_FORCE_LOAD
1057 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1058 #else /* ifndef FEATURE_FORCE_LOAD */
1059 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1060 #endif /* ndef FEATURE_FORCE_LOAD */
1062 #ifdef FEATURE_IMAGE_BLOCKING
1063 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1064 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1065 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1066 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1068 #ifdef FEATURE_IMAGE_DETECT_MSIE
1069 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1070 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1071 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1072 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1074 #ifdef FEATURE_KILL_POPUPS
1075 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1076 #else /* ifndef FEATURE_KILL_POPUPS */
1077 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1078 #endif /* ndef FEATURE_KILL_POPUPS */
1080 #ifdef FEATURE_NO_GIFS
1081 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1082 #else /* ifndef FEATURE_NO_GIFS */
1083 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1084 #endif /* ndef FEATURE_NO_GIFS */
1086 #ifdef FEATURE_PTHREAD
1087 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1088 #else /* ifndef FEATURE_PTHREAD */
1089 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1090 #endif /* ndef FEATURE_PTHREAD */
1092 #ifdef FEATURE_STATISTICS
1093 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1094 #else /* ifndef FEATURE_STATISTICS */
1095 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1096 #endif /* ndef FEATURE_STATISTICS */
1098 #ifdef FEATURE_TOGGLE
1099 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1100 #else /* ifndef FEATURE_TOGGLE */
1101 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1102 #endif /* ndef FEATURE_TOGGLE */
1104 #ifdef FEATURE_TRUST
1105 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1106 #else /* ifndef FEATURE_TRUST */
1107 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1108 #endif /* ndef FEATURE_TRUST */
1111 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1112 #else /* ifndef REGEX_GNU */
1113 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1114 #endif /* def REGEX_GNU */
1117 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1118 #else /* ifndef REGEX_PCRE */
1119 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1120 #endif /* def REGEX_PCRE */
1123 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1124 #else /* ifndef STATIC_PCRE */
1125 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1126 #endif /* ndef STATIC_PCRE */
1129 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1130 #else /* ifndef STATIC_PCRS */
1131 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1132 #endif /* ndef STATIC_PCRS */
1134 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1140 /*********************************************************************
1142 * Function : show_rcs
1144 * Description : Create a string with the rcs info for all sourcefiles
1148 * Returns : A string, or NULL on out-of-memory.
1150 *********************************************************************/
1151 static char *show_rcs(void)
1153 char *result = strdup("");
1154 char buf[BUFFER_SIZE];
1156 /* Instead of including *all* dot h's in the project (thus creating a
1157 * tremendous amount of dependencies), I will concede to declaring them
1158 * as extern's. This forces the developer to add to this list, but oh well.
1161 #define SHOW_RCS(__x) \
1163 extern const char __x[]; \
1164 sprintf(buf, "%s\n", __x); \
1165 string_append(&result, buf); \
1168 /* In alphabetical order */
1169 SHOW_RCS(actions_h_rcs)
1170 SHOW_RCS(actions_rcs)
1173 #ifdef FEATURE_CGI_EDIT_ACTIONS
1174 SHOW_RCS(cgiedit_h_rcs)
1175 SHOW_RCS(cgiedit_rcs)
1176 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1177 SHOW_RCS(cgisimple_h_rcs)
1178 SHOW_RCS(cgisimple_rcs)
1180 SHOW_RCS(cygwin_h_rcs)
1182 SHOW_RCS(deanimate_h_rcs)
1183 SHOW_RCS(deanimate_rcs)
1184 SHOW_RCS(encode_h_rcs)
1185 SHOW_RCS(encode_rcs)
1186 SHOW_RCS(errlog_h_rcs)
1187 SHOW_RCS(errlog_rcs)
1188 SHOW_RCS(filters_h_rcs)
1189 SHOW_RCS(filters_rcs)
1190 SHOW_RCS(gateway_h_rcs)
1191 SHOW_RCS(gateway_rcs)
1193 SHOW_RCS(gnu_regex_h_rcs)
1194 SHOW_RCS(gnu_regex_rcs)
1195 #endif /* def GNU_REGEX */
1196 SHOW_RCS(jbsockets_h_rcs)
1197 SHOW_RCS(jbsockets_rcs)
1200 #ifdef FEATURE_KILL_POPUPS
1201 SHOW_RCS(killpopup_h_rcs)
1202 SHOW_RCS(killpopup_rcs)
1203 #endif /* def FEATURE_KILL_POPUPS */
1204 SHOW_RCS(list_h_rcs)
1206 SHOW_RCS(loadcfg_h_rcs)
1207 SHOW_RCS(loadcfg_rcs)
1208 SHOW_RCS(loaders_h_rcs)
1209 SHOW_RCS(loaders_rcs)
1210 SHOW_RCS(miscutil_h_rcs)
1211 SHOW_RCS(miscutil_rcs)
1212 SHOW_RCS(parsers_h_rcs)
1213 SHOW_RCS(parsers_rcs)
1215 SHOW_RCS(pcrs_h_rcs)
1216 SHOW_RCS(project_h_rcs)
1217 SHOW_RCS(ssplit_h_rcs)
1218 SHOW_RCS(ssplit_rcs)
1219 SHOW_RCS(urlmatch_h_rcs)
1220 SHOW_RCS(urlmatch_rcs)
1222 #ifndef _WIN_CONSOLE
1223 SHOW_RCS(w32log_h_rcs)
1224 SHOW_RCS(w32log_rcs)
1225 SHOW_RCS(w32res_h_rcs)
1226 SHOW_RCS(w32taskbar_h_rcs)
1227 SHOW_RCS(w32taskbar_rcs)
1228 #endif /* ndef _WIN_CONSOLE */
1229 SHOW_RCS(win32_h_rcs)
1231 #endif /* def _WIN32 */