1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.55 2006/11/28 15:31:52 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.55 2006/11/28 15:31:52 fabiankeil
39 * Fix memory leak in case of config file reloads.
41 * Revision 1.54 2006/10/21 16:04:22 fabiankeil
42 * Modified kludge for win32 to make ming32 menu
43 * "Options/Edit Filters" (sort of) work again.
44 * Same limitations as for the action files apply.
47 * Revision 1.53 2006/09/06 18:45:03 fabiankeil
48 * Incorporate modified version of Roland Rosenfeld's patch to
49 * optionally access the user-manual via Privoxy. Closes patch 679075.
51 * Formatting changed to Privoxy style, added call to
52 * cgi_error_no_template if the requested file doesn't
53 * exist and modified check whether or not Privoxy itself
54 * should serve the manual. Should work cross-platform now.
56 * Revision 1.52 2006/09/06 10:43:32 fabiankeil
57 * Added config option enable-remote-http-toggle
58 * to specify if Privoxy should recognize special
59 * headers (currently only X-Filter) to change its
60 * behaviour. Disabled by default.
62 * Revision 1.51 2006/09/06 09:23:37 fabiankeil
63 * Make number of retries in case of forwarded-connect problems
64 * a config file option (forwarded-connect-retries) and use 0 as
67 * Revision 1.50 2006/07/18 14:48:46 david__schmidt
68 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
69 * with what was really the latest development (the v_3_0_branch branch)
71 * Revision 1.48.2.7 2006/02/02 17:29:16 david__schmidt
72 * Don't forget to malloc space for the null terminator...
74 * Revision 1.48.2.6 2006/01/29 23:10:56 david__schmidt
75 * Multiple filter file support
77 * Revision 1.48.2.5 2003/05/08 15:17:25 oes
78 * Closed two memory leaks; hopefully the last remaining ones
79 * (in the main execution paths, anyway).
81 * Revision 1.48.2.4 2003/04/11 12:06:14 oes
82 * Addressed bug #719435
83 * - Extraneous filterfile directives now logged as errors
84 * - This and unrecnonised directives now really obvious on status page
86 * Revision 1.48.2.3 2003/03/11 11:53:59 oes
87 * Cosmetic: Renamed cryptic variable
89 * Revision 1.48.2.2 2002/11/12 16:28:20 oes
90 * Move unrelated variable declaration out of #ifdef FEATURE_ACL; fixes bug #636655
92 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
93 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
95 * Revision 1.48 2002/05/14 21:30:38 oes
96 * savearg now uses own linking code instead of (now special-cased) add_help_link
98 * Revision 1.47 2002/05/12 21:36:29 jongfoster
99 * Correcting function comments
101 * Revision 1.46 2002/04/26 12:55:14 oes
102 * - New option "user-manual", defaults to our site
103 * via project.h #define
104 * - savearg now embeds option names in help links
106 * Revision 1.45 2002/04/24 02:11:54 oes
107 * Jon's multiple AF patch: Allow up to MAX_AF_FILES actionsfile options
109 * Revision 1.44 2002/04/08 20:37:13 swa
112 * Revision 1.43 2002/04/08 20:36:50 swa
115 * Revision 1.42 2002/04/05 15:50:15 oes
116 * fix for invalid HTML proxy_args
118 * Revision 1.41 2002/03/31 17:19:00 jongfoster
119 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
121 * Revision 1.40 2002/03/26 22:29:55 swa
122 * we have a new homepage!
124 * Revision 1.39 2002/03/24 13:25:43 swa
125 * name change related issues
127 * Revision 1.38 2002/03/24 13:05:48 jongfoster
128 * Renaming re_filterfile to filterfile
130 * Revision 1.37 2002/03/16 23:54:06 jongfoster
131 * Adding graceful termination feature, to help look for memory leaks.
132 * If you enable this (which, by design, has to be done by hand
133 * editing config.h) and then go to http://i.j.b/die, then the program
134 * will exit cleanly after the *next* request. It should free all the
135 * memory that was used.
137 * Revision 1.36 2002/03/13 00:27:05 jongfoster
140 * Revision 1.35 2002/03/07 03:52:44 oes
141 * Set logging to tty for --no-daemon mode
143 * Revision 1.34 2002/03/06 23:14:35 jongfoster
144 * Trivial cosmetic changes to make function comments easier to find.
146 * Revision 1.33 2002/03/05 04:52:42 oes
147 * Deleted non-errlog debugging code
149 * Revision 1.32 2002/03/04 18:24:53 oes
150 * Re-enabled output of unknown config directive hash
152 * Revision 1.31 2002/03/03 15:07:20 oes
153 * Re-enabled automatic config reloading
155 * Revision 1.30 2002/01/22 23:31:43 jongfoster
156 * Replacing strsav() with string_append()
158 * Revision 1.29 2002/01/17 21:02:30 jongfoster
159 * Moving all our URL and URL pattern parsing code to urlmatch.c.
161 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
163 * Revision 1.28 2001/12/30 14:07:32 steudten
164 * - Add signal handling (unix)
165 * - Add SIGHUP handler (unix)
166 * - Add creation of pidfile (unix)
167 * - Add action 'top' in rc file (RH)
168 * - Add entry 'SIGNALS' to manpage
169 * - Add exit message to logfile (unix)
171 * Revision 1.27 2001/11/07 00:02:13 steudten
172 * Add line number in error output for lineparsing for
173 * actionsfile and configfile.
174 * Special handling for CLF added.
176 * Revision 1.26 2001/11/05 21:41:43 steudten
177 * Add changes to be a real daemon just for unix os.
178 * (change cwd to /, detach from controlling tty, set
179 * process group and session leader to the own process.
181 * Add some fatal-error log message for failed malloc().
182 * Add '-d' if compiled with 'configure --with-debug' to
183 * enable debug output.
185 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
186 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
187 * threads to call select() simultaneously. So, it's time to do a real, live,
188 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
189 * (native). Both versions will work, but using __OS2__ offers multi-threading.
191 * Revision 1.24 2001/10/23 21:40:30 jongfoster
192 * Added support for enable-edit-actions and enable-remote-toggle config
195 * Revision 1.23 2001/10/07 15:36:00 oes
196 * Introduced new config option "buffer-limit"
198 * Revision 1.22 2001/09/22 16:36:59 jongfoster
199 * Removing unused parameter fs from read_config_line()
201 * Revision 1.21 2001/09/16 17:10:43 jongfoster
202 * Moving function savearg() here, since it was the only thing left in
205 * Revision 1.20 2001/07/30 22:08:36 jongfoster
206 * Tidying up #defines:
207 * - All feature #defines are now of the form FEATURE_xxx
208 * - Permanently turned off WIN_GUI_EDIT
209 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
211 * Revision 1.19 2001/07/15 17:45:16 jongfoster
212 * Removing some unused #includes
214 * Revision 1.18 2001/07/13 14:01:14 oes
215 * - Removed all #ifdef PCRS
216 * - Removed vim-settings
218 * Revision 1.17 2001/06/29 13:31:03 oes
219 * - Improved comments
220 * - Fixed (actionsfile) and sorted hashes
221 * - Introduced admin_address and proxy-info-url
222 * as config parameters
223 * - Renamed config->proxy_args_invocation (which didn't have
224 * the invocation but the options!) to config->proxy_args
225 * - Various adaptions
226 * - Removed logentry from cancelled commit
228 * Revision 1.16 2001/06/09 10:55:28 jongfoster
229 * Changing BUFSIZ ==> BUFFER_SIZE
231 * Revision 1.15 2001/06/07 23:13:40 jongfoster
232 * Merging ACL and forward files into config file.
233 * Cosmetic: Sorting config file options alphabetically.
234 * Cosmetic: Adding brief syntax comments to config file options.
236 * Revision 1.14 2001/06/07 14:46:25 joergs
237 * Missing make_path() added for re_filterfile.
239 * Revision 1.13 2001/06/05 22:33:54 jongfoster
241 * Fixed minor memory leak.
242 * Also now uses make_path to prepend the pathnames.
244 * Revision 1.12 2001/06/05 20:04:09 jongfoster
245 * Now uses _snprintf() in place of snprintf() under Win32.
247 * Revision 1.11 2001/06/04 18:31:58 swa
248 * files are now prefixed with either `confdir' or `logdir'.
249 * `make redhat-dist' replaces both entries confdir and logdir
252 * Revision 1.10 2001/06/03 19:11:54 oes
253 * introduced confdir option
255 * Revision 1.9 2001/06/01 20:06:24 jongfoster
256 * Removed support for "tinygif" option - moved to actions file.
258 * Revision 1.8 2001/05/31 21:27:13 jongfoster
259 * Removed many options from the config file and into the
260 * "actions" file: add_forwarded, suppress_vanilla_wafer,
261 * wafer, add_header, user_agent, referer, from
262 * Also globally replaced "permission" with "action".
264 * Revision 1.7 2001/05/29 09:50:24 jongfoster
265 * Unified blocklist/imagelist/permissionslist.
266 * File format is still under discussion, but the internal changes
269 * Also modified interceptor behaviour:
270 * - We now intercept all URLs beginning with one of the following
271 * prefixes (and *only* these prefixes):
273 * * http://ijbswa.sf.net/config/
274 * * http://ijbswa.sourceforge.net/config/
275 * - New interceptors "home page" - go to http://i.j.b/ to see it.
276 * - Internal changes so that intercepted and fast redirect pages
277 * are not replaced with an image.
278 * - Interceptors now have the option to send a binary page direct
279 * to the client. (i.e. ijb-send-banner uses this)
280 * - Implemented show-url-info interceptor. (Which is why I needed
281 * the above interceptors changes - a typical URL is
282 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
283 * The previous mechanism would not have intercepted that, and
284 * if it had been intercepted then it then it would have replaced
287 * Revision 1.6 2001/05/26 00:28:36 jongfoster
288 * Automatic reloading of config file.
289 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
290 * Most of the global variables have been moved to a new
291 * struct configuration_spec, accessed through csp->config->globalname
292 * Most of the globals remaining are used by the Win32 GUI.
294 * Revision 1.5 2001/05/25 22:34:30 jongfoster
297 * Revision 1.4 2001/05/22 18:46:04 oes
299 * - Enabled filtering banners by size rather than URL
300 * by adding patterns that replace all standard banner
301 * sizes with the "Junkbuster" gif to the re_filterfile
303 * - Enabled filtering WebBugs by providing a pattern
304 * which kills all 1x1 images
306 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
307 * which is selected by the (nonstandard and therefore
308 * capital) letter 'U' in the option string.
309 * It causes the quantifiers to be ungreedy by default.
310 * Appending a ? turns back to greedy (!).
312 * - Added a new interceptor ijb-send-banner, which
313 * sends back the "Junkbuster" gif. Without imagelist or
314 * MSIE detection support, or if tinygif = 1, or the
315 * URL isn't recognized as an imageurl, a lame HTML
316 * explanation is sent instead.
318 * - Added new feature, which permits blocking remote
319 * script redirects and firing back a local redirect
321 * The feature is conditionally compiled, i.e. it
322 * can be disabled with --disable-fast-redirects,
323 * plus it must be activated by a "fast-redirects"
324 * line in the config file, has its own log level
325 * and of course wants to be displayed by show-proxy-args
326 * Note: Boy, all the #ifdefs in 1001 locations and
327 * all the fumbling with configure.in and acconfig.h
328 * were *way* more work than the feature itself :-(
330 * - Because a generic redirect template was needed for
331 * this, tinygif = 3 now uses the same.
333 * - Moved GIFs, and other static HTTP response templates
338 * - Removed some >400 CRs again (Jon, you really worked
341 * Revision 1.3 2001/05/20 01:21:20 jongfoster
342 * Version 2.9.4 checkin.
343 * - Merged popupfile and cookiefile, and added control over PCRS
344 * filtering, in new "permissionsfile".
345 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
346 * file error you now get a message box (in the Win32 GUI) rather
347 * than the program exiting with no explanation.
348 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
350 * - Removed tabs from "config"
351 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
352 * - Bumped up version number.
354 * Revision 1.2 2001/05/17 23:01:01 oes
355 * - Cleaned CRLF's from the sources and related files
357 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
358 * Initial import of version 2.9.3 source tree
361 *********************************************************************/
367 #include <sys/types.h>
381 # include <windows.h>
384 # ifndef _WIN_CONSOLE
386 # endif /* ndef _WIN_CONSOLE */
388 /* VC++ has "_snprintf", not "snprintf" */
389 #define snprintf _snprintf
391 #else /* ifndef _WIN32 */
395 # include <sys/wait.h>
397 # include <sys/time.h>
398 # include <sys/stat.h>
408 #include "miscutil.h"
412 #include "urlmatch.h"
415 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
418 * Fix a problem with Solaris. There should be no effect on other
420 * Solaris's isspace() is a macro which uses it's argument directly
421 * as an array index. Therefore we need to make sure that high-bit
422 * characters generate +ve values, and ideally we also want to make
423 * the argument match the declared parameter type of "int".
425 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
426 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
428 #ifdef FEATURE_TOGGLE
429 /* Privoxy is enabled by default. */
430 int global_toggle_state = 1;
431 #endif /* def FEATURE_TOGGLE */
433 /* The filename of the configfile */
434 const char *configfile = NULL;
437 * CGI functions will later need access to the invocation args,
438 * so we will make argc and argv global.
441 const char **Argv = NULL;
443 static struct file_list *current_configfile = NULL;
447 * This takes the "cryptic" hash of each keyword and aliases them to
448 * something a little more readable. This also makes changing the
449 * hash values easier if they should change or the hash algorthm changes.
450 * Use the included "hash" program to find out what the hash will be
451 * for any string supplied on the command line. (Or just put it in the
452 * config file and read the number from the error message in the log).
454 * Please keep this list sorted alphabetically (but with the Windows
455 * console and GUI specific options last).
458 #define hash_actions_file 1196306641ul /* "actionsfile" */
459 #define hash_admin_address 4112573064ul /* "admin-address" */
460 #define hash_buffer_limit 1881726070ul /* "buffer-limit */
461 #define hash_confdir 1978389ul /* "confdir" */
462 #define hash_debug 78263ul /* "debug" */
463 #define hash_deny_access 1227333715ul /* "deny-access" */
464 #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */
465 #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */
466 #define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */
467 #define hash_filterfile 250887266ul /* "filterfile" */
468 #define hash_forward 2029845ul /* "forward" */
469 #define hash_forward_socks4 3963965521ul /* "forward-socks4" */
470 #define hash_forward_socks4a 2639958518ul /* "forward-socks4a" */
471 #define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
472 #define hash_jarfile 2046641ul /* "jarfile" */
473 #define hash_listen_address 1255650842ul /* "listen-address" */
474 #define hash_logdir 422889ul /* "logdir" */
475 #define hash_logfile 2114766ul /* "logfile" */
476 #define hash_permit_access 3587953268ul /* "permit-access" */
477 #define hash_proxy_info_url 3903079059ul /* "proxy-info-url" */
478 #define hash_single_threaded 4250084780ul /* "single-threaded" */
479 #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */
480 #define hash_toggle 447966ul /* "toggle" */
481 #define hash_trust_info_url 430331967ul /* "trust-info-url" */
482 #define hash_trustfile 56494766ul /* "trustfile" */
483 #define hash_usermanual 1416668518ul /* "user-manual" */
484 #define hash_activity_animation 1817904738ul /* "activity-animation" */
485 #define hash_close_button_minimizes 3651284693ul /* "close-button-minimizes" */
486 #define hash_hide_console 2048809870ul /* "hide-console" */
487 #define hash_log_buffer_size 2918070425ul /* "log-buffer-size" */
488 #define hash_log_font_name 2866730124ul /* "log-font-name" */
489 #define hash_log_font_size 2866731014ul /* "log-font-size" */
490 #define hash_log_highlight_messages 4032101240ul /* "log-highlight-messages" */
491 #define hash_log_max_lines 2868344173ul /* "log-max-lines" */
492 #define hash_log_messages 2291744899ul /* "log-messages" */
493 #define hash_show_on_task_bar 215410365ul /* "show-on-task-bar" */
496 static void savearg(char *command, char *argument, struct configuration_spec * config);
498 /*********************************************************************
500 * Function : unload_configfile
502 * Description : Free the config structure and all components.
505 * 1 : data: struct configuration_spec to unload
509 *********************************************************************/
510 void unload_configfile (void * data)
512 struct configuration_spec * config = (struct configuration_spec *)data;
513 struct forward_spec *cur_fwd = config->forward;
517 struct access_control_list *cur_acl = config->acl;
519 while (cur_acl != NULL)
521 struct access_control_list * next_acl = cur_acl->next;
526 #endif /* def FEATURE_ACL */
528 while (cur_fwd != NULL)
530 struct forward_spec * next_fwd = cur_fwd->next;
531 free_url_spec(cur_fwd->url);
533 freez(cur_fwd->gateway_host);
534 freez(cur_fwd->forward_host);
538 config->forward = NULL;
540 #ifdef FEATURE_COOKIE_JAR
541 if ( NULL != config->jar )
543 fclose( config->jar );
546 #endif /* def FEATURE_COOKIE_JAR */
548 freez(config->confdir);
549 freez(config->logdir);
551 freez(config->haddr);
552 freez(config->logfile);
554 for (i = 0; i < MAX_AF_FILES; i++)
556 freez(config->actions_file_short[i]);
557 freez(config->actions_file[i]);
558 freez(config->re_filterfile_short[i]);
559 freez(config->re_filterfile[i]);
562 freez(config->admin_address);
563 freez(config->proxy_info_url);
564 freez(config->proxy_args);
565 freez(config->usermanual);
567 #ifdef FEATURE_COOKIE_JAR
568 freez(config->jarfile);
569 #endif /* def FEATURE_COOKIE_JAR */
572 freez(config->trustfile);
573 list_remove_all(config->trust_info);
574 #endif /* def FEATURE_TRUST */
576 for (i = 0; i < MAX_AF_FILES; i++)
578 freez(config->re_filterfile[i]);
585 #ifdef FEATURE_GRACEFUL_TERMINATION
586 /*********************************************************************
588 * Function : unload_current_config_file
590 * Description : Unloads current config file - reset to state at
591 * beginning of program.
597 *********************************************************************/
598 void unload_current_config_file(void)
600 if (current_configfile)
602 current_configfile->unloader = unload_configfile;
603 current_configfile = NULL;
609 /*********************************************************************
611 * Function : load_config
613 * Description : Load the config file and all parameters.
617 * Returns : The configuration_spec, or NULL on error.
619 *********************************************************************/
620 struct configuration_spec * load_config(void)
622 char buf[BUFFER_SIZE];
624 FILE *configfp = NULL;
625 struct configuration_spec * config = NULL;
626 struct client_state * fake_csp;
627 struct file_list *fs;
628 unsigned long linenum = 0;
631 if ( !check_file_changed(current_configfile, configfile, &fs))
633 /* No need to load */
634 return ((struct configuration_spec *)current_configfile->f);
638 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
642 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
644 #ifdef FEATURE_TOGGLE
645 global_toggle_state = 1;
646 #endif /* def FEATURE_TOGGLE */
648 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
654 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
655 /* Never get here - LOG_LEVEL_FATAL causes program exit */
659 * This is backwards from how it's usually done.
660 * Following the usual pattern, "fs" would be stored in a member
661 * variable in "csp", and then we'd access "config" from "fs->f",
662 * using a cast. However, "config" is used so often that a
663 * cast each time would be very ugly, and the extra indirection
664 * would waste CPU cycles. Therefore we store "config" in
665 * "csp->config", and "fs" in "csp->config->config_file_list".
667 config->config_file_list = fs;
672 config->multi_threaded = 1;
673 config->hport = HADDR_PORT;
674 config->buffer_limit = 4096 * 1024;
675 config->usermanual = strdup(USER_MANUAL_URL);
676 config->proxy_args = strdup("");
677 config->forwarded_connect_retries = 0;
678 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
680 if ((configfp = fopen(configfile, "r")) == NULL)
682 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
684 /* Never get here - LOG_LEVEL_FATAL causes program exit */
687 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
689 char cmd[BUFFER_SIZE];
690 char arg[BUFFER_SIZE];
691 char tmp[BUFFER_SIZE];
693 struct access_control_list *cur_acl;
694 #endif /* def FEATURE_ACL */
695 struct forward_spec *cur_fwd;
701 /* Copy command (i.e. up to space or tab) into cmd */
704 while (*p && (*p != ' ') && (*p != '\t'))
710 /* Skip over the whitespace in buf */
711 while (*p && ((*p == ' ') || (*p == '\t')))
716 /* Copy the argument into arg */
719 /* Should never happen, but check this anyway */
725 /* Make sure the command field is lower case */
730 *p = ijb_tolower(*p);
734 /* Save the argument for show-proxy-args */
735 savearg(cmd, arg, config);
738 switch( hash_string( cmd ) )
740 /* *************************************************************************
741 * actionsfile actions-file-name
742 * In confdir by default
743 * *************************************************************************/
744 case hash_actions_file :
746 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
751 if (i >= MAX_AF_FILES)
753 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
754 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
757 config->actions_file_short[i] = strdup(arg);
758 p = malloc(strlen(arg) + sizeof(".action"));
761 log_error(LOG_LEVEL_FATAL, "Out of memory");
764 strcat(p, ".action");
765 config->actions_file[i] = make_path(config->confdir, p);
769 /* *************************************************************************
770 * admin-address email-address
771 * *************************************************************************/
772 case hash_admin_address :
773 freez(config->admin_address);
774 config->admin_address = strdup(arg);
777 /* *************************************************************************
779 * *************************************************************************/
780 case hash_buffer_limit :
781 config->buffer_limit = (size_t) 1024 * atoi(arg);
784 /* *************************************************************************
785 * confdir directory-name
786 * *************************************************************************/
788 freez(config->confdir);
789 config->confdir = make_path( NULL, arg);
792 /* *************************************************************************
794 * Specifies debug level, multiple values are ORed together.
795 * *************************************************************************/
797 config->debug |= atoi(arg);
800 /* *************************************************************************
801 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
802 * *************************************************************************/
804 case hash_deny_access:
805 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
807 if ((vec_count != 1) && (vec_count != 2))
809 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
810 "deny-access directive in configuration file.");
811 string_append(&config->proxy_args,
812 "<br>\nWARNING: Wrong number of parameters for "
813 "deny-access directive in configuration file.<br><br>\n");
817 /* allocate a new node */
818 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
822 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
823 /* Never get here - LOG_LEVEL_FATAL causes program exit */
826 cur_acl->action = ACL_DENY;
828 if (acl_addr(vec[0], cur_acl->src) < 0)
830 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
831 "directive in configuration file: \"%s\"", vec[0]);
832 string_append(&config->proxy_args,
833 "<br>\nWARNING: Invalid source IP for deny-access directive"
834 " in configuration file: \"");
835 string_append(&config->proxy_args,
837 string_append(&config->proxy_args,
844 if (acl_addr(vec[1], cur_acl->dst) < 0)
846 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
847 "directive in configuration file: \"%s\"", vec[0]);
848 string_append(&config->proxy_args,
849 "<br>\nWARNING: Invalid destination IP for deny-access directive"
850 " in configuration file: \"");
851 string_append(&config->proxy_args,
853 string_append(&config->proxy_args,
861 * Add it to the list. Note we reverse the list to get the
862 * behaviour the user expects. With both the ACL and
863 * actions file, the last match wins. However, the internal
864 * implementations are different: The actions file is stored
865 * in the same order as the file, and scanned completely.
866 * With the ACL, we reverse the order as we load it, then
867 * when we scan it we stop as soon as we get a match.
869 cur_acl->next = config->acl;
870 config->acl = cur_acl;
873 #endif /* def FEATURE_ACL */
875 /* *************************************************************************
876 * enable-edit-actions 0|1
877 * *************************************************************************/
878 #ifdef FEATURE_CGI_EDIT_ACTIONS
879 case hash_enable_edit_actions:
880 if ((*arg != '\0') && (0 != atoi(arg)))
882 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
886 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
889 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
891 /* *************************************************************************
892 * enable-remote-toggle 0|1
893 * *************************************************************************/
894 #ifdef FEATURE_CGI_EDIT_ACTIONS
895 case hash_enable_remote_toggle:
896 if ((*arg != '\0') && (0 != atoi(arg)))
898 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
902 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
905 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
907 /* *************************************************************************
908 * enable-remote-http-toggle 0|1
909 * *************************************************************************/
910 case hash_enable_remote_http_toggle:
911 if ((*arg != '\0') && (0 != atoi(arg)))
913 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
917 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
921 /* *************************************************************************
922 * filterfile file-name
923 * In confdir by default.
924 * *************************************************************************/
925 case hash_filterfile :
927 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
932 if (i >= MAX_AF_FILES)
934 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
935 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
938 config->re_filterfile_short[i] = strdup(arg);
939 p = malloc(strlen(arg) + 1);
942 log_error(LOG_LEVEL_FATAL, "Out of memory");
945 config->re_filterfile[i] = make_path(config->confdir, p);
949 /* *************************************************************************
950 * forward url-pattern (.|http-proxy-host[:port])
951 * *************************************************************************/
953 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
957 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
958 "directive in configuration file.");
959 string_append(&config->proxy_args,
960 "<br>\nWARNING: Wrong number of parameters for "
961 "forward directive in configuration file.");
965 /* allocate a new node */
966 cur_fwd = zalloc(sizeof(*cur_fwd));
969 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
970 /* Never get here - LOG_LEVEL_FATAL causes program exit */
974 cur_fwd->type = SOCKS_NONE;
976 /* Save the URL pattern */
977 if (create_url_spec(cur_fwd->url, vec[0]))
979 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
980 "directive in configuration file.");
981 string_append(&config->proxy_args,
982 "<br>\nWARNING: Bad URL specifier for "
983 "forward directive in configuration file.");
987 /* Parse the parent HTTP proxy host:port */
990 if (strcmp(p, ".") != 0)
992 cur_fwd->forward_host = strdup(p);
994 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
997 cur_fwd->forward_port = atoi(p);
1000 if (cur_fwd->forward_port <= 0)
1002 cur_fwd->forward_port = 8000;
1007 cur_fwd->next = config->forward;
1008 config->forward = cur_fwd;
1012 /* *************************************************************************
1013 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
1014 * *************************************************************************/
1015 case hash_forward_socks4:
1016 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1020 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1021 "forward-socks4 directive in configuration file.");
1022 string_append(&config->proxy_args,
1023 "<br>\nWARNING: Wrong number of parameters for "
1024 "forward-socks4 directive in configuration file.");
1028 /* allocate a new node */
1029 cur_fwd = zalloc(sizeof(*cur_fwd));
1030 if (cur_fwd == NULL)
1032 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1033 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1037 cur_fwd->type = SOCKS_4;
1039 /* Save the URL pattern */
1040 if (create_url_spec(cur_fwd->url, vec[0]))
1042 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
1043 "directive in configuration file.");
1044 string_append(&config->proxy_args,
1045 "<br>\nWARNING: Bad URL specifier for "
1046 "forward-socks4 directive in configuration file.");
1050 /* Parse the SOCKS proxy host[:port] */
1053 if (strcmp(p, ".") != 0)
1055 cur_fwd->gateway_host = strdup(p);
1057 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1060 cur_fwd->gateway_port = atoi(p);
1062 if (cur_fwd->gateway_port <= 0)
1064 cur_fwd->gateway_port = 1080;
1068 /* Parse the parent HTTP proxy host[:port] */
1071 if (strcmp(p, ".") != 0)
1073 cur_fwd->forward_host = strdup(p);
1075 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1078 cur_fwd->forward_port = atoi(p);
1081 if (cur_fwd->forward_port <= 0)
1083 cur_fwd->forward_port = 8000;
1088 cur_fwd->next = config->forward;
1089 config->forward = cur_fwd;
1093 /* *************************************************************************
1094 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1095 * *************************************************************************/
1096 case hash_forward_socks4a:
1097 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1101 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1102 "forward-socks4a directive in configuration file.");
1103 string_append(&config->proxy_args,
1104 "<br>\nWARNING: Wrong number of parameters for "
1105 "forward-socks4a directive in configuration file.");
1109 /* allocate a new node */
1110 cur_fwd = zalloc(sizeof(*cur_fwd));
1111 if (cur_fwd == NULL)
1113 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1114 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1118 cur_fwd->type = SOCKS_4A;
1120 /* Save the URL pattern */
1121 if (create_url_spec(cur_fwd->url, vec[0]))
1123 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1124 "directive in configuration file.");
1125 string_append(&config->proxy_args,
1126 "<br>\nWARNING: Bad URL specifier for "
1127 "forward-socks4a directive in configuration file.");
1131 /* Parse the SOCKS proxy host[:port] */
1134 cur_fwd->gateway_host = strdup(p);
1136 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1139 cur_fwd->gateway_port = atoi(p);
1141 if (cur_fwd->gateway_port <= 0)
1143 cur_fwd->gateway_port = 1080;
1146 /* Parse the parent HTTP proxy host[:port] */
1149 if (strcmp(p, ".") != 0)
1151 cur_fwd->forward_host = strdup(p);
1153 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1156 cur_fwd->forward_port = atoi(p);
1159 if (cur_fwd->forward_port <= 0)
1161 cur_fwd->forward_port = 8000;
1166 cur_fwd->next = config->forward;
1167 config->forward = cur_fwd;
1171 /* *************************************************************************
1172 * forwarded-connect-retries n
1173 * *************************************************************************/
1174 case hash_forwarded_connect_retries :
1175 config->forwarded_connect_retries = atoi(arg);
1178 /* *************************************************************************
1179 * jarfile jar-file-name
1180 * In logdir by default
1181 * *************************************************************************/
1182 #ifdef FEATURE_COOKIE_JAR
1184 freez(config->jarfile);
1185 config->jarfile = make_path(config->logdir, arg);
1187 #endif /* def FEATURE_COOKIE_JAR */
1189 /* *************************************************************************
1190 * listen-address [ip][:port]
1191 * *************************************************************************/
1192 case hash_listen_address :
1193 freez(config->haddr);
1194 config->haddr = strdup(arg);
1197 /* *************************************************************************
1198 * logdir directory-name
1199 * *************************************************************************/
1201 freez(config->logdir);
1202 config->logdir = make_path(NULL, arg);
1205 /* *************************************************************************
1206 * logfile log-file-name
1207 * In logdir by default
1208 * *************************************************************************/
1210 freez(config->logfile);
1211 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1214 /* *************************************************************************
1215 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1216 * *************************************************************************/
1218 case hash_permit_access:
1219 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1221 if ((vec_count != 1) && (vec_count != 2))
1223 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1224 "permit-access directive in configuration file.");
1225 string_append(&config->proxy_args,
1226 "<br>\nWARNING: Wrong number of parameters for "
1227 "permit-access directive in configuration file.<br><br>\n");
1232 /* allocate a new node */
1233 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1235 if (cur_acl == NULL)
1237 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1238 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1241 cur_acl->action = ACL_PERMIT;
1243 if (acl_addr(vec[0], cur_acl->src) < 0)
1245 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1246 "directive in configuration file: \"%s\"", vec[0]);
1247 string_append(&config->proxy_args,
1248 "<br>\nWARNING: Invalid source IP for permit-access directive"
1249 " in configuration file: \"");
1250 string_append(&config->proxy_args,
1252 string_append(&config->proxy_args,
1259 if (acl_addr(vec[1], cur_acl->dst) < 0)
1261 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1262 "permit-access directive in configuration file: \"%s\"",
1264 string_append(&config->proxy_args,
1265 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1266 " in configuration file: \"");
1267 string_append(&config->proxy_args,
1269 string_append(&config->proxy_args,
1277 * Add it to the list. Note we reverse the list to get the
1278 * behaviour the user expects. With both the ACL and
1279 * actions file, the last match wins. However, the internal
1280 * implementations are different: The actions file is stored
1281 * in the same order as the file, and scanned completely.
1282 * With the ACL, we reverse the order as we load it, then
1283 * when we scan it we stop as soon as we get a match.
1285 cur_acl->next = config->acl;
1286 config->acl = cur_acl;
1289 #endif /* def FEATURE_ACL */
1291 /* *************************************************************************
1292 * proxy-info-url url
1293 * *************************************************************************/
1294 case hash_proxy_info_url :
1295 freez(config->proxy_info_url);
1296 config->proxy_info_url = strdup(arg);
1299 /* *************************************************************************
1301 * *************************************************************************/
1302 case hash_single_threaded :
1303 config->multi_threaded = 0;
1306 /* *************************************************************************
1308 * *************************************************************************/
1309 #ifdef FEATURE_TOGGLE
1311 global_toggle_state = atoi(arg);
1313 #endif /* def FEATURE_TOGGLE */
1315 /* *************************************************************************
1316 * trust-info-url url
1317 * *************************************************************************/
1318 #ifdef FEATURE_TRUST
1319 case hash_trust_info_url :
1320 enlist(config->trust_info, arg);
1322 #endif /* def FEATURE_TRUST */
1324 /* *************************************************************************
1325 * trustfile filename
1326 * (In confdir by default.)
1327 * *************************************************************************/
1328 #ifdef FEATURE_TRUST
1329 case hash_trustfile :
1330 freez(config->trustfile);
1331 config->trustfile = make_path(config->confdir, arg);
1333 #endif /* def FEATURE_TRUST */
1335 /* *************************************************************************
1337 * *************************************************************************/
1338 case hash_usermanual :
1339 freez(config->usermanual);
1340 config->usermanual = strdup(arg);
1343 /* *************************************************************************
1344 * Win32 Console options:
1345 * *************************************************************************/
1347 /* *************************************************************************
1349 * *************************************************************************/
1351 case hash_hide_console :
1354 #endif /*def _WIN_CONSOLE*/
1357 /* *************************************************************************
1358 * Win32 GUI options:
1359 * *************************************************************************/
1361 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1362 /* *************************************************************************
1363 * activity-animation (0|1)
1364 * *************************************************************************/
1365 case hash_activity_animation :
1366 g_bShowActivityAnimation = atoi(arg);
1369 /* *************************************************************************
1370 * close-button-minimizes (0|1)
1371 * *************************************************************************/
1372 case hash_close_button_minimizes :
1373 g_bCloseHidesWindow = atoi(arg);
1376 /* *************************************************************************
1377 * log-buffer-size (0|1)
1378 * *************************************************************************/
1379 case hash_log_buffer_size :
1380 g_bLimitBufferSize = atoi(arg);
1383 /* *************************************************************************
1384 * log-font-name fontnane
1385 * *************************************************************************/
1386 case hash_log_font_name :
1387 strcpy( g_szFontFaceName, arg );
1390 /* *************************************************************************
1392 * *************************************************************************/
1393 case hash_log_font_size :
1394 g_nFontSize = atoi(arg);
1397 /* *************************************************************************
1398 * log-highlight-messages (0|1)
1399 * *************************************************************************/
1400 case hash_log_highlight_messages :
1401 g_bHighlightMessages = atoi(arg);
1404 /* *************************************************************************
1406 * *************************************************************************/
1407 case hash_log_max_lines :
1408 g_nMaxBufferLines = atoi(arg);
1411 /* *************************************************************************
1412 * log-messages (0|1)
1413 * *************************************************************************/
1414 case hash_log_messages :
1415 g_bLogMessages = atoi(arg);
1418 /* *************************************************************************
1419 * show-on-task-bar (0|1)
1420 * *************************************************************************/
1421 case hash_show_on_task_bar :
1422 g_bShowOnTaskBar = atoi(arg);
1425 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1428 /* *************************************************************************
1429 * Warnings about unsupported features
1430 * *************************************************************************/
1432 case hash_deny_access:
1433 #endif /* ndef FEATURE_ACL */
1434 #ifndef FEATURE_CGI_EDIT_ACTIONS
1435 case hash_enable_edit_actions:
1436 case hash_enable_remote_toggle:
1437 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1438 #ifndef FEATURE_COOKIE_JAR
1440 #endif /* ndef FEATURE_COOKIE_JAR */
1442 case hash_permit_access:
1443 #endif /* ndef FEATURE_ACL */
1444 #ifndef FEATURE_TOGGLE
1446 #endif /* ndef FEATURE_TOGGLE */
1447 #ifndef FEATURE_TRUST
1448 case hash_trustfile :
1449 case hash_trust_info_url :
1450 #endif /* ndef FEATURE_TRUST */
1452 #ifndef _WIN_CONSOLE
1453 case hash_hide_console :
1454 #endif /* ndef _WIN_CONSOLE */
1456 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1457 case hash_activity_animation :
1458 case hash_close_button_minimizes :
1459 case hash_log_buffer_size :
1460 case hash_log_font_name :
1461 case hash_log_font_size :
1462 case hash_log_highlight_messages :
1463 case hash_log_max_lines :
1464 case hash_log_messages :
1465 case hash_show_on_task_bar :
1466 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1467 /* These warnings are annoying - so hide them. -- Jon */
1468 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1471 /* *************************************************************************/
1473 /* *************************************************************************/
1475 * I decided that I liked this better as a warning than an
1476 * error. To change back to an error, just change log level
1477 * to LOG_LEVEL_FATAL.
1479 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive '%s' (%luul) in line %lu "
1480 "in configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1481 string_append(&config->proxy_args,
1482 " <b><font color=\"red\">WARNING: unrecognized directive, ignored</font></b>");
1485 /* *************************************************************************/
1486 } /* end switch( hash_string(cmd) ) */
1487 } /* end while ( read_config_line(...) ) */
1491 if (NULL == config->proxy_args)
1493 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1496 init_error_log(Argv[0], config->logfile, config->debug);
1498 if (config->actions_file[0])
1500 add_loader(load_actions_file, config);
1503 if (config->re_filterfile)
1505 add_loader(load_re_filterfile, config);
1508 #ifdef FEATURE_TRUST
1509 if (config->trustfile)
1511 add_loader(load_trustfile, config);
1513 #endif /* def FEATURE_TRUST */
1515 #ifdef FEATURE_COOKIE_JAR
1516 if ( NULL != config->jarfile )
1518 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1520 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1521 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1523 setbuf(config->jar, NULL);
1525 #endif /* def FEATURE_COOKIE_JAR */
1527 if ( NULL == config->haddr )
1529 config->haddr = strdup( HADDR_DEFAULT );
1532 if ( NULL != config->haddr )
1534 if (NULL != (p = strchr(config->haddr, ':')))
1539 config->hport = atoi(p);
1543 if (config->hport <= 0)
1546 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1547 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1549 if (*config->haddr == '\0')
1551 config->haddr = NULL;
1556 * Want to run all the loaders once now.
1558 * Need to set up a fake csp, so they can get to the config.
1560 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1561 fake_csp->config = config;
1563 if (run_loader(fake_csp))
1566 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1567 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1571 /* FIXME: this is a kludge for win32 */
1572 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1574 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1575 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1576 g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1578 #ifdef FEATURE_TRUST
1579 g_trustfile = config->trustfile;
1580 #endif /* def FEATURE_TRUST */
1583 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1584 /* FIXME: end kludge */
1587 config->need_bind = 1;
1589 if (current_configfile)
1591 struct configuration_spec * oldcfg = (struct configuration_spec *)
1592 current_configfile->f;
1594 * Check if config->haddr,hport == oldcfg->haddr,hport
1596 * The following could be written more compactly as a single,
1597 * (unreadably long) if statement.
1599 config->need_bind = 0;
1600 if (config->hport != oldcfg->hport)
1602 config->need_bind = 1;
1604 else if (config->haddr == NULL)
1606 if (oldcfg->haddr != NULL)
1608 config->need_bind = 1;
1611 else if (oldcfg->haddr == NULL)
1613 config->need_bind = 1;
1615 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1617 config->need_bind = 1;
1620 current_configfile->unloader = unload_configfile;
1623 fs->next = files->next;
1626 current_configfile = fs;
1632 /*********************************************************************
1634 * Function : savearg
1636 * Description : Called from `load_config'. It saves each non-empty
1637 * and non-comment line from config into
1638 * config->proxy_args. This is used to create the
1639 * show-proxy-args page. On error, frees
1640 * config->proxy_args and sets it to NULL
1643 * 1 : command = config setting that was found
1644 * 2 : argument = the setting's argument (if any)
1645 * 3 : config = Configuration to save into.
1649 *********************************************************************/
1650 static void savearg(char *command, char *argument, struct configuration_spec * config)
1660 * Add config option name embedded in
1661 * link to it's section in the user-manual
1663 buf = strdup("\n<a href=\"");
1664 if (!strncmpic(config->usermanual, "file://", 7) ||
1665 !strncmpic(config->usermanual, "http", 4))
1667 string_append(&buf, config->usermanual);
1671 string_append(&buf, "http://");
1672 string_append(&buf, CGI_SITE_2_HOST);
1673 string_append(&buf, "/user-manual/");
1675 string_append(&buf, CONFIG_HELP_PREFIX);
1676 string_join (&buf, string_toupper(command));
1677 string_append(&buf, "\">");
1678 string_append(&buf, command);
1679 string_append(&buf, "</a> ");
1683 freez(config->proxy_args);
1687 if ( (NULL != argument) && ('\0' != *argument) )
1689 s = html_encode(argument);
1693 freez(config->proxy_args);
1697 if (strncmpic(argument, "http://", 7) == 0)
1699 string_append(&buf, "<a href=\"");
1700 string_append(&buf, s);
1701 string_append(&buf, "\">");
1702 string_join (&buf, s);
1703 string_append(&buf, "</a>");
1707 string_join (&buf, s);
1711 string_append(&buf, "<br>");
1712 string_join(&config->proxy_args, buf);