1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.15 2002/03/06 22:54:35 jongfoster 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.15 2002/03/06 22:54:35 jongfoster
40 * Automated function-comment nitpicking.
42 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
43 * Clean up a little CRLF unpleasantness that suddenly appeared
45 * Revision 1.13 2002/02/21 00:10:37 jongfoster
46 * Adding send-banner?type=auto option
48 * Revision 1.12 2002/01/23 01:03:32 jongfoster
49 * Fixing gcc [CygWin] compiler warnings
51 * Revision 1.11 2002/01/23 00:01:04 jongfoster
52 * Adding cgi_transparent_gif() for http://i.j.b/t
53 * Adding missing html_encode() to many CGI functions.
54 * Adding urlmatch.[ch] to http://i.j.b/show-version
56 * Revision 1.10 2002/01/17 21:10:37 jongfoster
57 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
58 * Also fixing a problem in the same function with improperly quoted URLs
59 * in output HTML, and adding code to handle https:// URLs correctly.
61 * Revision 1.9 2001/11/30 23:09:15 jongfoster
62 * Now reports on FEATURE_CGI_EDIT_ACTIONS
63 * Removing FEATURE_DENY_GZIP from template
65 * Revision 1.8 2001/11/13 00:14:07 jongfoster
66 * Fixing stupid bug now I've figured out what || means.
67 * (It always returns 0 or 1, not one of it's paramaters.)
69 * Revision 1.7 2001/10/23 21:48:19 jongfoster
70 * Cleaning up error handling in CGI functions - they now send back
71 * a HTML error page and should never cause a FATAL error. (Fixes one
72 * potential source of "denial of service" attacks).
74 * CGI actions file editor that works and is actually useful.
76 * Ability to toggle JunkBuster remotely using a CGI call.
78 * You can turn off both the above features in the main configuration
79 * file, e.g. if you are running a multi-user proxy.
81 * Revision 1.6 2001/10/14 22:00:32 jongfoster
82 * Adding support for a 404 error when an invalid CGI page is requested.
84 * Revision 1.5 2001/10/07 15:30:41 oes
85 * Removed FEATURE_DENY_GZIP
87 * Revision 1.4 2001/10/02 15:31:12 oes
88 * Introduced show-request cgi
90 * Revision 1.3 2001/09/22 16:34:44 jongfoster
91 * Removing unneeded #includes
93 * Revision 1.2 2001/09/19 18:01:11 oes
94 * Fixed comments; cosmetics
96 * Revision 1.1 2001/09/16 17:08:54 jongfoster
97 * Moving simple CGI functions from cgi.c to new file cgisimple.c
100 **********************************************************************/
106 #include <sys/types.h>
113 #define snprintf _snprintf
114 #endif /* def _WIN32 */
118 #include "cgisimple.h"
124 #include "miscutil.h"
127 #include "urlmatch.h"
129 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
132 static char *show_rcs(void);
133 static jb_err show_defines(struct map *exports);
136 /*********************************************************************
138 * Function : cgi_default
140 * Description : CGI function that is called if no action was given.
141 * Lists menu of available unhidden CGIs.
144 * 1 : csp = Current client state (buffers, headers, etc...)
145 * 2 : rsp = http_response data structure for output
146 * 3 : parameters = map of cgi parameters
148 * CGI Parameters : none
150 * Returns : JB_ERR_OK on success
151 * JB_ERR_MEMORY on out-of-memory
152 * (Problems other than out-of-memory should be
153 * handled by this routine - it should set the
154 * rsp appropriately and return "success")
156 *********************************************************************/
157 jb_err cgi_default(struct client_state *csp,
158 struct http_response *rsp,
159 const struct map *parameters)
168 if (NULL == (exports = default_exports(csp, "")))
170 return JB_ERR_MEMORY;
173 /* If there were other parameters, export a dump as "cgi-parameters" */
174 if (parameters->first)
176 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
177 "Anyway, here they are, in case you're interested:</p>\n");
178 string_join(&tmp, dump_map(parameters));
182 return JB_ERR_MEMORY;
184 if (map(exports, "cgi-parameters", 1, tmp, 0))
186 return JB_ERR_MEMORY;
191 if (map(exports, "cgi-parameters", 1, "", 1))
193 return JB_ERR_MEMORY;
197 return template_fill_for_cgi(csp, "default", exports, rsp);
203 /*********************************************************************
205 * Function : cgi_error_404
207 * Description : CGI function that is called if an unknown action was
211 * 1 : csp = Current client state (buffers, headers, etc...)
212 * 2 : rsp = http_response data structure for output
213 * 3 : parameters = map of cgi parameters
215 * CGI Parameters : none
217 * Returns : JB_ERR_OK on success
218 * JB_ERR_MEMORY on out-of-memory error.
220 *********************************************************************/
221 jb_err cgi_error_404(struct client_state *csp,
222 struct http_response *rsp,
223 const struct map *parameters)
231 if (NULL == (exports = default_exports(csp, NULL)))
233 return JB_ERR_MEMORY;
236 rsp->status = strdup("404 JunkBuster configuration page not found");
237 if (rsp->status == NULL)
240 return JB_ERR_MEMORY;
243 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
247 /*********************************************************************
249 * Function : cgi_show_request
251 * Description : Show the client's request and what sed() would have
255 * 1 : csp = Current client state (buffers, headers, etc...)
256 * 2 : rsp = http_response data structure for output
257 * 3 : parameters = map of cgi parameters
259 * CGI Parameters : none
261 * Returns : JB_ERR_OK on success
262 * JB_ERR_MEMORY on out-of-memory error.
264 *********************************************************************/
265 jb_err cgi_show_request(struct client_state *csp,
266 struct http_response *rsp,
267 const struct map *parameters)
276 if (NULL == (exports = default_exports(csp, "show-request")))
278 return JB_ERR_MEMORY;
282 * Repair the damage done to the IOB by get_header()
284 for (p = csp->iob->buf; p < csp->iob->eod; p++)
286 if (*p == '\0') *p = '\n';
290 * Export the original client's request and the one we would
291 * be sending to the server if this wasn't a CGI call
294 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
297 return JB_ERR_MEMORY;
300 if (map(exports, "processed-request", 1, html_encode_and_free_original(
301 sed(client_patterns, add_client_headers, csp)), 0))
304 return JB_ERR_MEMORY;
307 return template_fill_for_cgi(csp, "show-request", exports, rsp);
311 /*********************************************************************
313 * Function : cgi_send_banner
315 * Description : CGI function that returns a banner.
318 * 1 : csp = Current client state (buffers, headers, etc...)
319 * 2 : rsp = http_response data structure for output
320 * 3 : parameters = map of cgi parameters
323 * type : Selects the type of banner between "trans", "logo",
324 * and "auto". Defaults to "logo" if absent or invalid.
325 * "auto" means to select as if we were image-blocking.
326 * (Only the first character really counts).
328 * Returns : JB_ERR_OK on success
329 * JB_ERR_MEMORY on out-of-memory error.
331 *********************************************************************/
332 jb_err cgi_send_banner(struct client_state *csp,
333 struct http_response *rsp,
334 const struct map *parameters)
336 char imagetype = lookup(parameters, "type")[0];
338 if (imagetype == 'a') /* auto */
340 /* Default to logo */
342 #ifdef FEATURE_IMAGE_BLOCKING
343 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
345 /* determine HOW images should be blocked */
346 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
348 /* and handle accordingly: */
349 if ((p != NULL) && (0 == strcmpic(p, "blank")))
353 else if ((p != NULL) && (0 == strcmpic(p, "pattern")))
358 #endif /* def FEATURE_IMAGE_BLOCKING */
361 if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
363 rsp->body = bindup(image_blank_data, image_blank_length);
364 rsp->content_length = image_blank_length;
367 else if (imagetype == 'p') /* pattern */
369 rsp->body = bindup(image_pattern_data, image_pattern_length);
370 rsp->content_length = image_pattern_length;
374 rsp->body = bindup(image_logo_data, image_logo_length);
375 rsp->content_length = image_logo_length;
378 if (rsp->body == NULL)
380 return JB_ERR_MEMORY;
383 if (enlist(rsp->headers, "Content-Type: image/png"))
385 return JB_ERR_MEMORY;
395 /*********************************************************************
397 * Function : cgi_transparent_png
399 * Description : CGI function that sends a 1x1 transparent PNG.
402 * 1 : csp = Current client state (buffers, headers, etc...)
403 * 2 : rsp = http_response data structure for output
404 * 3 : parameters = map of cgi parameters
406 * CGI Parameters : None
408 * Returns : JB_ERR_OK on success
409 * JB_ERR_MEMORY on out-of-memory error.
411 *********************************************************************/
412 jb_err cgi_transparent_png(struct client_state *csp,
413 struct http_response *rsp,
414 const struct map *parameters)
416 rsp->body = bindup(image_blank_data, image_blank_length);
417 rsp->content_length = image_blank_length;
419 if (rsp->body == NULL)
421 return JB_ERR_MEMORY;
424 if (enlist(rsp->headers, "Content-Type: image/png"))
426 return JB_ERR_MEMORY;
436 /*********************************************************************
438 * Function : cgi_show_version
440 * Description : CGI function that returns a a web page describing the
441 * file versions of IJB.
444 * 1 : csp = Current client state (buffers, headers, etc...)
445 * 2 : rsp = http_response data structure for output
446 * 3 : parameters = map of cgi parameters
448 * CGI Parameters : none
450 * Returns : JB_ERR_OK on success
451 * JB_ERR_MEMORY on out-of-memory error.
453 *********************************************************************/
454 jb_err cgi_show_version(struct client_state *csp,
455 struct http_response *rsp,
456 const struct map *parameters)
464 if (NULL == (exports = default_exports(csp, "show-version")))
466 return JB_ERR_MEMORY;
469 if (map(exports, "sourceversions", 1, show_rcs(), 0))
472 return JB_ERR_MEMORY;
475 return template_fill_for_cgi(csp, "show-version", exports, rsp);
479 /*********************************************************************
481 * Function : cgi_show_status
483 * Description : CGI function that returns a a web page describing the
484 * current status of IJB.
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
492 * file : Which file to show. Only first letter is checked,
494 * - "p"ermissions (actions) file
497 * Default is to show menu and other information.
499 * Returns : JB_ERR_OK on success
500 * JB_ERR_MEMORY on out-of-memory error.
502 *********************************************************************/
503 jb_err cgi_show_status(struct client_state *csp,
504 struct http_response *rsp,
505 const struct map *parameters)
511 char buf[BUFFER_SIZE];
512 const char * filename = NULL;
513 char * file_description = NULL;
514 #ifdef FEATURE_STATISTICS
515 float perc_rej; /* Percentage of http requests rejected */
517 int local_urls_rejected;
518 #endif /* ndef FEATURE_STATISTICS */
527 if (NULL == (exports = default_exports(csp, "show-status")))
529 return JB_ERR_MEMORY;
532 switch (*(lookup(parameters, "file")))
535 if (csp->actions_list)
537 filename = csp->actions_list->filename;
538 file_description = "Actions List";
545 filename = csp->rlist->filename;
546 file_description = "Regex Filter List";
554 filename = csp->tlist->filename;
555 file_description = "Trust List";
558 #endif /* def FEATURE_TRUST */
561 if (NULL != filename)
563 if ( map(exports, "file-description", 1, file_description, 1)
564 || map(exports, "filepath", 1, html_encode(filename), 0) )
567 return JB_ERR_MEMORY;
570 if ((fp = fopen(filename, "r")) == NULL)
572 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
575 return JB_ERR_MEMORY;
581 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
583 string_join (&s, html_encode(buf));
584 string_append(&s, "<br>");
588 if (map(exports, "contents", 1, s, 0))
591 return JB_ERR_MEMORY;
595 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
598 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
601 return JB_ERR_MEMORY;
605 for (i = 0; (s != NULL) && (i < Argc); i++)
607 string_join (&s, html_encode(Argv[i]));
608 string_append(&s, " ");
610 if (map(exports, "invocation", 1, s, 0))
613 return JB_ERR_MEMORY;
616 err = map(exports, "options", 1, csp->config->proxy_args, 1);
617 if (!err) err = show_defines(exports);
619 #ifdef FEATURE_STATISTICS
620 local_urls_read = urls_read;
621 local_urls_rejected = urls_rejected;
624 * Need to alter the stats not to include the fetch of this
627 * Can't do following thread safely! doh!
630 * urls_rejected--; * This will be incremented subsequently *
633 if (local_urls_read == 0)
635 if (!err) err = map_block_killer(exports, "have-stats");
639 if (!err) err = map_block_killer(exports, "have-no-stats");
641 perc_rej = (float)local_urls_rejected * 100.0F /
642 (float)local_urls_read;
644 sprintf(buf, "%d", local_urls_read);
645 if (!err) err = map(exports, "requests-received", 1, buf, 1);
647 sprintf(buf, "%d", local_urls_rejected);
648 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
650 sprintf(buf, "%6.2f", perc_rej);
651 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
654 #else /* ndef FEATURE_STATISTICS */
655 err = err || map_block_killer(exports, "statistics");
656 #endif /* ndef FEATURE_STATISTICS */
658 if (csp->actions_list)
660 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
664 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
669 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
673 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
679 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
683 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
686 if (!err) err = map_block_killer(exports, "trust-support");
687 #endif /* ndef FEATURE_TRUST */
692 return JB_ERR_MEMORY;
695 return template_fill_for_cgi(csp, "show-status", exports, rsp);
699 /*********************************************************************
701 * Function : cgi_show_url_info
703 * Description : CGI function that determines and shows which actions
704 * junkbuster will perform for a given url, and which
705 * matches starting from the defaults have lead to that.
708 * 1 : csp = Current client state (buffers, headers, etc...)
709 * 2 : rsp = http_response data structure for output
710 * 3 : parameters = map of cgi parameters
713 * url : The url whose actions are to be determined.
714 * If url is unset, the url-given conditional will be
715 * set, so that all but the form can be suppressed in
718 * Returns : JB_ERR_OK on success
719 * JB_ERR_MEMORY on out-of-memory error.
721 *********************************************************************/
722 jb_err cgi_show_url_info(struct client_state *csp,
723 struct http_response *rsp,
724 const struct map *parameters)
733 if (NULL == (exports = default_exports(csp, "show-url-info")))
735 return JB_ERR_MEMORY;
739 * Get the url= parameter (if present) and remove any leading/trailing spaces.
741 url_param = strdup(lookup(parameters, "url"));
742 if (url_param == NULL)
745 return JB_ERR_MEMORY;
750 * Handle prefixes. 4 possibilities:
751 * 1) "http://" or "https://" prefix present and followed by URL - OK
752 * 2) Only the "http://" or "https://" part is present, no URL - change
753 * to empty string so it will be detected later as "no URL".
754 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
756 * 4) Parameter not specified or is empty string - let this fall through
757 * for now, next block of code will handle it.
759 if (0 == strncmp(url_param, "http://", 7))
761 if (url_param[7] == '\0')
764 * Empty URL (just prefix).
765 * Make it totally empty so it's caught by the next if()
770 else if (0 == strncmp(url_param, "https://", 8))
772 if (url_param[8] == '\0')
775 * Empty URL (just prefix).
776 * Make it totally empty so it's caught by the next if()
781 else if (url_param[0] != '\0')
784 * Unknown prefix - assume http://
786 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
787 if (NULL == url_param_prefixed)
791 return JB_ERR_MEMORY;
793 strcpy(url_param_prefixed, "http://");
794 strcpy(url_param_prefixed + 7, url_param);
796 url_param = url_param_prefixed;
800 if (url_param[0] == '\0')
802 /* URL paramater not specified, display query form only. */
804 if (map_block_killer(exports, "url-given")
805 || map(exports, "url", 1, "", 1))
808 return JB_ERR_MEMORY;
813 /* Given a URL, so query it. */
818 struct file_list *fl;
819 struct url_actions *b;
820 struct http_request url_to_query[1];
821 struct current_action_spec action[1];
823 if (map(exports, "url", 1, html_encode(url_param), 0))
827 return JB_ERR_MEMORY;
830 init_current_action(action);
832 if (map(exports, "default", 1, html_encode_and_free_original(
833 current_action_to_text(action)), 0))
835 free_current_action(action);
838 return JB_ERR_MEMORY;
841 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
843 err = map(exports, "matches", 1, "none" , 1);
844 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
846 free_current_action(action);
852 return JB_ERR_MEMORY;
855 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
858 err = parse_http_url(url_param, url_to_query, csp);
862 if (err == JB_ERR_MEMORY)
864 free_current_action(action);
866 return JB_ERR_MEMORY;
872 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
873 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
875 free_current_action(action);
880 return JB_ERR_MEMORY;
883 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
887 * We have a warning about SSL paths. Hide it for insecure sites.
889 if (!url_to_query->ssl)
891 if (map_block_killer(exports, "https"))
893 free_current_action(action);
895 return JB_ERR_MEMORY;
899 matches = strdup("");
901 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
903 if (url_match(b->url, url_to_query))
905 string_append(&matches, "<b>{");
906 string_join (&matches, html_encode_and_free_original(
907 actions_to_text(b->action)));
908 string_append(&matches, " }</b><br>\n<code>");
909 string_join (&matches, html_encode(b->url->spec));
910 string_append(&matches, "</code><br>\n<br>\n");
912 if (merge_current_action(action, b->action))
915 free_http_request(url_to_query);
916 free_current_action(action);
918 return JB_ERR_MEMORY;
924 free_http_request(url_to_query);
928 free_current_action(action);
930 return JB_ERR_MEMORY;
936 matches = strdup("none");
938 if (map(exports, "matches", 1, matches , 0))
940 free_current_action(action);
942 return JB_ERR_MEMORY;
945 s = html_encode_and_free_original(current_action_to_text(action));
947 free_current_action(action);
949 if (map(exports, "final", 1, s, 0))
952 return JB_ERR_MEMORY;
956 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
960 /*********************************************************************
962 * Function : cgi_robots_txt
964 * Description : CGI function to return "/robots.txt".
967 * 1 : csp = Current client state (buffers, headers, etc...)
968 * 2 : rsp = http_response data structure for output
969 * 3 : parameters = map of cgi parameters
971 * CGI Parameters : None
973 * Returns : JB_ERR_OK on success
974 * JB_ERR_MEMORY on out-of-memory error.
976 *********************************************************************/
977 jb_err cgi_robots_txt(struct client_state *csp,
978 struct http_response *rsp,
979 const struct map *parameters)
985 "# This is the Internet Junkbuster control interface.\n"
986 "# It isn't very useful to index it, and you're likely to break stuff.\n"
992 if (rsp->body == NULL)
994 return JB_ERR_MEMORY;
997 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1001 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1002 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1004 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1008 /*********************************************************************
1010 * Function : show_defines
1012 * Description : Add to a map the state od all conditional #defines
1013 * used when building
1016 * 1 : exports = map to extend
1018 * Returns : JB_ERR_OK on success
1019 * JB_ERR_MEMORY on out-of-memory error.
1021 *********************************************************************/
1022 static jb_err show_defines(struct map *exports)
1024 jb_err err = JB_ERR_OK;
1027 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1028 #else /* ifndef FEATURE_ACL */
1029 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1030 #endif /* ndef FEATURE_ACL */
1032 #ifdef FEATURE_CGI_EDIT_ACTIONS
1033 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1034 #else /* ifndef FEATURE_COOKIE_JAR */
1035 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1036 #endif /* ndef FEATURE_COOKIE_JAR */
1038 #ifdef FEATURE_COOKIE_JAR
1039 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1040 #else /* ifndef FEATURE_COOKIE_JAR */
1041 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1042 #endif /* ndef FEATURE_COOKIE_JAR */
1044 #ifdef FEATURE_FAST_REDIRECTS
1045 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1046 #else /* ifndef FEATURE_FAST_REDIRECTS */
1047 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1048 #endif /* ndef FEATURE_FAST_REDIRECTS */
1050 #ifdef FEATURE_FORCE_LOAD
1051 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1052 #else /* ifndef FEATURE_FORCE_LOAD */
1053 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1054 #endif /* ndef FEATURE_FORCE_LOAD */
1056 #ifdef FEATURE_IMAGE_BLOCKING
1057 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1058 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1059 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1060 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1062 #ifdef FEATURE_IMAGE_DETECT_MSIE
1063 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1064 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1065 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1066 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1068 #ifdef FEATURE_KILL_POPUPS
1069 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1070 #else /* ifndef FEATURE_KILL_POPUPS */
1071 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1072 #endif /* ndef FEATURE_KILL_POPUPS */
1074 #ifdef FEATURE_PTHREAD
1075 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1076 #else /* ifndef FEATURE_PTHREAD */
1077 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1078 #endif /* ndef FEATURE_PTHREAD */
1080 #ifdef FEATURE_STATISTICS
1081 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1082 #else /* ifndef FEATURE_STATISTICS */
1083 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1084 #endif /* ndef FEATURE_STATISTICS */
1086 #ifdef FEATURE_TOGGLE
1087 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1088 #else /* ifndef FEATURE_TOGGLE */
1089 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1090 #endif /* ndef FEATURE_TOGGLE */
1092 #ifdef FEATURE_TRUST
1093 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1094 #else /* ifndef FEATURE_TRUST */
1095 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1096 #endif /* ndef FEATURE_TRUST */
1099 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1100 #else /* ifndef REGEX_GNU */
1101 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1102 #endif /* def REGEX_GNU */
1105 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1106 #else /* ifndef REGEX_PCRE */
1107 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1108 #endif /* def REGEX_PCRE */
1111 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1112 #else /* ifndef STATIC_PCRE */
1113 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1114 #endif /* ndef STATIC_PCRE */
1117 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1118 #else /* ifndef STATIC_PCRS */
1119 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1120 #endif /* ndef STATIC_PCRS */
1122 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1128 /*********************************************************************
1130 * Function : show_rcs
1132 * Description : Create a string with the rcs info for all sourcefiles
1136 * Returns : A string, or NULL on out-of-memory.
1138 *********************************************************************/
1139 static char *show_rcs(void)
1141 char *result = strdup("");
1142 char buf[BUFFER_SIZE];
1144 /* Instead of including *all* dot h's in the project (thus creating a
1145 * tremendous amount of dependencies), I will concede to declaring them
1146 * as extern's. This forces the developer to add to this list, but oh well.
1149 #define SHOW_RCS(__x) \
1151 extern const char __x[]; \
1152 sprintf(buf, "%s\n", __x); \
1153 string_append(&result, buf); \
1156 /* In alphabetical order */
1157 SHOW_RCS(actions_h_rcs)
1158 SHOW_RCS(actions_rcs)
1161 #ifdef FEATURE_CGI_EDIT_ACTIONS
1162 SHOW_RCS(cgiedit_h_rcs)
1163 SHOW_RCS(cgiedit_rcs)
1164 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1165 SHOW_RCS(cgisimple_h_rcs)
1166 SHOW_RCS(cgisimple_rcs)
1168 SHOW_RCS(cygwin_h_rcs)
1170 SHOW_RCS(deanimate_h_rcs)
1171 SHOW_RCS(deanimate_rcs)
1172 SHOW_RCS(encode_h_rcs)
1173 SHOW_RCS(encode_rcs)
1174 SHOW_RCS(errlog_h_rcs)
1175 SHOW_RCS(errlog_rcs)
1176 SHOW_RCS(filters_h_rcs)
1177 SHOW_RCS(filters_rcs)
1178 SHOW_RCS(gateway_h_rcs)
1179 SHOW_RCS(gateway_rcs)
1181 SHOW_RCS(gnu_regex_h_rcs)
1182 SHOW_RCS(gnu_regex_rcs)
1183 #endif /* def GNU_REGEX */
1184 SHOW_RCS(jbsockets_h_rcs)
1185 SHOW_RCS(jbsockets_rcs)
1188 #ifdef FEATURE_KILL_POPUPS
1189 SHOW_RCS(killpopup_h_rcs)
1190 SHOW_RCS(killpopup_rcs)
1191 #endif /* def FEATURE_KILL_POPUPS */
1192 SHOW_RCS(list_h_rcs)
1194 SHOW_RCS(loadcfg_h_rcs)
1195 SHOW_RCS(loadcfg_rcs)
1196 SHOW_RCS(loaders_h_rcs)
1197 SHOW_RCS(loaders_rcs)
1198 SHOW_RCS(miscutil_h_rcs)
1199 SHOW_RCS(miscutil_rcs)
1200 SHOW_RCS(parsers_h_rcs)
1201 SHOW_RCS(parsers_rcs)
1203 SHOW_RCS(pcrs_h_rcs)
1204 SHOW_RCS(project_h_rcs)
1205 SHOW_RCS(ssplit_h_rcs)
1206 SHOW_RCS(ssplit_rcs)
1207 SHOW_RCS(urlmatch_h_rcs)
1208 SHOW_RCS(urlmatch_rcs)
1210 #ifndef _WIN_CONSOLE
1211 SHOW_RCS(w32log_h_rcs)
1212 SHOW_RCS(w32log_rcs)
1213 SHOW_RCS(w32res_h_rcs)
1214 SHOW_RCS(w32taskbar_h_rcs)
1215 SHOW_RCS(w32taskbar_rcs)
1216 #endif /* ndef _WIN_CONSOLE */
1217 SHOW_RCS(win32_h_rcs)
1219 #endif /* def _WIN32 */