aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-08-25 12:49:16 -0400
committerNick Mathewson <nickm@torproject.org>2013-09-13 12:36:39 -0400
commit34ec954f8ef8201fd16942acca55ac19db8ff7b7 (patch)
treee55303f6c61dfaa3c918e0b9cfe57181eb8c839c /src/or/main.c
parentd98dfb3746790448b0dcff2aa9a00e5e2602688a (diff)
downloadtor-34ec954f8ef8201fd16942acca55ac19db8ff7b7.tar
tor-34ec954f8ef8201fd16942acca55ac19db8ff7b7.tar.gz
Expose commandline parser so that we can use it for --quiet,etc.
Fix for bug 9578.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 33e1c6437..e816a6667 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -21,6 +21,7 @@
#include "circuituse.h"
#include "command.h"
#include "config.h"
+#include "confparse.h"
#include "connection.h"
#include "connection_edge.h"
#include "connection_or.h"
@@ -2320,7 +2321,7 @@ int
tor_init(int argc, char *argv[])
{
char buf[256];
- int i, quiet = 0;
+ int quiet = 0;
time_of_process_start = time(NULL);
init_connection_lists();
/* Have the log set up with our application name. */
@@ -2333,17 +2334,25 @@ tor_init(int argc, char *argv[])
addressmap_init(); /* Init the client dns cache. Do it always, since it's
* cheap. */
+ {
/* We search for the "quiet" option first, since it decides whether we
* will log anything at all to the command line. */
- for (i=1;i<argc;++i) {
- if (!strcmp(argv[i], "--hush"))
- quiet = 1;
- if (!strcmp(argv[i], "--quiet"))
- quiet = 2;
- /* --version implies --quiet */
- if (!strcmp(argv[i], "--version"))
- quiet = 2;
+ config_line_t *opts = NULL, *cmdline_opts = NULL;
+ const config_line_t *cl;
+ (void) config_parse_commandline(argc, argv, 1, &opts, &cmdline_opts);
+ for (cl = cmdline_opts; cl; cl = cl->next) {
+ if (!strcmp(cl->key, "--hush"))
+ quiet = 1;
+ if (!strcmp(cl->key, "--quiet"))
+ quiet = 2;
+ /* --version implies --quiet */
+ if (!strcmp(cl->key, "--version"))
+ quiet = 2;
+ }
+ config_free_lines(opts);
+ config_free_lines(cmdline_opts);
}
+
/* give it somewhere to log to initially */
switch (quiet) {
case 2: