- * Description : Unload the re_filter list.
- *
- * Parameters :
- * 1 : f = the data structure associated with the filterfile.
- *
- * Returns : N/A
- *
- *********************************************************************/
-static void unload_re_filterfile(void *f)
-{
- pcrs_job *joblist;
- struct re_filterfile_spec *b = (struct re_filterfile_spec *)f;
-
- if (b == NULL) return;
-
- destroy_list(b->patterns);
-
- joblist = b->joblist;
- while ( NULL != (joblist = pcrs_free_job(joblist)) ) {}
-
- freez(b);
-
-}
-#endif /* def PCRS */
-
-
-/*********************************************************************
- *
- * Function : check_file_changed
- *
- * Description : Helper function to check if a file needs reloading.
- * If "current" is still current, return it. Otherwise
- * allocates a new (zeroed) "struct file_list", fills
- * in the disk file name and timestamp, and returns it.
- *
- * Parameters :
- * 1 : current = The file_list currently being used - will
- * be checked to see if it is out of date.
- * May be NULL (which is treated as out of
- * date).
- * 2 : filename = Name of file to check.
- * 3 : newfl = New file list. [Output only]
- * This will be set to NULL, OR a struct
- * file_list newly allocated on the
- * heap, with the filename and lastmodified
- * fields filled, standard header giving file
- * name in proxy_args, and all others zeroed.
- * (proxy_args is only filled in if !defined
- * SPLIT_PROXY_ARGS and !suppress_blocklists).
- *
- * Returns : If file unchanged: 0 (and sets newfl == NULL)
- * If file changed: 1 and sets newfl != NULL
- * On error: 1 and sets newfl == NULL
- *
- *********************************************************************/
-static int check_file_changed(const struct file_list * current,
- const char * filename,
- struct file_list ** newfl)
-{
- struct file_list *fs;
- struct stat statbuf[1];
-
- *newfl = NULL;
-
- if (stat(filename, statbuf) < 0)
- {
- /* Error, probably file not found. */
- return 1;
- }
-
- if (current
- && (current->lastmodified == statbuf->st_mtime)
- && (0 == strcmp(current->filename, filename)))
- {
- return 0;
- }
-
- fs = (struct file_list *)zalloc(sizeof(struct file_list));
-
- if (fs == NULL)
- {
- /* Out of memory error */
- return 1;
- }
-
- fs->filename = strdup(filename);
- fs->lastmodified = statbuf->st_mtime;
-
- if (fs->filename == NULL)
- {
- /* Out of memory error */
- freez (fs);
- return 1;
- }
-
-#ifndef SPLIT_PROXY_ARGS
- if (!suppress_blocklists)
- {
- char * p = html_encode(filename);
- if (p)
- {
- fs->proxy_args = strsav(fs->proxy_args, "<h2>The file `");
- fs->proxy_args = strsav(fs->proxy_args, p);
- fs->proxy_args = strsav(fs->proxy_args,
- "' contains the following patterns</h2>\n");
- freez(p);
- }
- fs->proxy_args = strsav(fs->proxy_args, "<pre>");
- }
-#endif /* ndef SPLIT_PROXY_ARGS */
-
- *newfl = fs;
- return 1;
-}
-
-
-/*********************************************************************
- *
- * Function : read_config_line
- *
- * Description : Read a single non-empty line from a file and return
- * it. Trims comments, leading and trailing whitespace.
- * Also wites the file to fs->proxy_args.
- *
- * Parameters :
- * 1 : buf = Buffer to use.
- * 2 : buflen = Size of buffer in bytes.
- * 3 : fp = File to read from
- * 4 : fs = File will be written to fs->proxy_args. May
- * be NULL to disable this feature.
- *
- * Returns : NULL on EOF or error
- * Otherwise, returns buf.
- *
- *********************************************************************/
-char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs)
-{
- char *p, *q;
- char linebuf[BUFSIZ];
-
- while (fgets(linebuf, sizeof(linebuf), fp))
- {
-#ifndef SPLIT_PROXY_ARGS
- if (fs && !suppress_blocklists)
- {
- char *html_line = html_encode(linebuf);
- if (html_line != NULL)
- {
- fs->proxy_args = strsav(fs->proxy_args, html_line);
- freez(html_line);
- }
- fs->proxy_args = strsav(fs->proxy_args, "<br>");
- }
-#endif /* ndef SPLIT_PROXY_ARGS */
-
- /* Trim off newline and any comment */
- if ((p = strpbrk(linebuf, "\r\n#")) != NULL)
- {
- *p = '\0';
- }
-
- /* Trim leading whitespace */
- p = linebuf;
- while (*p && ijb_isspace(*p))
- {
- *p++;
- }
-
- if (*p)
- {
- /* There is something other than whitespace on the line. */
-
- /* Move the data to the start of buf */
- if (p != linebuf)
- {
- /* strcpy that can cope with overlap. */
- q = linebuf;
- while ((*q++ = *p++) != '\0')
- {
- /* Do nothing */
- }
- }
-
- /* Trim trailing whitespace */
- p = linebuf + strlen(linebuf) - 1;
-
- /*
- * Note: the (p >= linebuf) below is paranoia, it's not really needed.
- * When p == linebuf then ijb_isspace(*p) will be false and we'll drop
- * out of the loop.
- */
- while ((p >= linebuf) && ijb_isspace(*p))
- {
- p--;
- }
- p[1] = '\0';
-
- /* More paranoia. This if statement is always true. */
- if (*linebuf)
- {
- strcpy(buf, linebuf);
- return buf;
- }
- }
- }
-
- /* EOF */
- return NULL;
-}
-
-
-#ifdef ACL_FILES
-/*********************************************************************
- *
- * Function : load_aclfile
- *
- * Description : Read and parse an aclfile and add to files list.