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

[or-cvs] r13941: options_init_from_torrc(): Split argv processing into two pa (tor/trunk/src/or)



Author: weasel
Date: 2008-03-10 08:41:26 -0400 (Mon, 10 Mar 2008)
New Revision: 13941

Modified:
   tor/trunk/src/or/config.c
Log:
options_init_from_torrc(): Split argv processing into two parts

Split the argv processing loop into two poarts, one that deals with
figuring out which conffile to use, and the other that figures out
which "command" (hash fingerprint, verify config, list fpr, run tor)
the user asked for.

There is a third part further down that imports command line args
into the config but that is not touched.


Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-03-10 12:39:48 UTC (rev 13940)
+++ tor/trunk/src/or/config.c	2008-03-10 12:41:26 UTC (rev 13941)
@@ -3569,12 +3569,24 @@
   newoptions = tor_malloc_zero(sizeof(or_options_t));
   newoptions->_magic = OR_OPTIONS_MAGIC;
   options_init(newoptions);
+  newoptions->command = CMD_RUN_TOR;
 
+  for (i = 1; i < argc; ++i) {
+    if (!strcmp(argv[i],"--list-fingerprint")) {
+      newoptions->command = CMD_LIST_FINGERPRINT;
+    } else if (!strcmp(argv[i],"--hash-password")) {
+      newoptions->command = CMD_HASH_PASSWORD;
+      newoptions->command_arg = tor_strdup( (i < argc-1) ? argv[i+1] : "");
+      ++i;
+    } else if (!strcmp(argv[i],"--verify-config")) {
+      newoptions->command = CMD_VERIFY_CONFIG;
+    }
+  }
+
   /* learn config file name */
   fname = NULL;
   using_default_torrc = 1;
   ignore_missing_torrc = 0;
-  newoptions->command = CMD_RUN_TOR;
   for (i = 1; i < argc; ++i) {
     if (i < argc-1 && !strcmp(argv[i],"-f")) {
       if (fname) {
@@ -3592,14 +3604,6 @@
       ++i;
     } else if (!strcmp(argv[i],"--ignore-missing-torrc")) {
       ignore_missing_torrc = 1;
-    } else if (!strcmp(argv[i],"--list-fingerprint")) {
-      newoptions->command = CMD_LIST_FINGERPRINT;
-    } else if (!strcmp(argv[i],"--hash-password")) {
-      newoptions->command = CMD_HASH_PASSWORD;
-      newoptions->command_arg = tor_strdup( (i < argc-1) ? argv[i+1] : "");
-      ++i;
-    } else if (!strcmp(argv[i],"--verify-config")) {
-      newoptions->command = CMD_VERIFY_CONFIG;
     }
   }
   if (using_default_torrc) {