*** empty log message ***
[privoxy.git] / loadcfg.c
1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.1 2001/05/13 21:57:06 administrator Exp $";
2 /*********************************************************************
3  *
4  * File        :  $Source: /home/administrator/cvs/ijb/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  *
39  *********************************************************************/
40 \f
41
42 #include "config.h"
43
44 #include <stdio.h>
45 #include <sys/types.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <signal.h>
49 #include <fcntl.h>
50 #include <errno.h>
51 #include <ctype.h>
52
53 #ifdef _WIN32
54
55 # include <sys/timeb.h>
56 # include <windows.h>
57 # include <io.h>
58 # include <process.h>
59 # ifdef TOGGLE
60 #  include <time.h>
61 # endif /* def TOGGLE */
62
63 # include "win32.h"
64 # ifndef _WIN_CONSOLE
65 #  include "w32log.h"
66 # endif /* ndef _WIN_CONSOLE */
67
68 #else /* ifndef _WIN32 */
69
70 # include <unistd.h>
71 # include <sys/time.h>
72 # include <sys/wait.h>
73 # include <sys/stat.h>
74 # include <signal.h>
75
76 #endif
77
78 #include "loadcfg.h"
79 #include "jcc.h"
80 #include "filters.h"
81 #include "loaders.h"
82 #include "showargs.h"
83 #include "parsers.h"
84 #include "killpopup.h"
85 #include "miscutil.h"
86 #include "errlog.h"
87 #include "jbsockets.h"
88 #include "gateway.h"
89
90 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
91
92 /*
93  * Fix a problem with Solaris.  There should be no effect on other
94  * platforms.
95  * Solaris's isspace() is a macro which uses it's argument directly
96  * as an array index.  Therefore we need to make sure that high-bit
97  * characters generate +ve values, and ideally we also want to make
98  * the argument match the declared parameter type of "int".
99  */
100 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
101 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
102
103 static const char VANILLA_WAFER[] =
104    "NOTICE=TO_WHOM_IT_MAY_CONCERN_"
105    "Do_not_send_me_any_copyrighted_information_other_than_the_"
106    "document_that_I_am_requesting_or_any_of_its_necessary_components._"
107    "In_particular_do_not_send_me_any_cookies_that_"
108    "are_subject_to_a_claim_of_copyright_by_anybody._"
109    "Take_notice_that_I_refuse_to_be_bound_by_any_license_condition_"
110    "(copyright_or_otherwise)_applying_to_any_cookie._";
111
112 #ifdef TOGGLE
113 /* by haroon - indicates if ijb is enabled */
114 int g_bToggleIJB        = 1;   /* JunkBusters is enabled by default. */
115 #endif
116
117 int debug               = 0;
118 int multi_threaded      = 1;
119
120 #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
121 int tinygif             = 0;
122 const char *tinygifurl  = NULL;\r
123 #endif /* defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) */
124
125 const char *logfile     = NULL;
126
127 const char *configfile  = NULL;
128
129 const char *blockfile   = NULL;
130 const char *cookiefile  = NULL;
131 const char *forwardfile = NULL;
132
133 #ifdef ACL_FILES
134 const char *aclfile     = NULL;
135 #endif /* def ACL_FILES */
136
137 #ifdef USE_IMAGE_LIST
138 const char *imagefile   = NULL;
139 #endif /* def USE_IMAGE_LIST */
140
141 #ifdef KILLPOPUPS
142 const char *popupfile   = NULL;
143 int kill_all_popups     = 0;     /* Not recommended really ... */
144 #endif /* def KILLPOPUPS */
145
146 #ifdef PCRS
147 const char *re_filterfile = NULL;
148 int re_filter_all       = 0;
149 #endif /* def PCRS */
150
151 #ifdef TRUST_FILES
152 const char *trustfile   = NULL;
153 #endif /* def TRUST_FILES */
154
155 #ifdef JAR_FILES
156 const char *jarfile     = NULL;
157 FILE *jar = NULL;
158 #endif /* def JAR_FILES */
159
160 const char *referrer    = NULL;
161 const char *uagent      = NULL;
162 const char *from        = NULL;
163
164 #ifndef SPLIT_PROXY_ARGS
165 const char *suppress_message = NULL;
166 #endif /* ndef SPLIT_PROXY_ARGS */
167
168 int suppress_vanilla_wafer = 0;
169 int add_forwarded       = 0;
170
171 struct list wafer_list[1];
172 struct list xtra_list[1];
173
174 #ifdef TRUST_FILES
175 struct list trust_info[1];
176 struct url_spec *trust_list[64];
177 #endif /* def TRUST_FILES */
178
179 /*
180  * Port and IP to bind to.
181  * Defaults to HADDR_DEFAULT:HADDR_PORT == 127.0.0.1:8000
182  */
183 const char *haddr = NULL;
184 int         hport = 0;
185
186 #ifndef SPLIT_PROXY_ARGS
187 int suppress_blocklists = 0;  /* suppress listing sblock and simage */
188 #endif /* ndef SPLIT_PROXY_ARGS */
189
190 struct proxy_args proxy_args[1];
191
192 int configret = 0;
193 int config_changed = 0;
194
195
196 /*
197  * The load_config function is now going to call `init_proxy_args',
198  * so it will need argc and argv.  Since load_config will also be
199  * a signal handler, we need to have these globally available.
200  */
201 int Argc = 0;
202 const char **Argv = NULL;
203
204
205 /*
206  * This takes the "cryptic" hash of each keyword and aliases them to
207  * something a little more readable.  This also makes changing the
208  * hash values easier if they should change or the hash algorthm changes.
209  * Use the included "hash" program to find out what the hash will be
210  * for any string supplied on the command line.
211  */
212
213 #define hash_trustfile                 56494766ul
214 #define hash_trust_info_url            449869467ul
215 #define hash_debug                     78263ul
216 #define hash_tinygif                   2227702ul
217 #define hash_add_forwarded_header      3191044770ul
218 #define hash_single_threaded           4250084780ul
219 #define hash_suppress_vanilla_wafer    3121233547ul
220 #define hash_wafer                     89669ul
221 #define hash_add_header                237434619ul
222 #define hash_cookiefile                247469766ul
223 #define hash_logfile                   2114766ul
224 #define hash_blockfile                 48845391ul
225 #define hash_imagefile                 51447891ul
226 #define hash_jarfile                   2046641ul
227 #define hash_listen_address            1255650842ul
228 #define hash_forwardfile               1268669141ul
229 #define hash_aclfile                   1908516ul
230 #define hash_popupfile                 54623516ul
231 #define hash_kill_all_popups           2311539906ul
232 #define hash_re_filterfile             3877522444ul
233 #define hash_re_filter_all             3877521376ul
234 #define hash_user_agent                283326691ul
235 #define hash_referrer                  10883969ul
236 #define hash_referer                   2176719ul
237 #define hash_from                      16264ul
238 #define hash_hide_console              2048809870ul
239 #define hash_include_stats             2174146548ul
240 #define hash_suppress_blocklists       1948693308ul
241 #define hash_toggle                    447966ul
242
243 #define hash_activity_animation        1817904738ul
244 #define hash_log_messages              2291744899ul
245 #define hash_log_highlight_messages    4032101240ul
246 #define hash_log_buffer_size           2918070425ul
247 #define hash_log_max_lines             2868344173ul
248 #define hash_log_font_name             2866730124ul
249 #define hash_log_font_size             2866731014ul
250 #define hash_show_on_task_bar          215410365ul
251 #define hash_close_button_minimizes    3651284693ul
252
253
254 /*********************************************************************
255  *
256  * Function    :  load_config
257  *
258  * Description :  Load the config file and all parameters.
259  *
260  * Parameters  :
261  *          1  :  signum : this can be the signal SIGHUP or 0 (if from main).
262  *                In any case, we just ignore this and reload the config file.
263  *
264  * Returns     :  configret : 0 => Ok, everything else is an error.
265  *                Note: we use configret since a signal handler cannot
266  *                return a value, and this function does double duty.
267  *                Ie. Is is called from main and from signal( SIGHUP );
268  *
269  *********************************************************************/
270 void load_config( int signum )
271 {
272    char buf[BUFSIZ];
273    char *p, *q;
274    FILE *configfp = NULL;
275
276    configret = 0;
277    config_changed = 1;
278
279    log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
280
281    init_proxy_args(Argc, Argv);
282
283
284    /* (Waste of memory [not quite a "leak"] here.  The 
285     * last blockfile/popupfile/... etc will not be 
286     * unloaded until we load a new one.  If the 
287     * block/popup/... feature has been disabled in 
288     * the new config file, then we're wasting some 
289     * memory we could otherwise reclaim.
290     */
291
292    /* Disable all loaders. */
293    remove_all_loaders();
294
295    /*
296     * Reset to as close to startup state as we can.
297     * But leave changing the logfile until after we're done loading.
298     */
299
300    #ifdef JAR_FILES
301    if ( NULL != jar )
302    {
303       fclose( jar );
304       jar = NULL;
305    }
306    #endif /* def JAR_FILES */
307
308    debug             = 0;
309    multi_threaded    = 1;
310
311 #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
312    tinygif           = 0;\r
313    freez((char *)tinygifurl);
314 #endif /* defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) */
315
316    suppress_vanilla_wafer = 0;
317    add_forwarded     = 0;
318    hport             = HADDR_PORT;
319
320 #ifdef _WIN_CONSOLE
321    hideConsole       = 0;
322 #endif /*def _WIN_CONSOLE*/
323
324 #ifdef PCRS
325    re_filter_all     = 0;
326 #endif /* def PCRS */
327
328 #ifdef KILLPOPUPS
329    kill_all_popups   = 0;
330 #endif /* def KILLPOPUPS */
331
332 #ifdef TOGGLE
333    g_bToggleIJB      = 1;
334 #endif
335
336 #ifdef STATISTICS
337    urls_read         = 0;
338    urls_rejected     = 0;
339 #endif /* def STATISTICS */
340
341 #ifndef SPLIT_PROXY_ARGS
342    suppress_blocklists = 0;
343 #endif /* ndef SPLIT_PROXY_ARGS */
344
345    freez((char *)from);
346    freez((char *)haddr);
347    freez((char *)uagent);
348    freez((char *)referrer);
349    freez((char *)logfile);
350
351
352    freez((char *)blockfile);
353    freez((char *)cookiefile);
354    freez((char *)forwardfile);
355
356 #ifdef ACL_FILES
357    freez((char *)aclfile);
358 #endif /* def ACL_FILES */
359
360 #ifdef USE_IMAGE_LIST
361    freez((char *)imagefile);
362 #endif /* def USE_IMAGE_LIST */
363
364 #ifdef JAR_FILES
365    freez((char *)jarfile);
366 #endif /* def JAR_FILES */
367
368 #ifdef KILLPOPUPS
369    freez((char *)popupfile);
370 #endif /* def KILLPOPUPS */
371
372 #ifndef SPLIT_PROXY_ARGS
373    freez((char *)suppress_message);
374 #endif /* ndef SPLIT_PROXY_ARGS */
375
376 #ifdef TRUST_FILES
377    freez((char *)trustfile);
378 #endif /* def TRUST_FILES */
379
380 #ifdef PCRS
381    freez((char *)re_filterfile);
382 #endif /* def PCRS */
383
384    if (NULL != configfile)
385    {
386       if ((configfp = fopen(configfile, "r")) == NULL)
387       {
388          log_error(LOG_LEVEL_ERROR, "can't open configuration file '%s':  %E",
389                  configfile);
390          configret = 1;
391          return;
392       }
393    }
394
395    if (NULL != configfp)
396    {
397       memset (buf, 'j', sizeof(buf));
398       while (read_config_line(buf, sizeof(buf), configfp, NULL) != NULL)
399       {
400          char cmd[BUFSIZ];
401          char arg[BUFSIZ];
402          char tmp[BUFSIZ];
403
404          strcpy(tmp, buf);
405
406          /* Copy command (i.e. up to space or tab) into cmd */
407          p = buf;
408          q = cmd;
409          while (*p && (*p != ' ') && (*p != '\t'))
410          {
411             *q++ = *p++;
412          }
413          *q = '\0';
414
415          /* Skip over the whitespace in buf */
416          while (*p && ((*p == ' ') || (*p == '\t')))
417          {
418             p++;
419          }
420
421          /* Copy the argument into arg */
422          strcpy(arg, p);
423
424          /* Should never happen, but check this anyway */
425          if (*cmd == '\0')
426          {
427             continue;
428          }
429
430          /* Make sure the command field is lower case */
431          for (p=cmd; *p; p++)
432          {
433             if (ijb_isupper(*p))
434             {
435                *p = ijb_tolower(*p);
436             }
437          }
438
439          /* Save the argument for show-proxy-args */
440          savearg(cmd, arg);
441
442
443          switch( hash_string( cmd ) )
444          {
445 #ifdef TRUST_FILES
446             case hash_trustfile :\r
447                freez((char *)trustfile);
448                trustfile = strdup(arg);
449                continue;
450
451             case hash_trust_info_url :
452                enlist(trust_info, arg);
453                continue;
454 #endif /* def TRUST_FILES */
455
456             case hash_debug :
457                debug |= atoi(arg);
458                continue;
459
460 #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
461             case hash_tinygif :\r
462                freez((char *)tinygifurl);
463                tinygif = atoi(arg);
464                if(3 == tinygif)\r
465                {\r
466                   p = arg;\r
467                   while((*p >= '0') && (*p <= '9'))\r
468                   {\r
469                      p++;\r
470                   }\r
471                   while((*p == ' ') || (*p == '\t'))\r
472                   {\r
473                      p++;\r
474                   }\r
475                   if (*p)\r
476                   {\r
477                      q = malloc(strlen(p) + 5);\r
478                      if (q)\r
479                      {\r
480                         strcpy(q, p);\r
481                         strcat(q, "\r\n\r\n");\r
482                         tinygifurl = q;\r
483                      }\r
484                   }\r
485                }\r
486                if ((tinygif != 1) && \r
487                    (tinygif != 2) && \r
488                    ((tinygif != 3) || (tinygifurl==NULL)) )\r
489                {\r
490                   log_error(LOG_LEVEL_ERROR, "tinygif setting invalid.");\r
491                }\r
492                continue;
493 #endif /* defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST) */
494
495             case hash_add_forwarded_header :
496                add_forwarded = 1;
497                continue;
498
499             case hash_single_threaded :
500                multi_threaded = 0;
501                continue;
502
503             case hash_suppress_vanilla_wafer :
504                suppress_vanilla_wafer = 1;
505                continue;
506
507             case hash_wafer :
508                enlist(wafer_list, arg);
509                continue;
510
511             case hash_add_header :
512                enlist(xtra_list, arg);
513                continue;
514
515             case hash_cookiefile :\r
516                freez((char *)cookiefile);
517                cookiefile = strdup(arg);
518                continue;
519
520             case hash_logfile :\r
521                freez((char *)logfile);
522                logfile = strdup(arg);
523                continue;
524
525             case hash_blockfile :\r
526                freez((char *)blockfile);
527                blockfile = strdup(arg);
528                continue;
529
530 #ifdef USE_IMAGE_LIST
531             case hash_imagefile :\r
532                freez((char *)imagefile);
533                imagefile = strdup(arg);
534                continue;
535 #endif /* def USE_IMAGE_LIST */
536
537 #ifdef JAR_FILES
538             case hash_jarfile :\r
539                freez((char *)jarfile);
540                jarfile = strdup(arg);
541                continue;
542 #endif /* def JAR_FILES */
543
544             case hash_listen_address :\r
545                freez((char *)haddr);
546                haddr = strdup(arg);
547                continue;
548
549             case hash_forwardfile :\r
550                freez((char *)forwardfile);
551                forwardfile = strdup(arg);
552                continue;
553
554 #ifdef ACL_FILES
555             case hash_aclfile :\r
556                freez((char *)aclfile);
557                aclfile = strdup(arg);
558                continue;
559 #endif /* def ACL_FILES */
560
561 #ifdef KILLPOPUPS
562             case hash_popupfile :\r
563                freez((char *)popupfile);
564                popupfile = strdup(arg);
565                continue;
566
567             case hash_kill_all_popups :
568                kill_all_popups = 1;
569                continue;
570 #endif /* def KILLPOPUPS */
571
572 #ifdef PCRS
573             case hash_re_filterfile :\r
574                freez((char *)re_filterfile);
575                re_filterfile = strdup(arg);
576                continue;
577
578             case hash_re_filter_all :
579                re_filter_all = 1;
580                log_error(LOG_LEVEL_REF, "re_filter policy is %s.",
581                           re_filter_all ? "RADICAL" : "SEMI-SMART");
582                continue;
583 #endif /* def PCRS */
584
585             case hash_user_agent :\r
586                freez((char *)uagent);
587                uagent = strdup(arg);
588                continue;
589
590                /*
591                 * Offer choice of correct spelling according to dictionary,
592                 * or the misspelling used in the HTTP spec.
593                 */
594             case hash_referrer :
595             case hash_referer :\r
596                freez((char *)referrer);
597                referrer = strdup(arg);
598                continue;
599
600             case hash_from :\r
601                freez((char *)from);
602                from = strdup(arg);
603                continue;
604
605 #ifdef _WIN_CONSOLE
606             case hash_hide_console :
607                hideConsole = 1;
608                continue;
609 #endif /*def _WIN_CONSOLE*/
610
611 #ifndef SPLIT_PROXY_ARGS
612             case hash_suppress_blocklists :
613                if (arg[0] != '\0')
614                {
615                   suppress_message = strdup(arg);
616                }
617                else
618                {
619                   /* There will be NO reference in proxy-args. */
620                   suppress_message = NULL;
621                }
622
623                suppress_blocklists = 1;
624                continue;
625 #endif /* ndef SPLIT_PROXY_ARGS */
626
627 #ifdef TOGGLE
628             case hash_toggle :
629                g_bToggleIJB = atoi(arg);
630                continue;
631 #endif /* def TOGGLE */
632
633 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
634             case hash_activity_animation :
635                g_bShowActivityAnimation = atoi(arg);
636                continue;
637
638             case hash_log_messages :
639                g_bLogMessages = atoi(arg);
640                continue;
641
642             case hash_log_highlight_messages :
643                g_bHighlightMessages = atoi(arg);
644                continue;
645
646             case hash_log_buffer_size :
647                g_bLimitBufferSize = atoi(arg);
648                continue;
649
650             case hash_log_max_lines :
651                g_nMaxBufferLines = atoi(arg);
652                continue;
653
654             case hash_log_font_name :
655                strcpy( g_szFontFaceName, arg );
656                continue;
657
658             case hash_log_font_size :
659                g_nFontSize = atoi(arg);
660                continue;
661
662             case hash_show_on_task_bar :
663                g_bShowOnTaskBar = atoi(arg);
664                continue;
665
666             case hash_close_button_minimizes :
667                g_bCloseHidesWindow = atoi(arg);
668                continue;
669 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
670
671             /* Warnings about unsupported features */
672
673 #ifndef TRUST_FILES
674             case hash_trustfile :
675             case hash_trust_info_url :
676 #endif /* ndef TRUST_FILES */
677 #ifndef USE_IMAGE_LIST
678             case hash_imagefile :
679 #endif /* ndef USE_IMAGE_LIST */
680 #ifndef PCRS
681             case hash_re_filterfile :
682             case hash_re_filter_all :
683 #endif /* ndef PCRS */
684 #ifndef TOGGLE
685             case hash_toggle :
686 #endif /* ndef TOGGLE */
687 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
688             case hash_activity_animation :
689             case hash_log_messages :
690             case hash_log_highlight_messages :
691             case hash_log_buffer_size :
692             case hash_log_max_lines :
693             case hash_log_font_name :
694             case hash_log_font_size :
695             case hash_show_on_task_bar :
696             case hash_close_button_minimizes :
697 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
698 #ifndef _WIN_CONSOLE
699             case hash_hide_console :
700 #endif /* ndef _WIN_CONSOLE */
701 #if !defined(DETECT_MSIE_IMAGES) && !defined(USE_IMAGE_LIST)
702             case hash_tinygif :
703 #endif /* !defined(DETECT_MSIE_IMAGES) && !defined(USE_IMAGE_LIST) */
704 #ifndef KILLPOPUPS
705             case hash_popupfile :
706             case hash_kill_all_popups :
707 #endif /* ndef KILLPOPUPS */
708 #ifndef JAR_FILES
709             case hash_jarfile :
710 #endif /* ndef JAR_FILES */
711 #ifndef ACL_FILES
712             case hash_aclfile :
713 #endif /* ndef ACL_FILES */
714
715 #ifdef SPLIT_PROXY_ARGS
716             case hash_suppress_blocklists :
717 #endif /* def SPLIT_PROXY_ARGS */
718                log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd);
719                continue;
720
721             default :
722                log_error(LOG_LEVEL_ERROR, "Unrecognized directive (%lulu) in "
723                      "configuration file: \"%s\"", hash_string( cmd ), buf);
724                p = malloc( BUFSIZ );
725                if (p != NULL)
726                {
727                   sprintf( p, "<br>\nWARNING: unrecognized directive : %s<br><br>\n", buf );
728                   proxy_args->invocation = strsav( proxy_args->invocation, p );
729                   freez( p );
730                }
731                /*
732                 * I decided that I liked this better as a warning than an
733                 * error.
734                 */
735
736                /*
737                 * configret = 1;
738                 * return;
739                 */
740                continue;
741          }
742       }
743       fclose(configfp);
744    }
745
746    init_error_log(Argv[0], logfile, debug);
747
748    if (cookiefile)
749    {
750       add_loader(load_cookiefile);
751    }
752
753    if (blockfile)
754    {
755       add_loader(load_blockfile);
756    }
757
758 #ifdef USE_IMAGE_LIST
759    if (imagefile)
760    {
761       add_loader(load_imagefile);
762    }
763 #endif /* def USE_IMAGE_LIST */
764
765 #ifdef TRUST_FILES
766    if (trustfile)
767    {
768       add_loader(load_trustfile);
769    }
770 #endif /* def TRUST_FILES */
771
772    if (forwardfile)
773    {
774       add_loader(load_forwardfile);
775    }
776
777 #ifdef ACL_FILES
778    if (aclfile)
779    {
780       add_loader(load_aclfile);
781    }
782 #endif /* def ACL_FILES */
783
784 #ifdef KILLPOPUPS
785    if (popupfile)
786    {
787       add_loader(load_popupfile);
788    }
789 #endif /* def KILLPOPUPS */
790
791 #ifdef PCRS
792    if (re_filterfile)
793    {
794       add_loader(load_re_filterfile);
795    }
796 #endif /* def PCRS */
797
798 #ifdef JAR_FILES
799    if ( NULL != jarfile )
800    {
801       if ( NULL == (jar = fopen(jarfile, "a")) )
802       {
803          log_error(LOG_LEVEL_ERROR, "can't open jarfile '%s': %E", jarfile);
804          configret = 1;
805          return;
806       }
807       setbuf(jar, NULL);
808    }
809 #endif /* def JAR_FILES */
810
811    if ( NULL == haddr )
812    {
813       haddr = strdup( HADDR_DEFAULT );
814    }
815
816    if ( NULL != haddr )
817    {
818       if ((p = strchr(haddr, ':')))
819       {
820          *p++ = '\0';
821          if (*p)
822          {
823             hport = atoi(p);
824          }
825       }
826
827       if (hport <= 0)
828       {
829          *--p = ':';
830          log_error(LOG_LEVEL_ERROR, "invalid bind port spec %s", haddr);
831          configret = 1;
832          return;
833       }
834       if (*haddr == '\0')
835       {
836          haddr = NULL;
837       }
838    }
839
840    if (run_loader(NULL))
841    {
842       configret = 1;
843       return;
844    }
845
846 #ifdef JAR_FILES
847    /*
848     * If we're logging cookies in a cookie jar, and the user has not
849     * supplied any wafers, and the user has not told us to suppress the
850     * vanilla wafer, then send the vanilla wafer.
851     */
852    if ((jarfile != NULL)
853        && (wafer_list->next == NULL)
854        && (suppress_vanilla_wafer == 0))
855    {
856       enlist(wafer_list, VANILLA_WAFER);
857    }
858 #endif /* def JAR_FILES */
859
860    end_proxy_args();
861
862 }
863
864
865 /*
866   Local Variables:
867   tab-width: 3
868   end:
869 */