aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.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/config.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/config.c')
-rw-r--r--src/or/config.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/or/config.c b/src/or/config.c
index de9c5eee1..c1bbf7896 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1792,12 +1792,14 @@ options_act(const or_options_t *old_options)
}
/** Helper: Read a list of configuration options from the command line. If
- * successful, put them in *<b>result</b>, put the commandline-only options in
- * *<b>cmdline_result</b>, and return 0; otherwise, return -1 and leave
- * *<b>result</b> and <b>cmdline_result</b> alone. */
-static int
-config_get_commandlines(int argc, char **argv, config_line_t **result,
- config_line_t **cmdline_result)
+ * successful, or if ignore_errors is set, put them in *<b>result</b>, put the
+ * commandline-only options in *<b>cmdline_result</b>, and return 0;
+ * otherwise, return -1 and leave *<b>result</b> and <b>cmdline_result</b>
+ * alone. */
+int
+config_parse_commandline(int argc, char **argv, int ignore_errors,
+ config_line_t **result,
+ config_line_t **cmdline_result)
{
config_line_t *param = NULL;
@@ -1823,7 +1825,8 @@ config_get_commandlines(int argc, char **argv, config_line_t **result,
!strcmp(argv[i],"--verify-config") ||
!strcmp(argv[i],"--ignore-missing-torrc") ||
!strcmp(argv[i],"--quiet") ||
- !strcmp(argv[i],"--hush")) {
+ !strcmp(argv[i],"--hush") ||
+ !strcmp(argv[1],"--version")) {
is_cmdline = 1;
want_arg = 0;
} else if (!strcmp(argv[i],"--nt-service") ||
@@ -1851,7 +1854,7 @@ config_get_commandlines(int argc, char **argv, config_line_t **result,
}
if (want_arg && i == argc-1) {
- if (!strcmp(argv[i],"--hash-password")) {
+ if (!strcmp(argv[i],"--hash-password") || ignore_errors) {
arg = strdup("");
} else {
log_warn(LD_CONFIG,"Command-line option '%s' with no value. Failing.",
@@ -3852,8 +3855,8 @@ options_init_from_torrc(int argc, char **argv)
if (!global_cmdline_options) {
/* Or we could redo the list every time we pass this place.
* It does not really matter */
- if (config_get_commandlines(argc, argv, &global_cmdline_options,
- &cmdline_only_options) < 0) {
+ if (config_parse_commandline(argc, argv, 0, &global_cmdline_options,
+ &cmdline_only_options) < 0) {
goto err;
}
}