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