1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.25 2002/04/03 22:28:03 gliptak Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
6 * Purpose : Simple CGIs to get information about Privoxy's
9 * Functions declared include:
12 * Copyright : Written by and Copyright (C) 2001 the SourceForge
13 * Privoxy team. http://www.privoxy.org/
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.25 2002/04/03 22:28:03 gliptak
40 * Removed references to gnu_regex
42 * Revision 1.24 2002/04/02 16:12:47 oes
43 * Fix: moving misplaced lines into #ifdef FEATURE_FORCE
45 * Revision 1.23 2002/03/26 22:29:54 swa
46 * we have a new homepage!
48 * Revision 1.22 2002/03/24 16:18:15 jongfoster
51 * Revision 1.21 2002/03/24 15:23:33 jongfoster
54 * Revision 1.20 2002/03/24 13:25:43 swa
55 * name change related issues
57 * Revision 1.19 2002/03/16 23:54:06 jongfoster
58 * Adding graceful termination feature, to help look for memory leaks.
59 * If you enable this (which, by design, has to be done by hand
60 * editing config.h) and then go to http://i.j.b/die, then the program
61 * will exit cleanly after the *next* request. It should free all the
62 * memory that was used.
64 * Revision 1.18 2002/03/12 01:44:49 oes
65 * Changed default for "blocked" image from jb logo to checkboard pattern
67 * Revision 1.17 2002/03/08 16:43:18 oes
68 * Added choice beween GIF and PNG built-in images
70 * Revision 1.16 2002/03/07 03:48:38 oes
71 * - Changed built-in images from GIF to PNG
72 * (with regard to Unisys patent issue)
73 * - Added a 4x4 pattern PNG which is less intrusive
74 * than the logo but also clearly marks the deleted banners
76 * Revision 1.15 2002/03/06 22:54:35 jongfoster
77 * Automated function-comment nitpicking.
79 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
80 * Clean up a little CRLF unpleasantness that suddenly appeared
82 * Revision 1.13 2002/02/21 00:10:37 jongfoster
83 * Adding send-banner?type=auto option
85 * Revision 1.12 2002/01/23 01:03:32 jongfoster
86 * Fixing gcc [CygWin] compiler warnings
88 * Revision 1.11 2002/01/23 00:01:04 jongfoster
89 * Adding cgi_transparent_gif() for http://i.j.b/t
90 * Adding missing html_encode() to many CGI functions.
91 * Adding urlmatch.[ch] to http://i.j.b/show-version
93 * Revision 1.10 2002/01/17 21:10:37 jongfoster
94 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
95 * Also fixing a problem in the same function with improperly quoted URLs
96 * in output HTML, and adding code to handle https:// URLs correctly.
98 * Revision 1.9 2001/11/30 23:09:15 jongfoster
99 * Now reports on FEATURE_CGI_EDIT_ACTIONS
100 * Removing FEATURE_DENY_GZIP from template
102 * Revision 1.8 2001/11/13 00:14:07 jongfoster
103 * Fixing stupid bug now I've figured out what || means.
104 * (It always returns 0 or 1, not one of it's paramaters.)
106 * Revision 1.7 2001/10/23 21:48:19 jongfoster
107 * Cleaning up error handling in CGI functions - they now send back
108 * a HTML error page and should never cause a FATAL error. (Fixes one
109 * potential source of "denial of service" attacks).
111 * CGI actions file editor that works and is actually useful.
113 * Ability to toggle JunkBuster remotely using a CGI call.
115 * You can turn off both the above features in the main configuration
116 * file, e.g. if you are running a multi-user proxy.
118 * Revision 1.6 2001/10/14 22:00:32 jongfoster
119 * Adding support for a 404 error when an invalid CGI page is requested.
121 * Revision 1.5 2001/10/07 15:30:41 oes
122 * Removed FEATURE_DENY_GZIP
124 * Revision 1.4 2001/10/02 15:31:12 oes
125 * Introduced show-request cgi
127 * Revision 1.3 2001/09/22 16:34:44 jongfoster
128 * Removing unneeded #includes
130 * Revision 1.2 2001/09/19 18:01:11 oes
131 * Fixed comments; cosmetics
133 * Revision 1.1 2001/09/16 17:08:54 jongfoster
134 * Moving simple CGI functions from cgi.c to new file cgisimple.c
137 **********************************************************************/
143 #include <sys/types.h>
150 #define snprintf _snprintf
151 #endif /* def _WIN32 */
155 #include "cgisimple.h"
161 #include "miscutil.h"
164 #include "urlmatch.h"
166 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
169 static char *show_rcs(void);
170 static jb_err show_defines(struct map *exports);
173 /*********************************************************************
175 * Function : cgi_default
177 * Description : CGI function that is called if no action was given.
178 * Lists menu of available unhidden CGIs.
181 * 1 : csp = Current client state (buffers, headers, etc...)
182 * 2 : rsp = http_response data structure for output
183 * 3 : parameters = map of cgi parameters
185 * CGI Parameters : none
187 * Returns : JB_ERR_OK on success
188 * JB_ERR_MEMORY on out-of-memory
189 * (Problems other than out-of-memory should be
190 * handled by this routine - it should set the
191 * rsp appropriately and return "success")
193 *********************************************************************/
194 jb_err cgi_default(struct client_state *csp,
195 struct http_response *rsp,
196 const struct map *parameters)
205 if (NULL == (exports = default_exports(csp, "")))
207 return JB_ERR_MEMORY;
210 /* If there were other parameters, export a dump as "cgi-parameters" */
211 if (parameters->first)
213 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
214 "Anyway, here they are, in case you're interested:</p>\n");
215 string_join(&tmp, dump_map(parameters));
219 return JB_ERR_MEMORY;
221 if (map(exports, "cgi-parameters", 1, tmp, 0))
223 return JB_ERR_MEMORY;
228 if (map(exports, "cgi-parameters", 1, "", 1))
230 return JB_ERR_MEMORY;
234 return template_fill_for_cgi(csp, "default", exports, rsp);
240 /*********************************************************************
242 * Function : cgi_error_404
244 * Description : CGI function that is called if an unknown action was
248 * 1 : csp = Current client state (buffers, headers, etc...)
249 * 2 : rsp = http_response data structure for output
250 * 3 : parameters = map of cgi parameters
252 * CGI Parameters : none
254 * Returns : JB_ERR_OK on success
255 * JB_ERR_MEMORY on out-of-memory error.
257 *********************************************************************/
258 jb_err cgi_error_404(struct client_state *csp,
259 struct http_response *rsp,
260 const struct map *parameters)
268 if (NULL == (exports = default_exports(csp, NULL)))
270 return JB_ERR_MEMORY;
273 rsp->status = strdup("404 Privoxy configuration page not found");
274 if (rsp->status == NULL)
277 return JB_ERR_MEMORY;
280 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
284 #ifdef FEATURE_GRACEFUL_TERMINATION
285 /*********************************************************************
289 * Description : CGI function to shut down Privoxy.
290 * NOTE: Turning this on in a production build
291 * would be a BAD idea. An EXTREMELY BAD idea.
292 * In short, don't do it.
295 * 1 : csp = Current client state (buffers, headers, etc...)
296 * 2 : rsp = http_response data structure for output
297 * 3 : parameters = map of cgi parameters
299 * CGI Parameters : none
301 * Returns : JB_ERR_OK on success
302 * JB_ERR_MEMORY on out-of-memory error.
304 *********************************************************************/
305 jb_err cgi_die (struct client_state *csp,
306 struct http_response *rsp,
307 const struct map *parameters)
317 * I don't really care what gets sent back to the browser.
318 * Take the easy option - "out of memory" page.
321 return JB_ERR_MEMORY;
323 #endif /* def FEATURE_GRACEFUL_TERMINATION */
326 /*********************************************************************
328 * Function : cgi_show_request
330 * Description : Show the client's request and what sed() would have
334 * 1 : csp = Current client state (buffers, headers, etc...)
335 * 2 : rsp = http_response data structure for output
336 * 3 : parameters = map of cgi parameters
338 * CGI Parameters : none
340 * Returns : JB_ERR_OK on success
341 * JB_ERR_MEMORY on out-of-memory error.
343 *********************************************************************/
344 jb_err cgi_show_request(struct client_state *csp,
345 struct http_response *rsp,
346 const struct map *parameters)
355 if (NULL == (exports = default_exports(csp, "show-request")))
357 return JB_ERR_MEMORY;
361 * Repair the damage done to the IOB by get_header()
363 for (p = csp->iob->buf; p < csp->iob->eod; p++)
365 if (*p == '\0') *p = '\n';
369 * Export the original client's request and the one we would
370 * be sending to the server if this wasn't a CGI call
373 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
376 return JB_ERR_MEMORY;
379 if (map(exports, "processed-request", 1, html_encode_and_free_original(
380 sed(client_patterns, add_client_headers, csp)), 0))
383 return JB_ERR_MEMORY;
386 return template_fill_for_cgi(csp, "show-request", exports, rsp);
390 /*********************************************************************
392 * Function : cgi_send_banner
394 * Description : CGI function that returns a banner.
397 * 1 : csp = Current client state (buffers, headers, etc...)
398 * 2 : rsp = http_response data structure for output
399 * 3 : parameters = map of cgi parameters
402 * type : Selects the type of banner between "trans", "logo",
403 * and "auto". Defaults to "logo" if absent or invalid.
404 * "auto" means to select as if we were image-blocking.
405 * (Only the first character really counts).
407 * Returns : JB_ERR_OK on success
408 * JB_ERR_MEMORY on out-of-memory error.
410 *********************************************************************/
411 jb_err cgi_send_banner(struct client_state *csp,
412 struct http_response *rsp,
413 const struct map *parameters)
415 char imagetype = lookup(parameters, "type")[0];
417 if (imagetype == 'a') /* auto */
419 /* Default to pattern */
421 #ifdef FEATURE_IMAGE_BLOCKING
422 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
424 /* determine HOW images should be blocked */
425 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
427 /* and handle accordingly: */
428 if ((p != NULL) && (0 == strcmpic(p, "blank")))
432 else if ((p != NULL) && (0 == strcmpic(p, "pattern")))
437 #endif /* def FEATURE_IMAGE_BLOCKING */
440 if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
442 rsp->body = bindup(image_blank_data, image_blank_length);
443 rsp->content_length = image_blank_length;
448 rsp->body = bindup(image_pattern_data, image_pattern_length);
449 rsp->content_length = image_pattern_length;
452 if (rsp->body == NULL)
454 return JB_ERR_MEMORY;
457 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
459 return JB_ERR_MEMORY;
469 /*********************************************************************
471 * Function : cgi_transparent_image
473 * Description : CGI function that sends a 1x1 transparent image.
476 * 1 : csp = Current client state (buffers, headers, etc...)
477 * 2 : rsp = http_response data structure for output
478 * 3 : parameters = map of cgi parameters
480 * CGI Parameters : None
482 * Returns : JB_ERR_OK on success
483 * JB_ERR_MEMORY on out-of-memory error.
485 *********************************************************************/
486 jb_err cgi_transparent_image(struct client_state *csp,
487 struct http_response *rsp,
488 const struct map *parameters)
490 rsp->body = bindup(image_blank_data, image_blank_length);
491 rsp->content_length = image_blank_length;
493 if (rsp->body == NULL)
495 return JB_ERR_MEMORY;
498 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
500 return JB_ERR_MEMORY;
510 /*********************************************************************
512 * Function : cgi_show_version
514 * Description : CGI function that returns a a web page describing the
515 * file versions of Privoxy.
518 * 1 : csp = Current client state (buffers, headers, etc...)
519 * 2 : rsp = http_response data structure for output
520 * 3 : parameters = map of cgi parameters
522 * CGI Parameters : none
524 * Returns : JB_ERR_OK on success
525 * JB_ERR_MEMORY on out-of-memory error.
527 *********************************************************************/
528 jb_err cgi_show_version(struct client_state *csp,
529 struct http_response *rsp,
530 const struct map *parameters)
538 if (NULL == (exports = default_exports(csp, "show-version")))
540 return JB_ERR_MEMORY;
543 if (map(exports, "sourceversions", 1, show_rcs(), 0))
546 return JB_ERR_MEMORY;
549 return template_fill_for_cgi(csp, "show-version", exports, rsp);
553 /*********************************************************************
555 * Function : cgi_show_status
557 * Description : CGI function that returns a a web page describing the
558 * current status of Privoxy.
561 * 1 : csp = Current client state (buffers, headers, etc...)
562 * 2 : rsp = http_response data structure for output
563 * 3 : parameters = map of cgi parameters
566 * file : Which file to show. Only first letter is checked,
568 * - "p"ermissions (actions) file
571 * Default is to show menu and other information.
573 * Returns : JB_ERR_OK on success
574 * JB_ERR_MEMORY on out-of-memory error.
576 *********************************************************************/
577 jb_err cgi_show_status(struct client_state *csp,
578 struct http_response *rsp,
579 const struct map *parameters)
585 char buf[BUFFER_SIZE];
586 const char * filename = NULL;
587 char * file_description = NULL;
588 #ifdef FEATURE_STATISTICS
589 float perc_rej; /* Percentage of http requests rejected */
591 int local_urls_rejected;
592 #endif /* ndef FEATURE_STATISTICS */
601 if (NULL == (exports = default_exports(csp, "show-status")))
603 return JB_ERR_MEMORY;
606 switch (*(lookup(parameters, "file")))
609 if (csp->actions_list)
611 filename = csp->actions_list->filename;
612 file_description = "Actions List";
619 filename = csp->rlist->filename;
620 file_description = "Regex Filter List";
628 filename = csp->tlist->filename;
629 file_description = "Trust List";
632 #endif /* def FEATURE_TRUST */
635 if (NULL != filename)
637 if ( map(exports, "file-description", 1, file_description, 1)
638 || map(exports, "filepath", 1, html_encode(filename), 0) )
641 return JB_ERR_MEMORY;
644 if ((fp = fopen(filename, "r")) == NULL)
646 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
649 return JB_ERR_MEMORY;
655 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
657 string_join (&s, html_encode(buf));
658 string_append(&s, "<br>");
662 if (map(exports, "contents", 1, s, 0))
665 return JB_ERR_MEMORY;
669 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
672 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
675 return JB_ERR_MEMORY;
679 for (i = 0; (s != NULL) && (i < Argc); i++)
681 string_join (&s, html_encode(Argv[i]));
682 string_append(&s, " ");
684 if (map(exports, "invocation", 1, s, 0))
687 return JB_ERR_MEMORY;
690 err = map(exports, "options", 1, csp->config->proxy_args, 1);
691 if (!err) err = show_defines(exports);
693 #ifdef FEATURE_STATISTICS
694 local_urls_read = urls_read;
695 local_urls_rejected = urls_rejected;
698 * Need to alter the stats not to include the fetch of this
701 * Can't do following thread safely! doh!
704 * urls_rejected--; * This will be incremented subsequently *
707 if (local_urls_read == 0)
709 if (!err) err = map_block_killer(exports, "have-stats");
713 if (!err) err = map_block_killer(exports, "have-no-stats");
715 perc_rej = (float)local_urls_rejected * 100.0F /
716 (float)local_urls_read;
718 sprintf(buf, "%d", local_urls_read);
719 if (!err) err = map(exports, "requests-received", 1, buf, 1);
721 sprintf(buf, "%d", local_urls_rejected);
722 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
724 sprintf(buf, "%6.2f", perc_rej);
725 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
728 #else /* ndef FEATURE_STATISTICS */
729 err = err || map_block_killer(exports, "statistics");
730 #endif /* ndef FEATURE_STATISTICS */
732 if (csp->actions_list)
734 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
738 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
743 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
747 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
753 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
757 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
760 if (!err) err = map_block_killer(exports, "trust-support");
761 #endif /* ndef FEATURE_TRUST */
766 return JB_ERR_MEMORY;
769 return template_fill_for_cgi(csp, "show-status", exports, rsp);
773 /*********************************************************************
775 * Function : cgi_show_url_info
777 * Description : CGI function that determines and shows which actions
778 * Privoxy will perform for a given url, and which
779 * matches starting from the defaults have lead to that.
782 * 1 : csp = Current client state (buffers, headers, etc...)
783 * 2 : rsp = http_response data structure for output
784 * 3 : parameters = map of cgi parameters
787 * url : The url whose actions are to be determined.
788 * If url is unset, the url-given conditional will be
789 * set, so that all but the form can be suppressed in
792 * Returns : JB_ERR_OK on success
793 * JB_ERR_MEMORY on out-of-memory error.
795 *********************************************************************/
796 jb_err cgi_show_url_info(struct client_state *csp,
797 struct http_response *rsp,
798 const struct map *parameters)
807 if (NULL == (exports = default_exports(csp, "show-url-info")))
809 return JB_ERR_MEMORY;
813 * Get the url= parameter (if present) and remove any leading/trailing spaces.
815 url_param = strdup(lookup(parameters, "url"));
816 if (url_param == NULL)
819 return JB_ERR_MEMORY;
824 * Handle prefixes. 4 possibilities:
825 * 1) "http://" or "https://" prefix present and followed by URL - OK
826 * 2) Only the "http://" or "https://" part is present, no URL - change
827 * to empty string so it will be detected later as "no URL".
828 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
830 * 4) Parameter not specified or is empty string - let this fall through
831 * for now, next block of code will handle it.
833 if (0 == strncmp(url_param, "http://", 7))
835 if (url_param[7] == '\0')
838 * Empty URL (just prefix).
839 * Make it totally empty so it's caught by the next if()
844 else if (0 == strncmp(url_param, "https://", 8))
846 if (url_param[8] == '\0')
849 * Empty URL (just prefix).
850 * Make it totally empty so it's caught by the next if()
855 else if (url_param[0] != '\0')
858 * Unknown prefix - assume http://
860 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
861 if (NULL == url_param_prefixed)
865 return JB_ERR_MEMORY;
867 strcpy(url_param_prefixed, "http://");
868 strcpy(url_param_prefixed + 7, url_param);
870 url_param = url_param_prefixed;
874 if (url_param[0] == '\0')
876 /* URL paramater not specified, display query form only. */
878 if (map_block_killer(exports, "url-given")
879 || map(exports, "url", 1, "", 1))
882 return JB_ERR_MEMORY;
887 /* Given a URL, so query it. */
892 struct file_list *fl;
893 struct url_actions *b;
894 struct http_request url_to_query[1];
895 struct current_action_spec action[1];
897 if (map(exports, "url", 1, html_encode(url_param), 0))
901 return JB_ERR_MEMORY;
904 init_current_action(action);
906 if (map(exports, "default", 1, html_encode_and_free_original(
907 current_action_to_text(action)), 0))
909 free_current_action(action);
912 return JB_ERR_MEMORY;
915 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
917 err = map(exports, "matches", 1, "none" , 1);
918 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
920 free_current_action(action);
926 return JB_ERR_MEMORY;
929 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
932 err = parse_http_url(url_param, url_to_query, csp);
936 if (err == JB_ERR_MEMORY)
938 free_current_action(action);
940 return JB_ERR_MEMORY;
946 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
947 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
949 free_current_action(action);
954 return JB_ERR_MEMORY;
957 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
961 * We have a warning about SSL paths. Hide it for insecure sites.
963 if (!url_to_query->ssl)
965 if (map_block_killer(exports, "https"))
967 free_current_action(action);
969 return JB_ERR_MEMORY;
973 matches = strdup("");
975 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
977 if (url_match(b->url, url_to_query))
979 string_append(&matches, "<b>{");
980 string_join (&matches, html_encode_and_free_original(
981 actions_to_text(b->action)));
982 string_append(&matches, " }</b><br>\n<code>");
983 string_join (&matches, html_encode(b->url->spec));
984 string_append(&matches, "</code><br>\n<br>\n");
986 if (merge_current_action(action, b->action))
989 free_http_request(url_to_query);
990 free_current_action(action);
992 return JB_ERR_MEMORY;
998 free_http_request(url_to_query);
1000 if (matches == NULL)
1002 free_current_action(action);
1004 return JB_ERR_MEMORY;
1010 matches = strdup("none");
1012 if (map(exports, "matches", 1, matches , 0))
1014 free_current_action(action);
1016 return JB_ERR_MEMORY;
1019 s = html_encode_and_free_original(current_action_to_text(action));
1021 free_current_action(action);
1023 if (map(exports, "final", 1, s, 0))
1026 return JB_ERR_MEMORY;
1030 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1034 /*********************************************************************
1036 * Function : cgi_robots_txt
1038 * Description : CGI function to return "/robots.txt".
1041 * 1 : csp = Current client state (buffers, headers, etc...)
1042 * 2 : rsp = http_response data structure for output
1043 * 3 : parameters = map of cgi parameters
1045 * CGI Parameters : None
1047 * Returns : JB_ERR_OK on success
1048 * JB_ERR_MEMORY on out-of-memory error.
1050 *********************************************************************/
1051 jb_err cgi_robots_txt(struct client_state *csp,
1052 struct http_response *rsp,
1053 const struct map *parameters)
1059 "# This is the Privoxy control interface.\n"
1060 "# It isn't very useful to index it, and you're likely to break stuff.\n"
1066 if (rsp->body == NULL)
1068 return JB_ERR_MEMORY;
1071 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1075 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1076 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1078 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1082 /*********************************************************************
1084 * Function : show_defines
1086 * Description : Add to a map the state od all conditional #defines
1087 * used when building
1090 * 1 : exports = map to extend
1092 * Returns : JB_ERR_OK on success
1093 * JB_ERR_MEMORY on out-of-memory error.
1095 *********************************************************************/
1096 static jb_err show_defines(struct map *exports)
1098 jb_err err = JB_ERR_OK;
1101 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1102 #else /* ifndef FEATURE_ACL */
1103 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1104 #endif /* ndef FEATURE_ACL */
1106 #ifdef FEATURE_CGI_EDIT_ACTIONS
1107 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1108 #else /* ifndef FEATURE_COOKIE_JAR */
1109 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1110 #endif /* ndef FEATURE_COOKIE_JAR */
1112 #ifdef FEATURE_COOKIE_JAR
1113 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1114 #else /* ifndef FEATURE_COOKIE_JAR */
1115 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1116 #endif /* ndef FEATURE_COOKIE_JAR */
1118 #ifdef FEATURE_FAST_REDIRECTS
1119 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1120 #else /* ifndef FEATURE_FAST_REDIRECTS */
1121 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1122 #endif /* ndef FEATURE_FAST_REDIRECTS */
1124 #ifdef FEATURE_FORCE_LOAD
1125 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1126 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1127 #else /* ifndef FEATURE_FORCE_LOAD */
1128 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1129 if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
1130 #endif /* ndef FEATURE_FORCE_LOAD */
1132 #ifdef FEATURE_IMAGE_BLOCKING
1133 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1134 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1135 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1136 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1138 #ifdef FEATURE_IMAGE_DETECT_MSIE
1139 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1140 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1141 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1142 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1144 #ifdef FEATURE_KILL_POPUPS
1145 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1146 #else /* ifndef FEATURE_KILL_POPUPS */
1147 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1148 #endif /* ndef FEATURE_KILL_POPUPS */
1150 #ifdef FEATURE_NO_GIFS
1151 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1152 #else /* ifndef FEATURE_NO_GIFS */
1153 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1154 #endif /* ndef FEATURE_NO_GIFS */
1156 #ifdef FEATURE_PTHREAD
1157 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1158 #else /* ifndef FEATURE_PTHREAD */
1159 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1160 #endif /* ndef FEATURE_PTHREAD */
1162 #ifdef FEATURE_STATISTICS
1163 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1164 #else /* ifndef FEATURE_STATISTICS */
1165 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1166 #endif /* ndef FEATURE_STATISTICS */
1168 #ifdef FEATURE_TOGGLE
1169 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1170 #else /* ifndef FEATURE_TOGGLE */
1171 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1172 #endif /* ndef FEATURE_TOGGLE */
1174 #ifdef FEATURE_TRUST
1175 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1176 #else /* ifndef FEATURE_TRUST */
1177 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1178 #endif /* ndef FEATURE_TRUST */
1181 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1182 #else /* ifndef STATIC_PCRE */
1183 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1184 #endif /* ndef STATIC_PCRE */
1187 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1188 #else /* ifndef STATIC_PCRS */
1189 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1190 #endif /* ndef STATIC_PCRS */
1196 /*********************************************************************
1198 * Function : show_rcs
1200 * Description : Create a string with the rcs info for all sourcefiles
1204 * Returns : A string, or NULL on out-of-memory.
1206 *********************************************************************/
1207 static char *show_rcs(void)
1209 char *result = strdup("");
1210 char buf[BUFFER_SIZE];
1212 /* Instead of including *all* dot h's in the project (thus creating a
1213 * tremendous amount of dependencies), I will concede to declaring them
1214 * as extern's. This forces the developer to add to this list, but oh well.
1217 #define SHOW_RCS(__x) \
1219 extern const char __x[]; \
1220 sprintf(buf, "%s\n", __x); \
1221 string_append(&result, buf); \
1224 /* In alphabetical order */
1225 SHOW_RCS(actions_h_rcs)
1226 SHOW_RCS(actions_rcs)
1229 #ifdef FEATURE_CGI_EDIT_ACTIONS
1230 SHOW_RCS(cgiedit_h_rcs)
1231 SHOW_RCS(cgiedit_rcs)
1232 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1233 SHOW_RCS(cgisimple_h_rcs)
1234 SHOW_RCS(cgisimple_rcs)
1236 SHOW_RCS(cygwin_h_rcs)
1238 SHOW_RCS(deanimate_h_rcs)
1239 SHOW_RCS(deanimate_rcs)
1240 SHOW_RCS(encode_h_rcs)
1241 SHOW_RCS(encode_rcs)
1242 SHOW_RCS(errlog_h_rcs)
1243 SHOW_RCS(errlog_rcs)
1244 SHOW_RCS(filters_h_rcs)
1245 SHOW_RCS(filters_rcs)
1246 SHOW_RCS(gateway_h_rcs)
1247 SHOW_RCS(gateway_rcs)
1248 SHOW_RCS(jbsockets_h_rcs)
1249 SHOW_RCS(jbsockets_rcs)
1252 #ifdef FEATURE_KILL_POPUPS
1253 SHOW_RCS(killpopup_h_rcs)
1254 SHOW_RCS(killpopup_rcs)
1255 #endif /* def FEATURE_KILL_POPUPS */
1256 SHOW_RCS(list_h_rcs)
1258 SHOW_RCS(loadcfg_h_rcs)
1259 SHOW_RCS(loadcfg_rcs)
1260 SHOW_RCS(loaders_h_rcs)
1261 SHOW_RCS(loaders_rcs)
1262 SHOW_RCS(miscutil_h_rcs)
1263 SHOW_RCS(miscutil_rcs)
1264 SHOW_RCS(parsers_h_rcs)
1265 SHOW_RCS(parsers_rcs)
1267 SHOW_RCS(pcrs_h_rcs)
1268 SHOW_RCS(project_h_rcs)
1269 SHOW_RCS(ssplit_h_rcs)
1270 SHOW_RCS(ssplit_rcs)
1271 SHOW_RCS(urlmatch_h_rcs)
1272 SHOW_RCS(urlmatch_rcs)
1274 #ifndef _WIN_CONSOLE
1275 SHOW_RCS(w32log_h_rcs)
1276 SHOW_RCS(w32log_rcs)
1277 SHOW_RCS(w32res_h_rcs)
1278 SHOW_RCS(w32taskbar_h_rcs)
1279 SHOW_RCS(w32taskbar_rcs)
1280 #endif /* ndef _WIN_CONSOLE */
1281 SHOW_RCS(win32_h_rcs)
1283 #endif /* def _WIN32 */