1 const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.24 2002/04/02 16:12:47 oes 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.24 2002/04/02 16:12:47 oes
40 * Fix: moving misplaced lines into #ifdef FEATURE_FORCE
42 * Revision 1.23 2002/03/26 22:29:54 swa
43 * we have a new homepage!
45 * Revision 1.22 2002/03/24 16:18:15 jongfoster
48 * Revision 1.21 2002/03/24 15:23:33 jongfoster
51 * Revision 1.20 2002/03/24 13:25:43 swa
52 * name change related issues
54 * Revision 1.19 2002/03/16 23:54:06 jongfoster
55 * Adding graceful termination feature, to help look for memory leaks.
56 * If you enable this (which, by design, has to be done by hand
57 * editing config.h) and then go to http://i.j.b/die, then the program
58 * will exit cleanly after the *next* request. It should free all the
59 * memory that was used.
61 * Revision 1.18 2002/03/12 01:44:49 oes
62 * Changed default for "blocked" image from jb logo to checkboard pattern
64 * Revision 1.17 2002/03/08 16:43:18 oes
65 * Added choice beween GIF and PNG built-in images
67 * Revision 1.16 2002/03/07 03:48:38 oes
68 * - Changed built-in images from GIF to PNG
69 * (with regard to Unisys patent issue)
70 * - Added a 4x4 pattern PNG which is less intrusive
71 * than the logo but also clearly marks the deleted banners
73 * Revision 1.15 2002/03/06 22:54:35 jongfoster
74 * Automated function-comment nitpicking.
76 * Revision 1.14 2002/03/02 04:14:50 david__schmidt
77 * Clean up a little CRLF unpleasantness that suddenly appeared
79 * Revision 1.13 2002/02/21 00:10:37 jongfoster
80 * Adding send-banner?type=auto option
82 * Revision 1.12 2002/01/23 01:03:32 jongfoster
83 * Fixing gcc [CygWin] compiler warnings
85 * Revision 1.11 2002/01/23 00:01:04 jongfoster
86 * Adding cgi_transparent_gif() for http://i.j.b/t
87 * Adding missing html_encode() to many CGI functions.
88 * Adding urlmatch.[ch] to http://i.j.b/show-version
90 * Revision 1.10 2002/01/17 21:10:37 jongfoster
91 * Changes to cgi_show_url_info to use new matching code from urlmatch.c.
92 * Also fixing a problem in the same function with improperly quoted URLs
93 * in output HTML, and adding code to handle https:// URLs correctly.
95 * Revision 1.9 2001/11/30 23:09:15 jongfoster
96 * Now reports on FEATURE_CGI_EDIT_ACTIONS
97 * Removing FEATURE_DENY_GZIP from template
99 * Revision 1.8 2001/11/13 00:14:07 jongfoster
100 * Fixing stupid bug now I've figured out what || means.
101 * (It always returns 0 or 1, not one of it's paramaters.)
103 * Revision 1.7 2001/10/23 21:48:19 jongfoster
104 * Cleaning up error handling in CGI functions - they now send back
105 * a HTML error page and should never cause a FATAL error. (Fixes one
106 * potential source of "denial of service" attacks).
108 * CGI actions file editor that works and is actually useful.
110 * Ability to toggle JunkBuster remotely using a CGI call.
112 * You can turn off both the above features in the main configuration
113 * file, e.g. if you are running a multi-user proxy.
115 * Revision 1.6 2001/10/14 22:00:32 jongfoster
116 * Adding support for a 404 error when an invalid CGI page is requested.
118 * Revision 1.5 2001/10/07 15:30:41 oes
119 * Removed FEATURE_DENY_GZIP
121 * Revision 1.4 2001/10/02 15:31:12 oes
122 * Introduced show-request cgi
124 * Revision 1.3 2001/09/22 16:34:44 jongfoster
125 * Removing unneeded #includes
127 * Revision 1.2 2001/09/19 18:01:11 oes
128 * Fixed comments; cosmetics
130 * Revision 1.1 2001/09/16 17:08:54 jongfoster
131 * Moving simple CGI functions from cgi.c to new file cgisimple.c
134 **********************************************************************/
140 #include <sys/types.h>
147 #define snprintf _snprintf
148 #endif /* def _WIN32 */
152 #include "cgisimple.h"
158 #include "miscutil.h"
161 #include "urlmatch.h"
163 const char cgisimple_h_rcs[] = CGISIMPLE_H_VERSION;
166 static char *show_rcs(void);
167 static jb_err show_defines(struct map *exports);
170 /*********************************************************************
172 * Function : cgi_default
174 * Description : CGI function that is called if no action was given.
175 * Lists menu of available unhidden CGIs.
178 * 1 : csp = Current client state (buffers, headers, etc...)
179 * 2 : rsp = http_response data structure for output
180 * 3 : parameters = map of cgi parameters
182 * CGI Parameters : none
184 * Returns : JB_ERR_OK on success
185 * JB_ERR_MEMORY on out-of-memory
186 * (Problems other than out-of-memory should be
187 * handled by this routine - it should set the
188 * rsp appropriately and return "success")
190 *********************************************************************/
191 jb_err cgi_default(struct client_state *csp,
192 struct http_response *rsp,
193 const struct map *parameters)
202 if (NULL == (exports = default_exports(csp, "")))
204 return JB_ERR_MEMORY;
207 /* If there were other parameters, export a dump as "cgi-parameters" */
208 if (parameters->first)
210 tmp = strdup("<p>What made you think this cgi takes parameters?\n"
211 "Anyway, here they are, in case you're interested:</p>\n");
212 string_join(&tmp, dump_map(parameters));
216 return JB_ERR_MEMORY;
218 if (map(exports, "cgi-parameters", 1, tmp, 0))
220 return JB_ERR_MEMORY;
225 if (map(exports, "cgi-parameters", 1, "", 1))
227 return JB_ERR_MEMORY;
231 return template_fill_for_cgi(csp, "default", exports, rsp);
237 /*********************************************************************
239 * Function : cgi_error_404
241 * Description : CGI function that is called if an unknown action was
245 * 1 : csp = Current client state (buffers, headers, etc...)
246 * 2 : rsp = http_response data structure for output
247 * 3 : parameters = map of cgi parameters
249 * CGI Parameters : none
251 * Returns : JB_ERR_OK on success
252 * JB_ERR_MEMORY on out-of-memory error.
254 *********************************************************************/
255 jb_err cgi_error_404(struct client_state *csp,
256 struct http_response *rsp,
257 const struct map *parameters)
265 if (NULL == (exports = default_exports(csp, NULL)))
267 return JB_ERR_MEMORY;
270 rsp->status = strdup("404 Privoxy configuration page not found");
271 if (rsp->status == NULL)
274 return JB_ERR_MEMORY;
277 return template_fill_for_cgi(csp, "cgi-error-404", exports, rsp);
281 #ifdef FEATURE_GRACEFUL_TERMINATION
282 /*********************************************************************
286 * Description : CGI function to shut down Privoxy.
287 * NOTE: Turning this on in a production build
288 * would be a BAD idea. An EXTREMELY BAD idea.
289 * In short, don't do it.
292 * 1 : csp = Current client state (buffers, headers, etc...)
293 * 2 : rsp = http_response data structure for output
294 * 3 : parameters = map of cgi parameters
296 * CGI Parameters : none
298 * Returns : JB_ERR_OK on success
299 * JB_ERR_MEMORY on out-of-memory error.
301 *********************************************************************/
302 jb_err cgi_die (struct client_state *csp,
303 struct http_response *rsp,
304 const struct map *parameters)
314 * I don't really care what gets sent back to the browser.
315 * Take the easy option - "out of memory" page.
318 return JB_ERR_MEMORY;
320 #endif /* def FEATURE_GRACEFUL_TERMINATION */
323 /*********************************************************************
325 * Function : cgi_show_request
327 * Description : Show the client's request and what sed() would have
331 * 1 : csp = Current client state (buffers, headers, etc...)
332 * 2 : rsp = http_response data structure for output
333 * 3 : parameters = map of cgi parameters
335 * CGI Parameters : none
337 * Returns : JB_ERR_OK on success
338 * JB_ERR_MEMORY on out-of-memory error.
340 *********************************************************************/
341 jb_err cgi_show_request(struct client_state *csp,
342 struct http_response *rsp,
343 const struct map *parameters)
352 if (NULL == (exports = default_exports(csp, "show-request")))
354 return JB_ERR_MEMORY;
358 * Repair the damage done to the IOB by get_header()
360 for (p = csp->iob->buf; p < csp->iob->eod; p++)
362 if (*p == '\0') *p = '\n';
366 * Export the original client's request and the one we would
367 * be sending to the server if this wasn't a CGI call
370 if (map(exports, "client-request", 1, html_encode(csp->iob->buf), 0))
373 return JB_ERR_MEMORY;
376 if (map(exports, "processed-request", 1, html_encode_and_free_original(
377 sed(client_patterns, add_client_headers, csp)), 0))
380 return JB_ERR_MEMORY;
383 return template_fill_for_cgi(csp, "show-request", exports, rsp);
387 /*********************************************************************
389 * Function : cgi_send_banner
391 * Description : CGI function that returns a banner.
394 * 1 : csp = Current client state (buffers, headers, etc...)
395 * 2 : rsp = http_response data structure for output
396 * 3 : parameters = map of cgi parameters
399 * type : Selects the type of banner between "trans", "logo",
400 * and "auto". Defaults to "logo" if absent or invalid.
401 * "auto" means to select as if we were image-blocking.
402 * (Only the first character really counts).
404 * Returns : JB_ERR_OK on success
405 * JB_ERR_MEMORY on out-of-memory error.
407 *********************************************************************/
408 jb_err cgi_send_banner(struct client_state *csp,
409 struct http_response *rsp,
410 const struct map *parameters)
412 char imagetype = lookup(parameters, "type")[0];
414 if (imagetype == 'a') /* auto */
416 /* Default to pattern */
418 #ifdef FEATURE_IMAGE_BLOCKING
419 if ((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0)
421 /* determine HOW images should be blocked */
422 const char * p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER];
424 /* and handle accordingly: */
425 if ((p != NULL) && (0 == strcmpic(p, "blank")))
429 else if ((p != NULL) && (0 == strcmpic(p, "pattern")))
434 #endif /* def FEATURE_IMAGE_BLOCKING */
437 if ((imagetype == 'b') || (imagetype == 't')) /* blank / transparent */
439 rsp->body = bindup(image_blank_data, image_blank_length);
440 rsp->content_length = image_blank_length;
445 rsp->body = bindup(image_pattern_data, image_pattern_length);
446 rsp->content_length = image_pattern_length;
449 if (rsp->body == NULL)
451 return JB_ERR_MEMORY;
454 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
456 return JB_ERR_MEMORY;
466 /*********************************************************************
468 * Function : cgi_transparent_image
470 * Description : CGI function that sends a 1x1 transparent image.
473 * 1 : csp = Current client state (buffers, headers, etc...)
474 * 2 : rsp = http_response data structure for output
475 * 3 : parameters = map of cgi parameters
477 * CGI Parameters : None
479 * Returns : JB_ERR_OK on success
480 * JB_ERR_MEMORY on out-of-memory error.
482 *********************************************************************/
483 jb_err cgi_transparent_image(struct client_state *csp,
484 struct http_response *rsp,
485 const struct map *parameters)
487 rsp->body = bindup(image_blank_data, image_blank_length);
488 rsp->content_length = image_blank_length;
490 if (rsp->body == NULL)
492 return JB_ERR_MEMORY;
495 if (enlist(rsp->headers, "Content-Type: " BUILTIN_IMAGE_MIMETYPE))
497 return JB_ERR_MEMORY;
507 /*********************************************************************
509 * Function : cgi_show_version
511 * Description : CGI function that returns a a web page describing the
512 * file versions of Privoxy.
515 * 1 : csp = Current client state (buffers, headers, etc...)
516 * 2 : rsp = http_response data structure for output
517 * 3 : parameters = map of cgi parameters
519 * CGI Parameters : none
521 * Returns : JB_ERR_OK on success
522 * JB_ERR_MEMORY on out-of-memory error.
524 *********************************************************************/
525 jb_err cgi_show_version(struct client_state *csp,
526 struct http_response *rsp,
527 const struct map *parameters)
535 if (NULL == (exports = default_exports(csp, "show-version")))
537 return JB_ERR_MEMORY;
540 if (map(exports, "sourceversions", 1, show_rcs(), 0))
543 return JB_ERR_MEMORY;
546 return template_fill_for_cgi(csp, "show-version", exports, rsp);
550 /*********************************************************************
552 * Function : cgi_show_status
554 * Description : CGI function that returns a a web page describing the
555 * current status of Privoxy.
558 * 1 : csp = Current client state (buffers, headers, etc...)
559 * 2 : rsp = http_response data structure for output
560 * 3 : parameters = map of cgi parameters
563 * file : Which file to show. Only first letter is checked,
565 * - "p"ermissions (actions) file
568 * Default is to show menu and other information.
570 * Returns : JB_ERR_OK on success
571 * JB_ERR_MEMORY on out-of-memory error.
573 *********************************************************************/
574 jb_err cgi_show_status(struct client_state *csp,
575 struct http_response *rsp,
576 const struct map *parameters)
582 char buf[BUFFER_SIZE];
583 const char * filename = NULL;
584 char * file_description = NULL;
585 #ifdef FEATURE_STATISTICS
586 float perc_rej; /* Percentage of http requests rejected */
588 int local_urls_rejected;
589 #endif /* ndef FEATURE_STATISTICS */
598 if (NULL == (exports = default_exports(csp, "show-status")))
600 return JB_ERR_MEMORY;
603 switch (*(lookup(parameters, "file")))
606 if (csp->actions_list)
608 filename = csp->actions_list->filename;
609 file_description = "Actions List";
616 filename = csp->rlist->filename;
617 file_description = "Regex Filter List";
625 filename = csp->tlist->filename;
626 file_description = "Trust List";
629 #endif /* def FEATURE_TRUST */
632 if (NULL != filename)
634 if ( map(exports, "file-description", 1, file_description, 1)
635 || map(exports, "filepath", 1, html_encode(filename), 0) )
638 return JB_ERR_MEMORY;
641 if ((fp = fopen(filename, "r")) == NULL)
643 if (map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1))
646 return JB_ERR_MEMORY;
652 while ((s != NULL) && fgets(buf, sizeof(buf), fp))
654 string_join (&s, html_encode(buf));
655 string_append(&s, "<br>");
659 if (map(exports, "contents", 1, s, 0))
662 return JB_ERR_MEMORY;
666 return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
669 if (map(exports, "redirect-url", 1, html_encode(REDIRECT_URL), 0))
672 return JB_ERR_MEMORY;
676 for (i = 0; (s != NULL) && (i < Argc); i++)
678 string_join (&s, html_encode(Argv[i]));
679 string_append(&s, " ");
681 if (map(exports, "invocation", 1, s, 0))
684 return JB_ERR_MEMORY;
687 err = map(exports, "options", 1, csp->config->proxy_args, 1);
688 if (!err) err = show_defines(exports);
690 #ifdef FEATURE_STATISTICS
691 local_urls_read = urls_read;
692 local_urls_rejected = urls_rejected;
695 * Need to alter the stats not to include the fetch of this
698 * Can't do following thread safely! doh!
701 * urls_rejected--; * This will be incremented subsequently *
704 if (local_urls_read == 0)
706 if (!err) err = map_block_killer(exports, "have-stats");
710 if (!err) err = map_block_killer(exports, "have-no-stats");
712 perc_rej = (float)local_urls_rejected * 100.0F /
713 (float)local_urls_read;
715 sprintf(buf, "%d", local_urls_read);
716 if (!err) err = map(exports, "requests-received", 1, buf, 1);
718 sprintf(buf, "%d", local_urls_rejected);
719 if (!err) err = map(exports, "requests-blocked", 1, buf, 1);
721 sprintf(buf, "%6.2f", perc_rej);
722 if (!err) err = map(exports, "percent-blocked", 1, buf, 1);
725 #else /* ndef FEATURE_STATISTICS */
726 err = err || map_block_killer(exports, "statistics");
727 #endif /* ndef FEATURE_STATISTICS */
729 if (csp->actions_list)
731 if (!err) err = map(exports, "actions-filename", 1, html_encode(csp->actions_list->filename), 0);
735 if (!err) err = map(exports, "actions-filename", 1, "None specified", 1);
740 if (!err) err = map(exports, "re-filter-filename", 1, html_encode(csp->rlist->filename), 0);
744 if (!err) err = map(exports, "re-filter-filename", 1, "None specified", 1);
750 if (!err) err = map(exports, "trust-filename", 1, html_encode(csp->tlist->filename), 0);
754 if (!err) err = map(exports, "trust-filename", 1, "None specified", 1);
757 if (!err) err = map_block_killer(exports, "trust-support");
758 #endif /* ndef FEATURE_TRUST */
763 return JB_ERR_MEMORY;
766 return template_fill_for_cgi(csp, "show-status", exports, rsp);
770 /*********************************************************************
772 * Function : cgi_show_url_info
774 * Description : CGI function that determines and shows which actions
775 * Privoxy will perform for a given url, and which
776 * matches starting from the defaults have lead to that.
779 * 1 : csp = Current client state (buffers, headers, etc...)
780 * 2 : rsp = http_response data structure for output
781 * 3 : parameters = map of cgi parameters
784 * url : The url whose actions are to be determined.
785 * If url is unset, the url-given conditional will be
786 * set, so that all but the form can be suppressed in
789 * Returns : JB_ERR_OK on success
790 * JB_ERR_MEMORY on out-of-memory error.
792 *********************************************************************/
793 jb_err cgi_show_url_info(struct client_state *csp,
794 struct http_response *rsp,
795 const struct map *parameters)
804 if (NULL == (exports = default_exports(csp, "show-url-info")))
806 return JB_ERR_MEMORY;
810 * Get the url= parameter (if present) and remove any leading/trailing spaces.
812 url_param = strdup(lookup(parameters, "url"));
813 if (url_param == NULL)
816 return JB_ERR_MEMORY;
821 * Handle prefixes. 4 possibilities:
822 * 1) "http://" or "https://" prefix present and followed by URL - OK
823 * 2) Only the "http://" or "https://" part is present, no URL - change
824 * to empty string so it will be detected later as "no URL".
825 * 3) Parameter specified but doesn't contain "http(s?)://" - add a
827 * 4) Parameter not specified or is empty string - let this fall through
828 * for now, next block of code will handle it.
830 if (0 == strncmp(url_param, "http://", 7))
832 if (url_param[7] == '\0')
835 * Empty URL (just prefix).
836 * Make it totally empty so it's caught by the next if()
841 else if (0 == strncmp(url_param, "https://", 8))
843 if (url_param[8] == '\0')
846 * Empty URL (just prefix).
847 * Make it totally empty so it's caught by the next if()
852 else if (url_param[0] != '\0')
855 * Unknown prefix - assume http://
857 char * url_param_prefixed = malloc(7 + 1 + strlen(url_param));
858 if (NULL == url_param_prefixed)
862 return JB_ERR_MEMORY;
864 strcpy(url_param_prefixed, "http://");
865 strcpy(url_param_prefixed + 7, url_param);
867 url_param = url_param_prefixed;
871 if (url_param[0] == '\0')
873 /* URL paramater not specified, display query form only. */
875 if (map_block_killer(exports, "url-given")
876 || map(exports, "url", 1, "", 1))
879 return JB_ERR_MEMORY;
884 /* Given a URL, so query it. */
889 struct file_list *fl;
890 struct url_actions *b;
891 struct http_request url_to_query[1];
892 struct current_action_spec action[1];
894 if (map(exports, "url", 1, html_encode(url_param), 0))
898 return JB_ERR_MEMORY;
901 init_current_action(action);
903 if (map(exports, "default", 1, html_encode_and_free_original(
904 current_action_to_text(action)), 0))
906 free_current_action(action);
909 return JB_ERR_MEMORY;
912 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
914 err = map(exports, "matches", 1, "none" , 1);
915 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
917 free_current_action(action);
923 return JB_ERR_MEMORY;
926 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
929 err = parse_http_url(url_param, url_to_query, csp);
933 if (err == JB_ERR_MEMORY)
935 free_current_action(action);
937 return JB_ERR_MEMORY;
943 err = map(exports, "matches", 1, "<b>[Invalid URL specified!]</b>" , 1);
944 if (!err) err = map(exports, "final", 1, lookup(exports, "default"), 1);
946 free_current_action(action);
951 return JB_ERR_MEMORY;
954 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
958 * We have a warning about SSL paths. Hide it for insecure sites.
960 if (!url_to_query->ssl)
962 if (map_block_killer(exports, "https"))
964 free_current_action(action);
966 return JB_ERR_MEMORY;
970 matches = strdup("");
972 for (b = b->next; (b != NULL) && (matches != NULL); b = b->next)
974 if (url_match(b->url, url_to_query))
976 string_append(&matches, "<b>{");
977 string_join (&matches, html_encode_and_free_original(
978 actions_to_text(b->action)));
979 string_append(&matches, " }</b><br>\n<code>");
980 string_join (&matches, html_encode(b->url->spec));
981 string_append(&matches, "</code><br>\n<br>\n");
983 if (merge_current_action(action, b->action))
986 free_http_request(url_to_query);
987 free_current_action(action);
989 return JB_ERR_MEMORY;
995 free_http_request(url_to_query);
999 free_current_action(action);
1001 return JB_ERR_MEMORY;
1007 matches = strdup("none");
1009 if (map(exports, "matches", 1, matches , 0))
1011 free_current_action(action);
1013 return JB_ERR_MEMORY;
1016 s = html_encode_and_free_original(current_action_to_text(action));
1018 free_current_action(action);
1020 if (map(exports, "final", 1, s, 0))
1023 return JB_ERR_MEMORY;
1027 return template_fill_for_cgi(csp, "show-url-info", exports, rsp);
1031 /*********************************************************************
1033 * Function : cgi_robots_txt
1035 * Description : CGI function to return "/robots.txt".
1038 * 1 : csp = Current client state (buffers, headers, etc...)
1039 * 2 : rsp = http_response data structure for output
1040 * 3 : parameters = map of cgi parameters
1042 * CGI Parameters : None
1044 * Returns : JB_ERR_OK on success
1045 * JB_ERR_MEMORY on out-of-memory error.
1047 *********************************************************************/
1048 jb_err cgi_robots_txt(struct client_state *csp,
1049 struct http_response *rsp,
1050 const struct map *parameters)
1056 "# This is the Privoxy control interface.\n"
1057 "# It isn't very useful to index it, and you're likely to break stuff.\n"
1063 if (rsp->body == NULL)
1065 return JB_ERR_MEMORY;
1068 err = enlist_unique(rsp->headers, "Content-Type: text/plain", 13);
1072 get_http_time(7 * 24 * 60 * 60, buf); /* 7 days into future */
1073 if (!err) err = enlist_unique_header(rsp->headers, "Expires", buf);
1075 return (err ? JB_ERR_MEMORY : JB_ERR_OK);
1079 /*********************************************************************
1081 * Function : show_defines
1083 * Description : Add to a map the state od all conditional #defines
1084 * used when building
1087 * 1 : exports = map to extend
1089 * Returns : JB_ERR_OK on success
1090 * JB_ERR_MEMORY on out-of-memory error.
1092 *********************************************************************/
1093 static jb_err show_defines(struct map *exports)
1095 jb_err err = JB_ERR_OK;
1098 if (!err) err = map_conditional(exports, "FEATURE_ACL", 1);
1099 #else /* ifndef FEATURE_ACL */
1100 if (!err) err = map_conditional(exports, "FEATURE_ACL", 0);
1101 #endif /* ndef FEATURE_ACL */
1103 #ifdef FEATURE_CGI_EDIT_ACTIONS
1104 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 1);
1105 #else /* ifndef FEATURE_COOKIE_JAR */
1106 if (!err) err = map_conditional(exports, "FEATURE_CGI_EDIT_ACTIONS", 0);
1107 #endif /* ndef FEATURE_COOKIE_JAR */
1109 #ifdef FEATURE_COOKIE_JAR
1110 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 1);
1111 #else /* ifndef FEATURE_COOKIE_JAR */
1112 if (!err) err = map_conditional(exports, "FEATURE_COOKIE_JAR", 0);
1113 #endif /* ndef FEATURE_COOKIE_JAR */
1115 #ifdef FEATURE_FAST_REDIRECTS
1116 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 1);
1117 #else /* ifndef FEATURE_FAST_REDIRECTS */
1118 if (!err) err = map_conditional(exports, "FEATURE_FAST_REDIRECTS", 0);
1119 #endif /* ndef FEATURE_FAST_REDIRECTS */
1121 #ifdef FEATURE_FORCE_LOAD
1122 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 1);
1123 if (!err) err = map(exports, "FORCE_PREFIX", 1, FORCE_PREFIX, 1);
1124 #else /* ifndef FEATURE_FORCE_LOAD */
1125 if (!err) err = map_conditional(exports, "FEATURE_FORCE_LOAD", 0);
1126 if (!err) err = map(exports, "FORCE_PREFIX", 1, "(none - disabled)", 1);
1127 #endif /* ndef FEATURE_FORCE_LOAD */
1129 #ifdef FEATURE_IMAGE_BLOCKING
1130 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 1);
1131 #else /* ifndef FEATURE_IMAGE_BLOCKING */
1132 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_BLOCKING", 0);
1133 #endif /* ndef FEATURE_IMAGE_BLOCKING */
1135 #ifdef FEATURE_IMAGE_DETECT_MSIE
1136 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 1);
1137 #else /* ifndef FEATURE_IMAGE_DETECT_MSIE */
1138 if (!err) err = map_conditional(exports, "FEATURE_IMAGE_DETECT_MSIE", 0);
1139 #endif /* ndef FEATURE_IMAGE_DETECT_MSIE */
1141 #ifdef FEATURE_KILL_POPUPS
1142 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 1);
1143 #else /* ifndef FEATURE_KILL_POPUPS */
1144 if (!err) err = map_conditional(exports, "FEATURE_KILL_POPUPS", 0);
1145 #endif /* ndef FEATURE_KILL_POPUPS */
1147 #ifdef FEATURE_NO_GIFS
1148 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 1);
1149 #else /* ifndef FEATURE_NO_GIFS */
1150 if (!err) err = map_conditional(exports, "FEATURE_NO_GIFS", 0);
1151 #endif /* ndef FEATURE_NO_GIFS */
1153 #ifdef FEATURE_PTHREAD
1154 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 1);
1155 #else /* ifndef FEATURE_PTHREAD */
1156 if (!err) err = map_conditional(exports, "FEATURE_PTHREAD", 0);
1157 #endif /* ndef FEATURE_PTHREAD */
1159 #ifdef FEATURE_STATISTICS
1160 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 1);
1161 #else /* ifndef FEATURE_STATISTICS */
1162 if (!err) err = map_conditional(exports, "FEATURE_STATISTICS", 0);
1163 #endif /* ndef FEATURE_STATISTICS */
1165 #ifdef FEATURE_TOGGLE
1166 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 1);
1167 #else /* ifndef FEATURE_TOGGLE */
1168 if (!err) err = map_conditional(exports, "FEATURE_TOGGLE", 0);
1169 #endif /* ndef FEATURE_TOGGLE */
1171 #ifdef FEATURE_TRUST
1172 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 1);
1173 #else /* ifndef FEATURE_TRUST */
1174 if (!err) err = map_conditional(exports, "FEATURE_TRUST", 0);
1175 #endif /* ndef FEATURE_TRUST */
1178 if (!err) err = map_conditional(exports, "REGEX_PCRE", 1);
1179 #else /* ifndef REGEX_PCRE */
1180 if (!err) err = map_conditional(exports, "REGEX_PCRE", 0);
1181 #endif /* def REGEX_PCRE */
1184 if (!err) err = map_conditional(exports, "STATIC_PCRE", 1);
1185 #else /* ifndef STATIC_PCRE */
1186 if (!err) err = map_conditional(exports, "STATIC_PCRE", 0);
1187 #endif /* ndef STATIC_PCRE */
1190 if (!err) err = map_conditional(exports, "STATIC_PCRS", 1);
1191 #else /* ifndef STATIC_PCRS */
1192 if (!err) err = map_conditional(exports, "STATIC_PCRS", 0);
1193 #endif /* ndef STATIC_PCRS */
1199 /*********************************************************************
1201 * Function : show_rcs
1203 * Description : Create a string with the rcs info for all sourcefiles
1207 * Returns : A string, or NULL on out-of-memory.
1209 *********************************************************************/
1210 static char *show_rcs(void)
1212 char *result = strdup("");
1213 char buf[BUFFER_SIZE];
1215 /* Instead of including *all* dot h's in the project (thus creating a
1216 * tremendous amount of dependencies), I will concede to declaring them
1217 * as extern's. This forces the developer to add to this list, but oh well.
1220 #define SHOW_RCS(__x) \
1222 extern const char __x[]; \
1223 sprintf(buf, "%s\n", __x); \
1224 string_append(&result, buf); \
1227 /* In alphabetical order */
1228 SHOW_RCS(actions_h_rcs)
1229 SHOW_RCS(actions_rcs)
1232 #ifdef FEATURE_CGI_EDIT_ACTIONS
1233 SHOW_RCS(cgiedit_h_rcs)
1234 SHOW_RCS(cgiedit_rcs)
1235 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1236 SHOW_RCS(cgisimple_h_rcs)
1237 SHOW_RCS(cgisimple_rcs)
1239 SHOW_RCS(cygwin_h_rcs)
1241 SHOW_RCS(deanimate_h_rcs)
1242 SHOW_RCS(deanimate_rcs)
1243 SHOW_RCS(encode_h_rcs)
1244 SHOW_RCS(encode_rcs)
1245 SHOW_RCS(errlog_h_rcs)
1246 SHOW_RCS(errlog_rcs)
1247 SHOW_RCS(filters_h_rcs)
1248 SHOW_RCS(filters_rcs)
1249 SHOW_RCS(gateway_h_rcs)
1250 SHOW_RCS(gateway_rcs)
1251 SHOW_RCS(jbsockets_h_rcs)
1252 SHOW_RCS(jbsockets_rcs)
1255 #ifdef FEATURE_KILL_POPUPS
1256 SHOW_RCS(killpopup_h_rcs)
1257 SHOW_RCS(killpopup_rcs)
1258 #endif /* def FEATURE_KILL_POPUPS */
1259 SHOW_RCS(list_h_rcs)
1261 SHOW_RCS(loadcfg_h_rcs)
1262 SHOW_RCS(loadcfg_rcs)
1263 SHOW_RCS(loaders_h_rcs)
1264 SHOW_RCS(loaders_rcs)
1265 SHOW_RCS(miscutil_h_rcs)
1266 SHOW_RCS(miscutil_rcs)
1267 SHOW_RCS(parsers_h_rcs)
1268 SHOW_RCS(parsers_rcs)
1270 SHOW_RCS(pcrs_h_rcs)
1271 SHOW_RCS(project_h_rcs)
1272 SHOW_RCS(ssplit_h_rcs)
1273 SHOW_RCS(ssplit_rcs)
1274 SHOW_RCS(urlmatch_h_rcs)
1275 SHOW_RCS(urlmatch_rcs)
1277 #ifndef _WIN_CONSOLE
1278 SHOW_RCS(w32log_h_rcs)
1279 SHOW_RCS(w32log_rcs)
1280 SHOW_RCS(w32res_h_rcs)
1281 SHOW_RCS(w32taskbar_h_rcs)
1282 SHOW_RCS(w32taskbar_rcs)
1283 #endif /* ndef _WIN_CONSOLE */
1284 SHOW_RCS(win32_h_rcs)
1286 #endif /* def _WIN32 */