1 const char loaders_rcs[] = "$Id: loaders.c,v 1.13 2001/05/31 21:28:49 jongfoster Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
6 * Purpose : Functions to load and unload the various
7 * configuration files. Also contains code to manage
8 * the list of active loaders, and to automatically
9 * unload files that are no longer in use.
11 * Copyright : Written by and Copyright (C) 2001 the SourceForge
12 * IJBSWA team. http://ijbswa.sourceforge.net
14 * Based on the Internet Junkbuster originally written
15 * by and Copyright (C) 1997 Anonymous Coders and
16 * Junkbusters Corporation. http://www.junkbusters.com
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.
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.
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.
38 * Revision 1.13 2001/05/31 21:28:49 jongfoster
39 * Removed all permissionsfile code - it's now called the actions
40 * file, and (almost) all the code is in actions.c
42 * Revision 1.12 2001/05/31 17:32:31 oes
44 * - Enhanced domain part globbing with infix and prefix asterisk
45 * matching and optional unanchored operation
47 * Revision 1.11 2001/05/29 23:25:24 oes
49 * - load_config_line() and load_permissions_file() now use chomp()
51 * Revision 1.10 2001/05/29 09:50:24 jongfoster
52 * Unified blocklist/imagelist/permissionslist.
53 * File format is still under discussion, but the internal changes
56 * Also modified interceptor behaviour:
57 * - We now intercept all URLs beginning with one of the following
58 * prefixes (and *only* these prefixes):
60 * * http://ijbswa.sf.net/config/
61 * * http://ijbswa.sourceforge.net/config/
62 * - New interceptors "home page" - go to http://i.j.b/ to see it.
63 * - Internal changes so that intercepted and fast redirect pages
64 * are not replaced with an image.
65 * - Interceptors now have the option to send a binary page direct
66 * to the client. (i.e. ijb-send-banner uses this)
67 * - Implemented show-url-info interceptor. (Which is why I needed
68 * the above interceptors changes - a typical URL is
69 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
70 * The previous mechanism would not have intercepted that, and
71 * if it had been intercepted then it then it would have replaced
74 * Revision 1.9 2001/05/26 17:12:07 jongfoster
75 * Fatal errors loading configuration files now give better error messages.
77 * Revision 1.8 2001/05/26 00:55:20 jongfoster
78 * Removing duplicated code. load_forwardfile() now uses create_url_spec()
80 * Revision 1.7 2001/05/26 00:28:36 jongfoster
81 * Automatic reloading of config file.
82 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
83 * Most of the global variables have been moved to a new
84 * struct configuration_spec, accessed through csp->config->globalname
85 * Most of the globals remaining are used by the Win32 GUI.
87 * Revision 1.6 2001/05/23 12:27:33 oes
89 * Fixed ugly indentation of my last changes
91 * Revision 1.5 2001/05/23 10:39:05 oes
92 * - Added support for escaping the comment character
93 * in config files by a backslash
94 * - Added support for line continuation in config
96 * - Fixed a buffer overflow bug with long config lines
98 * Revision 1.4 2001/05/22 18:56:28 oes
101 * Revision 1.3 2001/05/20 01:21:20 jongfoster
102 * Version 2.9.4 checkin.
103 * - Merged popupfile and cookiefile, and added control over PCRS
104 * filtering, in new "permissionsfile".
105 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
106 * file error you now get a message box (in the Win32 GUI) rather
107 * than the program exiting with no explanation.
108 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
110 * - Removed tabs from "config"
111 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
112 * - Bumped up version number.
114 * Revision 1.2 2001/05/17 23:01:01 oes
115 * - Cleaned CRLF's from the sources and related files
117 * Revision 1.1.1.1 2001/05/15 13:58:59 oes
118 * Initial import of version 2.9.3 source tree
121 *********************************************************************/
128 #include <sys/types.h>
132 #include <sys/stat.h>
147 #include "miscutil.h"
152 #ifndef SPLIT_PROXY_ARGS
154 #include "showargs.h"
155 #endif /* ndef SPLIT_PROXY_ARGS */
157 const char loaders_h_rcs[] = LOADERS_H_VERSION;
159 /* Fix a problem with Solaris. There should be no effect on other
161 * Solaris's isspace() is a macro which uses it's argument directly
162 * as an array index. Therefore we need to make sure that high-bit
163 * characters generate +ve values, and ideally we also want to make
164 * the argument match the declared parameter type of "int".
166 #define ijb_isspace(__X) isspace((int)(unsigned char)(__X))
170 * Currently active files.
171 * These are also entered in the main linked list of files.
173 static struct file_list *current_forwardfile = NULL;
176 static struct file_list *current_aclfile = NULL;
177 #endif /* def ACL_FILES */
180 static struct file_list *current_trustfile = NULL;
181 #endif /* def TRUST_FILES */
184 static struct file_list *current_re_filterfile = NULL;
185 #endif /* def PCRS */
188 /*********************************************************************
192 * Description : Basically a mark and sweep garbage collector, it is run
193 * (by the parent thread) every once in a while to reclaim memory.
195 * It uses a mark and sweep strategy:
196 * 1) mark all files as inactive
198 * 2) check with each client:
199 * if it is active, mark its files as active
200 * if it is inactive, free its resources
202 * 3) free the resources of all of the files that
203 * are still marked as inactive (and are obsolete).
205 * N.B. files that are not obsolete don't have an unloader defined.
211 *********************************************************************/
214 struct file_list *fl, *nfl;
215 struct client_state *csp, *ncsp;
217 /* clear all of the file's active flags */
218 for ( fl = files->next; NULL != fl; fl = fl->next )
223 for (csp = clients; csp && (ncsp = csp->next) ; csp = csp->next)
227 /* mark this client's files as active */
230 * Always have a configuration file.
231 * (Also note the slightly non-standard extra
234 ncsp->config->config_file_list->active = 1;
236 if (ncsp->actions_list) /* actions files */
238 ncsp->actions_list->active = 1;
241 if (ncsp->flist) /* forward files */
243 ncsp->flist->active = 1;
247 if (ncsp->alist) /* acl files */
249 ncsp->alist->active = 1;
251 #endif /* def ACL_FILES */
254 if (ncsp->rlist) /* perl re files */
256 ncsp->rlist->active = 1;
258 #endif /* def PCRS */
261 if (ncsp->tlist) /* trust files */
263 ncsp->tlist->active = 1;
265 #endif /* def TRUST_FILES */
270 /* this client one is not active, release its resources */
271 csp->next = ncsp->next;
273 freez(ncsp->ip_addr_str);
275 freez(ncsp->referrer);
276 #endif /* def TRUST_FILES */
277 freez(ncsp->x_forwarded);
278 freez(ncsp->iob->buf);
280 free_http_request(ncsp->http);
282 destroy_list(ncsp->headers);
283 destroy_list(ncsp->cookie_list);
285 free_current_action(ncsp->action);
293 #endif /* def STATISTICS */
299 for (fl = files; fl && (nfl = fl->next) ; fl = fl->next)
301 if ( ( 0 == nfl->active ) && ( NULL != nfl->unloader ) )
303 fl->next = nfl->next;
305 (nfl->unloader)(nfl->f);
307 #ifndef SPLIT_PROXY_ARGS
308 freez(nfl->proxy_args);
309 #endif /* ndef SPLIT_PROXY_ARGS */
311 freez(nfl->filename);
320 /*********************************************************************
322 * Function : create_url_spec
324 * Description : Creates a "url_spec" structure from a string.
325 * When finished, free with unload_url().
328 * 1 : url = Target url_spec to be filled in. Must be
329 * zeroed out before the call (e.g. using zalloc).
330 * 2 : buf = Source pattern, null terminated. NOTE: The
331 * contents of this buffer are destroyed by this
332 * function. If this function succeeds, the
333 * buffer is copied to url->spec. If this
334 * function fails, the contents of the buffer
337 * Returns : 0 => Ok, everything else is an error.
339 *********************************************************************/
340 int create_url_spec(struct url_spec * url, char * buf)
343 struct url_spec tmp_url[1];
345 /* paranoia - should never happen. */
346 if ((url == NULL) || (buf == NULL))
351 /* save a copy of the orignal specification */
352 if ((url->spec = strdup(buf)) == NULL)
357 if ((p = strchr(buf, '/')))
359 if (NULL == (url->path = strdup(p)))
364 url->pathlen = strlen(url->path);
378 if (NULL == (url->preg = zalloc(sizeof(*url->preg))))
385 sprintf(rebuf, "^(%s)", url->path);
387 errcode = regcomp(url->preg, rebuf,
388 (REG_EXTENDED|REG_NOSUB|REG_ICASE));
393 url->preg, buf, sizeof(buf));
397 log_error(LOG_LEVEL_ERROR, "error compiling %s: %s",
408 if ((p = strchr(buf, ':')) == NULL)
418 if ((url->domain = strdup(buf)) == NULL)
424 #endif /* def REGEX */
428 /* split domain into components */
430 *tmp_url = dsplit(url->domain);
431 url->dbuf = tmp_url->dbuf;
432 url->dcnt = tmp_url->dcnt;
433 url->dvec = tmp_url->dvec;
434 url->unanchored = tmp_url->unanchored;
440 /*********************************************************************
442 * Function : free_url
444 * Description : Called from the "unloaders". Freez the url
445 * structure elements.
448 * 1 : url = pointer to a url_spec structure.
452 *********************************************************************/
453 void free_url(struct url_spec *url)
455 if (url == NULL) return;
474 /*********************************************************************
476 * Function : unload_aclfile
478 * Description : Unloads an aclfile.
481 * 1 : f = the data structure associated with the aclfile.
485 *********************************************************************/
486 static void unload_aclfile(void *f)
488 struct access_control_list *b = (struct access_control_list *)f;
489 if (b == NULL) return;
491 unload_aclfile(b->next);
496 #endif /* def ACL_FILES */
500 /*********************************************************************
502 * Function : unload_trustfile
504 * Description : Unloads a trustfile.
507 * 1 : f = the data structure associated with the trustfile.
511 *********************************************************************/
512 static void unload_trustfile(void *f)
514 struct block_spec *b = (struct block_spec *)f;
515 if (b == NULL) return;
517 unload_trustfile(b->next);
524 #endif /* def TRUST_FILES */
527 /*********************************************************************
529 * Function : unload_forwardfile
531 * Description : Unloads a forwardfile.
534 * 1 : f = the data structure associated with the forwardfile.
538 *********************************************************************/
539 static void unload_forwardfile(void *f)
541 struct forward_spec *b = (struct forward_spec *)f;
542 if (b == NULL) return;
544 unload_forwardfile(b->next);
548 freez(b->gw->gateway_host);
549 freez(b->gw->forward_host);
557 /*********************************************************************
559 * Function : unload_re_filterfile
561 * Description : Unload the re_filter list.
564 * 1 : f = the data structure associated with the filterfile.
568 *********************************************************************/
569 static void unload_re_filterfile(void *f)
572 struct re_filterfile_spec *b = (struct re_filterfile_spec *)f;
574 if (b == NULL) return;
576 destroy_list(b->patterns);
578 joblist = b->joblist;
579 while ( NULL != (joblist = pcrs_free_job(joblist)) ) {}
584 #endif /* def PCRS */
587 /*********************************************************************
589 * Function : check_file_changed
591 * Description : Helper function to check if a file needs reloading.
592 * If "current" is still current, return it. Otherwise
593 * allocates a new (zeroed) "struct file_list", fills
594 * in the disk file name and timestamp, and returns it.
597 * 1 : current = The file_list currently being used - will
598 * be checked to see if it is out of date.
599 * May be NULL (which is treated as out of
601 * 2 : filename = Name of file to check.
602 * 3 : newfl = New file list. [Output only]
603 * This will be set to NULL, OR a struct
604 * file_list newly allocated on the
605 * heap, with the filename and lastmodified
606 * fields filled, standard header giving file
607 * name in proxy_args, and all others zeroed.
608 * (proxy_args is only filled in if !defined
609 * SPLIT_PROXY_ARGS and !suppress_blocklists).
611 * Returns : If file unchanged: 0 (and sets newfl == NULL)
612 * If file changed: 1 and sets newfl != NULL
613 * On error: 1 and sets newfl == NULL
615 *********************************************************************/
616 int check_file_changed(const struct file_list * current,
617 const char * filename,
618 struct file_list ** newfl)
620 struct file_list *fs;
621 struct stat statbuf[1];
625 if (stat(filename, statbuf) < 0)
627 /* Error, probably file not found. */
632 && (current->lastmodified == statbuf->st_mtime)
633 && (0 == strcmp(current->filename, filename)))
638 fs = (struct file_list *)zalloc(sizeof(struct file_list));
642 /* Out of memory error */
646 fs->filename = strdup(filename);
647 fs->lastmodified = statbuf->st_mtime;
649 if (fs->filename == NULL)
651 /* Out of memory error */
656 #ifndef SPLIT_PROXY_ARGS
657 if (!suppress_blocklists)
659 char * p = html_encode(filename);
662 fs->proxy_args = strsav(fs->proxy_args, "<h2>The file `");
663 fs->proxy_args = strsav(fs->proxy_args, p);
664 fs->proxy_args = strsav(fs->proxy_args,
665 "' contains the following patterns</h2>\n");
668 fs->proxy_args = strsav(fs->proxy_args, "<pre>");
670 #endif /* ndef SPLIT_PROXY_ARGS */
677 /*********************************************************************
679 * Function : read_config_line
681 * Description : Read a single non-empty line from a file and return
682 * it. Trims comments, leading and trailing whitespace
683 * and respects escaping of newline and comment char.
684 * Also writes the file to fs->proxy_args.
687 * 1 : buf = Buffer to use.
688 * 2 : buflen = Size of buffer in bytes.
689 * 3 : fp = File to read from
690 * 4 : fs = File will be written to fs->proxy_args. May
691 * be NULL to disable this feature.
693 * Returns : NULL on EOF or error
694 * Otherwise, returns buf.
696 *********************************************************************/
697 char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs)
700 char linebuf[BUFSIZ];
705 while (fgets(linebuf, sizeof(linebuf), fp))
707 #ifndef SPLIT_PROXY_ARGS
708 if (fs && !suppress_blocklists)
710 char *html_line = html_encode(linebuf);
711 if (html_line != NULL)
713 fs->proxy_args = strsav(fs->proxy_args, html_line);
716 fs->proxy_args = strsav(fs->proxy_args, "<br>");
718 #endif /* ndef SPLIT_PROXY_ARGS */
720 /* Trim off newline */
721 if ((p = strpbrk(linebuf, "\r\n")) != NULL)
726 /* Line continuation? Trim escape and set flag. */
727 if ((p != linebuf) && (*--p == '\\'))
733 /* If there's a comment char.. */
734 if ((p = strpbrk(linebuf, "#")) != NULL)
736 /* ..and it's escaped, left-shift the line over the escape. */
737 if ((p != linebuf) && (*(p-1) == '\\'))
740 while ((*q++ = *p++) != '\0') /* nop */;
742 /* Else, chop off the rest of the line */
749 /* Write to the buffer */
752 strncat(buf, linebuf, buflen - strlen(buf));
762 /* Remove leading and trailing whitespace */
778 /*********************************************************************
780 * Function : load_aclfile
782 * Description : Read and parse an aclfile and add to files list.
785 * 1 : csp = Current client state (buffers, headers, etc...)
787 * Returns : 0 => Ok, everything else is an error.
789 *********************************************************************/
790 int load_aclfile(struct client_state *csp)
793 char buf[BUFSIZ], *v[3], *p;
795 struct access_control_list *a, *bl;
796 struct file_list *fs;
798 if (!check_file_changed(current_aclfile, csp->config->aclfile, &fs))
800 /* No need to load */
803 csp->alist = current_aclfile;
809 goto load_aclfile_error;
812 fs->f = bl = (struct access_control_list *)zalloc(sizeof(*bl));
817 goto load_aclfile_error;
820 fp = fopen(csp->config->aclfile, "r");
824 goto load_aclfile_error;
827 while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
829 i = ssplit(buf, " \t", v, SZ(v), 1, 1);
831 /* allocate a new node */
832 a = (struct access_control_list *) zalloc(sizeof(*a));
840 goto load_aclfile_error;
843 /* add it to the list */
850 if (acl_addr(v[2], a->dst) < 0)
852 goto load_aclfile_error;
857 if (acl_addr(v[1], a->src) < 0)
859 goto load_aclfile_error;
863 if (strcmpic(p, "permit") == 0)
865 a->action = ACL_PERMIT;
869 if (strcmpic(p, "deny") == 0)
871 a->action = ACL_DENY;
877 goto load_aclfile_error;
883 #ifndef SPLIT_PROXY_ARGS
884 if (!suppress_blocklists)
886 fs->proxy_args = strsav(fs->proxy_args, "</pre>");
888 #endif /* ndef SPLIT_PROXY_ARGS */
892 current_aclfile->unloader = unload_aclfile;
895 fs->next = files->next;
897 current_aclfile = fs;
907 log_error(LOG_LEVEL_FATAL, "can't load access control list %s: %E",
908 csp->config->aclfile);
912 #endif /* def ACL_FILES */
916 /*********************************************************************
918 * Function : load_trustfile
920 * Description : Read and parse a trustfile and add to files list.
923 * 1 : csp = Current client state (buffers, headers, etc...)
925 * Returns : 0 => Ok, everything else is an error.
927 *********************************************************************/
928 int load_trustfile(struct client_state *csp)
932 struct block_spec *b, *bl;
933 struct url_spec **tl;
935 char buf[BUFSIZ], *p, *q;
937 struct file_list *fs;
939 if (!check_file_changed(current_trustfile, csp->config->trustfile, &fs))
941 /* No need to load */
944 csp->tlist = current_trustfile;
950 goto load_trustfile_error;
953 fs->f = bl = (struct block_spec *)zalloc(sizeof(*bl));
956 goto load_trustfile_error;
959 if ((fp = fopen(csp->config->trustfile, "r")) == NULL)
961 goto load_trustfile_error;
964 tl = csp->config->trust_list;
966 while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
982 while ((*p++ = *q++))
988 /* skip blank lines */
994 /* allocate a new node */
995 if ((b = zalloc(sizeof(*b))) == NULL)
998 goto load_trustfile_error;
1001 /* add it to the list */
1007 /* Save the URL pattern */
1008 if (create_url_spec(b->url, buf))
1011 goto load_trustfile_error;
1015 * save a pointer to URL's spec in the list of trusted URL's, too
1027 #ifndef SPLIT_PROXY_ARGS
1028 if (!suppress_blocklists)
1030 fs->proxy_args = strsav(fs->proxy_args, "</pre>");
1032 #endif /* ndef SPLIT_PROXY_ARGS */
1034 /* the old one is now obsolete */
1035 if (current_trustfile)
1037 current_trustfile->unloader = unload_trustfile;
1040 fs->next = files->next;
1042 current_trustfile = fs;
1051 load_trustfile_error:
1052 log_error(LOG_LEVEL_FATAL, "can't load trustfile '%s': %E",
1053 csp->config->trustfile);
1057 #endif /* def TRUST_FILES */
1060 /*********************************************************************
1062 * Function : load_forwardfile
1064 * Description : Read and parse a forwardfile and add to files list.
1067 * 1 : csp = Current client state (buffers, headers, etc...)
1069 * Returns : 0 => Ok, everything else is an error.
1071 *********************************************************************/
1072 int load_forwardfile(struct client_state *csp)
1076 struct forward_spec *b, *bl;
1081 struct file_list *fs;
1082 const struct gateway *gw;
1084 if (!check_file_changed(current_forwardfile, csp->config->forwardfile, &fs))
1086 /* No need to load */
1089 csp->flist = current_forwardfile;
1095 goto load_forwardfile_error;
1098 fs->f = bl = (struct forward_spec *)zalloc(sizeof(*bl));
1100 if ((fs == NULL) || (bl == NULL))
1102 goto load_forwardfile_error;
1105 if ((fp = fopen(csp->config->forwardfile, "r")) == NULL)
1107 goto load_forwardfile_error;
1112 while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
1118 n = ssplit(tmp, " \t", vec, SZ(vec), 1, 1);
1122 log_error(LOG_LEVEL_ERROR, "error in forwardfile: %s", buf);
1126 strcpy(buf, vec[0]);
1128 /* skip lines containing only ~ */
1134 /* allocate a new node */
1135 if (((b = zalloc(sizeof(*b))) == NULL)
1139 goto load_forwardfile_error;
1142 /* add it to the list */
1146 /* Save the URL pattern */
1147 if (create_url_spec(b->url, buf))
1150 goto load_forwardfile_error;
1153 /* now parse the gateway specs */
1157 for (gw = gateways; gw->name; gw++)
1159 if (strcmp(gw->name, p) == 0)
1165 if (gw->name == NULL)
1167 goto load_forwardfile_error;
1170 /* save this as the gateway type */
1173 /* now parse the gateway host[:port] spec */
1176 if (strcmp(p, ".") != 0)
1178 b->gw->gateway_host = strdup(p);
1180 if ((p = strchr(b->gw->gateway_host, ':')))
1183 b->gw->gateway_port = atoi(p);
1186 if (b->gw->gateway_port <= 0)
1188 goto load_forwardfile_error;
1192 /* now parse the forwarding spec */
1195 if (strcmp(p, ".") != 0)
1197 b->gw->forward_host = strdup(p);
1199 if ((p = strchr(b->gw->forward_host, ':')))
1202 b->gw->forward_port = atoi(p);
1205 if (b->gw->forward_port <= 0)
1207 b->gw->forward_port = 8000;
1216 #ifndef SPLIT_PROXY_ARGS
1217 if (!suppress_blocklists)
1219 fs->proxy_args = strsav(fs->proxy_args, "</pre>");
1221 #endif /* ndef SPLIT_PROXY_ARGS */
1223 /* the old one is now obsolete */
1224 if (current_forwardfile)
1226 current_forwardfile->unloader = unload_forwardfile;
1229 fs->next = files->next;
1231 current_forwardfile = fs;
1240 load_forwardfile_error:
1241 log_error(LOG_LEVEL_FATAL, "can't load forwardfile '%s': %E",
1242 csp->config->forwardfile);
1249 /*********************************************************************
1251 * Function : load_re_filterfile
1253 * Description : Load the re_filterfile. Each non-comment, non-empty
1254 * line is instantly added to the joblist, which is
1255 * a chained list of pcrs_job structs.
1258 * 1 : csp = Current client state (buffers, headers, etc...)
1260 * Returns : 0 => Ok, everything else is an error.
1262 *********************************************************************/
1263 int load_re_filterfile(struct client_state *csp)
1267 struct re_filterfile_spec *bl;
1268 struct file_list *fs;
1274 if (!check_file_changed(current_re_filterfile, csp->config->re_filterfile, &fs))
1276 /* No need to load */
1279 csp->rlist = current_re_filterfile;
1285 goto load_re_filterfile_error;
1288 fs->f = bl = (struct re_filterfile_spec *)zalloc(sizeof(*bl));
1291 goto load_re_filterfile_error;
1294 /* Open the file or fail */
1295 if ((fp = fopen(csp->config->re_filterfile, "r")) == NULL)
1297 goto load_re_filterfile_error;
1300 /* Read line by line */
1301 while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
1303 enlist( bl->patterns, buf );
1305 /* We have a meaningful line -> make it a job */
1306 if ((dummy = pcrs_make_job(buf, &error)) == NULL)
1308 log_error(LOG_LEVEL_RE_FILTER,
1309 "Adding re_filter job %s failed with error %d.", buf, error);
1314 dummy->next = bl->joblist;
1315 bl->joblist = dummy;
1316 log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s succeeded.", buf);
1322 #ifndef SPLIT_PROXY_ARGS
1323 if (!suppress_blocklists)
1325 fs->proxy_args = strsav(fs->proxy_args, "</pre>");
1327 #endif /* ndef SPLIT_PROXY_ARGS */
1329 /* the old one is now obsolete */
1330 if ( NULL != current_re_filterfile )
1332 current_re_filterfile->unloader = unload_re_filterfile;
1335 fs->next = files->next;
1337 current_re_filterfile = fs;
1346 load_re_filterfile_error:
1347 log_error(LOG_LEVEL_FATAL, "can't load re_filterfile '%s': %E",
1348 csp->config->re_filterfile);
1352 #endif /* def PCRS */
1355 /*********************************************************************
1357 * Function : add_loader
1359 * Description : Called from `load_config'. Called once for each input
1360 * file found in config.
1363 * 1 : loader = pointer to a function that can parse and load
1364 * the appropriate config file.
1365 * 2 : config = The configuration_spec to add the loader to.
1369 *********************************************************************/
1370 void add_loader(int (*loader)(struct client_state *),
1371 struct configuration_spec * config)
1375 for (i=0; i < NLOADERS; i++)
1377 if (config->loaders[i] == NULL)
1379 config->loaders[i] = loader;
1387 /*********************************************************************
1389 * Function : run_loader
1391 * Description : Called from `load_config' and `listen_loop'. This
1392 * function keeps the "csp" current with any file mods
1393 * since the last loop. If a file is unchanged, the
1394 * loader functions do NOT reload the file.
1397 * 1 : csp = Current client state (buffers, headers, etc...)
1398 * Must be non-null. Reads: "csp->config"
1399 * Writes: various data members.
1401 * Returns : 0 => Ok, everything else is an error.
1403 *********************************************************************/
1404 int run_loader(struct client_state *csp)
1409 for (i=0; i < NLOADERS; i++)
1411 if (csp->config->loaders[i] == NULL)
1415 ret |= (csp->config->loaders[i])(csp);