Added tarball-src target
[privoxy.git] / loaders.c
index 4cf6663..0dd8ebb 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.33 2001/11/13 00:16:38 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
@@ -35,6 +35,25 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster
  *
  * Revisions   :
  *    $Log: loaders.c,v $
+ *    Revision 1.33  2001/11/13 00:16:38  jongfoster
+ *    Replacing references to malloc.h with the standard stdlib.h
+ *    (See ANSI or K&R 2nd Ed)
+ *
+ *    Revision 1.32  2001/11/07 00:02:13  steudten
+ *    Add line number in error output for lineparsing for
+ *    actionsfile and configfile.
+ *    Special handling for CLF added.
+ *
+ *    Revision 1.31  2001/10/26 17:39:01  oes
+ *    Removed csp->referrer
+ *    Moved ijb_isspace and ijb_tolower to project.h
+ *
+ *    Revision 1.30  2001/10/25 03:40:48  david__schmidt
+ *    Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
+ *    threads to call select() simultaneously.  So, it's time to do a real, live,
+ *    native OS/2 port.  See defines for __EMX__ (the porting layer) vs. __OS2__
+ *    (native). Both versions will work, but using __OS2__ offers multi-threading.
+ *
  *    Revision 1.29  2001/10/23 21:38:53  jongfoster
  *    Adding error-checking to create_url_spec()
  *
@@ -186,7 +205,6 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster
 #include <stdlib.h>
 #include <sys/types.h>
 #include <string.h>
-#include <malloc.h>
 #include <errno.h>
 #include <sys/stat.h>
 #include <ctype.h>
@@ -208,16 +226,6 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.29 2001/10/23 21:38:53 jongfoster
 
 const char loaders_h_rcs[] = LOADERS_H_VERSION;
 
-/* Fix a problem with Solaris.  There should be no effect on other
- * platforms.
- * Solaris's isspace() is a macro which uses it's argument directly
- * as an array index.  Therefore we need to make sure that high-bit
- * characters generate +ve values, and ideally we also want to make
- * the argument match the declared parameter type of "int".
- */
-#define ijb_isspace(__X) isspace((int)(unsigned char)(__X))
-
-
 /*
  * Currently active files.
  * These are also entered in the main linked list of files.
@@ -311,10 +319,6 @@ void sweep(void)
             freez(ncsp->ip_addr_str);
             freez(ncsp->my_ip_addr_str);
             freez(ncsp->my_hostname);
-
-#ifdef FEATURE_TRUST
-            freez(ncsp->referrer);
-#endif /* def FEATURE_TRUST */
             freez(ncsp->x_forwarded);
             freez(ncsp->iob->buf);
 
@@ -572,11 +576,11 @@ int check_file_changed(const struct file_list * current,
        && (current->lastmodified == statbuf->st_mtime)
        && (0 == strcmp(current->filename, filename)))
    {
-      return 0;
+       /* force reload of configfile and all the logs */
+       if ( !MustReload ) return 0;
    }
 
    fs = (struct file_list *)zalloc(sizeof(struct file_list));
-
    if (fs == NULL)
    {
       /* Out of memory error */
@@ -592,11 +596,8 @@ int check_file_changed(const struct file_list * current,
       freez (fs);
       return 1;
    }
-
-
    *newfl = fs;
    return 1;
-
 }
 
 
@@ -612,12 +613,13 @@ int check_file_changed(const struct file_list * current,
  *          1  :  buf = Buffer to use.
  *          2  :  buflen = Size of buffer in bytes.
  *          3  :  fp = File to read from
+ *         4  :  linenum = linenumber in file
  *
  * Returns     :  NULL on EOF or error
  *                Otherwise, returns buf.
  *
  *********************************************************************/
-char *read_config_line(char *buf, int buflen, FILE *fp)
+char *read_config_line(char *buf, int buflen, FILE *fp, unsigned long *linenum)
 {
    char *p;
    char *src;
@@ -629,6 +631,7 @@ char *read_config_line(char *buf, int buflen, FILE *fp)
 
    while (fgets(linebuf, sizeof(linebuf), fp))
    {
+       (*linenum)++;
       /* Trim off newline */
       if ((p = strpbrk(linebuf, "\r\n")) != NULL)
       {
@@ -745,6 +748,7 @@ int load_trustfile(struct client_state *csp)
    char  buf[BUFFER_SIZE], *p, *q;
    int reject, trusted;
    struct file_list *fs;
+   unsigned long linenum = 0;
 
    if (!check_file_changed(current_trustfile, csp->config->trustfile, &fs))
    {
@@ -773,7 +777,7 @@ int load_trustfile(struct client_state *csp)
 
    tl = csp->config->trust_list;
 
-   while (read_config_line(buf, sizeof(buf), fp) != NULL)
+   while (read_config_line(buf, sizeof(buf), fp, &linenum) != NULL)
    {
       trusted = 0;
       reject  = 1;
@@ -911,6 +915,7 @@ int load_re_filterfile(struct client_state *csp)
 
    char  buf[BUFFER_SIZE];
    int error;
+   unsigned long linenum = 0;
    pcrs_job *dummy;
 
    if (!check_file_changed(current_re_filterfile, csp->config->re_filterfile, &fs))
@@ -940,7 +945,7 @@ int load_re_filterfile(struct client_state *csp)
    }
 
    /* Read line by line */
-   while (read_config_line(buf, sizeof(buf), fp) != NULL)
+   while (read_config_line(buf, sizeof(buf), fp, &linenum) != NULL)
    {
       enlist( bl->patterns, buf );
 
@@ -1057,4 +1062,4 @@ int run_loader(struct client_state *csp)
   Local Variables:
   tab-width: 3
   end:
-*/
\ No newline at end of file
+*/