new version.
[privoxy.git] / loaders.c
index cf4e59f..d800ed8 100644 (file)
--- a/loaders.c
+++ b/loaders.c
@@ -1,4 +1,4 @@
-const char loaders_rcs[] = "$Id: loaders.c,v 1.23 2001/07/20 15:51:54 oes Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.27 2001/09/22 16:36:59 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loaders.c,v $
@@ -35,6 +35,23 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.23 2001/07/20 15:51:54 oes Exp $"
  *
  * Revisions   :
  *    $Log: loaders.c,v $
+ *    Revision 1.27  2001/09/22 16:36:59  jongfoster
+ *    Removing unused parameter fs from read_config_line()
+ *
+ *    Revision 1.26  2001/09/22 14:05:22  jongfoster
+ *    Bugfix: Multiple escaped "#" characters in a configuration
+ *    file are now permitted.
+ *    Also removing 3 unused headers.
+ *
+ *    Revision 1.25  2001/09/13 22:44:03  jongfoster
+ *    Adding {} to an if statement
+ *
+ *    Revision 1.24  2001/07/30 22:08:36  jongfoster
+ *    Tidying up #defines:
+ *    - All feature #defines are now of the form FEATURE_xxx
+ *    - Permanently turned off WIN_GUI_EDIT
+ *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
+ *
  *    Revision 1.23  2001/07/20 15:51:54  oes
  *    Fixed indentation of prepocessor commands
  *
@@ -175,14 +192,11 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.23 2001/07/20 15:51:54 oes Exp $"
 #include "project.h"
 #include "list.h"
 #include "loaders.h"
-#include "encode.h"
 #include "filters.h"
 #include "parsers.h"
 #include "jcc.h"
-#include "ssplit.h"
 #include "miscutil.h"
 #include "errlog.h"
-#include "gateway.h"
 #include "actions.h"
 
 const char loaders_h_rcs[] = LOADERS_H_VERSION;
@@ -247,7 +261,7 @@ void sweep(void)
 
    for (csp = clients; csp && (ncsp = csp->next) ; csp = csp->next)
    {
-      if (ncsp->active)
+      if (ncsp->flags & CSP_FLAG_ACTIVE)
       {
          /* mark this client's files as active */
 
@@ -283,7 +297,7 @@ void sweep(void)
        * follow it
        */
       {
-         while( !ncsp->active )
+         while (!(ncsp->flags & CSP_FLAG_ACTIVE))
          {
             csp->next = ncsp->next;
    
@@ -303,10 +317,10 @@ void sweep(void)
             destroy_list(ncsp->cookie_list);
    
             free_current_action(ncsp->action);
-   
+
 #ifdef FEATURE_STATISTICS
             urls_read++;
-            if (ncsp->rejected)
+            if (ncsp->flags & CSP_FLAG_REJECTED)
             {
                urls_rejected++;
             }
@@ -571,22 +585,21 @@ int check_file_changed(const struct file_list * current,
  * Description :  Read a single non-empty line from a file and return
  *                it.  Trims comments, leading and trailing whitespace
  *                and respects escaping of newline and comment char.
- *                Also writes 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 *read_config_line(char *buf, int buflen, FILE *fp)
 {
-   char *p, *q;
+   char *p;
+   char *src;
+   char *dest;
    char linebuf[BUFFER_SIZE];
    int contflag = 0;
 
@@ -612,13 +625,19 @@ char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs)
       }
 
       /* If there's a comment char.. */
-      if ((p = strpbrk(linebuf, "#")) != NULL)
+      p = linebuf;
+      while ((p = strchr(p, '#')) != NULL)
       {
          /* ..and it's escaped, left-shift the line over the escape. */
          if ((p != linebuf) && (*(p-1) == '\\'))
          {
-            q = p-1;
-            while ((*q++ = *p++) != '\0') /* nop */;
+            src = p;
+            dest = p - 1;
+            while ((*dest++ = *src++) != '\0')
+            {
+               /* nop */
+            }
+            /* Now scan from just after the "#". */
          }
          /* Else, chop off the rest of the line */
          else
@@ -637,7 +656,7 @@ char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs)
       if (contflag)
       {
          contflag = 0;
-               continue;
+         continue;
       }
 
       /* Remove leading and trailing whitespace */         
@@ -732,7 +751,7 @@ int load_trustfile(struct client_state *csp)
 
    tl = csp->config->trust_list;
 
-   while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
+   while (read_config_line(buf, sizeof(buf), fp) != NULL)
    {
       trusted = 0;
       reject  = 1;
@@ -835,7 +854,10 @@ static void unload_re_filterfile(void *f)
 {
    struct re_filterfile_spec *b = (struct re_filterfile_spec *)f;
 
-   if (b == NULL) return;
+   if (b == NULL)
+   {
+      return;
+   }
 
    destroy_list(b->patterns);
    pcrs_free_joblist(b->joblist);
@@ -896,7 +918,7 @@ int load_re_filterfile(struct client_state *csp)
    }
 
    /* Read line by line */
-   while (read_config_line(buf, sizeof(buf), fp, fs) != NULL)
+   while (read_config_line(buf, sizeof(buf), fp) != NULL)
    {
       enlist( bl->patterns, buf );