introduced confdir option
[privoxy.git] / loadcfg.c
1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.10 2001/06/03 11:03:48 oes 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.10  2001/06/03 11:03:48  oes
39  *    Makefile/in
40  *
41  *    introduced cgi.c
42  *
43  *    actions.c:
44  *
45  *    adapted to new enlist_unique arg format
46  *
47  *    conf loadcfg.c
48  *
49  *    introduced confdir option
50  *
51  *    filters.c filtrers.h
52  *
53  *     extracted-CGI relevant stuff
54  *
55  *    jbsockets.c
56  *
57  *     filled comment
58  *
59  *    jcc.c
60  *
61  *     support for new cgi mechansim
62  *
63  *    list.c list.h
64  *
65  *    functions for new list type: "map"
66  *    extended enlist_unique
67  *
68  *    miscutil.c .h
69  *    introduced bindup()
70  *
71  *    parsers.c parsers.h
72  *
73  *    deleted const struct interceptors
74  *
75  *    pcrs.c
76  *    added FIXME
77  *
78  *    project.h
79  *
80  *    added struct map
81  *    added struct http_response
82  *    changes struct interceptors to struct cgi_dispatcher
83  *    moved HTML stuff to cgi.h
84  *
85  *    re_filterfile:
86  *
87  *    changed
88  *
89  *    showargs.c
90  *    NO TIME LEFT
91  *
92  *    Revision 1.9  2001/06/01 20:06:24  jongfoster
93  *    Removed support for "tinygif" option - moved to actions file.
94  *
95  *    Revision 1.8  2001/05/31 21:27:13  jongfoster
96  *    Removed many options from the config file and into the
97  *    "actions" file: add_forwarded, suppress_vanilla_wafer,
98  *    wafer, add_header, user_agent, referer, from
99  *    Also globally replaced "permission" with "action".
100  *
101  *    Revision 1.7  2001/05/29 09:50:24  jongfoster
102  *    Unified blocklist/imagelist/permissionslist.
103  *    File format is still under discussion, but the internal changes
104  *    are (mostly) done.
105  *
106  *    Also modified interceptor behaviour:
107  *    - We now intercept all URLs beginning with one of the following
108  *      prefixes (and *only* these prefixes):
109  *        * http://i.j.b/
110  *        * http://ijbswa.sf.net/config/
111  *        * http://ijbswa.sourceforge.net/config/
112  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
113  *    - Internal changes so that intercepted and fast redirect pages
114  *      are not replaced with an image.
115  *    - Interceptors now have the option to send a binary page direct
116  *      to the client. (i.e. ijb-send-banner uses this)
117  *    - Implemented show-url-info interceptor.  (Which is why I needed
118  *      the above interceptors changes - a typical URL is
119  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
120  *      The previous mechanism would not have intercepted that, and
121  *      if it had been intercepted then it then it would have replaced
122  *      it with an image.)
123  *
124  *    Revision 1.6  2001/05/26 00:28:36  jongfoster
125  *    Automatic reloading of config file.
126  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
127  *    Most of the global variables have been moved to a new
128  *    struct configuration_spec, accessed through csp->config->globalname
129  *    Most of the globals remaining are used by the Win32 GUI.
130  *
131  *    Revision 1.5  2001/05/25 22:34:30  jongfoster
132  *    Hard tabs->Spaces
133  *
134  *    Revision 1.4  2001/05/22 18:46:04  oes
135  *
136  *    - Enabled filtering banners by size rather than URL
137  *      by adding patterns that replace all standard banner
138  *      sizes with the "Junkbuster" gif to the re_filterfile
139  *
140  *    - Enabled filtering WebBugs by providing a pattern
141  *      which kills all 1x1 images
142  *
143  *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
144  *      which is selected by the (nonstandard and therefore
145  *      capital) letter 'U' in the option string.
146  *      It causes the quantifiers to be ungreedy by default.
147  *      Appending a ? turns back to greedy (!).
148  *
149  *    - Added a new interceptor ijb-send-banner, which
150  *      sends back the "Junkbuster" gif. Without imagelist or
151  *      MSIE detection support, or if tinygif = 1, or the
152  *      URL isn't recognized as an imageurl, a lame HTML
153  *      explanation is sent instead.
154  *
155  *    - Added new feature, which permits blocking remote
156  *      script redirects and firing back a local redirect
157  *      to the browser.
158  *      The feature is conditionally compiled, i.e. it
159  *      can be disabled with --disable-fast-redirects,
160  *      plus it must be activated by a "fast-redirects"
161  *      line in the config file, has its own log level
162  *      and of course wants to be displayed by show-proxy-args
163  *      Note: Boy, all the #ifdefs in 1001 locations and
164  *      all the fumbling with configure.in and acconfig.h
165  *      were *way* more work than the feature itself :-(
166  *
167  *    - Because a generic redirect template was needed for
168  *      this, tinygif = 3 now uses the same.
169  *
170  *    - Moved GIFs, and other static HTTP response templates
171  *      to project.h
172  *
173  *    - Some minor fixes
174  *
175  *    - Removed some >400 CRs again (Jon, you really worked
176  *      a lot! ;-)
177  *
178  *    Revision 1.3  2001/05/20 01:21:20  jongfoster
179  *    Version 2.9.4 checkin.
180  *    - Merged popupfile and cookiefile, and added control over PCRS
181  *      filtering, in new "permissionsfile".
182  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
183  *      file error you now get a message box (in the Win32 GUI) rather
184  *      than the program exiting with no explanation.
185  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
186  *      skipping.
187  *    - Removed tabs from "config"
188  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
189  *    - Bumped up version number.
190  *
191  *    Revision 1.2  2001/05/17 23:01:01  oes
192  *     - Cleaned CRLF's from the sources and related files
193  *
194  *    Revision 1.1.1.1  2001/05/15 13:58:58  oes
195  *    Initial import of version 2.9.3 source tree
196  *
197  *
198  *********************************************************************/
199 \f
200
201 #include "config.h"
202
203 #include <stdio.h>
204 #include <sys/types.h>
205 #include <stdlib.h>
206 #include <string.h>
207 #include <signal.h>
208 #include <fcntl.h>
209 #include <errno.h>
210 #include <ctype.h>
211
212 #ifdef _WIN32
213
214 # include <sys/timeb.h>
215 # include <windows.h>
216 # include <io.h>
217 # include <process.h>
218 # ifdef TOGGLE
219 #  include <time.h>
220 # endif /* def TOGGLE */
221
222 # include "win32.h"
223 # ifndef _WIN_CONSOLE
224 #  include "w32log.h"
225 # endif /* ndef _WIN_CONSOLE */
226
227 #else /* ifndef _WIN32 */
228
229 # include <unistd.h>
230 # include <sys/time.h>
231 # include <sys/wait.h>
232 # include <sys/stat.h>
233 # include <signal.h>
234
235 #endif
236
237 #include "loadcfg.h"
238 #include "list.h"
239 #include "jcc.h"
240 #include "filters.h"
241 #include "loaders.h"
242 #include "showargs.h"
243 #include "parsers.h"
244 #include "killpopup.h"
245 #include "miscutil.h"
246 #include "errlog.h"
247 #include "jbsockets.h"
248 #include "gateway.h"
249
250 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
251
252 /*
253  * Fix a problem with Solaris.  There should be no effect on other
254  * platforms.
255  * Solaris's isspace() is a macro which uses it's argument directly
256  * as an array index.  Therefore we need to make sure that high-bit
257  * characters generate +ve values, and ideally we also want to make
258  * the argument match the declared parameter type of "int".
259  */
260 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
261 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
262
263 #ifdef TOGGLE
264 /* by haroon - indicates if ijb is enabled */
265 int g_bToggleIJB        = 1;   /* JunkBusters is enabled by default. */
266 #endif
267
268 /* The filename of the configfile */
269 const char *configfile  = NULL;
270
271 /*
272  * The load_config function is now going to call `init_proxy_args',
273  * so it will need argc and argv.  So we need to have these
274  * globally available.
275  */
276 int Argc = 0;
277 const char **Argv = NULL;
278
279 static struct file_list *current_configfile = NULL;
280
281
282 /*
283  * This takes the "cryptic" hash of each keyword and aliases them to
284  * something a little more readable.  This also makes changing the
285  * hash values easier if they should change or the hash algorthm changes.
286  * Use the included "hash" program to find out what the hash will be
287  * for any string supplied on the command line.  (Or just put it in the
288  * config file and read the number from the error message in the log).
289  */
290
291
292 #define hash_aclfile                      1908516ul
293 #define hash_actions_file              3825730796ul /* FIXME "permissionsfile" */
294 #define hash_debug                          78263ul
295 #define hash_confdir                      1978389lu
296 #define hash_forwardfile               1268669141ul
297 #define hash_jarfile                      2046641ul
298 #define hash_listen_address            1255650842ul
299 #define hash_logfile                      2114766ul
300 #define hash_re_filterfile             3877522444ul
301 #define hash_single_threaded           4250084780ul
302 #define hash_suppress_blocklists       1948693308ul
303 #define hash_toggle                        447966ul
304 #define hash_trust_info_url             449869467ul
305 #define hash_trustfile                   56494766ul
306
307 #define hash_hide_console              2048809870ul
308
309 #define hash_activity_animation        1817904738ul
310 #define hash_close_button_minimizes    3651284693ul
311 #define hash_log_buffer_size           2918070425ul
312 #define hash_log_font_name             2866730124ul
313 #define hash_log_font_size             2866731014ul
314 #define hash_log_highlight_messages    4032101240ul
315 #define hash_log_max_lines             2868344173ul
316 #define hash_log_messages              2291744899ul
317 #define hash_show_on_task_bar           215410365ul
318
319
320
321 /*********************************************************************
322  *
323  * Function    :  unload_configfile
324  *
325  * Description :  Free the config structure and all components.
326  *
327  * Parameters  :
328  *          1  :  data: struct configuration_spec to unload
329  *
330  * Returns     :  N/A
331  *
332  *********************************************************************/
333 void unload_configfile (void * data)
334 {
335    struct configuration_spec * config = (struct configuration_spec *)data;
336
337 #ifdef JAR_FILES
338    if ( NULL != config->jar )
339    {
340       fclose( config->jar );
341       config->jar = NULL;
342    }
343 #endif /* def JAR_FILES */
344
345    freez((char *)config->haddr);
346    freez((char *)config->logfile);
347
348    freez((char *)config->actions_file);
349    freez((char *)config->forwardfile);
350
351 #ifdef ACL_FILES
352    freez((char *)config->aclfile);
353 #endif /* def ACL_FILES */
354
355 #ifdef JAR_FILES
356    freez((char *)config->jarfile);
357 #endif /* def JAR_FILES */
358
359 #ifndef SPLIT_PROXY_ARGS
360    freez((char *)config->suppress_message);
361 #endif /* ndef SPLIT_PROXY_ARGS */
362
363 #ifdef PCRS
364    freez((char *)config->re_filterfile);
365 #endif /* def PCRS */
366
367 }
368
369
370 /*********************************************************************
371  *
372  * Function    :  load_config
373  *
374  * Description :  Load the config file and all parameters.
375  *
376  * Parameters  :
377  *          1  :  csp = Client state (the config member will be 
378  *                filled in by this function).
379  *
380  * Returns     :  0 => Ok, everything else is an error.
381  *
382  *********************************************************************/
383 struct configuration_spec * load_config(void)
384 {
385    char buf[BUFSIZ];
386    char *p, *q;
387    FILE *configfp = NULL;
388    struct configuration_spec * config = NULL;
389    struct client_state * fake_csp;
390
391    struct file_list *fs;
392
393    if (!check_file_changed(current_configfile, configfile, &fs))
394    {
395       /* No need to load */
396       return ((struct configuration_spec *)current_configfile->f);
397    }
398    if (!fs)
399    {
400       log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s':  %E",
401                 configfile);
402    }
403
404    log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
405
406 #ifdef TOGGLE
407    g_bToggleIJB      = 1;
408 #endif
409
410    fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
411
412    if (config==NULL)
413    {
414       freez(fs->filename);
415       freez(fs);
416       log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
417       /* Never get here - LOG_LEVEL_FATAL causes program exit */
418    }
419
420    /*
421     * This is backwards from how it's usually done.
422     * Following the usual pattern, "fs" would be stored in a member 
423     * variable in "csp", and then we'd access "config" from "fs->f",
424     * using a cast.  However, "config" is used so often that a 
425     * cast each time would be very ugly, and the extra indirection
426     * would waste CPU cycles.  Therefore we store "config" in
427     * "csp->config", and "fs" in "csp->config->config_file_list".
428     */
429    config->config_file_list = fs;
430
431    init_proxy_args(Argc, Argv, config);
432
433    /*
434     * Set to defaults
435     */
436
437    config->multi_threaded    = 1;
438    config->hport             = HADDR_PORT;
439
440    if ((configfp = fopen(configfile, "r")) == NULL)
441    {
442       log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s':  %E",
443               configfile);
444       /* Never get here - LOG_LEVEL_FATAL causes program exit */
445    }
446
447    while (read_config_line(buf, sizeof(buf), configfp, fs) != NULL)
448    {
449       char cmd[BUFSIZ];
450       char arg[BUFSIZ];
451       char tmp[BUFSIZ];
452
453       strcpy(tmp, buf);
454
455       /* Copy command (i.e. up to space or tab) into cmd */
456       p = buf;
457       q = cmd;
458       while (*p && (*p != ' ') && (*p != '\t'))
459       {
460          *q++ = *p++;
461       }
462       *q = '\0';
463
464       /* Skip over the whitespace in buf */
465       while (*p && ((*p == ' ') || (*p == '\t')))
466       {
467          p++;
468       }
469
470       /* Copy the argument into arg */
471       strcpy(arg, p);
472
473       /* Should never happen, but check this anyway */
474       if (*cmd == '\0')
475       {
476          continue;
477       }
478
479       /* Make sure the command field is lower case */
480       for (p=cmd; *p; p++)
481       {
482          if (ijb_isupper(*p))
483          {
484             *p = ijb_tolower(*p);
485          }
486       }
487
488       /* Save the argument for show-proxy-args */
489       savearg(cmd, arg, config);
490
491
492       switch( hash_string( cmd ) )
493       {
494 #ifdef TRUST_FILES
495          case hash_trustfile :
496             freez((char *)config->trustfile);
497             config->trustfile = strdup(arg);
498             continue;
499
500          case hash_trust_info_url :
501             enlist(config->trust_info, arg);
502             continue;
503 #endif /* def TRUST_FILES */
504
505          case hash_debug :
506             config->debug |= atoi(arg);
507             continue;
508
509          case hash_confdir :
510             config->confdir = strdup(arg);
511             continue;            
512
513          case hash_single_threaded :
514             config->multi_threaded = 0;
515             continue;
516
517          case hash_actions_file :
518             freez((char *)config->actions_file);
519             config->actions_file = strdup(arg);
520             continue;
521
522          case hash_logfile :
523             freez((char *)config->logfile);
524             config->logfile = strdup(arg);
525             continue;
526
527 #ifdef JAR_FILES
528          case hash_jarfile :
529             freez((char *)config->jarfile);
530             config->jarfile = strdup(arg);
531             continue;
532 #endif /* def JAR_FILES */
533
534          case hash_listen_address :
535             freez((char *)config->haddr);
536             config->haddr = strdup(arg);
537             continue;
538
539          case hash_forwardfile :
540             freez((char *)config->forwardfile);
541             config->forwardfile = strdup(arg);
542             continue;
543
544 #ifdef ACL_FILES
545          case hash_aclfile :
546             freez((char *)config->aclfile);
547             config->aclfile = strdup(arg);
548             continue;
549 #endif /* def ACL_FILES */
550
551 #ifdef PCRS
552          case hash_re_filterfile :
553             freez((char *)config->re_filterfile);
554             config->re_filterfile = strdup(arg);
555             continue;
556 #endif /* def PCRS */
557
558 #ifdef _WIN_CONSOLE
559          case hash_hide_console :
560             hideConsole = 1;
561             continue;
562 #endif /*def _WIN_CONSOLE*/
563
564 #ifndef SPLIT_PROXY_ARGS
565          case hash_suppress_blocklists :
566             if (arg[0] != '\0')
567             {
568                config->suppress_message = strdup(arg);
569             }
570             else
571             {
572                /* There will be NO reference in proxy-args. */
573                config->suppress_message = NULL;
574             }
575
576             config->suppress_blocklists = 1;
577             continue;
578 #endif /* ndef SPLIT_PROXY_ARGS */
579
580 #ifdef TOGGLE
581          case hash_toggle :
582             g_bToggleIJB = atoi(arg);
583             continue;
584 #endif /* def TOGGLE */
585
586 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
587          case hash_activity_animation :
588             g_bShowActivityAnimation = atoi(arg);
589             continue;
590
591          case hash_log_messages :
592             g_bLogMessages = atoi(arg);
593             continue;
594
595          case hash_log_highlight_messages :
596             g_bHighlightMessages = atoi(arg);
597             continue;
598
599          case hash_log_buffer_size :
600             g_bLimitBufferSize = atoi(arg);
601             continue;
602
603          case hash_log_max_lines :
604             g_nMaxBufferLines = atoi(arg);
605             continue;
606
607          case hash_log_font_name :
608             strcpy( g_szFontFaceName, arg );
609             continue;
610
611          case hash_log_font_size :
612             g_nFontSize = atoi(arg);
613             continue;
614
615          case hash_show_on_task_bar :
616             g_bShowOnTaskBar = atoi(arg);
617             continue;
618
619          case hash_close_button_minimizes :
620             g_bCloseHidesWindow = atoi(arg);
621             continue;
622 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
623
624          /* Warnings about unsupported features */
625
626 #ifndef PCRS
627          case hash_re_filterfile :
628 #endif /* ndef PCRS */
629 #ifndef TOGGLE
630          case hash_toggle :
631 #endif /* ndef TOGGLE */
632 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
633          case hash_activity_animation :
634          case hash_log_messages :
635          case hash_log_highlight_messages :
636          case hash_log_buffer_size :
637          case hash_log_max_lines :
638          case hash_log_font_name :
639          case hash_log_font_size :
640          case hash_show_on_task_bar :
641          case hash_close_button_minimizes :
642 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
643 #ifndef _WIN_CONSOLE
644          case hash_hide_console :
645 #endif /* ndef _WIN_CONSOLE */
646 #ifndef JAR_FILES
647          case hash_jarfile :
648 #endif /* ndef JAR_FILES */
649 #ifndef ACL_FILES
650          case hash_aclfile :
651 #endif /* ndef ACL_FILES */
652 #ifdef SPLIT_PROXY_ARGS
653          case hash_suppress_blocklists :
654 #endif /* def SPLIT_PROXY_ARGS */
655             log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd);
656             continue;
657
658          default :
659             /*
660              * I decided that I liked this better as a warning than an
661              * error.  To change back to an error, just change log level
662              * to LOG_LEVEL_FATAL.
663              */
664             log_error(LOG_LEVEL_ERROR, "Unrecognized directive (%lulu) in "
665                   "configuration file: \"%s\"", hash_string( cmd ), buf);
666             p = malloc( BUFSIZ );
667             if (p != NULL)
668             {
669                sprintf( p, "<br>\nWARNING: unrecognized directive : %s<br><br>\n", buf );
670                config->proxy_args_invocation = strsav( config->proxy_args_invocation, p );
671                freez( p );
672             }
673             continue;
674       } /* end switch( hash_string(cmd) ) */
675    } /* end while ( read_config_line(...) ) */
676
677    fclose(configfp);
678
679    init_error_log(Argv[0], config->logfile, config->debug);
680
681    if (config->actions_file)
682    {
683       add_loader(load_actions_file, config);
684    }
685
686    if (config->forwardfile)
687    {
688       add_loader(load_forwardfile, config);
689    }
690
691 #ifdef ACL_FILES
692    if (config->aclfile)
693    {
694       add_loader(load_aclfile, config);
695    }
696 #endif /* def ACL_FILES */
697
698 #ifdef PCRS
699    if (config->re_filterfile)
700    {
701       add_loader(load_re_filterfile, config);
702    }
703 #endif /* def PCRS */
704
705 #ifdef TRUST_FILES
706    if (config->trustfile)
707    {
708       add_loader(load_trustfile, config);
709    }
710 #endif
711
712 #ifdef JAR_FILES
713    if ( NULL != config->jarfile )
714    {
715       if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
716       {
717          log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
718          /* Never get here - LOG_LEVEL_FATAL causes program exit */
719       }
720       setbuf(config->jar, NULL);
721    }
722 #endif /* def JAR_FILES */
723
724    if ( NULL == config->haddr )
725    {
726       config->haddr = strdup( HADDR_DEFAULT );
727    }
728
729    if ( NULL != config->haddr )
730    {
731       if ((p = strchr(config->haddr, ':')))
732       {
733          *p++ = '\0';
734          if (*p)
735          {
736             config->hport = atoi(p);
737          }
738       }
739
740       if (config->hport <= 0)
741       {
742          *--p = ':';
743          log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
744          /* Never get here - LOG_LEVEL_FATAL causes program exit */
745       }
746       if (*config->haddr == '\0')
747       {
748          config->haddr = NULL;
749       }
750    }
751
752    /*
753     * Want to run all the loaders once now.
754     *
755     * Need to set up a fake csp, so they can get to the config.
756     */
757    fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
758    fake_csp->config = config;
759
760    if (run_loader(fake_csp))
761    {
762       freez(fake_csp);
763       log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
764       /* Never get here - LOG_LEVEL_FATAL causes program exit */
765    }
766    freez(fake_csp);
767
768 #ifndef SPLIT_PROXY_ARGS
769    if (!suppress_blocklists)
770    {
771       fs->proxy_args = strsav(fs->proxy_args, "</pre>");
772    }
773 #endif /* ndef SPLIT_PROXY_ARGS */
774
775 /* FIXME: this is a kludge for win32 */
776 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
777
778    g_actions_file     = config->actions_file;
779    g_forwardfile      = config->forwardfile;
780 #ifdef ACL_FILES
781    g_aclfile          = config->aclfile;
782 #endif /* def ACL_FILES */
783 #ifdef PCRS
784    g_re_filterfile    = config->re_filterfile;
785 #endif
786 #ifdef TRUST_FILES
787    g_trustfile        = config->trustfile;
788 #endif
789    
790
791 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
792 /* FIXME: end kludge */
793
794
795    config->need_bind = 1;
796
797    if (current_configfile)
798    {
799       struct configuration_spec * oldcfg = (struct configuration_spec *)
800                                            current_configfile->f;
801       /*
802        * Check if config->haddr,hport == oldcfg->haddr,hport
803        *
804        * The following could be written more compactly as a single,
805        * (unreadably long) if statement.
806        */
807       config->need_bind = 0;
808       if (config->hport != oldcfg->hport)
809       {
810          config->need_bind = 1;
811       }
812       else if (config->haddr == NULL)
813       {
814          if (oldcfg->haddr != NULL)
815          {
816             config->need_bind = 1;
817          }
818       }
819       else if (oldcfg->haddr == NULL)
820       {
821          config->need_bind = 1;
822       }
823       else if (0 != strcmp(config->haddr, oldcfg->haddr))
824       {
825          config->need_bind = 1;
826       }
827
828       current_configfile->unloader = unload_configfile;
829    }
830
831    fs->next = files->next;
832    files->next = fs;
833
834    current_configfile = fs;
835
836    return (config);
837 }
838
839
840 /*
841   Local Variables:
842   tab-width: 3
843   end:
844 */