1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.11 2002/01/23 00:01:04 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.11 2002/01/23 00:01:04 jongfoster
40 * Adding cgi_transparent_gif() for http://i.j.b/t
41 * Adding missing html_encode() to many CGI functions.
42 * Adding urlmatch.[ch] to http://i.j.b/show-version
44 * Revision 1.10 2002/01/17 21:10:37 jongfoster
45 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
46 * Also fixing a problem in the same function with improperly quoted URLs
47 * in output HTML, and adding code to handle https:// URLs correctly.
49 * Revision 1.9 2001/11/30 23:09:15 jongfoster
50 * Now reports on FEATURE_CGI_EDIT_ACTIONS
51 * Removing FEATURE_DENY_GZIP from template
53 * Revision 1.8 2001/11/13 00:14:07 jongfoster
54 * Fixing stupid bug now I've figured out what || means.
55 * (It always returns 0 or 1, not one of it's paramaters.)
57 * Revision 1.7 2001/10/23 21:48:19 jongfoster
58 * Cleaning up error handling in CGI functions - they now send back
59 * a HTML error page and should never cause a FATAL error. (Fixes one
60 * potential source of "denial of service" attacks).
62 * CGI actions file editor that works and is actually useful.
64 * Ability to toggle JunkBuster remotely using a CGI call.
66 * You can turn off both the above features in the main configuration
67 * file, e.g. if you are running a multi-user proxy.
69 * Revision 1.6 2001/10/14 22:00:32 jongfoster
70 * Adding support for a 404 error when an invalid CGI page is requested.
72 * Revision 1.5 2001/10/07 15:30:41 oes
73 * Removed FEATURE_DENY_GZIP
75 * Revision 1.4 2001/10/02 15:31:12 oes
76 * Introduced show-request cgi
78 * Revision 1.3 2001/09/22 16:34:44 jongfoster
79 * Removing unneeded #includes
81 * Revision 1.2 2001/09/19 18:01:11 oes
82 * Fixed comments; cosmetics
84 * Revision 1.1 2001/09/16 17:08:54 jongfoster
85 * Moving simple CGI functions from cgi.c to new file cgisimple.c
88 **********************************************************************/
94 #include <sys/types.h>
101 #define snprintf _snprintf
102 #endif /* def _WIN32 */
106 #include "cgisimple.h"
112 #include "miscutil.h"
115 #include "urlmatch.h"
117 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
120 static char *show_rcs(void);
121 static jb_err show_defines(struct map *exports);
124 /*********************************************************************
126 * Function : cgi_default
128 * Description : CGI function that is called if no action was given.
129 * Lists menu of available unhidden CGIs.
132 * 1 : csp = Current client state (buffers, headers, etc...)
133 * 2 : rsp = http_response data structure for output
134 * 3 : parameters = map of cgi parameters
136 * CGI Parameters : none
138 * Returns : JB_ERR_OK on success
139 * JB_ERR_MEMORY on out-of-memory
140 * (Problems other than out-of-memory should be
141 * handled by this routine - it should set the
142 * rsp appropriately and return "success")
144 *********************************************************************/
145 jb_err cgi_default(struct client_state *csp,
146 struct http_response *rsp,
147 const struct map *parameters)
156 if (NULL == (exports = default_exports(csp, "")))
158 return JB_ERR_MEMORY;
161 /* If there were other parameters, export a dump as "cgi-parameters" */
162 if (parameters->first)
164 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
165 "Anyway, here they are, in case you're interested:</p>\n");
166 string_join(&tmp, dump_map(parameters));
170 return JB_ERR_MEMORY;
172 if (map(exports, "cgi-parameters", 1, tmp, 0))
174 return JB_ERR_MEMORY;
179 if (map(exports, "cgi-parameters", 1, "", 1))
181 return JB_ERR_MEMORY;
185 return template_fill_for_cgi(csp, "default", exports, rsp);
191 /*********************************************************************
193 * Function : cgi_error_404
195 * Description : CGI function that is called if an unknown action was
199 * 1 : csp = Current client state (buffers, headers, etc...)
200 * 2 : rsp = http_response data structure for output
201 * 3 : parameters = map of cgi parameters
203 * CGI Parameters : none
205 * Returns : JB_ERR_OK on success
206 * JB_ERR_MEMORY on out-of-memory error.
208 *********************************************************************/
209 jb_err cgi_error_404(struct client_state *csp,
210 struct http_response *rsp,
211 const struct map *parameters)
219 if (NULL == (exports = default_exports(csp, NULL)))
221 return JB_ERR_MEMORY;
224 rsp->status = strdup("404 JunkBuster configuration page not found");
225 if (rsp->status == NULL)
228 return JB_ERR_MEMORY;
231 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
235 /*********************************************************************
237 * Function : cgi_show_request
239 * Description : Show the client's request and what sed() would have
243 * 1 : csp = Current client state (buffers, headers, etc...)
244 * 2 : rsp = http_response data structure for output
245 * 3 : parameters = map of cgi parameters
247 * CGI Parameters : none
249 * Returns : JB_ERR_OK on success
250 * JB_ERR_MEMORY on out-of-memory error.
252 *********************************************************************/
253 jb_err cgi_show_request(struct client_state *csp,
254 struct http_response *rsp,
255 const struct map *parameters)
264 if (NULL == (exports = default_exports(csp, "show-request")))
266 return JB_ERR_MEMORY;
270 * Repair the damage done to the IOB by get_header()
272 for (p = csp->iob->buf; p < csp->iob->eod; p++)
274 if (*p == '\0') *p = '\n';
278 * Export the original client's request and the one we would
279 * be sending to the server if this wasn't a CGI call
282 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
285 return JB_ERR_MEMORY;
288 if (map(exports, "processed-request", 1, html_encode_and_free_original(
289 sed(client_patterns, add_client_headers, csp)), 0))
292 return JB_ERR_MEMORY;
295 return template_fill_for_cgi(csp, "show-request", exports, rsp);
299 /*********************************************************************
301 * Function : cgi_send_banner
303 * Description : CGI function that returns a banner.
306 * 1 : csp = Current client state (buffers, headers, etc...)
307 * 2 : rsp = http_response data structure for output
308 * 3 : parameters = map of cgi parameters
311 * type : Selects the type of banner between "trans" and "jb".
312 * Defaults to "jb" if absent or != "trans".
314 * Returns : JB_ERR_OK on success
315 * JB_ERR_MEMORY on out-of-memory error.
317 *********************************************************************/
318 jb_err cgi_send_banner(struct client_state *csp,
319 struct http_response *rsp,
320 const struct map *parameters)
322 if (strcmp(lookup(parameters, "type"), "trans"))
324 rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length);
325 rsp->content_length = image_junkbuster_gif_length;
329 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
330 rsp->content_length = image_blank_gif_length;
333 if (rsp->body == NULL)
335 return JB_ERR_MEMORY;
338 if (enlist(rsp->headers, "Content-Type: image/gif"))
340 return JB_ERR_MEMORY;
350 /*********************************************************************
352 * Function : cgi_transparent_gif
354 * Description : CGI function that sends a 1x1 transparent GIF.
357 * 1 : csp = Current client state (buffers, headers, etc...)
358 * 2 : rsp = http_response data structure for output
359 * 3 : parameters = map of cgi parameters
361 * CGI Parameters : None
363 * Returns : JB_ERR_OK on success
364 * JB_ERR_MEMORY on out-of-memory error.
366 *********************************************************************/
367 jb_err cgi_transparent_gif(struct client_state *csp,
368 struct http_response *rsp,
369 const struct map *parameters)
371 rsp->body = bindup(image_blank_gif_data, image_blank_gif_length);
372 rsp->content_length = image_blank_gif_length;
374 if (rsp->body == NULL)
376 return JB_ERR_MEMORY;
379 if (enlist(rsp->headers, "Content-Type: image/gif"))
381 return JB_ERR_MEMORY;
391 /*********************************************************************
393 * Function : cgi_show_version
395 * Description : CGI function that returns a a web page describing the
396 * file versions of IJB.
399 * 1 : csp = Current client state (buffers, headers, etc...)
400 * 2 : rsp = http_response data structure for output
401 * 3 : parameters = map of cgi parameters
403 * CGI Parameters : none
405 * Returns : JB_ERR_OK on success
406 * JB_ERR_MEMORY on out-of-memory error.
408 *********************************************************************/
409 jb_err cgi_show_version(struct client_state *csp,
410 struct http_response *rsp,
411 const struct map *parameters)
419 if (NULL == (exports = default_exports(csp, "show-version")))
421 return JB_ERR_MEMORY;
424 if (map(exports, "sourceversions", 1, show_rcs(), 0))
427 return JB_ERR_MEMORY;
430 return template_fill_for_cgi(csp, "show-version", exports, rsp);
434 /*********************************************************************
436 * Function : cgi_show_status
438 * Description : CGI function that returns a a web page describing the
439 * current status of IJB.
442 * 1 : csp = Current client state (buffers, headers, etc...)
443 * 2 : rsp = http_response data structure for output
444 * 3 : parameters = map of cgi parameters
447 * file : Which file to show. Only first letter is checked,
449 * - "p"ermissions (actions) file
452 * Default is to show menu and other information.
454 * Returns : JB_ERR_OK on success
455 * JB_ERR_MEMORY on out-of-memory error.
457 *********************************************************************/
458 jb_err cgi_show_status(struct client_state *csp,
459 struct http_response *rsp,
460 const struct map *parameters)
466 char buf[BUFFER_SIZE];
467 const char * filename = NULL;
468 char * file_description = NULL;
469 #ifdef FEATURE_STATISTICS
470 float perc_rej; /* Percentage of http requests rejected */
472 int local_urls_rejected;
473 #endif /* ndef FEATURE_STATISTICS */
482 if (NULL == (exports = default_exports(csp, "show-status")))
484 return JB_ERR_MEMORY;
487 switch (*(lookup(parameters, "file")))
490 if (csp->actions_list)
492 filename = csp->actions_list->filename;
493 file_description = "Actions List";
500 filename = csp->rlist->filename;
501 file_description = "Regex Filter List";
509 filename = csp->tlist->filename;
510 file_description = "Trust List";
513 #endif /* def FEATURE_TRUST */
516 if (NULL != filename)
518 if ( map(exports, "file-description", 1, file_description, 1)
519 || map(exports, "filepath", 1, html_encode(filename), 0) )
522 return JB_ERR_MEMORY;
525 if ((fp = fopen(filename, "r")) == NULL)
527 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
530 return JB_ERR_MEMORY;
536 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
538 string_join (&s, html_encode(buf));
539 string_append(&s, "<br>");
543 if (map(exports, "contents", 1, s, 0))
546 return JB_ERR_MEMORY;
550 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
553 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
556 return JB_ERR_MEMORY;
560 for (i = 0; (s != NULL) && (i < Argc); i++)
562 string_join (&s, html_encode(Argv[i]));
563 string_append(&s, " ");
565 if (map(exports, "invocation", 1, s, 0))
568 return JB_ERR_MEMORY;
571 err = map(exports, "options", 1, csp->config->proxy_args, 1);
572 if (!err) err = show_defines(exports);
574 #ifdef FEATURE_STATISTICS
575 local_urls_read = urls_read;
576 local_urls_rejected = urls_rejected;
579 * Need to alter the stats not to include the fetch of this
582 * Can't do following thread safely! doh!
585 * urls_rejected--; * This will be incremented subsequently *
588 if (local_urls_read == 0)
590 if (!err) err = map_block_killer(exports, "have-stats");
594 if (!err) err = map_block_killer(exports, "have-no-stats");
596 perc_rej = (float)local_urls_rejected * 100.0F /
597 (float)local_urls_read;
599 sprintf(buf, "%d", local_urls_read);
600 if (!err) err = map(exports, "requests-received", 1, buf, 1);
602 sprintf(buf, "%d", local_urls_rejected);
603 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
605 sprintf(buf, "%6.2f", perc_rej);
606 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
609 #else /* ndef FEATURE_STATISTICS */
610 err = err || map_block_killer(exports, "statistics");
611 #endif /* ndef FEATURE_STATISTICS */
613 if (csp->actions_list)
615 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
619 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
624 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
628 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
634 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
638 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
641 if (!err) err = map_block_killer(exports, "trust-support");
642 #endif /* ndef FEATURE_TRUST */
647 return JB_ERR_MEMORY;
650 return template_fill_for_cgi(csp, "show-status", exports, rsp);
654 /*********************************************************************
656 * Function : cgi_show_url_info
658 * Description : CGI function that determines and shows which actions
659 * junkbuster will perform for a given url, and which
660 * matches starting from the defaults have lead to that.
663 * 1 : csp = Current client state (buffers, headers, etc...)
664 * 2 : rsp = http_response data structure for output
665 * 3 : parameters = map of cgi parameters
668 * url : The url whose actions are to be determined.
669 * If url is unset, the url-given conditional will be
670 * set, so that all but the form can be suppressed in
673 * Returns : JB_ERR_OK on success
674 * JB_ERR_MEMORY on out-of-memory error.
676 *********************************************************************/
677 jb_err cgi_show_url_info(struct client_state *csp,
678 struct http_response *rsp,
679 const struct map *parameters)
688 if (NULL == (exports = default_exports(csp, "show-url-info")))
690 return JB_ERR_MEMORY;
694 * Get the url= parameter (if present) and remove any leading/trailing spaces.
696 url_param = strdup(lookup(parameters, "url"));
697 if (url_param == NULL)
700 return JB_ERR_MEMORY;
705 * Handle prefixes. 4 possibilities:
706 * 1) "http://" or "https://" prefix present and followed by URL - OK
707 * 2) Only the "http://" or "https://" part is present, no URL - change
708 * to empty string so it will be detected later as "no URL".
709 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
711 * 4) Parameter not specified or is empty string - let this fall through
712 * for now, next block of code will handle it.
714 if (0 == strncmp(url_param, "http://", 7))
716 if (url_param[7] == '\0')
719 * Empty URL (just prefix).
720 * Make it totally empty so it's caught by the next if()
725 else if (0 == strncmp(url_param, "https://", 8))
727 if (url_param[8] == '\0')
730 * Empty URL (just prefix).
731 * Make it totally empty so it's caught by the next if()
736 else if (url_param[0] != '\0')
739 * Unknown prefix - assume http://
741 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
742 if (NULL == url_param_prefixed)
746 return JB_ERR_MEMORY;
748 strcpy(url_param_prefixed, "http://");
749 strcpy(url_param_prefixed + 7, url_param);
751 url_param = url_param_prefixed;
755 if (url_param[0] == '\0')
757 /* URL paramater not specified, display query form only. */
759 if (map_block_killer(exports, "url-given")
760 || map(exports, "url", 1, "", 1))
763 return JB_ERR_MEMORY;
768 /* Given a URL, so query it. */
773 struct file_list *fl;
774 struct url_actions *b;
775 struct http_request url_to_query[1];
776 struct current_action_spec action[1];
778 if (map(exports, "url", 1, html_encode(url_param), 0))
782 return JB_ERR_MEMORY;
785 init_current_action(action);
787 if (map(exports, "default", 1, html_encode_and_free_original(
788 current_action_to_text(action)), 0))
790 free_current_action(action);
793 return JB_ERR_MEMORY;
796 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
798 err = map(exports, "matches", 1, "none" , 1);
799 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
801 free_current_action(action);
807 return JB_ERR_MEMORY;
810 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
813 err = parse_http_url(url_param, url_to_query, csp);
817 if (err == JB_ERR_MEMORY)
819 free_current_action(action);
821 return JB_ERR_MEMORY;
827 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
828 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
830 free_current_action(action);
835 return JB_ERR_MEMORY;
838 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
842 * We have a warning about SSL paths. Hide it for insecure sites.
844 if (!url_to_query->ssl)
846 if (map_block_killer(exports, "https"))
848 free_current_action(action);
850 return JB_ERR_MEMORY;
854 matches = strdup("");
856 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
858 if (url_match(b->url, url_to_query))
860 string_append(&matches, "<b>{");
861 string_join (&matches, html_encode_and_free_original(
862 actions_to_text(b->action)));
863 string_append(&matches, " }</b><br>\n<code>");
864 string_join (&matches, html_encode(b->url->spec));
865 string_append(&matches, "</code><br>\n<br>\n");
867 if (merge_current_action(action, b->action))
870 free_http_request(url_to_query);
871 free_current_action(action);
873 return JB_ERR_MEMORY;
879 free_http_request(url_to_query);
883 free_current_action(action);
885 return JB_ERR_MEMORY;
891 matches = strdup("none");
893 if (map(exports, "matches", 1, matches , 0))
895 free_current_action(action);
897 return JB_ERR_MEMORY;
900 s = html_encode_and_free_original(current_action_to_text(action));
902 free_current_action(action);
904 if (map(exports, "final", 1, s, 0))
907 return JB_ERR_MEMORY;
911 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
915 /*********************************************************************
917 * Function : cgi_robots_txt
919 * Description : CGI function to return "/robots.txt".
922 * 1 : csp = Current client state (buffers, headers, etc...)
923 * 2 : rsp = http_response data structure for output
924 * 3 : parameters = map of cgi parameters
926 * CGI Parameters : None
928 * Returns : JB_ERR_OK on success
929 * JB_ERR_MEMORY on out-of-memory error.
931 *********************************************************************/
932 jb_err cgi_robots_txt(struct client_state *csp,
933 struct http_response *rsp,
934 const struct map *parameters)
940 "# This is the Internet Junkbuster control interface.\n"
941 "# It isn't very useful to index it, and you're likely to break stuff.\n"
947 if (rsp->body == NULL)
949 return JB_ERR_MEMORY;
952 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
956 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
957 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
959 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
963 /*********************************************************************
965 * Function : show_defines
967 * Description : Add to a map the state od all conditional #defines
971 * 1 : exports = map to extend
973 * Returns : JB_ERR_OK on success
974 * JB_ERR_MEMORY on out-of-memory error.
976 *********************************************************************/
977 static jb_err show_defines(struct map *exports)
979 jb_err err = JB_ERR_OK;
982 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
983 #else /* ifndef FEATURE_ACL */
984 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
985 #endif /* ndef FEATURE_ACL */
987 #ifdef FEATURE_CGI_EDIT_ACTIONS
988 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
989 #else /* ifndef FEATURE_COOKIE_JAR */
990 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
991 #endif /* ndef FEATURE_COOKIE_JAR */
993 #ifdef FEATURE_COOKIE_JAR
994 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
995 #else /* ifndef FEATURE_COOKIE_JAR */
996 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
997 #endif /* ndef FEATURE_COOKIE_JAR */
999 #ifdef FEATURE_FAST_REDIRECTS
1000 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1001 #else /* ifndef FEATURE_FAST_REDIRECTS */
1002 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1003 #endif /* ndef FEATURE_FAST_REDIRECTS */
1005 #ifdef FEATURE_FORCE_LOAD
1006 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1007 #else /* ifndef FEATURE_FORCE_LOAD */
1008 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1009 #endif /* ndef FEATURE_FORCE_LOAD */
1011 #ifdef FEATURE_IMAGE_BLOCKING
1012 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1013 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1014 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1015 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1017 #ifdef FEATURE_IMAGE_DETECT_MSIE
1018 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1019 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1020 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1021 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1023 #ifdef FEATURE_KILL_POPUPS
1024 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1025 #else /* ifndef FEATURE_KILL_POPUPS */
1026 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1027 #endif /* ndef FEATURE_KILL_POPUPS */
1029 #ifdef FEATURE_PTHREAD
1030 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1031 #else /* ifndef FEATURE_PTHREAD */
1032 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1033 #endif /* ndef FEATURE_PTHREAD */
1035 #ifdef FEATURE_STATISTICS
1036 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1037 #else /* ifndef FEATURE_STATISTICS */
1038 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1039 #endif /* ndef FEATURE_STATISTICS */
1041 #ifdef FEATURE_TOGGLE
1042 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1043 #else /* ifndef FEATURE_TOGGLE */
1044 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1045 #endif /* ndef FEATURE_TOGGLE */
1047 #ifdef FEATURE_TRUST
1048 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1049 #else /* ifndef FEATURE_TRUST */
1050 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1051 #endif /* ndef FEATURE_TRUST */
1054 if (!err) err = map_conditional(exports, "REGEX_GNU", 1);
1055 #else /* ifndef REGEX_GNU */
1056 if (!err) err = map_conditional(exports, "REGEX_GNU", 0);
1057 #endif /* def REGEX_GNU */
1060 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1061 #else /* ifndef REGEX_PCRE */
1062 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1063 #endif /* def REGEX_PCRE */
1066 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1067 #else /* ifndef STATIC_PCRE */
1068 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1069 #endif /* ndef STATIC_PCRE */
1072 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1073 #else /* ifndef STATIC_PCRS */
1074 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1075 #endif /* ndef STATIC_PCRS */
1077 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1083 /*********************************************************************
1085 * Function : show_rcs
1087 * Description : Create a string with the rcs info for all sourcefiles
1091 * Returns : A string, or NULL on out-of-memory.
1093 *********************************************************************/
1094 static char *show_rcs(void)
1096 char *result = strdup("");
1097 char buf[BUFFER_SIZE];
1099 /* Instead of including *all* dot h's in the project (thus creating a
1100 * tremendous amount of dependencies), I will concede to declaring them
1101 * as extern's. This forces the developer to add to this list, but oh well.
1104 #define SHOW_RCS(__x) \
1106 extern const char __x[]; \
1107 sprintf(buf, "%s\n", __x); \
1108 string_append(&result, buf); \
1111 /* In alphabetical order */
1112 SHOW_RCS(actions_h_rcs)
1113 SHOW_RCS(actions_rcs)
1116 #ifdef FEATURE_CGI_EDIT_ACTIONS
1117 SHOW_RCS(cgiedit_h_rcs)
1118 SHOW_RCS(cgiedit_rcs)
1119 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1120 SHOW_RCS(cgisimple_h_rcs)
1121 SHOW_RCS(cgisimple_rcs)
1123 SHOW_RCS(cygwin_h_rcs)
1125 SHOW_RCS(deanimate_h_rcs)
1126 SHOW_RCS(deanimate_rcs)
1127 SHOW_RCS(encode_h_rcs)
1128 SHOW_RCS(encode_rcs)
1129 SHOW_RCS(errlog_h_rcs)
1130 SHOW_RCS(errlog_rcs)
1131 SHOW_RCS(filters_h_rcs)
1132 SHOW_RCS(filters_rcs)
1133 SHOW_RCS(gateway_h_rcs)
1134 SHOW_RCS(gateway_rcs)
1136 SHOW_RCS(gnu_regex_h_rcs)
1137 SHOW_RCS(gnu_regex_rcs)
1138 #endif /* def GNU_REGEX */
1139 SHOW_RCS(jbsockets_h_rcs)
1140 SHOW_RCS(jbsockets_rcs)
1143 #ifdef FEATURE_KILL_POPUPS
1144 SHOW_RCS(killpopup_h_rcs)
1145 SHOW_RCS(killpopup_rcs)
1146 #endif /* def FEATURE_KILL_POPUPS */
1147 SHOW_RCS(list_h_rcs)
1149 SHOW_RCS(loadcfg_h_rcs)
1150 SHOW_RCS(loadcfg_rcs)
1151 SHOW_RCS(loaders_h_rcs)
1152 SHOW_RCS(loaders_rcs)
1153 SHOW_RCS(miscutil_h_rcs)
1154 SHOW_RCS(miscutil_rcs)
1155 SHOW_RCS(parsers_h_rcs)
1156 SHOW_RCS(parsers_rcs)
1158 SHOW_RCS(pcrs_h_rcs)
1159 SHOW_RCS(project_h_rcs)
1160 SHOW_RCS(ssplit_h_rcs)
1161 SHOW_RCS(ssplit_rcs)
1162 SHOW_RCS(urlmatch_h_rcs)
1163 SHOW_RCS(urlmatch_rcs)
1165 #ifndef _WIN_CONSOLE
1166 SHOW_RCS(w32log_h_rcs)
1167 SHOW_RCS(w32log_rcs)
1168 SHOW_RCS(w32res_h_rcs)
1169 SHOW_RCS(w32taskbar_h_rcs)
1170 SHOW_RCS(w32taskbar_rcs)
1171 #endif /* ndef _WIN_CONSOLE */
1172 SHOW_RCS(win32_h_rcs)
1174 #endif /* def _WIN32 */