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

[or-cvs] Do not reverse command-line configuration options; Use new ...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv4300/src/or

Modified Files:
	config.c or.h 
Log Message:
Do not reverse command-line configuration options; Use new minimal-listener-close code; Add code to canonicalize configuration names.

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.365
retrieving revision 1.366
diff -u -d -r1.365 -r1.366
--- config.c	20 Jun 2005 18:56:34 -0000	1.365
+++ config.c	11 Jul 2005 17:35:36 -0000	1.366
@@ -389,7 +389,7 @@
   if (accounting_is_enabled(options))
     configure_accounting(time(NULL));
 
-  if (!we_are_hibernating() && retry_all_listeners(1) < 0) {
+  if (!we_are_hibernating() && retry_all_listeners(0) < 0) {
     log_fn(LOG_ERR,"Failed to bind one of the listener ports.");
     return -1;
   }
@@ -429,8 +429,8 @@
 static struct config_line_t *
 config_get_commandlines(int argc, char **argv)
 {
-  struct config_line_t *new;
   struct config_line_t *front = NULL;
+  struct config_line_t **new = &front;
   char *s;
   int i = 1;
 
@@ -447,19 +447,19 @@
       continue;
     }
 
-    new = tor_malloc(sizeof(struct config_line_t));
+    *new = tor_malloc_zero(sizeof(struct config_line_t));
     s = argv[i];
 
     while (*s == '-')
       s++;
 
-    new->key = tor_strdup(expand_abbrev(s, 1));
-    new->value = tor_strdup(argv[i+1]);
-
+    (*new)->key = tor_strdup(expand_abbrev(s, 1));
+    (*new)->value = tor_strdup(argv[i+1]);
+    (*new)->next = NULL;
     log(LOG_DEBUG,"Commandline: parsed keyword '%s', value '%s'",
-        new->key, new->value);
-    new->next = front;
-    front = new;
+        (*new)->key, (*new)->value);
+
+    new = &((*new)->next);
     i += 2;
   }
   return front;
@@ -694,6 +694,14 @@
   return (var != NULL);
 }
 
+/** Return the canonical name of a configuration option. */
+const char *
+config_option_get_canonical_name(const char *key)
+{
+  config_var_t *var = config_find_option(key);
+  return var->name;
+}
+
 /** Return a canonicalized list of the options assigned for key.
  */
 struct config_line_t *

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.622
retrieving revision 1.623
diff -u -d -r1.622 -r1.623
--- or.h	29 Jun 2005 21:46:55 -0000	1.622
+++ or.h	11 Jul 2005 17:35:36 -0000	1.623
@@ -1337,6 +1337,7 @@
 void config_append_default_exit_policy(addr_policy_t **policy);
 void addr_policy_free(addr_policy_t *p);
 int config_option_is_recognized(const char *key);
+const char *config_option_get_canonical_name(const char *key);
 struct config_line_t *config_get_assigned_option(or_options_t *options,
                                                  const char *key);
 char *config_dump_options(or_options_t *options, int minimal);