1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.54 2006/10/21 16:04:22 fabiankeil Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
6 * Purpose : Loads settings from the configuration file into
7 * global variables. This file contains both the
8 * routine to load the configuration and the global
9 * variables it writes to.
11 * Copyright : Written by and Copyright (C) 2001 the SourceForge
12 * Privoxy team. http://www.privoxy.org/
14 * Based on the Internet Junkbuster originally written
15 * by and Copyright (C) 1997 Anonymous Coders and
16 * Junkbusters Corporation. http://www.junkbusters.com
18 * This program is free software; you can redistribute it
19 * and/or modify it under the terms of the GNU General
20 * Public License as published by the Free Software
21 * Foundation; either version 2 of the License, or (at
22 * your option) any later version.
24 * This program is distributed in the hope that it will
25 * be useful, but WITHOUT ANY WARRANTY; without even the
26 * implied warranty of MERCHANTABILITY or FITNESS FOR A
27 * PARTICULAR PURPOSE. See the GNU General Public
28 * License for more details.
30 * The GNU General Public License should be included with
31 * this file. If not, you can view it at
32 * http://www.gnu.org/copyleft/gpl.html
33 * or write to the Free Software Foundation, Inc., 59
34 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 * Revision 1.54 2006/10/21 16:04:22 fabiankeil
39 * Modified kludge for win32 to make ming32 menu
40 * "Options/Edit Filters" (sort of) work again.
41 * Same limitations as for the action files apply.
44 * Revision 1.53 2006/09/06 18:45:03 fabiankeil
45 * Incorporate modified version of Roland Rosenfeld's patch to
46 * optionally access the user-manual via Privoxy. Closes patch 679075.
48 * Formatting changed to Privoxy style, added call to
49 * cgi_error_no_template if the requested file doesn't
50 * exist and modified check whether or not Privoxy itself
51 * should serve the manual. Should work cross-platform now.
53 * Revision 1.52 2006/09/06 10:43:32 fabiankeil
54 * Added config option enable-remote-http-toggle
55 * to specify if Privoxy should recognize special
56 * headers (currently only X-Filter) to change its
57 * behaviour. Disabled by default.
59 * Revision 1.51 2006/09/06 09:23:37 fabiankeil
60 * Make number of retries in case of forwarded-connect problems
61 * a config file option (forwarded-connect-retries) and use 0 as
64 * Revision 1.50 2006/07/18 14:48:46 david__schmidt
65 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
66 * with what was really the latest development (the v_3_0_branch branch)
68 * Revision 1.48.2.7 2006/02/02 17:29:16 david__schmidt
69 * Don't forget to malloc space for the null terminator...
71 * Revision 1.48.2.6 2006/01/29 23:10:56 david__schmidt
72 * Multiple filter file support
74 * Revision 1.48.2.5 2003/05/08 15:17:25 oes
75 * Closed two memory leaks; hopefully the last remaining ones
76 * (in the main execution paths, anyway).
78 * Revision 1.48.2.4 2003/04/11 12:06:14 oes
79 * Addressed bug #719435
80 * - Extraneous filterfile directives now logged as errors
81 * - This and unrecnonised directives now really obvious on status page
83 * Revision 1.48.2.3 2003/03/11 11:53:59 oes
84 * Cosmetic: Renamed cryptic variable
86 * Revision 1.48.2.2 2002/11/12 16:28:20 oes
87 * Move unrelated variable declaration out of #ifdef FEATURE_ACL; fixes bug #636655
89 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
90 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
92 * Revision 1.48 2002/05/14 21:30:38 oes
93 * savearg now uses own linking code instead of (now special-cased) add_help_link
95 * Revision 1.47 2002/05/12 21:36:29 jongfoster
96 * Correcting function comments
98 * Revision 1.46 2002/04/26 12:55:14 oes
99 * - New option "user-manual", defaults to our site
100 * via project.h #define
101 * - savearg now embeds option names in help links
103 * Revision 1.45 2002/04/24 02:11:54 oes
104 * Jon's multiple AF patch: Allow up to MAX_AF_FILES actionsfile options
106 * Revision 1.44 2002/04/08 20:37:13 swa
109 * Revision 1.43 2002/04/08 20:36:50 swa
112 * Revision 1.42 2002/04/05 15:50:15 oes
113 * fix for invalid HTML proxy_args
115 * Revision 1.41 2002/03/31 17:19:00 jongfoster
116 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
118 * Revision 1.40 2002/03/26 22:29:55 swa
119 * we have a new homepage!
121 * Revision 1.39 2002/03/24 13:25:43 swa
122 * name change related issues
124 * Revision 1.38 2002/03/24 13:05:48 jongfoster
125 * Renaming re_filterfile to filterfile
127 * Revision 1.37 2002/03/16 23:54:06 jongfoster
128 * Adding graceful termination feature, to help look for memory leaks.
129 * If you enable this (which, by design, has to be done by hand
130 * editing config.h) and then go to http://i.j.b/die, then the program
131 * will exit cleanly after the *next* request. It should free all the
132 * memory that was used.
134 * Revision 1.36 2002/03/13 00:27:05 jongfoster
137 * Revision 1.35 2002/03/07 03:52:44 oes
138 * Set logging to tty for --no-daemon mode
140 * Revision 1.34 2002/03/06 23:14:35 jongfoster
141 * Trivial cosmetic changes to make function comments easier to find.
143 * Revision 1.33 2002/03/05 04:52:42 oes
144 * Deleted non-errlog debugging code
146 * Revision 1.32 2002/03/04 18:24:53 oes
147 * Re-enabled output of unknown config directive hash
149 * Revision 1.31 2002/03/03 15:07:20 oes
150 * Re-enabled automatic config reloading
152 * Revision 1.30 2002/01/22 23:31:43 jongfoster
153 * Replacing strsav() with string_append()
155 * Revision 1.29 2002/01/17 21:02:30 jongfoster
156 * Moving all our URL and URL pattern parsing code to urlmatch.c.
158 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
160 * Revision 1.28 2001/12/30 14:07:32 steudten
161 * - Add signal handling (unix)
162 * - Add SIGHUP handler (unix)
163 * - Add creation of pidfile (unix)
164 * - Add action 'top' in rc file (RH)
165 * - Add entry 'SIGNALS' to manpage
166 * - Add exit message to logfile (unix)
168 * Revision 1.27 2001/11/07 00:02:13 steudten
169 * Add line number in error output for lineparsing for
170 * actionsfile and configfile.
171 * Special handling for CLF added.
173 * Revision 1.26 2001/11/05 21:41:43 steudten
174 * Add changes to be a real daemon just for unix os.
175 * (change cwd to /, detach from controlling tty, set
176 * process group and session leader to the own process.
178 * Add some fatal-error log message for failed malloc().
179 * Add '-d' if compiled with 'configure --with-debug' to
180 * enable debug output.
182 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
183 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
184 * threads to call select() simultaneously. So, it's time to do a real, live,
185 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
186 * (native). Both versions will work, but using __OS2__ offers multi-threading.
188 * Revision 1.24 2001/10/23 21:40:30 jongfoster
189 * Added support for enable-edit-actions and enable-remote-toggle config
192 * Revision 1.23 2001/10/07 15:36:00 oes
193 * Introduced new config option "buffer-limit"
195 * Revision 1.22 2001/09/22 16:36:59 jongfoster
196 * Removing unused parameter fs from read_config_line()
198 * Revision 1.21 2001/09/16 17:10:43 jongfoster
199 * Moving function savearg() here, since it was the only thing left in
202 * Revision 1.20 2001/07/30 22:08:36 jongfoster
203 * Tidying up #defines:
204 * - All feature #defines are now of the form FEATURE_xxx
205 * - Permanently turned off WIN_GUI_EDIT
206 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
208 * Revision 1.19 2001/07/15 17:45:16 jongfoster
209 * Removing some unused #includes
211 * Revision 1.18 2001/07/13 14:01:14 oes
212 * - Removed all #ifdef PCRS
213 * - Removed vim-settings
215 * Revision 1.17 2001/06/29 13:31:03 oes
216 * - Improved comments
217 * - Fixed (actionsfile) and sorted hashes
218 * - Introduced admin_address and proxy-info-url
219 * as config parameters
220 * - Renamed config->proxy_args_invocation (which didn't have
221 * the invocation but the options!) to config->proxy_args
222 * - Various adaptions
223 * - Removed logentry from cancelled commit
225 * Revision 1.16 2001/06/09 10:55:28 jongfoster
226 * Changing BUFSIZ ==> BUFFER_SIZE
228 * Revision 1.15 2001/06/07 23:13:40 jongfoster
229 * Merging ACL and forward files into config file.
230 * Cosmetic: Sorting config file options alphabetically.
231 * Cosmetic: Adding brief syntax comments to config file options.
233 * Revision 1.14 2001/06/07 14:46:25 joergs
234 * Missing make_path() added for re_filterfile.
236 * Revision 1.13 2001/06/05 22:33:54 jongfoster
238 * Fixed minor memory leak.
239 * Also now uses make_path to prepend the pathnames.
241 * Revision 1.12 2001/06/05 20:04:09 jongfoster
242 * Now uses _snprintf() in place of snprintf() under Win32.
244 * Revision 1.11 2001/06/04 18:31:58 swa
245 * files are now prefixed with either `confdir' or `logdir'.
246 * `make redhat-dist' replaces both entries confdir and logdir
249 * Revision 1.10 2001/06/03 19:11:54 oes
250 * introduced confdir option
252 * Revision 1.9 2001/06/01 20:06:24 jongfoster
253 * Removed support for "tinygif" option - moved to actions file.
255 * Revision 1.8 2001/05/31 21:27:13 jongfoster
256 * Removed many options from the config file and into the
257 * "actions" file: add_forwarded, suppress_vanilla_wafer,
258 * wafer, add_header, user_agent, referer, from
259 * Also globally replaced "permission" with "action".
261 * Revision 1.7 2001/05/29 09:50:24 jongfoster
262 * Unified blocklist/imagelist/permissionslist.
263 * File format is still under discussion, but the internal changes
266 * Also modified interceptor behaviour:
267 * - We now intercept all URLs beginning with one of the following
268 * prefixes (and *only* these prefixes):
270 * * http://ijbswa.sf.net/config/
271 * * http://ijbswa.sourceforge.net/config/
272 * - New interceptors "home page" - go to http://i.j.b/ to see it.
273 * - Internal changes so that intercepted and fast redirect pages
274 * are not replaced with an image.
275 * - Interceptors now have the option to send a binary page direct
276 * to the client. (i.e. ijb-send-banner uses this)
277 * - Implemented show-url-info interceptor. (Which is why I needed
278 * the above interceptors changes - a typical URL is
279 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
280 * The previous mechanism would not have intercepted that, and
281 * if it had been intercepted then it then it would have replaced
284 * Revision 1.6 2001/05/26 00:28:36 jongfoster
285 * Automatic reloading of config file.
286 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
287 * Most of the global variables have been moved to a new
288 * struct configuration_spec, accessed through csp->config->globalname
289 * Most of the globals remaining are used by the Win32 GUI.
291 * Revision 1.5 2001/05/25 22:34:30 jongfoster
294 * Revision 1.4 2001/05/22 18:46:04 oes
296 * - Enabled filtering banners by size rather than URL
297 * by adding patterns that replace all standard banner
298 * sizes with the "Junkbuster" gif to the re_filterfile
300 * - Enabled filtering WebBugs by providing a pattern
301 * which kills all 1x1 images
303 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
304 * which is selected by the (nonstandard and therefore
305 * capital) letter 'U' in the option string.
306 * It causes the quantifiers to be ungreedy by default.
307 * Appending a ? turns back to greedy (!).
309 * - Added a new interceptor ijb-send-banner, which
310 * sends back the "Junkbuster" gif. Without imagelist or
311 * MSIE detection support, or if tinygif = 1, or the
312 * URL isn't recognized as an imageurl, a lame HTML
313 * explanation is sent instead.
315 * - Added new feature, which permits blocking remote
316 * script redirects and firing back a local redirect
318 * The feature is conditionally compiled, i.e. it
319 * can be disabled with --disable-fast-redirects,
320 * plus it must be activated by a "fast-redirects"
321 * line in the config file, has its own log level
322 * and of course wants to be displayed by show-proxy-args
323 * Note: Boy, all the #ifdefs in 1001 locations and
324 * all the fumbling with configure.in and acconfig.h
325 * were *way* more work than the feature itself :-(
327 * - Because a generic redirect template was needed for
328 * this, tinygif = 3 now uses the same.
330 * - Moved GIFs, and other static HTTP response templates
335 * - Removed some >400 CRs again (Jon, you really worked
338 * Revision 1.3 2001/05/20 01:21:20 jongfoster
339 * Version 2.9.4 checkin.
340 * - Merged popupfile and cookiefile, and added control over PCRS
341 * filtering, in new "permissionsfile".
342 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
343 * file error you now get a message box (in the Win32 GUI) rather
344 * than the program exiting with no explanation.
345 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
347 * - Removed tabs from "config"
348 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
349 * - Bumped up version number.
351 * Revision 1.2 2001/05/17 23:01:01 oes
352 * - Cleaned CRLF's from the sources and related files
354 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
355 * Initial import of version 2.9.3 source tree
358 *********************************************************************/
364 #include <sys/types.h>
378 # include <windows.h>
381 # ifndef _WIN_CONSOLE
383 # endif /* ndef _WIN_CONSOLE */
385 /* VC++ has "_snprintf", not "snprintf" */
386 #define snprintf _snprintf
388 #else /* ifndef _WIN32 */
392 # include <sys/wait.h>
394 # include <sys/time.h>
395 # include <sys/stat.h>
405 #include "miscutil.h"
409 #include "urlmatch.h"
412 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
415 * Fix a problem with Solaris. There should be no effect on other
417 * Solaris's isspace() is a macro which uses it's argument directly
418 * as an array index. Therefore we need to make sure that high-bit
419 * characters generate +ve values, and ideally we also want to make
420 * the argument match the declared parameter type of "int".
422 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
423 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
425 #ifdef FEATURE_TOGGLE
426 /* Privoxy is enabled by default. */
427 int global_toggle_state = 1;
428 #endif /* def FEATURE_TOGGLE */
430 /* The filename of the configfile */
431 const char *configfile = NULL;
434 * CGI functions will later need access to the invocation args,
435 * so we will make argc and argv global.
438 const char **Argv = NULL;
440 static struct file_list *current_configfile = NULL;
444 * This takes the "cryptic" hash of each keyword and aliases them to
445 * something a little more readable. This also makes changing the
446 * hash values easier if they should change or the hash algorthm changes.
447 * Use the included "hash" program to find out what the hash will be
448 * for any string supplied on the command line. (Or just put it in the
449 * config file and read the number from the error message in the log).
451 * Please keep this list sorted alphabetically (but with the Windows
452 * console and GUI specific options last).
455 #define hash_actions_file 1196306641ul /* "actionsfile" */
456 #define hash_admin_address 4112573064ul /* "admin-address" */
457 #define hash_buffer_limit 1881726070ul /* "buffer-limit */
458 #define hash_confdir 1978389ul /* "confdir" */
459 #define hash_debug 78263ul /* "debug" */
460 #define hash_deny_access 1227333715ul /* "deny-access" */
461 #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */
462 #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */
463 #define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */
464 #define hash_filterfile 250887266ul /* "filterfile" */
465 #define hash_forward 2029845ul /* "forward" */
466 #define hash_forward_socks4 3963965521ul /* "forward-socks4" */
467 #define hash_forward_socks4a 2639958518ul /* "forward-socks4a" */
468 #define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
469 #define hash_jarfile 2046641ul /* "jarfile" */
470 #define hash_listen_address 1255650842ul /* "listen-address" */
471 #define hash_logdir 422889ul /* "logdir" */
472 #define hash_logfile 2114766ul /* "logfile" */
473 #define hash_permit_access 3587953268ul /* "permit-access" */
474 #define hash_proxy_info_url 3903079059ul /* "proxy-info-url" */
475 #define hash_single_threaded 4250084780ul /* "single-threaded" */
476 #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */
477 #define hash_toggle 447966ul /* "toggle" */
478 #define hash_trust_info_url 430331967ul /* "trust-info-url" */
479 #define hash_trustfile 56494766ul /* "trustfile" */
480 #define hash_usermanual 1416668518ul /* "user-manual" */
481 #define hash_activity_animation 1817904738ul /* "activity-animation" */
482 #define hash_close_button_minimizes 3651284693ul /* "close-button-minimizes" */
483 #define hash_hide_console 2048809870ul /* "hide-console" */
484 #define hash_log_buffer_size 2918070425ul /* "log-buffer-size" */
485 #define hash_log_font_name 2866730124ul /* "log-font-name" */
486 #define hash_log_font_size 2866731014ul /* "log-font-size" */
487 #define hash_log_highlight_messages 4032101240ul /* "log-highlight-messages" */
488 #define hash_log_max_lines 2868344173ul /* "log-max-lines" */
489 #define hash_log_messages 2291744899ul /* "log-messages" */
490 #define hash_show_on_task_bar 215410365ul /* "show-on-task-bar" */
493 static void savearg(char *command, char *argument, struct configuration_spec * config);
495 /*********************************************************************
497 * Function : unload_configfile
499 * Description : Free the config structure and all components.
502 * 1 : data: struct configuration_spec to unload
506 *********************************************************************/
507 void unload_configfile (void * data)
509 struct configuration_spec * config = (struct configuration_spec *)data;
510 struct forward_spec *cur_fwd = config->forward;
514 struct access_control_list *cur_acl = config->acl;
516 while (cur_acl != NULL)
518 struct access_control_list * next_acl = cur_acl->next;
523 #endif /* def FEATURE_ACL */
525 while (cur_fwd != NULL)
527 struct forward_spec * next_fwd = cur_fwd->next;
528 free_url_spec(cur_fwd->url);
530 freez(cur_fwd->gateway_host);
531 freez(cur_fwd->forward_host);
535 config->forward = NULL;
537 #ifdef FEATURE_COOKIE_JAR
538 if ( NULL != config->jar )
540 fclose( config->jar );
543 #endif /* def FEATURE_COOKIE_JAR */
545 freez(config->confdir);
546 freez(config->logdir);
548 freez(config->haddr);
549 freez(config->logfile);
551 for (i = 0; i < MAX_AF_FILES; i++)
553 freez(config->actions_file_short[i]);
554 freez(config->actions_file[i]);
555 freez(config->re_filterfile_short[i]);
556 freez(config->re_filterfile[i]);
559 freez(config->admin_address);
560 freez(config->proxy_info_url);
561 freez(config->proxy_args);
562 freez(config->usermanual);
564 #ifdef FEATURE_COOKIE_JAR
565 freez(config->jarfile);
566 #endif /* def FEATURE_COOKIE_JAR */
569 freez(config->trustfile);
570 list_remove_all(config->trust_info);
571 #endif /* def FEATURE_TRUST */
573 for (i = 0; i < MAX_AF_FILES; i++)
575 freez(config->re_filterfile[i]);
582 #ifdef FEATURE_GRACEFUL_TERMINATION
583 /*********************************************************************
585 * Function : unload_current_config_file
587 * Description : Unloads current config file - reset to state at
588 * beginning of program.
594 *********************************************************************/
595 void unload_current_config_file(void)
597 if (current_configfile)
599 current_configfile->unloader = unload_configfile;
600 current_configfile = NULL;
606 /*********************************************************************
608 * Function : load_config
610 * Description : Load the config file and all parameters.
614 * Returns : The configuration_spec, or NULL on error.
616 *********************************************************************/
617 struct configuration_spec * load_config(void)
619 char buf[BUFFER_SIZE];
621 FILE *configfp = NULL;
622 struct configuration_spec * config = NULL;
623 struct client_state * fake_csp;
624 struct file_list *fs;
625 unsigned long linenum = 0;
628 if ( !check_file_changed(current_configfile, configfile, &fs))
630 /* No need to load */
631 return ((struct configuration_spec *)current_configfile->f);
635 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
639 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
641 #ifdef FEATURE_TOGGLE
642 global_toggle_state = 1;
643 #endif /* def FEATURE_TOGGLE */
645 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
651 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
652 /* Never get here - LOG_LEVEL_FATAL causes program exit */
656 * This is backwards from how it's usually done.
657 * Following the usual pattern, "fs" would be stored in a member
658 * variable in "csp", and then we'd access "config" from "fs->f",
659 * using a cast. However, "config" is used so often that a
660 * cast each time would be very ugly, and the extra indirection
661 * would waste CPU cycles. Therefore we store "config" in
662 * "csp->config", and "fs" in "csp->config->config_file_list".
664 config->config_file_list = fs;
669 config->multi_threaded = 1;
670 config->hport = HADDR_PORT;
671 config->buffer_limit = 4096 * 1024;
672 config->usermanual = strdup(USER_MANUAL_URL);
673 config->proxy_args = strdup("");
674 config->forwarded_connect_retries = 0;
675 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
677 if ((configfp = fopen(configfile, "r")) == NULL)
679 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
681 /* Never get here - LOG_LEVEL_FATAL causes program exit */
684 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
686 char cmd[BUFFER_SIZE];
687 char arg[BUFFER_SIZE];
688 char tmp[BUFFER_SIZE];
690 struct access_control_list *cur_acl;
691 #endif /* def FEATURE_ACL */
692 struct forward_spec *cur_fwd;
698 /* Copy command (i.e. up to space or tab) into cmd */
701 while (*p && (*p != ' ') && (*p != '\t'))
707 /* Skip over the whitespace in buf */
708 while (*p && ((*p == ' ') || (*p == '\t')))
713 /* Copy the argument into arg */
716 /* Should never happen, but check this anyway */
722 /* Make sure the command field is lower case */
727 *p = ijb_tolower(*p);
731 /* Save the argument for show-proxy-args */
732 savearg(cmd, arg, config);
735 switch( hash_string( cmd ) )
737 /* *************************************************************************
738 * actionsfile actions-file-name
739 * In confdir by default
740 * *************************************************************************/
741 case hash_actions_file :
743 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
748 if (i >= MAX_AF_FILES)
750 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
751 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
754 config->actions_file_short[i] = strdup(arg);
755 p = malloc(strlen(arg) + sizeof(".action"));
758 log_error(LOG_LEVEL_FATAL, "Out of memory");
761 strcat(p, ".action");
762 config->actions_file[i] = make_path(config->confdir, p);
766 /* *************************************************************************
767 * admin-address email-address
768 * *************************************************************************/
769 case hash_admin_address :
770 freez(config->admin_address);
771 config->admin_address = strdup(arg);
774 /* *************************************************************************
776 * *************************************************************************/
777 case hash_buffer_limit :
778 config->buffer_limit = (size_t) 1024 * atoi(arg);
781 /* *************************************************************************
782 * confdir directory-name
783 * *************************************************************************/
785 freez(config->confdir);
786 config->confdir = make_path( NULL, arg);
789 /* *************************************************************************
791 * Specifies debug level, multiple values are ORed together.
792 * *************************************************************************/
794 config->debug |= atoi(arg);
797 /* *************************************************************************
798 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
799 * *************************************************************************/
801 case hash_deny_access:
802 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
804 if ((vec_count != 1) && (vec_count != 2))
806 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
807 "deny-access directive in configuration file.");
808 string_append(&config->proxy_args,
809 "<br>\nWARNING: Wrong number of parameters for "
810 "deny-access directive in configuration file.<br><br>\n");
814 /* allocate a new node */
815 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
819 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
820 /* Never get here - LOG_LEVEL_FATAL causes program exit */
823 cur_acl->action = ACL_DENY;
825 if (acl_addr(vec[0], cur_acl->src) < 0)
827 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
828 "directive in configuration file: \"%s\"", vec[0]);
829 string_append(&config->proxy_args,
830 "<br>\nWARNING: Invalid source IP for deny-access directive"
831 " in configuration file: \"");
832 string_append(&config->proxy_args,
834 string_append(&config->proxy_args,
841 if (acl_addr(vec[1], cur_acl->dst) < 0)
843 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
844 "directive in configuration file: \"%s\"", vec[0]);
845 string_append(&config->proxy_args,
846 "<br>\nWARNING: Invalid destination IP for deny-access directive"
847 " in configuration file: \"");
848 string_append(&config->proxy_args,
850 string_append(&config->proxy_args,
858 * Add it to the list. Note we reverse the list to get the
859 * behaviour the user expects. With both the ACL and
860 * actions file, the last match wins. However, the internal
861 * implementations are different: The actions file is stored
862 * in the same order as the file, and scanned completely.
863 * With the ACL, we reverse the order as we load it, then
864 * when we scan it we stop as soon as we get a match.
866 cur_acl->next = config->acl;
867 config->acl = cur_acl;
870 #endif /* def FEATURE_ACL */
872 /* *************************************************************************
873 * enable-edit-actions 0|1
874 * *************************************************************************/
875 #ifdef FEATURE_CGI_EDIT_ACTIONS
876 case hash_enable_edit_actions:
877 if ((*arg != '\0') && (0 != atoi(arg)))
879 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
883 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
886 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
888 /* *************************************************************************
889 * enable-remote-toggle 0|1
890 * *************************************************************************/
891 #ifdef FEATURE_CGI_EDIT_ACTIONS
892 case hash_enable_remote_toggle:
893 if ((*arg != '\0') && (0 != atoi(arg)))
895 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
899 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
902 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
904 /* *************************************************************************
905 * enable-remote-http-toggle 0|1
906 * *************************************************************************/
907 case hash_enable_remote_http_toggle:
908 if ((*arg != '\0') && (0 != atoi(arg)))
910 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
914 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
918 /* *************************************************************************
919 * filterfile file-name
920 * In confdir by default.
921 * *************************************************************************/
922 case hash_filterfile :
924 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
929 if (i >= MAX_AF_FILES)
931 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
932 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
935 config->re_filterfile_short[i] = strdup(arg);
936 p = malloc(strlen(arg) + 1);
939 log_error(LOG_LEVEL_FATAL, "Out of memory");
942 config->re_filterfile[i] = make_path(config->confdir, p);
946 /* *************************************************************************
947 * forward url-pattern (.|http-proxy-host[:port])
948 * *************************************************************************/
950 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
954 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
955 "directive in configuration file.");
956 string_append(&config->proxy_args,
957 "<br>\nWARNING: Wrong number of parameters for "
958 "forward directive in configuration file.");
962 /* allocate a new node */
963 cur_fwd = zalloc(sizeof(*cur_fwd));
966 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
967 /* Never get here - LOG_LEVEL_FATAL causes program exit */
971 cur_fwd->type = SOCKS_NONE;
973 /* Save the URL pattern */
974 if (create_url_spec(cur_fwd->url, vec[0]))
976 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
977 "directive in configuration file.");
978 string_append(&config->proxy_args,
979 "<br>\nWARNING: Bad URL specifier for "
980 "forward directive in configuration file.");
984 /* Parse the parent HTTP proxy host:port */
987 if (strcmp(p, ".") != 0)
989 cur_fwd->forward_host = strdup(p);
991 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
994 cur_fwd->forward_port = atoi(p);
997 if (cur_fwd->forward_port <= 0)
999 cur_fwd->forward_port = 8000;
1004 cur_fwd->next = config->forward;
1005 config->forward = cur_fwd;
1009 /* *************************************************************************
1010 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
1011 * *************************************************************************/
1012 case hash_forward_socks4:
1013 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1017 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1018 "forward-socks4 directive in configuration file.");
1019 string_append(&config->proxy_args,
1020 "<br>\nWARNING: Wrong number of parameters for "
1021 "forward-socks4 directive in configuration file.");
1025 /* allocate a new node */
1026 cur_fwd = zalloc(sizeof(*cur_fwd));
1027 if (cur_fwd == NULL)
1029 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1030 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1034 cur_fwd->type = SOCKS_4;
1036 /* Save the URL pattern */
1037 if (create_url_spec(cur_fwd->url, vec[0]))
1039 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
1040 "directive in configuration file.");
1041 string_append(&config->proxy_args,
1042 "<br>\nWARNING: Bad URL specifier for "
1043 "forward-socks4 directive in configuration file.");
1047 /* Parse the SOCKS proxy host[:port] */
1050 if (strcmp(p, ".") != 0)
1052 cur_fwd->gateway_host = strdup(p);
1054 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1057 cur_fwd->gateway_port = atoi(p);
1059 if (cur_fwd->gateway_port <= 0)
1061 cur_fwd->gateway_port = 1080;
1065 /* Parse the parent HTTP proxy host[:port] */
1068 if (strcmp(p, ".") != 0)
1070 cur_fwd->forward_host = strdup(p);
1072 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1075 cur_fwd->forward_port = atoi(p);
1078 if (cur_fwd->forward_port <= 0)
1080 cur_fwd->forward_port = 8000;
1085 cur_fwd->next = config->forward;
1086 config->forward = cur_fwd;
1090 /* *************************************************************************
1091 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1092 * *************************************************************************/
1093 case hash_forward_socks4a:
1094 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1098 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1099 "forward-socks4a directive in configuration file.");
1100 string_append(&config->proxy_args,
1101 "<br>\nWARNING: Wrong number of parameters for "
1102 "forward-socks4a directive in configuration file.");
1106 /* allocate a new node */
1107 cur_fwd = zalloc(sizeof(*cur_fwd));
1108 if (cur_fwd == NULL)
1110 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1111 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1115 cur_fwd->type = SOCKS_4A;
1117 /* Save the URL pattern */
1118 if (create_url_spec(cur_fwd->url, vec[0]))
1120 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1121 "directive in configuration file.");
1122 string_append(&config->proxy_args,
1123 "<br>\nWARNING: Bad URL specifier for "
1124 "forward-socks4a directive in configuration file.");
1128 /* Parse the SOCKS proxy host[:port] */
1131 cur_fwd->gateway_host = strdup(p);
1133 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1136 cur_fwd->gateway_port = atoi(p);
1138 if (cur_fwd->gateway_port <= 0)
1140 cur_fwd->gateway_port = 1080;
1143 /* Parse the parent HTTP proxy host[:port] */
1146 if (strcmp(p, ".") != 0)
1148 cur_fwd->forward_host = strdup(p);
1150 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1153 cur_fwd->forward_port = atoi(p);
1156 if (cur_fwd->forward_port <= 0)
1158 cur_fwd->forward_port = 8000;
1163 cur_fwd->next = config->forward;
1164 config->forward = cur_fwd;
1168 /* *************************************************************************
1169 * forwarded-connect-retries n
1170 * *************************************************************************/
1171 case hash_forwarded_connect_retries :
1172 config->forwarded_connect_retries = atoi(arg);
1175 /* *************************************************************************
1176 * jarfile jar-file-name
1177 * In logdir by default
1178 * *************************************************************************/
1179 #ifdef FEATURE_COOKIE_JAR
1181 freez(config->jarfile);
1182 config->jarfile = make_path(config->logdir, arg);
1184 #endif /* def FEATURE_COOKIE_JAR */
1186 /* *************************************************************************
1187 * listen-address [ip][:port]
1188 * *************************************************************************/
1189 case hash_listen_address :
1190 freez(config->haddr);
1191 config->haddr = strdup(arg);
1194 /* *************************************************************************
1195 * logdir directory-name
1196 * *************************************************************************/
1198 freez(config->logdir);
1199 config->logdir = make_path(NULL, arg);
1202 /* *************************************************************************
1203 * logfile log-file-name
1204 * In logdir by default
1205 * *************************************************************************/
1207 freez(config->logfile);
1208 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1211 /* *************************************************************************
1212 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1213 * *************************************************************************/
1215 case hash_permit_access:
1216 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1218 if ((vec_count != 1) && (vec_count != 2))
1220 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1221 "permit-access directive in configuration file.");
1222 string_append(&config->proxy_args,
1223 "<br>\nWARNING: Wrong number of parameters for "
1224 "permit-access directive in configuration file.<br><br>\n");
1229 /* allocate a new node */
1230 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1232 if (cur_acl == NULL)
1234 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1235 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1238 cur_acl->action = ACL_PERMIT;
1240 if (acl_addr(vec[0], cur_acl->src) < 0)
1242 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1243 "directive in configuration file: \"%s\"", vec[0]);
1244 string_append(&config->proxy_args,
1245 "<br>\nWARNING: Invalid source IP for permit-access directive"
1246 " in configuration file: \"");
1247 string_append(&config->proxy_args,
1249 string_append(&config->proxy_args,
1256 if (acl_addr(vec[1], cur_acl->dst) < 0)
1258 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1259 "permit-access directive in configuration file: \"%s\"",
1261 string_append(&config->proxy_args,
1262 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1263 " in configuration file: \"");
1264 string_append(&config->proxy_args,
1266 string_append(&config->proxy_args,
1274 * Add it to the list. Note we reverse the list to get the
1275 * behaviour the user expects. With both the ACL and
1276 * actions file, the last match wins. However, the internal
1277 * implementations are different: The actions file is stored
1278 * in the same order as the file, and scanned completely.
1279 * With the ACL, we reverse the order as we load it, then
1280 * when we scan it we stop as soon as we get a match.
1282 cur_acl->next = config->acl;
1283 config->acl = cur_acl;
1286 #endif /* def FEATURE_ACL */
1288 /* *************************************************************************
1289 * proxy-info-url url
1290 * *************************************************************************/
1291 case hash_proxy_info_url :
1292 freez(config->proxy_info_url);
1293 config->proxy_info_url = strdup(arg);
1296 /* *************************************************************************
1298 * *************************************************************************/
1299 case hash_single_threaded :
1300 config->multi_threaded = 0;
1303 /* *************************************************************************
1305 * *************************************************************************/
1306 #ifdef FEATURE_TOGGLE
1308 global_toggle_state = atoi(arg);
1310 #endif /* def FEATURE_TOGGLE */
1312 /* *************************************************************************
1313 * trust-info-url url
1314 * *************************************************************************/
1315 #ifdef FEATURE_TRUST
1316 case hash_trust_info_url :
1317 enlist(config->trust_info, arg);
1319 #endif /* def FEATURE_TRUST */
1321 /* *************************************************************************
1322 * trustfile filename
1323 * (In confdir by default.)
1324 * *************************************************************************/
1325 #ifdef FEATURE_TRUST
1326 case hash_trustfile :
1327 freez(config->trustfile);
1328 config->trustfile = make_path(config->confdir, arg);
1330 #endif /* def FEATURE_TRUST */
1332 /* *************************************************************************
1334 * *************************************************************************/
1335 case hash_usermanual :
1336 freez(config->usermanual);
1337 config->usermanual = strdup(arg);
1340 /* *************************************************************************
1341 * Win32 Console options:
1342 * *************************************************************************/
1344 /* *************************************************************************
1346 * *************************************************************************/
1348 case hash_hide_console :
1351 #endif /*def _WIN_CONSOLE*/
1354 /* *************************************************************************
1355 * Win32 GUI options:
1356 * *************************************************************************/
1358 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1359 /* *************************************************************************
1360 * activity-animation (0|1)
1361 * *************************************************************************/
1362 case hash_activity_animation :
1363 g_bShowActivityAnimation = atoi(arg);
1366 /* *************************************************************************
1367 * close-button-minimizes (0|1)
1368 * *************************************************************************/
1369 case hash_close_button_minimizes :
1370 g_bCloseHidesWindow = atoi(arg);
1373 /* *************************************************************************
1374 * log-buffer-size (0|1)
1375 * *************************************************************************/
1376 case hash_log_buffer_size :
1377 g_bLimitBufferSize = atoi(arg);
1380 /* *************************************************************************
1381 * log-font-name fontnane
1382 * *************************************************************************/
1383 case hash_log_font_name :
1384 strcpy( g_szFontFaceName, arg );
1387 /* *************************************************************************
1389 * *************************************************************************/
1390 case hash_log_font_size :
1391 g_nFontSize = atoi(arg);
1394 /* *************************************************************************
1395 * log-highlight-messages (0|1)
1396 * *************************************************************************/
1397 case hash_log_highlight_messages :
1398 g_bHighlightMessages = atoi(arg);
1401 /* *************************************************************************
1403 * *************************************************************************/
1404 case hash_log_max_lines :
1405 g_nMaxBufferLines = atoi(arg);
1408 /* *************************************************************************
1409 * log-messages (0|1)
1410 * *************************************************************************/
1411 case hash_log_messages :
1412 g_bLogMessages = atoi(arg);
1415 /* *************************************************************************
1416 * show-on-task-bar (0|1)
1417 * *************************************************************************/
1418 case hash_show_on_task_bar :
1419 g_bShowOnTaskBar = atoi(arg);
1422 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1425 /* *************************************************************************
1426 * Warnings about unsupported features
1427 * *************************************************************************/
1429 case hash_deny_access:
1430 #endif /* ndef FEATURE_ACL */
1431 #ifndef FEATURE_CGI_EDIT_ACTIONS
1432 case hash_enable_edit_actions:
1433 case hash_enable_remote_toggle:
1434 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1435 #ifndef FEATURE_COOKIE_JAR
1437 #endif /* ndef FEATURE_COOKIE_JAR */
1439 case hash_permit_access:
1440 #endif /* ndef FEATURE_ACL */
1441 #ifndef FEATURE_TOGGLE
1443 #endif /* ndef FEATURE_TOGGLE */
1444 #ifndef FEATURE_TRUST
1445 case hash_trustfile :
1446 case hash_trust_info_url :
1447 #endif /* ndef FEATURE_TRUST */
1449 #ifndef _WIN_CONSOLE
1450 case hash_hide_console :
1451 #endif /* ndef _WIN_CONSOLE */
1453 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1454 case hash_activity_animation :
1455 case hash_close_button_minimizes :
1456 case hash_log_buffer_size :
1457 case hash_log_font_name :
1458 case hash_log_font_size :
1459 case hash_log_highlight_messages :
1460 case hash_log_max_lines :
1461 case hash_log_messages :
1462 case hash_show_on_task_bar :
1463 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1464 /* These warnings are annoying - so hide them. -- Jon */
1465 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1468 /* *************************************************************************/
1470 /* *************************************************************************/
1472 * I decided that I liked this better as a warning than an
1473 * error. To change back to an error, just change log level
1474 * to LOG_LEVEL_FATAL.
1476 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive '%s' (%luul) in line %lu "
1477 "in configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1478 string_append(&config->proxy_args,
1479 " <b><font color=\"red\">WARNING: unrecognized directive, ignored</font></b>");
1482 /* *************************************************************************/
1483 } /* end switch( hash_string(cmd) ) */
1484 } /* end while ( read_config_line(...) ) */
1488 if (NULL == config->proxy_args)
1490 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1493 init_error_log(Argv[0], config->logfile, config->debug);
1495 if (config->actions_file[0])
1497 add_loader(load_actions_file, config);
1500 if (config->re_filterfile)
1502 add_loader(load_re_filterfile, config);
1505 #ifdef FEATURE_TRUST
1506 if (config->trustfile)
1508 add_loader(load_trustfile, config);
1510 #endif /* def FEATURE_TRUST */
1512 #ifdef FEATURE_COOKIE_JAR
1513 if ( NULL != config->jarfile )
1515 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1517 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1518 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1520 setbuf(config->jar, NULL);
1522 #endif /* def FEATURE_COOKIE_JAR */
1524 if ( NULL == config->haddr )
1526 config->haddr = strdup( HADDR_DEFAULT );
1529 if ( NULL != config->haddr )
1531 if (NULL != (p = strchr(config->haddr, ':')))
1536 config->hport = atoi(p);
1540 if (config->hport <= 0)
1543 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1544 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1546 if (*config->haddr == '\0')
1548 config->haddr = NULL;
1553 * Want to run all the loaders once now.
1555 * Need to set up a fake csp, so they can get to the config.
1557 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1558 fake_csp->config = config;
1560 if (run_loader(fake_csp))
1563 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1564 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1568 /* FIXME: this is a kludge for win32 */
1569 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1571 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1572 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1573 g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1575 #ifdef FEATURE_TRUST
1576 g_trustfile = config->trustfile;
1577 #endif /* def FEATURE_TRUST */
1580 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1581 /* FIXME: end kludge */
1584 config->need_bind = 1;
1586 if (current_configfile)
1588 struct configuration_spec * oldcfg = (struct configuration_spec *)
1589 current_configfile->f;
1591 * Check if config->haddr,hport == oldcfg->haddr,hport
1593 * The following could be written more compactly as a single,
1594 * (unreadably long) if statement.
1596 config->need_bind = 0;
1597 if (config->hport != oldcfg->hport)
1599 config->need_bind = 1;
1601 else if (config->haddr == NULL)
1603 if (oldcfg->haddr != NULL)
1605 config->need_bind = 1;
1608 else if (oldcfg->haddr == NULL)
1610 config->need_bind = 1;
1612 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1614 config->need_bind = 1;
1617 current_configfile->unloader = unload_configfile;
1620 fs->next = files->next;
1623 current_configfile = fs;
1629 /*********************************************************************
1631 * Function : savearg
1633 * Description : Called from `load_config'. It saves each non-empty
1634 * and non-comment line from config into
1635 * config->proxy_args. This is used to create the
1636 * show-proxy-args page. On error, frees
1637 * config->proxy_args and sets it to NULL
1640 * 1 : command = config setting that was found
1641 * 2 : argument = the setting's argument (if any)
1642 * 3 : config = Configuration to save into.
1646 *********************************************************************/
1647 static void savearg(char *command, char *argument, struct configuration_spec * config)
1657 * Add config option name embedded in
1658 * link to it's section in the user-manual
1660 buf = strdup("\n<br><a href=\"");
1661 if (!strncmpic(config->usermanual, "file://", 7) ||
1662 !strncmpic(config->usermanual, "http", 4))
1664 string_append(&buf, config->usermanual);
1668 string_append(&buf, "http://");
1669 string_append(&buf, CGI_SITE_2_HOST);
1670 string_append(&buf, "/user-manual/");
1672 string_append(&buf, CONFIG_HELP_PREFIX);
1673 string_join (&buf, string_toupper(command));
1674 string_append(&buf, "\">");
1675 string_append(&buf, command);
1676 string_append(&buf, "</a> ");
1680 freez(config->proxy_args);
1684 if ( (NULL != argument) && ('\0' != *argument) )
1686 s = html_encode(argument);
1690 freez(config->proxy_args);
1694 if (strncmpic(argument, "http://", 7) == 0)
1696 string_append(&buf, "<a href=\"");
1697 string_append(&buf, s);
1698 string_append(&buf, "\">");
1699 string_join (&buf, s);
1700 string_append(&buf, "</a>");
1704 string_join (&buf, s);
1708 string_join(&config->proxy_args, buf);