[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] if you give a config option in the torrc or the commandline...



Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	config.c 
Log Message:
if you give a config option in the torrc or the commandline with no
value, and reset is false, then it clears it entirely.


Index: config.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.406
retrieving revision 1.407
diff -u -d -r1.406 -r1.407
--- config.c	8 Sep 2005 06:37:50 -0000	1.406
+++ config.c	8 Sep 2005 06:55:53 -0000	1.407
@@ -770,8 +770,11 @@
     c->key = tor_strdup(var->name);
   }
 
-  if (reset && !strlen(c->value)) {
-    option_reset(fmt, options, var);
+  if (!strlen(c->value)) { /* reset or clear it, then return */
+    if (reset)
+      option_reset(fmt, options, var);
+    else
+      option_clear(fmt, options, var);
     return 0;
   }
 
@@ -1012,8 +1015,10 @@
  *
  * If <b>reset</b>, then interpret empty lines as meaning "restore to
  * default value", and interpret LINELIST* options as replacing (not
- * extending) their previous values.  Return 0 on success, -1 on bad key,
- * -2 on bad value.
+ * extending) their previous values. Otherwise, interpret empty lines
+ * as meaning "make the value 0 or null".
+ *
+ * Return 0 on success, -1 on bad key, -2 on bad value.
  */
 static int
 config_assign(config_format_t *fmt,
@@ -1080,17 +1085,12 @@
   return 0;
 }
 
-/** Replace the option indexed by <b>var</b> in <b>options</b> with its
- * default value. */
+/** Reset config option <b>var</b> to 0, 0.0, "", or the equivalent. */
 static void
-option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
+option_clear(config_format_t *fmt, or_options_t *options, config_var_t *var)
 {
   config_line_t *c;
-  void *lvalue;
-
-  CHECK(fmt, options);
-
-  lvalue = ((char*)options) + var->var_offset;
+  void *lvalue = ((char*)options) + var->var_offset;
   switch (var->type) {
     case CONFIG_TYPE_STRING:
       tor_free(*(char**)lvalue);
@@ -1126,6 +1126,17 @@
     case CONFIG_TYPE_OBSOLETE:
       break;
   }
+
+/** Replace the option indexed by <b>var</b> in <b>options</b> with its
+ * default value. */
+static void
+option_reset(config_format_t *fmt, or_options_t *options, config_var_t *var)
+{
+  config_line_t *c;
+  void *lvalue;
+  CHECK(fmt, options);
+  option_clear(fmt, options, var); /* clear it first */
+  lvalue = ((char*)options) + var->var_offset;
   if (var->initvalue) {
     c = tor_malloc_zero(sizeof(config_line_t));
     c->key = tor_strdup(var->name);