1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.13 2002/02/21 00:10:37 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.13 2002/02/21 00:10:37 jongfoster
40 * Adding send-banner?type=auto option
42 * Revision 1.12 2002/01/23 01:03:32 jongfoster
43 * Fixing gcc [CygWin] compiler warnings
45 * Revision 1.11 2002/01/23 00:01:04 jongfoster
46 * Adding cgi_transparent_gif() for http://i.j.b/t
47 * Adding missing html_encode() to many CGI functions.
48 * Adding urlmatch.[ch] to http://i.j.b/show-version
50 * Revision 1.10 2002/01/17 21:10:37 jongfoster
51 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
52 * Also fixing a problem in the same function with improperly quoted URLs
53 * in output HTML, and adding code to handle https:// URLs correctly.
55 * Revision 1.9 2001/11/30 23:09:15 jongfoster
56 * Now reports on FEATURE_CGI_EDIT_ACTIONS
57 * Removing FEATURE_DENY_GZIP from template
59 * Revision 1.8 2001/11/13 00:14:07 jongfoster
60 * Fixing stupid bug now I've figured out what || means.
61 * (It always returns 0 or 1, not one of it's paramaters.)
63 * Revision 1.7 2001/10/23 21:48:19 jongfoster
64 * Cleaning up error handling in CGI functions - they now send back
65 * a HTML error page and should never cause a FATAL error. (Fixes one
66 * potential source of "denial of service" attacks).
68 * CGI actions file editor that works and is actually useful.
70 * Ability to toggle JunkBuster remotely using a CGI call.
72 * You can turn off both the above features in the main configuration
73 * file, e.g. if you are running a multi-user proxy.
75 * Revision 1.6 2001/10/14 22:00:32 jongfoster
76 * Adding support for a 404 error when an invalid CGI page is requested.
78 * Revision 1.5 2001/10/07 15:30:41 oes
79 * Removed FEATURE_DENY_GZIP
81 * Revision 1.4 2001/10/02 15:31:12 oes
82 * Introduced show-request cgi
84 * Revision 1.3 2001/09/22 16:34:44 jongfoster
85 * Removing unneeded #includes
87 * Revision 1.2 2001/09/19 18:01:11 oes
88 * Fixed comments; cosmetics
90 * Revision 1.1 2001/09/16 17:08:54 jongfoster
91 * Moving simple CGI functions from cgi.c to new file cgisimple.c
94 **********************************************************************/
100 #include <sys/types.h>
107 #define snprintf _snprintf
108 #endif /* def _WIN32 */
112 #include "cgisimple.h"
118 #include "miscutil.h"
121 #include "urlmatch.h"
123 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
126 static char *show_rcs(void);
127 static jb_err show_defines(struct map *exports);
130 /*********************************************************************
132 * Function : cgi_default
134 * Description : CGI function that is called if no action was given.
135 * Lists menu of available unhidden CGIs.
138 * 1 : csp = Current client state (buffers, headers, etc...)
139 * 2 : rsp = http_response data structure for output
140 * 3 : parameters = map of cgi parameters
142 * CGI Parameters : none
144 * Returns : JB_ERR_OK on success
145 * JB_ERR_MEMORY on out-of-memory
146 * (Problems other than out-of-memory should be
147 * handled by this routine - it should set the
148 * rsp appropriately and return "success")
150 *********************************************************************/
151 jb_err cgi_default(struct client_state *csp,
152 struct http_response *rsp,
153 const struct map *parameters)
162 if (NULL == (exports = default_exports(csp, "")))
164 return JB_ERR_MEMORY;
167 /* If there were other parameters, export a dump as "cgi-parameters" */
168 if (parameters->first)
170 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
171 "Anyway, here they are, in case you're interested:</p>\n");
172 string_join(&tmp, dump_map(parameters));
176 return JB_ERR_MEMORY;
178 if (map(exports, "cgi-parameters", 1, tmp, 0))
180 return JB_ERR_MEMORY;
185 if (map(exports, "cgi-parameters", 1, "", 1))
187 return JB_ERR_MEMORY;
191 return template_fill_for_cgi(csp, "default", exports, rsp);
197 /*********************************************************************
199 * Function : cgi_error_404
201 * Description : CGI function that is called if an unknown action was
205 * 1 : csp = Current client state (buffers, headers, etc...)
206 * 2 : rsp = http_response data structure for output
207 * 3 : parameters = map of cgi parameters
209 * CGI Parameters : none
211 * Returns : JB_ERR_OK on success
212 * JB_ERR_MEMORY on out-of-memory error.
214 *********************************************************************/
215 jb_err cgi_error_404(struct client_state *csp,
216 struct http_response *rsp,
217 const struct map *parameters)
225 if (NULL == (exports = default_exports(csp, NULL)))
227 return JB_ERR_MEMORY;
230 rsp->status = strdup("404 JunkBuster configuration page not found");
231 if (rsp->status == NULL)
234 return JB_ERR_MEMORY;
237 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
241 /*********************************************************************
243 * Function : cgi_show_request
245 * Description : Show the client's request and what sed() would have
249 * 1 : csp = Current client state (buffers, headers, etc...)
250 * 2 : rsp = http_response data structure for output
251 * 3 : parameters = map of cgi parameters
253 * CGI Parameters : none
255 * Returns : JB_ERR_OK on success
256 * JB_ERR_MEMORY on out-of-memory error.
258 *********************************************************************/
259 jb_err cgi_show_request(struct client_state *csp,
260 struct http_response *rsp,
261 const struct map *parameters)
270 if (NULL == (exports = default_exports(csp, "show-request")))
272 return JB_ERR_MEMORY;
276 * Repair the damage done to the IOB by get_header()
278 for (p = csp->iob->buf; p < csp->iob->eod; p++)
280 if (*p == '\0') *p = '\n';
284 * Export the original client's request and the one we would
285 * be sending to the server if this wasn't a CGI call
288 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
291 return JB_ERR_MEMORY;
294 if (map(exports, "processed-request", 1, html_encode_and_free_original(
295 sed(client_patterns, add_client_headers, csp)), 0))
298 return JB_ERR_MEMORY;
301 return template_fill_for_cgi(csp, "show-request", exports, rsp);
305 /*********************************************************************
307 * Function : cgi_send_banner
309 * Description : CGI function that returns a banner.
312 * 1 : csp = Current client state (buffers, headers, etc...)
313 * 2 : rsp = http_response data structure for output
314 * 3 : parameters = map of cgi parameters
317 * type : Selects the type of banner between "trans", "logo",
318 * and "auto". Defaults to "logo" if absent or invalid.
319 * "auto" means to select as if we were image-blocking.
320 * (Only the first character really counts).
322 * Returns : JB_ERR_OK on success
323 * JB_ERR_MEMORY on out-of-memory error.
325 *********************************************************************/
326 jb_err cgi_send_banner(struct client_state *csp,
327 struct http_response *rsp,
328 const struct map *parameters)
330 char imagetype = lookup(parameters, "type")[0];
332 if (imagetype == 'a') /* auto */
334 /* Default to logo */
336 #ifdef FEATURE_IMAGE_BLOCKING
337 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
339 /* determine HOW images should be blocked */
340 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
342 /* and handle accordingly: */
343 if ((p != NULL) && (0 == strcmpic(p, "blank")))
348 #endif /* def FEATURE_IMAGE_BLOCKING */
351 if ((imagetype != 't') && (imagetype != 'b')) /* transparant/blank */
353 rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length);
354 rsp->content_length = image_junkbuster_gif_length;
358 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
359 rsp->content_length = image_blank_gif_length;
362 if (rsp->body == NULL)
364 return JB_ERR_MEMORY;
367 if (enlist(rsp->headers, "Content-Type: image/gif"))
369 return JB_ERR_MEMORY;
379 /*********************************************************************
381 * Function : cgi_transparent_gif
383 * Description : CGI function that sends a 1x1 transparent GIF.
386 * 1 : csp = Current client state (buffers, headers, etc...)
387 * 2 : rsp = http_response data structure for output
388 * 3 : parameters = map of cgi parameters
390 * CGI Parameters : None
392 * Returns : JB_ERR_OK on success
393 * JB_ERR_MEMORY on out-of-memory error.
395 *********************************************************************/
396 jb_err cgi_transparent_gif(struct client_state *csp,
397 struct http_response *rsp,
398 const struct map *parameters)
400 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
401 rsp->content_length = image_blank_gif_length;
403 if (rsp->body == NULL)
405 return JB_ERR_MEMORY;
408 if (enlist(rsp->headers, "Content-Type: image/gif"))
410 return JB_ERR_MEMORY;
420 /*********************************************************************
422 * Function : cgi_show_version
424 * Description : CGI function that returns a a web page describing the
425 * file versions of IJB.
428 * 1 : csp = Current client state (buffers, headers, etc...)
429 * 2 : rsp = http_response data structure for output
430 * 3 : parameters = map of cgi parameters
432 * CGI Parameters : none
434 * Returns : JB_ERR_OK on success
435 * JB_ERR_MEMORY on out-of-memory error.
437 *********************************************************************/
438 jb_err cgi_show_version(struct client_state *csp,
439 struct http_response *rsp,
440 const struct map *parameters)
448 if (NULL == (exports = default_exports(csp, "show-version")))
450 return JB_ERR_MEMORY;
453 if (map(exports, "sourceversions", 1, show_rcs(), 0))
456 return JB_ERR_MEMORY;
459 return template_fill_for_cgi(csp, "show-version", exports, rsp);
463 /*********************************************************************
465 * Function : cgi_show_status
467 * Description : CGI function that returns a a web page describing the
468 * current status of IJB.
471 * 1 : csp = Current client state (buffers, headers, etc...)
472 * 2 : rsp = http_response data structure for output
473 * 3 : parameters = map of cgi parameters
476 * file : Which file to show. Only first letter is checked,
478 * - "p"ermissions (actions) file
481 * Default is to show menu and other information.
483 * Returns : JB_ERR_OK on success
484 * JB_ERR_MEMORY on out-of-memory error.
486 *********************************************************************/
487 jb_err cgi_show_status(struct client_state *csp,
488 struct http_response *rsp,
489 const struct map *parameters)
495 char buf[BUFFER_SIZE];
496 const char * filename = NULL;
497 char * file_description = NULL;
498 #ifdef FEATURE_STATISTICS
499 float perc_rej; /* Percentage of http requests rejected */
501 int local_urls_rejected;
502 #endif /* ndef FEATURE_STATISTICS */
511 if (NULL == (exports = default_exports(csp, "show-status")))
513 return JB_ERR_MEMORY;
516 switch (*(lookup(parameters, "file")))
519 if (csp->actions_list)
521 filename = csp->actions_list->filename;
522 file_description = "Actions List";
529 filename = csp->rlist->filename;
530 file_description = "Regex Filter List";
538 filename = csp->tlist->filename;
539 file_description = "Trust List";
542 #endif /* def FEATURE_TRUST */
545 if (NULL != filename)
547 if ( map(exports, "file-description", 1, file_description, 1)
548 || map(exports, "filepath", 1, html_encode(filename), 0) )
551 return JB_ERR_MEMORY;
554 if ((fp = fopen(filename, "r")) == NULL)
556 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
559 return JB_ERR_MEMORY;
565 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
567 string_join (&s, html_encode(buf));
568 string_append(&s, "<br>");
572 if (map(exports, "contents", 1, s, 0))
575 return JB_ERR_MEMORY;
579 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
582 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
585 return JB_ERR_MEMORY;
589 for (i = 0; (s != NULL) && (i < Argc); i++)
591 string_join (&s, html_encode(Argv[i]));
592 string_append(&s, " ");
594 if (map(exports, "invocation", 1, s, 0))
597 return JB_ERR_MEMORY;
600 err = map(exports, "options", 1, csp->config->proxy_args, 1);
601 if (!err) err = show_defines(exports);
603 #ifdef FEATURE_STATISTICS
604 local_urls_read = urls_read;
605 local_urls_rejected = urls_rejected;
608 * Need to alter the stats not to include the fetch of this
611 * Can't do following thread safely! doh!
614 * urls_rejected--; * This will be incremented subsequently *
617 if (local_urls_read == 0)
619 if (!err) err = map_block_killer(exports, "have-stats");
623 if (!err) err = map_block_killer(exports, "have-no-stats");
625 perc_rej = (float)local_urls_rejected * 100.0F /
626 (float)local_urls_read;
628 sprintf(buf, "%d", local_urls_read);
629 if (!err) err = map(exports, "requests-received", 1, buf, 1);
631 sprintf(buf, "%d", local_urls_rejected);
632 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
634 sprintf(buf, "%6.2f", perc_rej);
635 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
638 #else /* ndef FEATURE_STATISTICS */
639 err = err || map_block_killer(exports, "statistics");
640 #endif /* ndef FEATURE_STATISTICS */
642 if (csp->actions_list)
644 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
648 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
653 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
657 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
663 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
667 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
670 if (!err) err = map_block_killer(exports, "trust-support");
671 #endif /* ndef FEATURE_TRUST */
676 return JB_ERR_MEMORY;
679 return template_fill_for_cgi(csp, "show-status", exports, rsp);
683 /*********************************************************************
685 * Function : cgi_show_url_info
687 * Description : CGI function that determines and shows which actions
688 * junkbuster will perform for a given url, and which
689 * matches starting from the defaults have lead to that.
692 * 1 : csp = Current client state (buffers, headers, etc...)
693 * 2 : rsp = http_response data structure for output
694 * 3 : parameters = map of cgi parameters
697 * url : The url whose actions are to be determined.
698 * If url is unset, the url-given conditional will be
699 * set, so that all but the form can be suppressed in
702 * Returns : JB_ERR_OK on success
703 * JB_ERR_MEMORY on out-of-memory error.
705 *********************************************************************/
706 jb_err cgi_show_url_info(struct client_state *csp,
707 struct http_response *rsp,
708 const struct map *parameters)
717 if (NULL == (exports = default_exports(csp, "show-url-info")))
719 return JB_ERR_MEMORY;
723 * Get the url= parameter (if present) and remove any leading/trailing spaces.
725 url_param = strdup(lookup(parameters, "url"));
726 if (url_param == NULL)
729 return JB_ERR_MEMORY;
734 * Handle prefixes. 4 possibilities:
735 * 1) "http://" or "https://" prefix present and followed by URL - OK
736 * 2) Only the "http://" or "https://" part is present, no URL - change
737 * to empty string so it will be detected later as "no URL".
738 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
740 * 4) Parameter not specified or is empty string - let this fall through
741 * for now, next block of code will handle it.
743 if (0 == strncmp(url_param, "http://", 7))
745 if (url_param[7] == '\0')
748 * Empty URL (just prefix).
749 * Make it totally empty so it's caught by the next if()
754 else if (0 == strncmp(url_param, "https://", 8))
756 if (url_param[8] == '\0')
759 * Empty URL (just prefix).
760 * Make it totally empty so it's caught by the next if()
765 else if (url_param[0] != '\0')
768 * Unknown prefix - assume http://
770 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
771 if (NULL == url_param_prefixed)
775 return JB_ERR_MEMORY;
777 strcpy(url_param_prefixed, "http://");
778 strcpy(url_param_prefixed + 7, url_param);
780 url_param = url_param_prefixed;
784 if (url_param[0] == '\0')
786 /* URL paramater not specified, display query form only. */
788 if (map_block_killer(exports, "url-given")
789 || map(exports, "url", 1, "", 1))
792 return JB_ERR_MEMORY;
797 /* Given a URL, so query it. */
802 struct file_list *fl;
803 struct url_actions *b;
804 struct http_request url_to_query[1];
805 struct current_action_spec action[1];
807 if (map(exports, "url", 1, html_encode(url_param), 0))
811 return JB_ERR_MEMORY;
814 init_current_action(action);
816 if (map(exports, "default", 1, html_encode_and_free_original(
817 current_action_to_text(action)), 0))
819 free_current_action(action);
822 return JB_ERR_MEMORY;
825 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
827 err = map(exports, "matches", 1, "none" , 1);
828 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
830 free_current_action(action);
836 return JB_ERR_MEMORY;
839 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
842 err = parse_http_url(url_param, url_to_query, csp);
846 if (err == JB_ERR_MEMORY)
848 free_current_action(action);
850 return JB_ERR_MEMORY;
856 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
857 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
859 free_current_action(action);
864 return JB_ERR_MEMORY;
867 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
871 * We have a warning about SSL paths. Hide it for insecure sites.
873 if (!url_to_query->ssl)
875 if (map_block_killer(exports, "https"))
877 free_current_action(action);
879 return JB_ERR_MEMORY;
883 matches = strdup("");
885 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
887 if (url_match(b->url, url_to_query))
889 string_append(&matches, "<b>{");
890 string_join (&matches, html_encode_and_free_original(
891 actions_to_text(b->action)));
892 string_append(&matches, " }</b><br>\n<code>");
893 string_join (&matches, html_encode(b->url->spec));
894 string_append(&matches, "</code><br>\n<br>\n");
896 if (merge_current_action(action, b->action))
899 free_http_request(url_to_query);
900 free_current_action(action);
902 return JB_ERR_MEMORY;
908 free_http_request(url_to_query);
912 free_current_action(action);
914 return JB_ERR_MEMORY;
920 matches = strdup("none");
922 if (map(exports, "matches", 1, matches , 0))
924 free_current_action(action);
926 return JB_ERR_MEMORY;
929 s = html_encode_and_free_original(current_action_to_text(action));
931 free_current_action(action);
933 if (map(exports, "final", 1, s, 0))
936 return JB_ERR_MEMORY;
940 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
944 /*********************************************************************
946 * Function : cgi_robots_txt
948 * Description : CGI function to return "/robots.txt".
951 * 1 : csp = Current client state (buffers, headers, etc...)
952 * 2 : rsp = http_response data structure for output
953 * 3 : parameters = map of cgi parameters
955 * CGI Parameters : None
957 * Returns : JB_ERR_OK on success
958 * JB_ERR_MEMORY on out-of-memory error.
960 *********************************************************************/
961 jb_err cgi_robots_txt(struct client_state *csp,
962 struct http_response *rsp,
963 const struct map *parameters)
969 "# This is the Internet Junkbuster control interface.\n"
970 "# It isn't very useful to index it, and you're likely to break stuff.\n"
976 if (rsp->body == NULL)
978 return JB_ERR_MEMORY;
981 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
985 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
986 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
988 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
992 /*********************************************************************
994 * Function : show_defines
996 * Description : Add to a map the state od all conditional #defines
1000 * 1 : exports = map to extend
1002 * Returns : JB_ERR_OK on success
1003 * JB_ERR_MEMORY on out-of-memory error.
1005 *********************************************************************/
1006 static jb_err show_defines(struct map *exports)
1008 jb_err err = JB_ERR_OK;
1011 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1012 #else /* ifndef FEATURE_ACL */
1013 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1014 #endif /* ndef FEATURE_ACL */
1016 #ifdef FEATURE_CGI_EDIT_ACTIONS
1017 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1018 #else /* ifndef FEATURE_COOKIE_JAR */
1019 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1020 #endif /* ndef FEATURE_COOKIE_JAR */
1022 #ifdef FEATURE_COOKIE_JAR
1023 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1024 #else /* ifndef FEATURE_COOKIE_JAR */
1025 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1026 #endif /* ndef FEATURE_COOKIE_JAR */
1028 #ifdef FEATURE_FAST_REDIRECTS
1029 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1030 #else /* ifndef FEATURE_FAST_REDIRECTS */
1031 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1032 #endif /* ndef FEATURE_FAST_REDIRECTS */
1034 #ifdef FEATURE_FORCE_LOAD
1035 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1036 #else /* ifndef FEATURE_FORCE_LOAD */
1037 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1038 #endif /* ndef FEATURE_FORCE_LOAD */
1040 #ifdef FEATURE_IMAGE_BLOCKING
1041 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1042 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1043 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1044 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1046 #ifdef FEATURE_IMAGE_DETECT_MSIE
1047 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1048 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1049 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1050 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1052 #ifdef FEATURE_KILL_POPUPS
1053 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1054 #else /* ifndef FEATURE_KILL_POPUPS */
1055 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1056 #endif /* ndef FEATURE_KILL_POPUPS */
1058 #ifdef FEATURE_PTHREAD
1059 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1060 #else /* ifndef FEATURE_PTHREAD */
1061 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1062 #endif /* ndef FEATURE_PTHREAD */
1064 #ifdef FEATURE_STATISTICS
1065 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1066 #else /* ifndef FEATURE_STATISTICS */
1067 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1068 #endif /* ndef FEATURE_STATISTICS */
1070 #ifdef FEATURE_TOGGLE
1071 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1072 #else /* ifndef FEATURE_TOGGLE */
1073 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1074 #endif /* ndef FEATURE_TOGGLE */
1076 #ifdef FEATURE_TRUST
1077 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1078 #else /* ifndef FEATURE_TRUST */
1079 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1080 #endif /* ndef FEATURE_TRUST */
1083 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1084 #else /* ifndef REGEX_GNU */
1085 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1086 #endif /* def REGEX_GNU */
1089 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1090 #else /* ifndef REGEX_PCRE */
1091 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1092 #endif /* def REGEX_PCRE */
1095 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1096 #else /* ifndef STATIC_PCRE */
1097 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1098 #endif /* ndef STATIC_PCRE */
1101 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1102 #else /* ifndef STATIC_PCRS */
1103 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1104 #endif /* ndef STATIC_PCRS */
1106 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1112 /*********************************************************************
1114 * Function : show_rcs
1116 * Description : Create a string with the rcs info for all sourcefiles
1120 * Returns : A string, or NULL on out-of-memory.
1122 *********************************************************************/
1123 static char *show_rcs(void)
1125 char *result = strdup("");
1126 char buf[BUFFER_SIZE];
1128 /* Instead of including *all* dot h's in the project (thus creating a
1129 * tremendous amount of dependencies), I will concede to declaring them
1130 * as extern's. This forces the developer to add to this list, but oh well.
1133 #define SHOW_RCS(__x) \
1135 extern const char __x[]; \
1136 sprintf(buf, "%s\n", __x); \
1137 string_append(&result, buf); \
1140 /* In alphabetical order */
1141 SHOW_RCS(actions_h_rcs)
1142 SHOW_RCS(actions_rcs)
1145 #ifdef FEATURE_CGI_EDIT_ACTIONS
1146 SHOW_RCS(cgiedit_h_rcs)
1147 SHOW_RCS(cgiedit_rcs)
1148 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1149 SHOW_RCS(cgisimple_h_rcs)
1150 SHOW_RCS(cgisimple_rcs)
1152 SHOW_RCS(cygwin_h_rcs)
1154 SHOW_RCS(deanimate_h_rcs)
1155 SHOW_RCS(deanimate_rcs)
1156 SHOW_RCS(encode_h_rcs)
1157 SHOW_RCS(encode_rcs)
1158 SHOW_RCS(errlog_h_rcs)
1159 SHOW_RCS(errlog_rcs)
1160 SHOW_RCS(filters_h_rcs)
1161 SHOW_RCS(filters_rcs)
1162 SHOW_RCS(gateway_h_rcs)
1163 SHOW_RCS(gateway_rcs)
1165 SHOW_RCS(gnu_regex_h_rcs)
1166 SHOW_RCS(gnu_regex_rcs)
1167 #endif /* def GNU_REGEX */
1168 SHOW_RCS(jbsockets_h_rcs)
1169 SHOW_RCS(jbsockets_rcs)
1172 #ifdef FEATURE_KILL_POPUPS
1173 SHOW_RCS(killpopup_h_rcs)
1174 SHOW_RCS(killpopup_rcs)
1175 #endif /* def FEATURE_KILL_POPUPS */
1176 SHOW_RCS(list_h_rcs)
1178 SHOW_RCS(loadcfg_h_rcs)
1179 SHOW_RCS(loadcfg_rcs)
1180 SHOW_RCS(loaders_h_rcs)
1181 SHOW_RCS(loaders_rcs)
1182 SHOW_RCS(miscutil_h_rcs)
1183 SHOW_RCS(miscutil_rcs)
1184 SHOW_RCS(parsers_h_rcs)
1185 SHOW_RCS(parsers_rcs)
1187 SHOW_RCS(pcrs_h_rcs)
1188 SHOW_RCS(project_h_rcs)
1189 SHOW_RCS(ssplit_h_rcs)
1190 SHOW_RCS(ssplit_rcs)
1191 SHOW_RCS(urlmatch_h_rcs)
1192 SHOW_RCS(urlmatch_rcs)
1194 #ifndef _WIN_CONSOLE
1195 SHOW_RCS(w32log_h_rcs)
1196 SHOW_RCS(w32log_rcs)
1197 SHOW_RCS(w32res_h_rcs)
1198 SHOW_RCS(w32taskbar_h_rcs)
1199 SHOW_RCS(w32taskbar_rcs)
1200 #endif /* ndef _WIN_CONSOLE */
1201 SHOW_RCS(win32_h_rcs)
1203 #endif /* def _WIN32 */