Hard tabs->Spaces
[privoxy.git] / loadcfg.c
index 185241b..ae33439 100644 (file)
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -1,4 +1,4 @@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.2 2001/05/17 23:01:01 oes Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.4 2001/05/22 18:46:04 oes Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@ -35,6 +35,63 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.2 2001/05/17 23:01:01 oes Exp $";
  *
  * Revisions   :
  *    $Log: loadcfg.c,v $
+ *    Revision 1.4  2001/05/22 18:46:04  oes
+ *
+ *    - Enabled filtering banners by size rather than URL
+ *      by adding patterns that replace all standard banner
+ *      sizes with the "Junkbuster" gif to the re_filterfile
+ *
+ *    - Enabled filtering WebBugs by providing a pattern
+ *      which kills all 1x1 images
+ *
+ *    - Added support for PCRE_UNGREEDY behaviour to pcrs,
+ *      which is selected by the (nonstandard and therefore
+ *      capital) letter 'U' in the option string.
+ *      It causes the quantifiers to be ungreedy by default.
+ *      Appending a ? turns back to greedy (!).
+ *
+ *    - Added a new interceptor ijb-send-banner, which
+ *      sends back the "Junkbuster" gif. Without imagelist or
+ *      MSIE detection support, or if tinygif = 1, or the
+ *      URL isn't recognized as an imageurl, a lame HTML
+ *      explanation is sent instead.
+ *
+ *    - Added new feature, which permits blocking remote
+ *      script redirects and firing back a local redirect
+ *      to the browser.
+ *      The feature is conditionally compiled, i.e. it
+ *      can be disabled with --disable-fast-redirects,
+ *      plus it must be activated by a "fast-redirects"
+ *      line in the config file, has its own log level
+ *      and of course wants to be displayed by show-proxy-args
+ *      Note: Boy, all the #ifdefs in 1001 locations and
+ *      all the fumbling with configure.in and acconfig.h
+ *      were *way* more work than the feature itself :-(
+ *
+ *    - Because a generic redirect template was needed for
+ *      this, tinygif = 3 now uses the same.
+ *
+ *    - Moved GIFs, and other static HTTP response templates
+ *      to project.h
+ *
+ *    - Some minor fixes
+ *
+ *    - Removed some >400 CRs again (Jon, you really worked
+ *      a lot! ;-)
+ *
+ *    Revision 1.3  2001/05/20 01:21:20  jongfoster
+ *    Version 2.9.4 checkin.
+ *    - Merged popupfile and cookiefile, and added control over PCRS
+ *      filtering, in new "permissionsfile".
+ *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
+ *      file error you now get a message box (in the Win32 GUI) rather
+ *      than the program exiting with no explanation.
+ *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
+ *      skipping.
+ *    - Removed tabs from "config"
+ *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
+ *    - Bumped up version number.
+ *
  *    Revision 1.2  2001/05/17 23:01:01  oes
  *     - Cleaned CRLF's from the sources and related files
  *
@@ -143,16 +200,20 @@ const char *aclfile     = NULL;
 #ifdef USE_IMAGE_LIST
 const char *imagefile   = NULL;
 #endif /* def USE_IMAGE_LIST */
-\r
-/*\r
- * Permissions to use for URLs not in the permissions list.\r
+
+/*
+ * Permissions to use for URLs not in the permissions list.
  */
-int default_permissions = PERMIT_RE_FILTER;\r
+int default_permissions = PERMIT_RE_FILTER;
 
 #ifdef PCRS
 const char *re_filterfile = NULL;
 #endif /* def PCRS */
 
+#ifdef FAST_REDIRECTS
+int fast_redirects = 0;
+#endif /* def FAST_REDIRECTS */
+
 #ifdef TRUST_FILES
 const char *trustfile   = NULL;
 #endif /* def TRUST_FILES */
@@ -212,7 +273,7 @@ const char **Argv = NULL;
  * something a little more readable.  This also makes changing the
  * hash values easier if they should change or the hash algorthm changes.
  * Use the included "hash" program to find out what the hash will be
- * for any string supplied on the command line.  (Or just put it in the\r
+ * for any string supplied on the command line.  (Or just put it in the
  * config file and read the number from the error message in the log).
  */
 
@@ -225,7 +286,7 @@ const char **Argv = NULL;
 #define hash_suppress_vanilla_wafer    3121233547ul
 #define hash_wafer                     89669ul
 #define hash_add_header                237434619ul
-#define hash_permissions_file          3825730796lu /* "permissionsfile" */\r
+#define hash_permissions_file          3825730796lu /* "permissionsfile" */
 #define hash_logfile                   2114766ul
 #define hash_blockfile                 48845391ul
 #define hash_imagefile                 51447891ul
@@ -238,6 +299,7 @@ const char **Argv = NULL;
 #define hash_referrer                  10883969ul
 #define hash_referer                   2176719ul
 #define hash_from                      16264ul
+#define hash_fast_redirects            464873764lu
 #define hash_hide_console              2048809870ul
 #define hash_include_stats             2174146548ul
 #define hash_suppress_blocklists       1948693308ul
@@ -267,7 +329,7 @@ const char **Argv = NULL;
  * Returns     :  configret : 0 => Ok, everything else is an error.
  *                Note: we use configret since a signal handler cannot
  *                return a value, and this function does double duty.
- *                Ie. Is is called from main and from signal( SIGHUP );\r
+ *                Ie. Is is called from main and from signal( SIGHUP );
  *
  *********************************************************************/
 void load_config( int signum )
@@ -309,8 +371,8 @@ void load_config( int signum )
 #endif /* def JAR_FILES */
 
    debug             = 0;
-   multi_threaded    = 1;\r
-\r
+   multi_threaded    = 1;
+
    default_permissions = PERMIT_RE_FILTER;
 
 #if defined(DETECT_MSIE_IMAGES) || defined(USE_IMAGE_LIST)
@@ -374,13 +436,17 @@ void load_config( int signum )
    freez((char *)re_filterfile);
 #endif /* def PCRS */
 
+#ifdef FAST_REDIRECTS
+   fast_redirects = 0;
+#endif /* def FAST_REDIRECTS */
+
    if (NULL != configfile)
    {
       if ((configfp = fopen(configfile, "r")) == NULL)
       {
          log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s':  %E",
                  configfile);
-         /* Never get here - LOG_LEVEL_FATAL causes program exit */\r
+         /* Never get here - LOG_LEVEL_FATAL causes program exit */
       }
    }
 
@@ -577,6 +643,12 @@ void load_config( int signum )
                from = strdup(arg);
                continue;
 
+#ifdef FAST_REDIRECTS
+            case hash_fast_redirects :
+               fast_redirects = 1;
+               continue;
+#endif /* def FAST_REDIRECTS */
+
 #ifdef _WIN_CONSOLE
             case hash_hide_console :
                hideConsole = 1;
@@ -689,11 +761,11 @@ void load_config( int signum )
                continue;
 
             default :
-               /*\r
-                * I decided that I liked this better as a warning than an\r
-                * error.  To change back to an error, just change log level\r
-                * to LOG_LEVEL_FATAL.\r
-                */\r
+               /*
+                * I decided that I liked this better as a warning than an
+                * error.  To change back to an error, just change log level
+                * to LOG_LEVEL_FATAL.
+                */
                log_error(LOG_LEVEL_ERROR, "Unrecognized directive (%lulu) in "
                      "configuration file: \"%s\"", hash_string( cmd ), buf);
                p = malloc( BUFSIZ );
@@ -786,7 +858,7 @@ void load_config( int signum )
       {
          *--p = ':';
          log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", haddr);
-         /* Never get here - LOG_LEVEL_FATAL causes program exit */\r
+         /* Never get here - LOG_LEVEL_FATAL causes program exit */
       }
       if (*haddr == '\0')
       {
@@ -796,8 +868,8 @@ void load_config( int signum )
 
    if (run_loader(NULL))
    {
-      log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");\r
-      /* Never get here - LOG_LEVEL_FATAL causes program exit */\r
+      log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
+      /* Never get here - LOG_LEVEL_FATAL causes program exit */
    }
 
 #ifdef JAR_FILES