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