Fixed minor memory leak.
[privoxy.git] / loadcfg.c
index f788df2..d92dfa1 100644 (file)
--- a/loadcfg.c
+++ b/loadcfg.c
@@ -1,4 +1,4 @@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.7 2001/05/29 09:50:24 jongfoster Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.12 2001/06/05 20:04:09 jongfoster Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@ -35,6 +35,80 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.7 2001/05/29 09:50:24 jongfoster
  *
  * Revisions   :
  *    $Log: loadcfg.c,v $
+ *    Revision 1.12  2001/06/05 20:04:09  jongfoster
+ *    Now uses _snprintf() in place of snprintf() under Win32.
+ *
+ *    Revision 1.11  2001/06/04 18:31:58  swa
+ *    files are now prefixed with either `confdir' or `logdir'.
+ *    `make redhat-dist' replaces both entries confdir and logdir
+ *    with redhat values
+ *
+ *    Revision 1.10  2001/06/03 19:11:54  oes
+ *    introduced confdir option
+ *
+ *    Revision 1.10  2001/06/03 11:03:48  oes
+ *    Makefile/in
+ *
+ *    introduced cgi.c
+ *
+ *    actions.c:
+ *
+ *    adapted to new enlist_unique arg format
+ *
+ *    conf loadcfg.c
+ *
+ *    introduced confdir option
+ *
+ *    filters.c filtrers.h
+ *
+ *     extracted-CGI relevant stuff
+ *
+ *    jbsockets.c
+ *
+ *     filled comment
+ *
+ *    jcc.c
+ *
+ *     support for new cgi mechansim
+ *
+ *    list.c list.h
+ *
+ *    functions for new list type: "map"
+ *    extended enlist_unique
+ *
+ *    miscutil.c .h
+ *    introduced bindup()
+ *
+ *    parsers.c parsers.h
+ *
+ *    deleted const struct interceptors
+ *
+ *    pcrs.c
+ *    added FIXME
+ *
+ *    project.h
+ *
+ *    added struct map
+ *    added struct http_response
+ *    changes struct interceptors to struct cgi_dispatcher
+ *    moved HTML stuff to cgi.h
+ *
+ *    re_filterfile:
+ *
+ *    changed
+ *
+ *    showargs.c
+ *    NO TIME LEFT
+ *
+ *    Revision 1.9  2001/06/01 20:06:24  jongfoster
+ *    Removed support for "tinygif" option - moved to actions file.
+ *
+ *    Revision 1.8  2001/05/31 21:27:13  jongfoster
+ *    Removed many options from the config file and into the
+ *    "actions" file: add_forwarded, suppress_vanilla_wafer,
+ *    wafer, add_header, user_agent, referer, from
+ *    Also globally replaced "permission" with "action".
+ *
  *    Revision 1.7  2001/05/29 09:50:24  jongfoster
  *    Unified blocklist/imagelist/permissionslist.
  *    File format is still under discussion, but the internal changes
@@ -161,6 +235,9 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.7 2001/05/29 09:50:24 jongfoster
 #  include "w32log.h"
 # endif /* ndef _WIN_CONSOLE */
 
+/* VC++ has "_snprintf", not "snprintf" */
+#define snprintf _snprintf
+
 #else /* ifndef _WIN32 */
 
 # include <unistd.h>
@@ -229,6 +306,8 @@ static struct file_list *current_configfile = NULL;
 #define hash_aclfile                      1908516ul
 #define hash_actions_file              3825730796ul /* FIXME "permissionsfile" */
 #define hash_debug                          78263ul
+#define hash_confdir                      1978389lu
+#define hash_logdir                        422889lu
 #define hash_forwardfile               1268669141ul
 #define hash_jarfile                      2046641ul
 #define hash_listen_address            1255650842ul
@@ -236,7 +315,6 @@ static struct file_list *current_configfile = NULL;
 #define hash_re_filterfile             3877522444ul
 #define hash_single_threaded           4250084780ul
 #define hash_suppress_blocklists       1948693308ul
-#define hash_tinygif                      2227702ul /* FIXME should be in actions file */
 #define hash_toggle                        447966ul
 #define hash_trust_info_url             449869467ul
 #define hash_trustfile                   56494766ul
@@ -254,7 +332,6 @@ static struct file_list *current_configfile = NULL;
 #define hash_show_on_task_bar           215410365ul
 
 
-
 /*********************************************************************
  *
  * Function    :  unload_configfile
@@ -278,9 +355,9 @@ void unload_configfile (void * data)
       config->jar = NULL;
    }
 #endif /* def JAR_FILES */
-#ifdef IMAGE_BLOCKING
-   freez((char *)config->tinygifurl);
-#endif /* def IMAGE_BLOCKING */
+
+   freez((char *)config->confdir);
+   freez((char *)config->logdir);
 
    freez((char *)config->haddr);
    freez((char *)config->logfile);
@@ -327,7 +404,6 @@ struct configuration_spec * load_config(void)
    FILE *configfp = NULL;
    struct configuration_spec * config = NULL;
    struct client_state * fake_csp;
-
    struct file_list *fs;
 
    if (!check_file_changed(current_configfile, configfile, &fs))
@@ -434,7 +510,7 @@ struct configuration_spec * load_config(void)
 #ifdef TRUST_FILES
          case hash_trustfile :
             freez((char *)config->trustfile);
-            config->trustfile = strdup(arg);
+            config->trustfile = make_path(config->confdir, arg);
             continue;
 
          case hash_trust_info_url :
@@ -446,40 +522,15 @@ struct configuration_spec * load_config(void)
             config->debug |= atoi(arg);
             continue;
 
-#ifdef IMAGE_BLOCKING
-         case hash_tinygif :
-            freez((char *)config->tinygifurl);
-            config->tinygif = atoi(arg);
-            if(3 == config->tinygif)
-            {
-               p = arg;
-               while((*p >= '0') && (*p <= '9'))
-               {
-                  p++;
-               }
-               while((*p == ' ') || (*p == '\t'))
-               {
-                  p++;
-               }
-               if (*p)
-               {
-                  q = malloc(strlen(p) + 5);
-                  if (q)
-                  {
-                     strcpy(q, p);
-                     strcat(q, "\r\n\r\n");
-                     config->tinygifurl = q;
-                  }
-               }
-            }
-            if ((config->tinygif != 1) && 
-                (config->tinygif != 2) && 
-                ((config->tinygif != 3) || (config->tinygifurl==NULL)) )
-            {
-               log_error(LOG_LEVEL_ERROR, "tinygif setting invalid.");
-            }
-            continue;
-#endif /* def IMAGE_BLOCKING */
+         case hash_confdir :
+            freez((char *)config->confdir);
+            config->confdir = strdup(arg);
+            continue;            
+
+         case hash_logdir :
+            freez((char *)config->logdir);
+            config->logdir = strdup(arg);
+            continue;            
 
          case hash_single_threaded :
             config->multi_threaded = 0;
@@ -487,18 +538,18 @@ struct configuration_spec * load_config(void)
 
          case hash_actions_file :
             freez((char *)config->actions_file);
-            config->actions_file = strdup(arg);
+            config->actions_file = make_path(config->confdir, arg);
             continue;
 
          case hash_logfile :
             freez((char *)config->logfile);
-            config->logfile = strdup(arg);
+            config->logfile = make_path(config->logdir, arg);
             continue;
 
 #ifdef JAR_FILES
          case hash_jarfile :
             freez((char *)config->jarfile);
-            config->jarfile = strdup(arg);
+            config->jarfile = make_path(config->logdir, arg);
             continue;
 #endif /* def JAR_FILES */
 
@@ -509,13 +560,13 @@ struct configuration_spec * load_config(void)
 
          case hash_forwardfile :
             freez((char *)config->forwardfile);
-            config->forwardfile = strdup(arg);
+            config->forwardfile = make_path(config->confdir, arg);
             continue;
 
 #ifdef ACL_FILES
          case hash_aclfile :
             freez((char *)config->aclfile);
-            config->aclfile = strdup(arg);
+            config->aclfile = make_path(config->confdir, arg);
             continue;
 #endif /* def ACL_FILES */
 
@@ -614,9 +665,6 @@ struct configuration_spec * load_config(void)
 #ifndef _WIN_CONSOLE
          case hash_hide_console :
 #endif /* ndef _WIN_CONSOLE */
-#ifndef IMAGE_BLOCKING
-         case hash_tinygif :
-#endif /* def IMAGE_BLOCKING */
 #ifndef JAR_FILES
          case hash_jarfile :
 #endif /* ndef JAR_FILES */
@@ -739,8 +787,6 @@ struct configuration_spec * load_config(void)
    }
    freez(fake_csp);
 
-   end_proxy_args(config);
-
 #ifndef SPLIT_PROXY_ARGS
    if (!suppress_blocklists)
    {