{ .name="--hash-password",
.takes_argument=ARGUMENT_NECESSARY,
.command=CMD_HASH_PASSWORD,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--dump-config",
.takes_argument=ARGUMENT_OPTIONAL,
.command=CMD_DUMP_CONFIG,
- .quiet=2 },
+ .quiet=QUIET_SILENT },
{ .name="--list-fingerprint",
.command=CMD_LIST_FINGERPRINT },
{ .name="--keygen",
.command=CMD_VERIFY_CONFIG },
{ .name="--ignore-missing-torrc" },
{ .name="--quiet",
- .quiet=2 },
+ .quiet=QUIET_SILENT },
{ .name="--hush",
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--version",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--list-modules",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--library-versions",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="-h",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--help",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--list-torrc-options",
.command=CMD_IMMEDIATE,
- .quiet=1 },
+ .quiet=QUIET_HUSH },
{ .name="--list-deprecated-options",
.command=CMD_IMMEDIATE },
{ .name="--nt-service" },
is_a_command = true;
result->command = CMDLINE_ONLY_OPTIONS[j].command;
}
- int quiet = CMDLINE_ONLY_OPTIONS[j].quiet;
+ quiet_level_t quiet = CMDLINE_ONLY_OPTIONS[j].quiet;
if (quiet > result->quiet_level)
result->quiet_level = quiet;
break;
#include "app/config/or_options_st.h"
#include "lib/testsupport/testsupport.h"
+#include "app/config/quiet_level.h"
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(DARWIN)
#define KERNEL_MAY_SUPPORT_IPFW
tor_cmdline_mode_t command;
/** Argument for the command mode, if any. */
const char *command_arg;
- /** How quiet have we been told to be? 1 for "hush", and 2 for "quiet".
- */
- int quiet_level;
+ /** How quiet have we been told to be? */
+ quiet_level_t quiet_level;
} parsed_cmdline_t;
parsed_cmdline_t *config_parse_commandline(int argc, char **argv,
--- /dev/null
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file quiet_level.h
+ * \brief Declare the quiet_level enumeration and global.
+ **/
+
+#ifndef QUIET_LEVEL_H
+#define QUIET_LEVEL_H
+
+/** Enumeration to define how quietly Tor should log at startup. */
+typedef enum {
+ /** Default quiet level: we log everything of level NOTICE or higher. */
+ QUIET_NONE = 0,
+ /** "--hush" quiet level: we log everything of level WARNING or higher. */
+ QUIET_HUSH = 1 ,
+ /** "--quiet" quiet level: we log nothing at all. */
+ QUIET_SILENT = 2
+} quiet_level_t;
+
+/** How quietly should Tor log at startup? */
+extern quiet_level_t quiet_level;
+
+#endif /* !defined(QUIET_LEVEL_H) */
#include "app/config/config.h"
#include "app/config/statefile.h"
+#include "app/config/quiet_level.h"
#include "app/main/main.h"
#include "app/main/ntmain.h"
#include "app/main/shutdown.h"
/********* START VARIABLES **********/
-/** Decides our behavior when no logs are configured/before any
- * logs have been configured. For 0, we log notice to stdout as normal.
- * For 1, we log warnings only. For 2, we log nothing.
+/** Decides our behavior when no logs are configured/before any logs have been
+ * configured. For QUIET_NONE, we log notice to stdout as normal. For
+ * QUIET_HUSH, we log warnings only. For QUIET_SILENT, we log nothing.
*/
-int quiet_level = 0;
+quiet_level_t quiet_level = 0;
/********* END VARIABLES ************/
tor_init(int argc, char *argv[])
{
char progname[256];
- int quiet = 0;
+ quiet_level_t quiet = QUIET_NONE;
time_of_process_start = time(NULL);
tor_init_connection_lists();
/* give it somewhere to log to initially */
switch (quiet) {
- case 2:
+ case QUIET_SILENT:
/* --quiet: no initial logging */
break;
- case 1:
+ case QUIET_HUSH:
/* --hush: log at warning or higher. */
add_temp_log(LOG_WARN);
break;
+ case QUIET_NONE: /* fall through */
default:
add_temp_log(LOG_NOTICE);
}
result = 0;
break;
case CMD_VERIFY_CONFIG:
- if (quiet_level == 0)
+ if (quiet_level == QUIET_NONE)
printf("Configuration was valid\n");
result = 0;
break;
src/app/config/config.h \
src/app/config/or_options_st.h \
src/app/config/or_state_st.h \
+ src/app/config/quiet_level.h \
src/app/config/statefile.h \
src/app/config/tor_cmdline_mode.h \
src/app/main/main.h \
struct token_bucket_rw_t;
extern time_t time_of_process_start;
-extern int quiet_level;
extern struct token_bucket_rw_t global_bucket;
extern struct token_bucket_rw_t global_relayed_bucket;