- Added AC_CHECK_FUNC tests for the availability of
[privoxy.git] / loadcfg.c
1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.27 2001/11/07 00:02:13 steudten Exp $";
2 /*********************************************************************
3  *
4  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
5  *
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.
10  *
11  * Copyright   :  Written by and Copyright (C) 2001 the SourceForge
12  *                IJBSWA team.  http://ijbswa.sourceforge.net
13  *
14  *                Based on the Internet Junkbuster originally written
15  *                by and Copyright (C) 1997 Anonymous Coders and
16  *                Junkbusters Corporation.  http://www.junkbusters.com
17  *
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.
23  *
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.
29  *
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.
35  *
36  * Revisions   :
37  *    $Log: loadcfg.c,v $
38  *    Revision 1.27  2001/11/07 00:02:13  steudten
39  *    Add line number in error output for lineparsing for
40  *    actionsfile and configfile.
41  *    Special handling for CLF added.
42  *
43  *    Revision 1.26  2001/11/05 21:41:43  steudten
44  *    Add changes to be a real daemon just for unix os.
45  *    (change cwd to /, detach from controlling tty, set
46  *    process group and session leader to the own process.
47  *    Add DBG() Macro.
48  *    Add some fatal-error log message for failed malloc().
49  *    Add '-d' if compiled with 'configure --with-debug' to
50  *    enable debug output.
51  *
52  *    Revision 1.25  2001/10/25 03:40:48  david__schmidt
53  *    Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
54  *    threads to call select() simultaneously.  So, it's time to do a real, live,
55  *    native OS/2 port.  See defines for __EMX__ (the porting layer) vs. __OS2__
56  *    (native). Both versions will work, but using __OS2__ offers multi-threading.
57  *
58  *    Revision 1.24  2001/10/23 21:40:30  jongfoster
59  *    Added support for enable-edit-actions and enable-remote-toggle config
60  *    file options.
61  *
62  *    Revision 1.23  2001/10/07 15:36:00  oes
63  *    Introduced new config option "buffer-limit"
64  *
65  *    Revision 1.22  2001/09/22 16:36:59  jongfoster
66  *    Removing unused parameter fs from read_config_line()
67  *
68  *    Revision 1.21  2001/09/16 17:10:43  jongfoster
69  *    Moving function savearg() here, since it was the only thing left in
70  *    showargs.c.
71  *
72  *    Revision 1.20  2001/07/30 22:08:36  jongfoster
73  *    Tidying up #defines:
74  *    - All feature #defines are now of the form FEATURE_xxx
75  *    - Permanently turned off WIN_GUI_EDIT
76  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
77  *
78  *    Revision 1.19  2001/07/15 17:45:16  jongfoster
79  *    Removing some unused #includes
80  *
81  *    Revision 1.18  2001/07/13 14:01:14  oes
82  *     - Removed all #ifdef PCRS
83  *     - Removed vim-settings
84  *
85  *    Revision 1.17  2001/06/29 13:31:03  oes
86  *    - Improved comments
87  *    - Fixed (actionsfile) and sorted hashes
88  *    - Introduced admin_address and proxy-info-url
89  *      as config parameters
90  *    - Renamed config->proxy_args_invocation (which didn't have
91  *      the invocation but the options!) to config->proxy_args
92  *    - Various adaptions
93  *    - Removed logentry from cancelled commit
94  *
95  *    Revision 1.16  2001/06/09 10:55:28  jongfoster
96  *    Changing BUFSIZ ==> BUFFER_SIZE
97  *
98  *    Revision 1.15  2001/06/07 23:13:40  jongfoster
99  *    Merging ACL and forward files into config file.
100  *    Cosmetic: Sorting config file options alphabetically.
101  *    Cosmetic: Adding brief syntax comments to config file options.
102  *
103  *    Revision 1.14  2001/06/07 14:46:25  joergs
104  *    Missing make_path() added for re_filterfile.
105  *
106  *    Revision 1.13  2001/06/05 22:33:54  jongfoster
107  *
108  *    Fixed minor memory leak.
109  *    Also now uses make_path to prepend the pathnames.
110  *
111  *    Revision 1.12  2001/06/05 20:04:09  jongfoster
112  *    Now uses _snprintf() in place of snprintf() under Win32.
113  *
114  *    Revision 1.11  2001/06/04 18:31:58  swa
115  *    files are now prefixed with either `confdir' or `logdir'.
116  *    `make redhat-dist' replaces both entries confdir and logdir
117  *    with redhat values
118  *
119  *    Revision 1.10  2001/06/03 19:11:54  oes
120  *    introduced confdir option
121  *
122  *    Revision 1.9  2001/06/01 20:06:24  jongfoster
123  *    Removed support for "tinygif" option - moved to actions file.
124  *
125  *    Revision 1.8  2001/05/31 21:27:13  jongfoster
126  *    Removed many options from the config file and into the
127  *    "actions" file: add_forwarded, suppress_vanilla_wafer,
128  *    wafer, add_header, user_agent, referer, from
129  *    Also globally replaced "permission" with "action".
130  *
131  *    Revision 1.7  2001/05/29 09:50:24  jongfoster
132  *    Unified blocklist/imagelist/permissionslist.
133  *    File format is still under discussion, but the internal changes
134  *    are (mostly) done.
135  *
136  *    Also modified interceptor behaviour:
137  *    - We now intercept all URLs beginning with one of the following
138  *      prefixes (and *only* these prefixes):
139  *        * http://i.j.b/
140  *        * http://ijbswa.sf.net/config/
141  *        * http://ijbswa.sourceforge.net/config/
142  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
143  *    - Internal changes so that intercepted and fast redirect pages
144  *      are not replaced with an image.
145  *    - Interceptors now have the option to send a binary page direct
146  *      to the client. (i.e. ijb-send-banner uses this)
147  *    - Implemented show-url-info interceptor.  (Which is why I needed
148  *      the above interceptors changes - a typical URL is
149  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
150  *      The previous mechanism would not have intercepted that, and
151  *      if it had been intercepted then it then it would have replaced
152  *      it with an image.)
153  *
154  *    Revision 1.6  2001/05/26 00:28:36  jongfoster
155  *    Automatic reloading of config file.
156  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
157  *    Most of the global variables have been moved to a new
158  *    struct configuration_spec, accessed through csp->config->globalname
159  *    Most of the globals remaining are used by the Win32 GUI.
160  *
161  *    Revision 1.5  2001/05/25 22:34:30  jongfoster
162  *    Hard tabs->Spaces
163  *
164  *    Revision 1.4  2001/05/22 18:46:04  oes
165  *
166  *    - Enabled filtering banners by size rather than URL
167  *      by adding patterns that replace all standard banner
168  *      sizes with the "Junkbuster" gif to the re_filterfile
169  *
170  *    - Enabled filtering WebBugs by providing a pattern
171  *      which kills all 1x1 images
172  *
173  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
174  *      which is selected by the (nonstandard and therefore
175  *      capital) letter 'U' in the option string.
176  *      It causes the quantifiers to be ungreedy by default.
177  *      Appending a ? turns back to greedy (!).
178  *
179  *    - Added a new interceptor ijb-send-banner, which
180  *      sends back the "Junkbuster" gif. Without imagelist or
181  *      MSIE detection support, or if tinygif = 1, or the
182  *      URL isn't recognized as an imageurl, a lame HTML
183  *      explanation is sent instead.
184  *
185  *    - Added new feature, which permits blocking remote
186  *      script redirects and firing back a local redirect
187  *      to the browser.
188  *      The feature is conditionally compiled, i.e. it
189  *      can be disabled with --disable-fast-redirects,
190  *      plus it must be activated by a "fast-redirects"
191  *      line in the config file, has its own log level
192  *      and of course wants to be displayed by show-proxy-args
193  *      Note: Boy, all the #ifdefs in 1001 locations and
194  *      all the fumbling with configure.in and acconfig.h
195  *      were *way* more work than the feature itself :-(
196  *
197  *    - Because a generic redirect template was needed for
198  *      this, tinygif = 3 now uses the same.
199  *
200  *    - Moved GIFs, and other static HTTP response templates
201  *      to project.h
202  *
203  *    - Some minor fixes
204  *
205  *    - Removed some >400 CRs again (Jon, you really worked
206  *      a lot! ;-)
207  *
208  *    Revision 1.3  2001/05/20 01:21:20  jongfoster
209  *    Version 2.9.4 checkin.
210  *    - Merged popupfile and cookiefile, and added control over PCRS
211  *      filtering, in new "permissionsfile".
212  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
213  *      file error you now get a message box (in the Win32 GUI) rather
214  *      than the program exiting with no explanation.
215  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
216  *      skipping.
217  *    - Removed tabs from "config"
218  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
219  *    - Bumped up version number.
220  *
221  *    Revision 1.2  2001/05/17 23:01:01  oes
222  *     - Cleaned CRLF's from the sources and related files
223  *
224  *    Revision 1.1.1.1  2001/05/15 13:58:58  oes
225  *    Initial import of version 2.9.3 source tree
226  *
227  *
228  *********************************************************************/
229 \f
230
231 #include "config.h"
232
233 #include <stdio.h>
234 #include <sys/types.h>
235 #include <stdlib.h>
236 #include <string.h>
237 #include <signal.h>
238 #include <fcntl.h>
239 #include <errno.h>
240 #include <ctype.h>
241
242 #ifdef _WIN32
243
244 # include <windows.h>
245
246 # include "win32.h"
247 # ifndef _WIN_CONSOLE
248 #  include "w32log.h"
249 # endif /* ndef _WIN_CONSOLE */
250
251 /* VC++ has "_snprintf", not "snprintf" */
252 #define snprintf _snprintf
253
254 #else /* ifndef _WIN32 */
255
256 #ifndef __OS2__
257 # include <unistd.h>
258 # include <sys/wait.h>
259 #endif
260 # include <sys/time.h>
261 # include <sys/stat.h>
262 # include <signal.h>
263
264 #endif
265
266 #include "loadcfg.h"
267 #include "list.h"
268 #include "jcc.h"
269 #include "filters.h"
270 #include "loaders.h"
271 #include "miscutil.h"
272 #include "errlog.h"
273 #include "ssplit.h"
274 #include "encode.h"
275
276 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
277
278 /*
279  * Fix a problem with Solaris.  There should be no effect on other
280  * platforms.
281  * Solaris's isspace() is a macro which uses it's argument directly
282  * as an array index.  Therefore we need to make sure that high-bit
283  * characters generate +ve values, and ideally we also want to make
284  * the argument match the declared parameter type of "int".
285  */
286 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
287 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
288
289 #ifdef FEATURE_TOGGLE
290 /* by haroon - indicates if ijb is enabled */
291 int g_bToggleIJB        = 1;   /* JunkBusters is enabled by default. */
292 #endif /* def FEATURE_TOGGLE */
293
294 /* The filename of the configfile */
295 const char *configfile  = NULL;
296
297 /*
298  * CGI functions will later need access to the invocation args,
299  * so we will make argc and argv global.
300  */
301 int Argc = 0;
302 const char **Argv = NULL;
303
304 static struct file_list *current_configfile = NULL;
305
306
307 /*
308  * This takes the "cryptic" hash of each keyword and aliases them to
309  * something a little more readable.  This also makes changing the
310  * hash values easier if they should change or the hash algorthm changes.
311  * Use the included "hash" program to find out what the hash will be
312  * for any string supplied on the command line.  (Or just put it in the
313  * config file and read the number from the error message in the log).
314  *
315  * Please keep this list sorted alphabetically (but with the Windows
316  * console and GUI specific options last).
317  */
318
319 #define hash_actions_file              1196306641ul /* "actionsfile" */
320 #define hash_admin_address             4112573064ul /* "admin-address" */
321 #define hash_buffer_limit              1881726070ul /* "buffer-limit */
322 #define hash_confdir                      1978389ul /* "confdir" */
323 #define hash_debug                          78263ul /* "debug" */
324 #define hash_deny_access               1227333715ul /* "deny-access" */
325 #define hash_enable_edit_actions       2517097536ul /* "enable-edit-actions" */
326 #define hash_enable_remote_toggle      2979744683ul /* "enable-remote-toggle" */
327 #define hash_forward                      2029845ul /* "forward" */
328 #define hash_forward_socks4            3963965521ul /* "forward-socks4" */
329 #define hash_forward_socks4a           2639958518ul /* "forward-socks4a" */
330 #define hash_jarfile                      2046641ul /* "jarfile" */
331 #define hash_listen_address            1255650842ul /* "listen-address" */
332 #define hash_logdir                        422889ul /* "logdir" */
333 #define hash_logfile                      2114766ul /* "logfile" */
334 #define hash_permit_access             3587953268ul /* "permit-access" */
335 #define hash_proxy_info_url            3903079059ul /* "proxy-info-url" */
336 #define hash_re_filterfile             3877522444ul /* "re_filterfile" */
337 #define hash_single_threaded           4250084780ul /* "single-threaded" */
338 #define hash_suppress_blocklists       1948693308ul /* "suppress-blocklists" */
339 #define hash_toggle                        447966ul /* "toggle" */
340 #define hash_trust_info_url             430331967ul /* "trust-info-url" */
341 #define hash_trustfile                   56494766ul /* "trustfile" */
342
343 #define hash_activity_animation        1817904738ul /* "activity-animation" */
344 #define hash_close_button_minimizes    3651284693ul /* "close-button-minimizes" */
345 #define hash_hide_console              2048809870ul /* "hide-console" */
346 #define hash_log_buffer_size           2918070425ul /* "log-buffer-size" */
347 #define hash_log_font_name             2866730124ul /* "log-font-name" */
348 #define hash_log_font_size             2866731014ul /* "log-font-size" */
349 #define hash_log_highlight_messages    4032101240ul /* "log-highlight-messages" */
350 #define hash_log_max_lines             2868344173ul /* "log-max-lines" */
351 #define hash_log_messages              2291744899ul /* "log-messages" */
352 #define hash_show_on_task_bar           215410365ul /* "show-on-task-bar" */
353
354
355 static void savearg(char *c, char *o, struct configuration_spec * config);
356
357 /*********************************************************************
358  *
359  * Function    :  unload_configfile
360  *
361  * Description :  Free the config structure and all components.
362  *
363  * Parameters  :
364  *          1  :  data: struct configuration_spec to unload
365  *
366  * Returns     :  N/A
367  *
368  *********************************************************************/
369 void unload_configfile (void * data)
370 {
371    struct configuration_spec * config = (struct configuration_spec *)data;
372    struct forward_spec *cur_fwd = config->forward;
373 #ifdef FEATURE_ACL
374    struct access_control_list *cur_acl = config->acl;
375
376    while (cur_acl != NULL)
377    {
378       struct access_control_list * next_acl = cur_acl->next;
379       free(cur_acl);
380       cur_acl = next_acl;
381    }
382    config->acl = NULL;
383 #endif /* def FEATURE_ACL */
384
385    while (cur_fwd != NULL)
386    {
387       struct forward_spec * next_fwd = cur_fwd->next;
388       free_url(cur_fwd->url);
389
390       freez(cur_fwd->gateway_host);
391       freez(cur_fwd->forward_host);
392       free(cur_fwd);
393       cur_fwd = next_fwd;
394    }
395    config->forward = NULL;
396
397 #ifdef FEATURE_COOKIE_JAR
398    if ( NULL != config->jar )
399    {
400       fclose( config->jar );
401       config->jar = NULL;
402    }
403 #endif /* def FEATURE_COOKIE_JAR */
404
405    freez(config->confdir);
406    freez(config->logdir);
407
408    freez(config->haddr);
409    freez(config->logfile);
410
411    freez(config->actions_file);
412    freez(config->admin_address);
413    freez(config->proxy_info_url);
414    freez(config->proxy_args);
415
416 #ifdef FEATURE_COOKIE_JAR
417    freez(config->jarfile);
418 #endif /* def FEATURE_COOKIE_JAR */
419
420    freez(config->re_filterfile);
421
422 }
423
424
425 /*********************************************************************
426  *
427  * Function    :  load_config
428  *
429  * Description :  Load the config file and all parameters.
430  *
431  * Parameters  :
432  *          1  :  csp = Client state (the config member will be
433  *                filled in by this function).
434  *
435  * Returns     :  0 => Ok, everything else is an error.
436  *
437  *********************************************************************/
438 struct configuration_spec * load_config(void)
439 {
440    char buf[BUFFER_SIZE];
441    char *p, *q;
442    FILE *configfp = NULL;
443    struct configuration_spec * config = NULL;
444    struct client_state * fake_csp;
445    struct file_list *fs;
446    unsigned long linenum = 0;
447
448    DBG(1, ("load_config() entered..\n") );
449    if ( !check_file_changed(current_configfile, configfile, &fs))
450    {
451       /* No need to load */
452       return ((struct configuration_spec *)current_configfile->f);
453    }
454    if (!fs)
455    {
456       log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s':  %E",
457                 configfile);
458    }
459
460    /*
461    log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
462    */
463
464 #ifdef FEATURE_TOGGLE
465    g_bToggleIJB      = 1;
466 #endif /* def FEATURE_TOGGLE */
467
468    fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
469
470    if (config==NULL)
471    {
472       freez(fs->filename);
473       freez(fs);
474       log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
475       /* Never get here - LOG_LEVEL_FATAL causes program exit */
476    }
477
478    /*
479     * This is backwards from how it's usually done.
480     * Following the usual pattern, "fs" would be stored in a member
481     * variable in "csp", and then we'd access "config" from "fs->f",
482     * using a cast.  However, "config" is used so often that a
483     * cast each time would be very ugly, and the extra indirection
484     * would waste CPU cycles.  Therefore we store "config" in
485     * "csp->config", and "fs" in "csp->config->config_file_list".
486     */
487    config->config_file_list = fs;
488
489    /*
490     * Set to defaults
491     */
492
493    config->multi_threaded    = 1;
494    config->hport             = HADDR_PORT;
495    config->buffer_limit      = 4096 * 1024;
496
497    if ((configfp = fopen(configfile, "r")) == NULL)
498    {
499       log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s':  %E",
500               configfile);
501       /* Never get here - LOG_LEVEL_FATAL causes program exit */
502    }
503
504    while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
505    {
506       char cmd[BUFFER_SIZE];
507       char arg[BUFFER_SIZE];
508       char tmp[BUFFER_SIZE];
509 #ifdef FEATURE_ACL
510       struct access_control_list *cur_acl;
511 #endif /* def FEATURE_ACL */
512       struct forward_spec *cur_fwd;
513       int vec_count;
514       char *vec[3];
515
516       strcpy(tmp, buf);
517
518       /* Copy command (i.e. up to space or tab) into cmd */
519       p = buf;
520       q = cmd;
521       while (*p && (*p != ' ') && (*p != '\t'))
522       {
523          *q++ = *p++;
524       }
525       *q = '\0';
526
527       /* Skip over the whitespace in buf */
528       while (*p && ((*p == ' ') || (*p == '\t')))
529       {
530          p++;
531       }
532
533       /* Copy the argument into arg */
534       strcpy(arg, p);
535
536       /* Should never happen, but check this anyway */
537       if (*cmd == '\0')
538       {
539          continue;
540       }
541
542       /* Make sure the command field is lower case */
543       for (p=cmd; *p; p++)
544       {
545          if (ijb_isupper(*p))
546          {
547             *p = ijb_tolower(*p);
548          }
549       }
550
551       /* Save the argument for show-proxy-args */
552       savearg(cmd, arg, config);
553
554
555       switch( hash_string( cmd ) )
556       {
557 /****************************************************************************
558  * actionsfile actions-file-name
559  * In confdir by default
560  ****************************************************************************/
561          case hash_actions_file :
562             freez(config->actions_file);
563             config->actions_file = make_path(config->confdir, arg);
564             continue;
565
566 /****************************************************************************
567  * admin-address email-address
568  ****************************************************************************/
569          case hash_admin_address :
570             freez(config->admin_address);
571             config->admin_address = strdup(arg);
572             continue;
573
574 /****************************************************************************
575  * buffer-limit n
576  ****************************************************************************/
577          case hash_buffer_limit :
578             config->buffer_limit = (size_t) 1024 * atoi(arg);
579             continue;
580
581 /****************************************************************************
582  * confdir directory-name
583  ****************************************************************************/
584          case hash_confdir :
585             freez(config->confdir);
586             config->confdir = make_path( NULL, arg);
587             continue;
588
589 /****************************************************************************
590  * debug n
591  * Specifies debug level, multiple values are ORed together.
592  ****************************************************************************/
593          case hash_debug :
594             config->debug |= atoi(arg);
595             continue;
596
597 /****************************************************************************
598  * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
599  ****************************************************************************/
600 #ifdef FEATURE_ACL
601          case hash_deny_access:
602             vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
603
604             if ((vec_count != 1) && (vec_count != 2))
605             {
606                log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
607                      "deny-access directive in configuration file.");
608                config->proxy_args = strsav( config->proxy_args,
609                   "<br>\nWARNING: Wrong number of parameters for "
610                   "deny-access directive in configuration file.<br><br>\n");
611                continue;
612             }
613
614             /* allocate a new node */
615             cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
616
617             if (cur_acl == NULL)
618             {
619                log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
620                /* Never get here - LOG_LEVEL_FATAL causes program exit */
621                continue;
622             }
623             cur_acl->action = ACL_DENY;
624
625             if (acl_addr(vec[0], cur_acl->src) < 0)
626             {
627                log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
628                      "directive in configuration file: \"%s\"", vec[0]);
629                config->proxy_args = strsav( config->proxy_args,
630                   "<br>\nWARNING: Invalid source IP for deny-access directive"
631                   " in configuration file: \"");
632                config->proxy_args = strsav( config->proxy_args,
633                   vec[0]);
634                config->proxy_args = strsav( config->proxy_args,
635                   "\"<br><br>\n");
636                freez(cur_acl);
637                continue;
638             }
639             if (vec_count == 2)
640             {
641                if (acl_addr(vec[1], cur_acl->dst) < 0)
642                {
643                   log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
644                         "directive in configuration file: \"%s\"", vec[0]);
645                   config->proxy_args = strsav( config->proxy_args,
646                      "<br>\nWARNING: Invalid destination IP for deny-access directive"
647                      " in configuration file: \"");
648                   config->proxy_args = strsav( config->proxy_args,
649                      vec[0]);
650                   config->proxy_args = strsav( config->proxy_args,
651                      "\"<br><br>\n");
652                   freez(cur_acl);
653                   continue;
654                }
655             }
656
657             /*
658              * Add it to the list.  Note we reverse the list to get the
659              * behaviour the user expects.  With both the ACL and
660              * actions file, the last match wins.  However, the internal
661              * implementations are different:  The actions file is stored
662              * in the same order as the file, and scanned completely.
663              * With the ACL, we reverse the order as we load it, then
664              * when we scan it we stop as soon as we get a match.
665              */
666             cur_acl->next  = config->acl;
667             config->acl = cur_acl;
668
669             continue;
670 #endif /* def FEATURE_ACL */
671
672 /****************************************************************************
673  * enable-edit-actions 0|1
674  ****************************************************************************/
675 #ifdef FEATURE_CGI_EDIT_ACTIONS
676          case hash_enable_edit_actions:
677             if ((*arg != '\0') && (0 != atoi(arg)))
678             {
679                config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
680             }
681             else
682             {
683                config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
684             }
685             continue;
686 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
687
688 /****************************************************************************
689  * enable-remote-toggle 0|1
690  ****************************************************************************/
691 #ifdef FEATURE_CGI_EDIT_ACTIONS
692          case hash_enable_remote_toggle:
693             if ((*arg != '\0') && (0 != atoi(arg)))
694             {
695                config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
696             }
697             else
698             {
699                config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
700             }
701             continue;
702 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
703
704 /****************************************************************************
705  * forward url-pattern (.|http-proxy-host[:port])
706  ****************************************************************************/
707          case hash_forward:
708             vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
709
710             if (vec_count != 2)
711             {
712                log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
713                      "directive in configuration file.");
714                config->proxy_args = strsav( config->proxy_args,
715                   "<br>\nWARNING: Wrong number of parameters for "
716                   "forward directive in configuration file.");
717                continue;
718             }
719
720             /* allocate a new node */
721             cur_fwd = zalloc(sizeof(*cur_fwd));
722             if (cur_fwd == NULL)
723             {
724                log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
725                /* Never get here - LOG_LEVEL_FATAL causes program exit */
726                continue;
727             }
728
729             cur_fwd->type = SOCKS_NONE;
730
731             /* Save the URL pattern */
732             if (create_url_spec(cur_fwd->url, vec[0]))
733             {
734                log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
735                      "directive in configuration file.");
736                config->proxy_args = strsav( config->proxy_args,
737                   "<br>\nWARNING: Bad URL specifier for "
738                   "forward directive in configuration file.");
739                continue;
740             }
741
742             /* Parse the parent HTTP proxy host:port */
743             p = vec[1];
744
745             if (strcmp(p, ".") != 0)
746             {
747                cur_fwd->forward_host = strdup(p);
748
749                if ((p = strchr(cur_fwd->forward_host, ':')))
750                {
751                   *p++ = '\0';
752                   cur_fwd->forward_port = atoi(p);
753                }
754
755                if (cur_fwd->forward_port <= 0)
756                {
757                   cur_fwd->forward_port = 8000;
758                }
759             }
760
761             /* Add to list. */
762             cur_fwd->next = config->forward;
763             config->forward = cur_fwd;
764
765             continue;
766
767 /****************************************************************************
768  * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
769  ****************************************************************************/
770          case hash_forward_socks4:
771             vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
772
773             if (vec_count != 3)
774             {
775                log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
776                      "forward-socks4 directive in configuration file.");
777                config->proxy_args = strsav( config->proxy_args,
778                   "<br>\nWARNING: Wrong number of parameters for "
779                   "forward-socks4 directive in configuration file.");
780                continue;
781             }
782
783             /* allocate a new node */
784             cur_fwd = zalloc(sizeof(*cur_fwd));
785             if (cur_fwd == NULL)
786             {
787                log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
788                /* Never get here - LOG_LEVEL_FATAL causes program exit */
789                continue;
790             }
791
792             cur_fwd->type = SOCKS_4;
793
794             /* Save the URL pattern */
795             if (create_url_spec(cur_fwd->url, vec[0]))
796             {
797                log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
798                      "directive in configuration file.");
799                config->proxy_args = strsav( config->proxy_args,
800                   "<br>\nWARNING: Bad URL specifier for "
801                   "forward-socks4 directive in configuration file.");
802                continue;
803             }
804
805             /* Parse the SOCKS proxy host[:port] */
806             p = vec[1];
807
808             if (strcmp(p, ".") != 0)
809             {
810                cur_fwd->gateway_host = strdup(p);
811
812                if ((p = strchr(cur_fwd->gateway_host, ':')))
813                {
814                   *p++ = '\0';
815                   cur_fwd->gateway_port = atoi(p);
816                }
817                if (cur_fwd->gateway_port <= 0)
818                {
819                   cur_fwd->gateway_port = 1080;
820                }
821             }
822
823             /* Parse the parent HTTP proxy host[:port] */
824             p = vec[2];
825
826             if (strcmp(p, ".") != 0)
827             {
828                cur_fwd->forward_host = strdup(p);
829
830                if ((p = strchr(cur_fwd->forward_host, ':')))
831                {
832                   *p++ = '\0';
833                   cur_fwd->forward_port = atoi(p);
834                }
835
836                if (cur_fwd->forward_port <= 0)
837                {
838                   cur_fwd->forward_port = 8000;
839                }
840             }
841
842             /* Add to list. */
843             cur_fwd->next = config->forward;
844             config->forward = cur_fwd;
845
846             continue;
847
848 /****************************************************************************
849  * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
850  ****************************************************************************/
851          case hash_forward_socks4a:
852             vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
853
854             if (vec_count != 3)
855             {
856                log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
857                      "forward-socks4a directive in configuration file.");
858                config->proxy_args = strsav( config->proxy_args,
859                   "<br>\nWARNING: Wrong number of parameters for "
860                   "forward-socks4a directive in configuration file.");
861                continue;
862             }
863
864             /* allocate a new node */
865             cur_fwd = zalloc(sizeof(*cur_fwd));
866             if (cur_fwd == NULL)
867             {
868                log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
869                /* Never get here - LOG_LEVEL_FATAL causes program exit */
870                continue;
871             }
872
873             cur_fwd->type = SOCKS_4A;
874
875             /* Save the URL pattern */
876             if (create_url_spec(cur_fwd->url, vec[0]))
877             {
878                log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
879                      "directive in configuration file.");
880                config->proxy_args = strsav( config->proxy_args,
881                   "<br>\nWARNING: Bad URL specifier for "
882                   "forward-socks4a directive in configuration file.");
883                continue;
884             }
885
886             /* Parse the SOCKS proxy host[:port] */
887             p = vec[1];
888
889             cur_fwd->gateway_host = strdup(p);
890
891             if ((p = strchr(cur_fwd->gateway_host, ':')))
892             {
893                *p++ = '\0';
894                cur_fwd->gateway_port = atoi(p);
895             }
896             if (cur_fwd->gateway_port <= 0)
897             {
898                cur_fwd->gateway_port = 1080;
899             }
900
901             /* Parse the parent HTTP proxy host[:port] */
902             p = vec[2];
903
904             if (strcmp(p, ".") != 0)
905             {
906                cur_fwd->forward_host = strdup(p);
907
908                if ((p = strchr(cur_fwd->forward_host, ':')))
909                {
910                   *p++ = '\0';
911                   cur_fwd->forward_port = atoi(p);
912                }
913
914                if (cur_fwd->forward_port <= 0)
915                {
916                   cur_fwd->forward_port = 8000;
917                }
918             }
919
920             /* Add to list. */
921             cur_fwd->next = config->forward;
922             config->forward = cur_fwd;
923
924             continue;
925
926 /****************************************************************************
927  * jarfile jar-file-name
928  * In logdir by default
929  ****************************************************************************/
930 #ifdef FEATURE_COOKIE_JAR
931          case hash_jarfile :
932             freez(config->jarfile);
933             config->jarfile = make_path(config->logdir, arg);
934             continue;
935 #endif /* def FEATURE_COOKIE_JAR */
936
937 /****************************************************************************
938  * listen-address [ip][:port]
939  ****************************************************************************/
940          case hash_listen_address :
941             freez(config->haddr);
942             config->haddr = strdup(arg);
943             continue;
944
945 /****************************************************************************
946  * logdir directory-name
947  ****************************************************************************/
948          case hash_logdir :
949             freez(config->logdir);
950             config->logdir = make_path(NULL, arg);
951             continue;
952
953 /****************************************************************************
954  * logfile log-file-name
955  * In logdir by default
956  ****************************************************************************/
957          case hash_logfile :
958             freez(config->logfile);
959             config->logfile = make_path(config->logdir, arg);
960             continue;
961
962 /****************************************************************************
963  * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
964  ****************************************************************************/
965 #ifdef FEATURE_ACL
966          case hash_permit_access:
967             vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
968
969             if ((vec_count != 1) && (vec_count != 2))
970             {
971                log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
972                      "permit-access directive in configuration file.");
973                config->proxy_args = strsav( config->proxy_args,
974                   "<br>\nWARNING: Wrong number of parameters for "
975                   "permit-access directive in configuration file.<br><br>\n");
976
977                continue;
978             }
979
980             /* allocate a new node */
981             cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
982
983             if (cur_acl == NULL)
984             {
985                log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
986                /* Never get here - LOG_LEVEL_FATAL causes program exit */
987                continue;
988             }
989             cur_acl->action = ACL_PERMIT;
990
991             if (acl_addr(vec[0], cur_acl->src) < 0)
992             {
993                log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
994                      "directive in configuration file: \"%s\"", vec[0]);
995                config->proxy_args = strsav( config->proxy_args,
996                   "<br>\nWARNING: Invalid source IP for permit-access directive"
997                   " in configuration file: \"");
998                config->proxy_args = strsav( config->proxy_args,
999                   vec[0]);
1000                config->proxy_args = strsav( config->proxy_args,
1001                   "\"<br><br>\n");
1002                freez(cur_acl);
1003                continue;
1004             }
1005             if (vec_count == 2)
1006             {
1007                if (acl_addr(vec[1], cur_acl->dst) < 0)
1008                {
1009                   log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1010                         "permit-access directive in configuration file: \"%s\"",
1011                         vec[0]);
1012                   config->proxy_args = strsav( config->proxy_args,
1013                      "<br>\nWARNING: Invalid destination IP for permit-access directive"
1014                      " in configuration file: \"");
1015                   config->proxy_args = strsav( config->proxy_args,
1016                      vec[0]);
1017                   config->proxy_args = strsav( config->proxy_args,
1018                      "\"<br><br>\n");
1019                   freez(cur_acl);
1020                   continue;
1021                }
1022             }
1023
1024             /*
1025              * Add it to the list.  Note we reverse the list to get the
1026              * behaviour the user expects.  With both the ACL and
1027              * actions file, the last match wins.  However, the internal
1028              * implementations are different:  The actions file is stored
1029              * in the same order as the file, and scanned completely.
1030              * With the ACL, we reverse the order as we load it, then
1031              * when we scan it we stop as soon as we get a match.
1032              */
1033             cur_acl->next  = config->acl;
1034             config->acl = cur_acl;
1035
1036             continue;
1037 #endif /* def FEATURE_ACL */
1038
1039 /****************************************************************************
1040  * proxy-info-url url
1041  ****************************************************************************/
1042          case hash_proxy_info_url :
1043             freez(config->proxy_info_url);
1044             config->proxy_info_url = strdup(arg);
1045             continue;
1046
1047 /****************************************************************************
1048  * re_filterfile file-name
1049  * In confdir by default.
1050  ****************************************************************************/
1051          case hash_re_filterfile :
1052             freez(config->re_filterfile);
1053             config->re_filterfile = make_path(config->confdir, arg);
1054             continue;
1055
1056 /****************************************************************************
1057  * single-threaded
1058  ****************************************************************************/
1059          case hash_single_threaded :
1060             config->multi_threaded = 0;
1061             continue;
1062
1063 /****************************************************************************
1064  * toggle (0|1)
1065  ****************************************************************************/
1066 #ifdef FEATURE_TOGGLE
1067          case hash_toggle :
1068             g_bToggleIJB = atoi(arg);
1069             continue;
1070 #endif /* def FEATURE_TOGGLE */
1071
1072 /****************************************************************************
1073  * trust-info-url url
1074  ****************************************************************************/
1075 #ifdef FEATURE_TRUST
1076          case hash_trust_info_url :
1077             enlist(config->trust_info, arg);
1078             continue;
1079 #endif /* def FEATURE_TRUST */
1080
1081 /****************************************************************************
1082  * trustfile filename
1083  * (In confdir by default.)
1084  ****************************************************************************/
1085 #ifdef FEATURE_TRUST
1086          case hash_trustfile :
1087             freez(config->trustfile);
1088             config->trustfile = make_path(config->confdir, arg);
1089             continue;
1090 #endif /* def FEATURE_TRUST */
1091
1092
1093 /****************************************************************************
1094  * Win32 Console options:
1095  ****************************************************************************/
1096
1097 /****************************************************************************
1098  * hide-console
1099  ****************************************************************************/
1100 #ifdef _WIN_CONSOLE
1101          case hash_hide_console :
1102             hideConsole = 1;
1103             continue;
1104 #endif /*def _WIN_CONSOLE*/
1105
1106
1107 /****************************************************************************
1108  * Win32 GUI options:
1109  ****************************************************************************/
1110
1111 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1112 /****************************************************************************
1113  * activity-animation (0|1)
1114  ****************************************************************************/
1115          case hash_activity_animation :
1116             g_bShowActivityAnimation = atoi(arg);
1117             continue;
1118
1119 /****************************************************************************
1120  *  close-button-minimizes (0|1)
1121  ****************************************************************************/
1122          case hash_close_button_minimizes :
1123             g_bCloseHidesWindow = atoi(arg);
1124             continue;
1125
1126 /****************************************************************************
1127  * log-buffer-size (0|1)
1128  ****************************************************************************/
1129          case hash_log_buffer_size :
1130             g_bLimitBufferSize = atoi(arg);
1131             continue;
1132
1133 /****************************************************************************
1134  * log-font-name fontnane
1135  ****************************************************************************/
1136          case hash_log_font_name :
1137             strcpy( g_szFontFaceName, arg );
1138             continue;
1139
1140 /****************************************************************************
1141  * log-font-size n
1142  ****************************************************************************/
1143          case hash_log_font_size :
1144             g_nFontSize = atoi(arg);
1145             continue;
1146
1147 /****************************************************************************
1148  * log-highlight-messages (0|1)
1149  ****************************************************************************/
1150          case hash_log_highlight_messages :
1151             g_bHighlightMessages = atoi(arg);
1152             continue;
1153
1154 /****************************************************************************
1155  * log-max-lines n
1156  ****************************************************************************/
1157          case hash_log_max_lines :
1158             g_nMaxBufferLines = atoi(arg);
1159             continue;
1160
1161 /****************************************************************************
1162  * log-messages (0|1)
1163  ****************************************************************************/
1164          case hash_log_messages :
1165             g_bLogMessages = atoi(arg);
1166             continue;
1167
1168 /****************************************************************************
1169  * show-on-task-bar (0|1)
1170  ****************************************************************************/
1171          case hash_show_on_task_bar :
1172             g_bShowOnTaskBar = atoi(arg);
1173             continue;
1174
1175 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1176
1177
1178 /****************************************************************************/
1179 /* Warnings about unsupported features                                      */
1180 /****************************************************************************/
1181 #ifndef FEATURE_ACL
1182          case hash_deny_access:
1183 #endif /* ndef FEATURE_ACL */
1184 #ifndef FEATURE_CGI_EDIT_ACTIONS
1185          case hash_enable_edit_actions:
1186          case hash_enable_remote_toggle:
1187 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1188 #ifndef FEATURE_COOKIE_JAR
1189          case hash_jarfile :
1190 #endif /* ndef FEATURE_COOKIE_JAR */
1191 #ifndef FEATURE_ACL
1192          case hash_permit_access:
1193 #endif /* ndef FEATURE_ACL */
1194 #ifndef FEATURE_TOGGLE
1195          case hash_toggle :
1196 #endif /* ndef FEATURE_TOGGLE */
1197 #ifndef FEATURE_TRUST
1198          case hash_trustfile :
1199          case hash_trust_info_url :
1200 #endif /* ndef FEATURE_TRUST */
1201
1202 #ifndef _WIN_CONSOLE
1203          case hash_hide_console :
1204 #endif /* ndef _WIN_CONSOLE */
1205
1206 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1207          case hash_activity_animation :
1208          case hash_close_button_minimizes :
1209          case hash_log_buffer_size :
1210          case hash_log_font_name :
1211          case hash_log_font_size :
1212          case hash_log_highlight_messages :
1213          case hash_log_max_lines :
1214          case hash_log_messages :
1215          case hash_show_on_task_bar :
1216 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1217             /* These warnings are annoying - so hide them. -- Jon */
1218             /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1219             continue;
1220
1221 /****************************************************************************/
1222          default :
1223 /****************************************************************************/
1224             /*
1225              * I decided that I liked this better as a warning than an
1226              * error.  To change back to an error, just change log level
1227              * to LOG_LEVEL_FATAL.
1228              */
1229             log_error(LOG_LEVEL_ERROR, "Unrecognized directive '%s' in line %lu in "
1230                   "configuration file (%s).",  buf, linenum, configfile);
1231             /* log_error(LOG_LEVEL_ERROR, "Unrecognized directive (%luul) in "
1232                   "configuration file: \"%s\"", hash_string( cmd ), buf);
1233             */
1234             config->proxy_args = strsav( config->proxy_args, "<br>\nWARNING: unrecognized directive : ");
1235             config->proxy_args = strsav( config->proxy_args, buf);
1236             config->proxy_args = strsav( config->proxy_args, "<br><br>\n");
1237             continue;
1238
1239 /****************************************************************************/
1240       } /* end switch( hash_string(cmd) ) */
1241    } /* end while ( read_config_line(...) ) */
1242
1243    fclose(configfp);
1244
1245    init_error_log(Argv[0], config->logfile, config->debug);
1246
1247    if (config->actions_file)
1248    {
1249       add_loader(load_actions_file, config);
1250    }
1251
1252    if (config->re_filterfile)
1253    {
1254       add_loader(load_re_filterfile, config);
1255    }
1256
1257 #ifdef FEATURE_TRUST
1258    if (config->trustfile)
1259    {
1260       add_loader(load_trustfile, config);
1261    }
1262 #endif /* def FEATURE_TRUST */
1263
1264 #ifdef FEATURE_COOKIE_JAR
1265    if ( NULL != config->jarfile )
1266    {
1267       if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1268       {
1269          log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1270          /* Never get here - LOG_LEVEL_FATAL causes program exit */
1271       }
1272       setbuf(config->jar, NULL);
1273    }
1274 #endif /* def FEATURE_COOKIE_JAR */
1275
1276    if ( NULL == config->haddr )
1277    {
1278       config->haddr = strdup( HADDR_DEFAULT );
1279    }
1280
1281    if ( NULL != config->haddr )
1282    {
1283       if ((p = strchr(config->haddr, ':')))
1284       {
1285          *p++ = '\0';
1286          if (*p)
1287          {
1288             config->hport = atoi(p);
1289          }
1290       }
1291
1292       if (config->hport <= 0)
1293       {
1294          *--p = ':';
1295          log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1296          /* Never get here - LOG_LEVEL_FATAL causes program exit */
1297       }
1298       if (*config->haddr == '\0')
1299       {
1300          config->haddr = NULL;
1301       }
1302    }
1303
1304    /*
1305     * Want to run all the loaders once now.
1306     *
1307     * Need to set up a fake csp, so they can get to the config.
1308     */
1309    fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1310    fake_csp->config = config;
1311
1312    if (run_loader(fake_csp))
1313    {
1314       freez(fake_csp);
1315       log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1316       /* Never get here - LOG_LEVEL_FATAL causes program exit */
1317    }
1318    freez(fake_csp);
1319
1320 /* FIXME: this is a kludge for win32 */
1321 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1322
1323    g_actions_file     = config->actions_file;
1324    g_re_filterfile    = config->re_filterfile;
1325
1326 #ifdef FEATURE_TRUST
1327    g_trustfile        = config->trustfile;
1328 #endif /* def FEATURE_TRUST */
1329
1330
1331 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1332 /* FIXME: end kludge */
1333
1334
1335    config->need_bind = 1;
1336
1337    if (current_configfile)
1338    {
1339       struct configuration_spec * oldcfg = (struct configuration_spec *)
1340                                            current_configfile->f;
1341       /*
1342        * Check if config->haddr,hport == oldcfg->haddr,hport
1343        *
1344        * The following could be written more compactly as a single,
1345        * (unreadably long) if statement.
1346        */
1347       config->need_bind = 0;
1348       if (config->hport != oldcfg->hport)
1349       {
1350          config->need_bind = 1;
1351       }
1352       else if (config->haddr == NULL)
1353       {
1354          if (oldcfg->haddr != NULL)
1355          {
1356             config->need_bind = 1;
1357          }
1358       }
1359       else if (oldcfg->haddr == NULL)
1360       {
1361          config->need_bind = 1;
1362       }
1363       else if (0 != strcmp(config->haddr, oldcfg->haddr))
1364       {
1365          config->need_bind = 1;
1366       }
1367
1368       current_configfile->unloader = unload_configfile;
1369    }
1370
1371    fs->next = files->next;
1372    files->next = fs;
1373
1374    current_configfile = fs;
1375    MustReload = 0;
1376
1377    return (config);
1378 }
1379
1380
1381 /*********************************************************************
1382  *
1383  * Function    :  savearg
1384  *
1385  * Description :  Called from `load_config'.  It saves each non-empty
1386  *                and non-comment line from config into a list.  This
1387  *                list is used to create the show-proxy-args page.
1388  *
1389  * Parameters  :
1390  *          1  :  c = config setting that was found
1391  *          2  :  o = the setting's argument (if any)
1392  *
1393  * Returns     :  N/A
1394  *
1395  *********************************************************************/
1396 static void savearg(char *c, char *o, struct configuration_spec * config)
1397 {
1398    char buf[BUFFER_SIZE];
1399
1400    *buf = '\0';
1401
1402    if ( ( NULL != c ) && ( '\0' != *c ) )
1403    {
1404       if ((c = html_encode(c)))
1405       {
1406          sprintf(buf, "<a href=\"" REDIRECT_URL "option#%s\">%s</a> ", c, c);
1407       }
1408       freez(c);
1409    }
1410    if ( ( NULL != o ) && ( '\0' != *o ) )
1411    {
1412       if ((o = html_encode(o)))
1413       {
1414          if (strncmpic(o, "http://", 7) == 0)
1415          {
1416             strcat(buf, "<a href=\"");
1417             strcat(buf, o);
1418             strcat(buf, "\">");
1419             strcat(buf, o);
1420             strcat(buf, "</a>");
1421          }
1422          else
1423          {
1424             strcat(buf, o);
1425          }
1426       }
1427       freez(o);
1428    }
1429
1430    strcat(buf, "<br>\n");
1431
1432    config->proxy_args = strsav(config->proxy_args, buf);
1433
1434 }
1435
1436
1437 /*
1438   Local Variables:
1439   tab-width: 3
1440   end:
1441 */