1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.12 2002/01/23 01:03:32 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.12 2002/01/23 01:03:32 jongfoster
40 * Fixing gcc [CygWin] compiler warnings
42 * Revision 1.11 2002/01/23 00:01:04 jongfoster
43 * Adding cgi_transparent_gif() for http://i.j.b/t
44 * Adding missing html_encode() to many CGI functions.
45 * Adding urlmatch.[ch] to http://i.j.b/show-version
47 * Revision 1.10 2002/01/17 21:10:37 jongfoster
48 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
49 * Also fixing a problem in the same function with improperly quoted URLs
50 * in output HTML, and adding code to handle https:// URLs correctly.
52 * Revision 1.9 2001/11/30 23:09:15 jongfoster
53 * Now reports on FEATURE_CGI_EDIT_ACTIONS
54 * Removing FEATURE_DENY_GZIP from template
56 * Revision 1.8 2001/11/13 00:14:07 jongfoster
57 * Fixing stupid bug now I've figured out what || means.
58 * (It always returns 0 or 1, not one of it's paramaters.)
60 * Revision 1.7 2001/10/23 21:48:19 jongfoster
61 * Cleaning up error handling in CGI functions - they now send back
62 * a HTML error page and should never cause a FATAL error. (Fixes one
63 * potential source of "denial of service" attacks).
65 * CGI actions file editor that works and is actually useful.
67 * Ability to toggle JunkBuster remotely using a CGI call.
69 * You can turn off both the above features in the main configuration
70 * file, e.g. if you are running a multi-user proxy.
72 * Revision 1.6 2001/10/14 22:00:32 jongfoster
73 * Adding support for a 404 error when an invalid CGI page is requested.
75 * Revision 1.5 2001/10/07 15:30:41 oes
76 * Removed FEATURE_DENY_GZIP
78 * Revision 1.4 2001/10/02 15:31:12 oes
79 * Introduced show-request cgi
81 * Revision 1.3 2001/09/22 16:34:44 jongfoster
82 * Removing unneeded #includes
84 * Revision 1.2 2001/09/19 18:01:11 oes
85 * Fixed comments; cosmetics
87 * Revision 1.1 2001/09/16 17:08:54 jongfoster
88 * Moving simple CGI functions from cgi.c to new file cgisimple.c
91 **********************************************************************/
97 #include <sys/types.h>
104 #define snprintf _snprintf
105 #endif /* def _WIN32 */
109 #include "cgisimple.h"
115 #include "miscutil.h"
118 #include "urlmatch.h"
120 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
123 static char *show_rcs(void);
124 static jb_err show_defines(struct map *exports);
127 /*********************************************************************
129 * Function : cgi_default
131 * Description : CGI function that is called if no action was given.
132 * Lists menu of available unhidden CGIs.
135 * 1 : csp = Current client state (buffers, headers, etc...)
136 * 2 : rsp = http_response data structure for output
137 * 3 : parameters = map of cgi parameters
139 * CGI Parameters : none
141 * Returns : JB_ERR_OK on success
142 * JB_ERR_MEMORY on out-of-memory
143 * (Problems other than out-of-memory should be
144 * handled by this routine - it should set the
145 * rsp appropriately and return "success")
147 *********************************************************************/
148 jb_err cgi_default(struct client_state *csp,
149 struct http_response *rsp,
150 const struct map *parameters)
159 if (NULL == (exports = default_exports(csp, "")))
161 return JB_ERR_MEMORY;
164 /* If there were other parameters, export a dump as "cgi-parameters" */
165 if (parameters->first)
167 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
168 "Anyway, here they are, in case you're interested:</p>\n");
169 string_join(&tmp, dump_map(parameters));
173 return JB_ERR_MEMORY;
175 if (map(exports, "cgi-parameters", 1, tmp, 0))
177 return JB_ERR_MEMORY;
182 if (map(exports, "cgi-parameters", 1, "", 1))
184 return JB_ERR_MEMORY;
188 return template_fill_for_cgi(csp, "default", exports, rsp);
194 /*********************************************************************
196 * Function : cgi_error_404
198 * Description : CGI function that is called if an unknown action was
202 * 1 : csp = Current client state (buffers, headers, etc...)
203 * 2 : rsp = http_response data structure for output
204 * 3 : parameters = map of cgi parameters
206 * CGI Parameters : none
208 * Returns : JB_ERR_OK on success
209 * JB_ERR_MEMORY on out-of-memory error.
211 *********************************************************************/
212 jb_err cgi_error_404(struct client_state *csp,
213 struct http_response *rsp,
214 const struct map *parameters)
222 if (NULL == (exports = default_exports(csp, NULL)))
224 return JB_ERR_MEMORY;
227 rsp->status = strdup("404 JunkBuster configuration page not found");
228 if (rsp->status == NULL)
231 return JB_ERR_MEMORY;
234 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
238 /*********************************************************************
240 * Function : cgi_show_request
242 * Description : Show the client's request and what sed() would have
246 * 1 : csp = Current client state (buffers, headers, etc...)
247 * 2 : rsp = http_response data structure for output
248 * 3 : parameters = map of cgi parameters
250 * CGI Parameters : none
252 * Returns : JB_ERR_OK on success
253 * JB_ERR_MEMORY on out-of-memory error.
255 *********************************************************************/
256 jb_err cgi_show_request(struct client_state *csp,
257 struct http_response *rsp,
258 const struct map *parameters)
267 if (NULL == (exports = default_exports(csp, "show-request")))
269 return JB_ERR_MEMORY;
273 * Repair the damage done to the IOB by get_header()
275 for (p = csp->iob->buf; p < csp->iob->eod; p++)
277 if (*p == '\0') *p = '\n';
281 * Export the original client's request and the one we would
282 * be sending to the server if this wasn't a CGI call
285 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
288 return JB_ERR_MEMORY;
291 if (map(exports, "processed-request", 1, html_encode_and_free_original(
292 sed(client_patterns, add_client_headers, csp)), 0))
295 return JB_ERR_MEMORY;
298 return template_fill_for_cgi(csp, "show-request", exports, rsp);
302 /*********************************************************************
304 * Function : cgi_send_banner
306 * Description : CGI function that returns a banner.
309 * 1 : csp = Current client state (buffers, headers, etc...)
310 * 2 : rsp = http_response data structure for output
311 * 3 : parameters = map of cgi parameters
314 * type : Selects the type of banner between "trans", "logo",
315 * and "auto". Defaults to "logo" if absent or invalid.
\r
316 * "auto" means to select as if we were image-blocking.
\r
317 * (Only the first character really counts).
319 * Returns : JB_ERR_OK on success
320 * JB_ERR_MEMORY on out-of-memory error.
322 *********************************************************************/
323 jb_err cgi_send_banner(struct client_state *csp,
324 struct http_response *rsp,
325 const struct map *parameters)
327 char imagetype = lookup(parameters, "type")[0];
329 if (imagetype == 'a') /* auto */
\r
331 /* Default to logo */
\r
333 #ifdef FEATURE_IMAGE_BLOCKING
\r
334 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
\r
336 /* determine HOW images should be blocked */
\r
337 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
\r
339 /* and handle accordingly: */
\r
340 if ((p != NULL) && (0 == strcmpic(p, "blank")))
\r
345 #endif /* def FEATURE_IMAGE_BLOCKING */
\r
348 if ((imagetype != 't') && (imagetype != 'b')) /* transparant/blank */
350 rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length);
351 rsp->content_length = image_junkbuster_gif_length;
355 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
356 rsp->content_length = image_blank_gif_length;
359 if (rsp->body == NULL)
361 return JB_ERR_MEMORY;
364 if (enlist(rsp->headers, "Content-Type: image/gif"))
366 return JB_ERR_MEMORY;
376 /*********************************************************************
378 * Function : cgi_transparent_gif
380 * Description : CGI function that sends a 1x1 transparent GIF.
383 * 1 : csp = Current client state (buffers, headers, etc...)
384 * 2 : rsp = http_response data structure for output
385 * 3 : parameters = map of cgi parameters
387 * CGI Parameters : None
389 * Returns : JB_ERR_OK on success
390 * JB_ERR_MEMORY on out-of-memory error.
392 *********************************************************************/
393 jb_err cgi_transparent_gif(struct client_state *csp,
394 struct http_response *rsp,
395 const struct map *parameters)
397 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
398 rsp->content_length = image_blank_gif_length;
400 if (rsp->body == NULL)
402 return JB_ERR_MEMORY;
405 if (enlist(rsp->headers, "Content-Type: image/gif"))
407 return JB_ERR_MEMORY;
417 /*********************************************************************
419 * Function : cgi_show_version
421 * Description : CGI function that returns a a web page describing the
422 * file versions of IJB.
425 * 1 : csp = Current client state (buffers, headers, etc...)
426 * 2 : rsp = http_response data structure for output
427 * 3 : parameters = map of cgi parameters
429 * CGI Parameters : none
431 * Returns : JB_ERR_OK on success
432 * JB_ERR_MEMORY on out-of-memory error.
434 *********************************************************************/
435 jb_err cgi_show_version(struct client_state *csp,
436 struct http_response *rsp,
437 const struct map *parameters)
445 if (NULL == (exports = default_exports(csp, "show-version")))
447 return JB_ERR_MEMORY;
450 if (map(exports, "sourceversions", 1, show_rcs(), 0))
453 return JB_ERR_MEMORY;
456 return template_fill_for_cgi(csp, "show-version", exports, rsp);
460 /*********************************************************************
462 * Function : cgi_show_status
464 * Description : CGI function that returns a a web page describing the
465 * current status of IJB.
468 * 1 : csp = Current client state (buffers, headers, etc...)
469 * 2 : rsp = http_response data structure for output
470 * 3 : parameters = map of cgi parameters
473 * file : Which file to show. Only first letter is checked,
475 * - "p"ermissions (actions) file
478 * Default is to show menu and other information.
480 * Returns : JB_ERR_OK on success
481 * JB_ERR_MEMORY on out-of-memory error.
483 *********************************************************************/
484 jb_err cgi_show_status(struct client_state *csp,
485 struct http_response *rsp,
486 const struct map *parameters)
492 char buf[BUFFER_SIZE];
493 const char * filename = NULL;
494 char * file_description = NULL;
495 #ifdef FEATURE_STATISTICS
496 float perc_rej; /* Percentage of http requests rejected */
498 int local_urls_rejected;
499 #endif /* ndef FEATURE_STATISTICS */
508 if (NULL == (exports = default_exports(csp, "show-status")))
510 return JB_ERR_MEMORY;
513 switch (*(lookup(parameters, "file")))
516 if (csp->actions_list)
518 filename = csp->actions_list->filename;
519 file_description = "Actions List";
526 filename = csp->rlist->filename;
527 file_description = "Regex Filter List";
535 filename = csp->tlist->filename;
536 file_description = "Trust List";
539 #endif /* def FEATURE_TRUST */
542 if (NULL != filename)
544 if ( map(exports, "file-description", 1, file_description, 1)
545 || map(exports, "filepath", 1, html_encode(filename), 0) )
548 return JB_ERR_MEMORY;
551 if ((fp = fopen(filename, "r")) == NULL)
553 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
556 return JB_ERR_MEMORY;
562 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
564 string_join (&s, html_encode(buf));
565 string_append(&s, "<br>");
569 if (map(exports, "contents", 1, s, 0))
572 return JB_ERR_MEMORY;
576 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
579 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
582 return JB_ERR_MEMORY;
586 for (i = 0; (s != NULL) && (i < Argc); i++)
588 string_join (&s, html_encode(Argv[i]));
589 string_append(&s, " ");
591 if (map(exports, "invocation", 1, s, 0))
594 return JB_ERR_MEMORY;
597 err = map(exports, "options", 1, csp->config->proxy_args, 1);
598 if (!err) err = show_defines(exports);
600 #ifdef FEATURE_STATISTICS
601 local_urls_read = urls_read;
602 local_urls_rejected = urls_rejected;
605 * Need to alter the stats not to include the fetch of this
608 * Can't do following thread safely! doh!
611 * urls_rejected--; * This will be incremented subsequently *
614 if (local_urls_read == 0)
616 if (!err) err = map_block_killer(exports, "have-stats");
620 if (!err) err = map_block_killer(exports, "have-no-stats");
622 perc_rej = (float)local_urls_rejected * 100.0F /
623 (float)local_urls_read;
625 sprintf(buf, "%d", local_urls_read);
626 if (!err) err = map(exports, "requests-received", 1, buf, 1);
628 sprintf(buf, "%d", local_urls_rejected);
629 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
631 sprintf(buf, "%6.2f", perc_rej);
632 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
635 #else /* ndef FEATURE_STATISTICS */
636 err = err || map_block_killer(exports, "statistics");
637 #endif /* ndef FEATURE_STATISTICS */
639 if (csp->actions_list)
641 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
645 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
650 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
654 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
660 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
664 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
667 if (!err) err = map_block_killer(exports, "trust-support");
668 #endif /* ndef FEATURE_TRUST */
673 return JB_ERR_MEMORY;
676 return template_fill_for_cgi(csp, "show-status", exports, rsp);
680 /*********************************************************************
682 * Function : cgi_show_url_info
684 * Description : CGI function that determines and shows which actions
685 * junkbuster will perform for a given url, and which
686 * matches starting from the defaults have lead to that.
689 * 1 : csp = Current client state (buffers, headers, etc...)
690 * 2 : rsp = http_response data structure for output
691 * 3 : parameters = map of cgi parameters
694 * url : The url whose actions are to be determined.
695 * If url is unset, the url-given conditional will be
696 * set, so that all but the form can be suppressed in
699 * Returns : JB_ERR_OK on success
700 * JB_ERR_MEMORY on out-of-memory error.
702 *********************************************************************/
703 jb_err cgi_show_url_info(struct client_state *csp,
704 struct http_response *rsp,
705 const struct map *parameters)
714 if (NULL == (exports = default_exports(csp, "show-url-info")))
716 return JB_ERR_MEMORY;
720 * Get the url= parameter (if present) and remove any leading/trailing spaces.
722 url_param = strdup(lookup(parameters, "url"));
723 if (url_param == NULL)
726 return JB_ERR_MEMORY;
731 * Handle prefixes. 4 possibilities:
732 * 1) "http://" or "https://" prefix present and followed by URL - OK
733 * 2) Only the "http://" or "https://" part is present, no URL - change
734 * to empty string so it will be detected later as "no URL".
735 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
737 * 4) Parameter not specified or is empty string - let this fall through
738 * for now, next block of code will handle it.
740 if (0 == strncmp(url_param, "http://", 7))
742 if (url_param[7] == '\0')
745 * Empty URL (just prefix).
746 * Make it totally empty so it's caught by the next if()
751 else if (0 == strncmp(url_param, "https://", 8))
753 if (url_param[8] == '\0')
756 * Empty URL (just prefix).
757 * Make it totally empty so it's caught by the next if()
762 else if (url_param[0] != '\0')
765 * Unknown prefix - assume http://
767 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
768 if (NULL == url_param_prefixed)
772 return JB_ERR_MEMORY;
774 strcpy(url_param_prefixed, "http://");
775 strcpy(url_param_prefixed + 7, url_param);
777 url_param = url_param_prefixed;
781 if (url_param[0] == '\0')
783 /* URL paramater not specified, display query form only. */
785 if (map_block_killer(exports, "url-given")
786 || map(exports, "url", 1, "", 1))
789 return JB_ERR_MEMORY;
794 /* Given a URL, so query it. */
799 struct file_list *fl;
800 struct url_actions *b;
801 struct http_request url_to_query[1];
802 struct current_action_spec action[1];
804 if (map(exports, "url", 1, html_encode(url_param), 0))
808 return JB_ERR_MEMORY;
811 init_current_action(action);
813 if (map(exports, "default", 1, html_encode_and_free_original(
814 current_action_to_text(action)), 0))
816 free_current_action(action);
819 return JB_ERR_MEMORY;
822 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
824 err = map(exports, "matches", 1, "none" , 1);
825 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
827 free_current_action(action);
833 return JB_ERR_MEMORY;
836 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
839 err = parse_http_url(url_param, url_to_query, csp);
843 if (err == JB_ERR_MEMORY)
845 free_current_action(action);
847 return JB_ERR_MEMORY;
853 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
854 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
856 free_current_action(action);
861 return JB_ERR_MEMORY;
864 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
868 * We have a warning about SSL paths. Hide it for insecure sites.
870 if (!url_to_query->ssl)
872 if (map_block_killer(exports, "https"))
874 free_current_action(action);
876 return JB_ERR_MEMORY;
880 matches = strdup("");
882 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
884 if (url_match(b->url, url_to_query))
886 string_append(&matches, "<b>{");
887 string_join (&matches, html_encode_and_free_original(
888 actions_to_text(b->action)));
889 string_append(&matches, " }</b><br>\n<code>");
890 string_join (&matches, html_encode(b->url->spec));
891 string_append(&matches, "</code><br>\n<br>\n");
893 if (merge_current_action(action, b->action))
896 free_http_request(url_to_query);
897 free_current_action(action);
899 return JB_ERR_MEMORY;
905 free_http_request(url_to_query);
909 free_current_action(action);
911 return JB_ERR_MEMORY;
917 matches = strdup("none");
919 if (map(exports, "matches", 1, matches , 0))
921 free_current_action(action);
923 return JB_ERR_MEMORY;
926 s = html_encode_and_free_original(current_action_to_text(action));
928 free_current_action(action);
930 if (map(exports, "final", 1, s, 0))
933 return JB_ERR_MEMORY;
937 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
941 /*********************************************************************
943 * Function : cgi_robots_txt
945 * Description : CGI function to return "/robots.txt".
948 * 1 : csp = Current client state (buffers, headers, etc...)
949 * 2 : rsp = http_response data structure for output
950 * 3 : parameters = map of cgi parameters
952 * CGI Parameters : None
954 * Returns : JB_ERR_OK on success
955 * JB_ERR_MEMORY on out-of-memory error.
957 *********************************************************************/
958 jb_err cgi_robots_txt(struct client_state *csp,
959 struct http_response *rsp,
960 const struct map *parameters)
966 "# This is the Internet Junkbuster control interface.\n"
967 "# It isn't very useful to index it, and you're likely to break stuff.\n"
973 if (rsp->body == NULL)
975 return JB_ERR_MEMORY;
978 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
982 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
983 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
985 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
989 /*********************************************************************
991 * Function : show_defines
993 * Description : Add to a map the state od all conditional #defines
997 * 1 : exports = map to extend
999 * Returns : JB_ERR_OK on success
1000 * JB_ERR_MEMORY on out-of-memory error.
1002 *********************************************************************/
1003 static jb_err show_defines(struct map *exports)
1005 jb_err err = JB_ERR_OK;
1008 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1009 #else /* ifndef FEATURE_ACL */
1010 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1011 #endif /* ndef FEATURE_ACL */
1013 #ifdef FEATURE_CGI_EDIT_ACTIONS
1014 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1015 #else /* ifndef FEATURE_COOKIE_JAR */
1016 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1017 #endif /* ndef FEATURE_COOKIE_JAR */
1019 #ifdef FEATURE_COOKIE_JAR
1020 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1021 #else /* ifndef FEATURE_COOKIE_JAR */
1022 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1023 #endif /* ndef FEATURE_COOKIE_JAR */
1025 #ifdef FEATURE_FAST_REDIRECTS
1026 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1027 #else /* ifndef FEATURE_FAST_REDIRECTS */
1028 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1029 #endif /* ndef FEATURE_FAST_REDIRECTS */
1031 #ifdef FEATURE_FORCE_LOAD
1032 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1033 #else /* ifndef FEATURE_FORCE_LOAD */
1034 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1035 #endif /* ndef FEATURE_FORCE_LOAD */
1037 #ifdef FEATURE_IMAGE_BLOCKING
1038 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1039 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1040 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1041 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1043 #ifdef FEATURE_IMAGE_DETECT_MSIE
1044 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1045 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1046 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1047 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1049 #ifdef FEATURE_KILL_POPUPS
1050 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1051 #else /* ifndef FEATURE_KILL_POPUPS */
1052 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1053 #endif /* ndef FEATURE_KILL_POPUPS */
1055 #ifdef FEATURE_PTHREAD
1056 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1057 #else /* ifndef FEATURE_PTHREAD */
1058 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1059 #endif /* ndef FEATURE_PTHREAD */
1061 #ifdef FEATURE_STATISTICS
1062 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1063 #else /* ifndef FEATURE_STATISTICS */
1064 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1065 #endif /* ndef FEATURE_STATISTICS */
1067 #ifdef FEATURE_TOGGLE
1068 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1069 #else /* ifndef FEATURE_TOGGLE */
1070 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1071 #endif /* ndef FEATURE_TOGGLE */
1073 #ifdef FEATURE_TRUST
1074 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1075 #else /* ifndef FEATURE_TRUST */
1076 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1077 #endif /* ndef FEATURE_TRUST */
1080 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1081 #else /* ifndef REGEX_GNU */
1082 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1083 #endif /* def REGEX_GNU */
1086 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1087 #else /* ifndef REGEX_PCRE */
1088 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1089 #endif /* def REGEX_PCRE */
1092 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1093 #else /* ifndef STATIC_PCRE */
1094 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1095 #endif /* ndef STATIC_PCRE */
1098 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1099 #else /* ifndef STATIC_PCRS */
1100 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1101 #endif /* ndef STATIC_PCRS */
1103 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1109 /*********************************************************************
1111 * Function : show_rcs
1113 * Description : Create a string with the rcs info for all sourcefiles
1117 * Returns : A string, or NULL on out-of-memory.
1119 *********************************************************************/
1120 static char *show_rcs(void)
1122 char *result = strdup("");
1123 char buf[BUFFER_SIZE];
1125 /* Instead of including *all* dot h's in the project (thus creating a
1126 * tremendous amount of dependencies), I will concede to declaring them
1127 * as extern's. This forces the developer to add to this list, but oh well.
1130 #define SHOW_RCS(__x) \
1132 extern const char __x[]; \
1133 sprintf(buf, "%s\n", __x); \
1134 string_append(&result, buf); \
1137 /* In alphabetical order */
1138 SHOW_RCS(actions_h_rcs)
1139 SHOW_RCS(actions_rcs)
1142 #ifdef FEATURE_CGI_EDIT_ACTIONS
1143 SHOW_RCS(cgiedit_h_rcs)
1144 SHOW_RCS(cgiedit_rcs)
1145 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1146 SHOW_RCS(cgisimple_h_rcs)
1147 SHOW_RCS(cgisimple_rcs)
1149 SHOW_RCS(cygwin_h_rcs)
1151 SHOW_RCS(deanimate_h_rcs)
1152 SHOW_RCS(deanimate_rcs)
1153 SHOW_RCS(encode_h_rcs)
1154 SHOW_RCS(encode_rcs)
1155 SHOW_RCS(errlog_h_rcs)
1156 SHOW_RCS(errlog_rcs)
1157 SHOW_RCS(filters_h_rcs)
1158 SHOW_RCS(filters_rcs)
1159 SHOW_RCS(gateway_h_rcs)
1160 SHOW_RCS(gateway_rcs)
1162 SHOW_RCS(gnu_regex_h_rcs)
1163 SHOW_RCS(gnu_regex_rcs)
1164 #endif /* def GNU_REGEX */
1165 SHOW_RCS(jbsockets_h_rcs)
1166 SHOW_RCS(jbsockets_rcs)
1169 #ifdef FEATURE_KILL_POPUPS
1170 SHOW_RCS(killpopup_h_rcs)
1171 SHOW_RCS(killpopup_rcs)
1172 #endif /* def FEATURE_KILL_POPUPS */
1173 SHOW_RCS(list_h_rcs)
1175 SHOW_RCS(loadcfg_h_rcs)
1176 SHOW_RCS(loadcfg_rcs)
1177 SHOW_RCS(loaders_h_rcs)
1178 SHOW_RCS(loaders_rcs)
1179 SHOW_RCS(miscutil_h_rcs)
1180 SHOW_RCS(miscutil_rcs)
1181 SHOW_RCS(parsers_h_rcs)
1182 SHOW_RCS(parsers_rcs)
1184 SHOW_RCS(pcrs_h_rcs)
1185 SHOW_RCS(project_h_rcs)
1186 SHOW_RCS(ssplit_h_rcs)
1187 SHOW_RCS(ssplit_rcs)
1188 SHOW_RCS(urlmatch_h_rcs)
1189 SHOW_RCS(urlmatch_rcs)
1191 #ifndef _WIN_CONSOLE
1192 SHOW_RCS(w32log_h_rcs)
1193 SHOW_RCS(w32log_rcs)
1194 SHOW_RCS(w32res_h_rcs)
1195 SHOW_RCS(w32taskbar_h_rcs)
1196 SHOW_RCS(w32taskbar_rcs)
1197 #endif /* ndef _WIN_CONSOLE */
1198 SHOW_RCS(win32_h_rcs)
1200 #endif /* def _WIN32 */