[tor-commits] [tor/master] Extract the enumeration that tells Tor what command it is running.

nickm at torproject.org nickm at torproject.org
Thu Oct 17 16:01:55 UTC 2019


commit c42a79499afe45304b9dcdd63357c851f9a6d115
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Oct 8 10:41:49 2019 -0400

    Extract the enumeration that tells Tor what command it is running.
---
 src/app/config/or_options_st.h    |  8 ++------
 src/app/config/tor_cmdline_mode.h | 32 ++++++++++++++++++++++++++++++++
 src/core/include.am               |  1 +
 3 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 32dcd9fb1..21ddbb18b 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -15,6 +15,7 @@
 
 #include "lib/cc/torint.h"
 #include "lib/net/address.h"
+#include "app/config/tor_cmdline_mode.h"
 
 struct smartlist_t;
 struct config_line_t;
@@ -31,12 +32,7 @@ struct or_options_t {
   uint32_t magic_;
 
   /** What should the tor process actually do? */
-  enum {
-    CMD_RUN_TOR=0, CMD_LIST_FINGERPRINT, CMD_HASH_PASSWORD,
-    CMD_VERIFY_CONFIG, CMD_RUN_UNITTESTS, CMD_DUMP_CONFIG,
-    CMD_KEYGEN,
-    CMD_KEY_EXPIRATION,
-  } command;
+  tor_cmdline_mode_t command;
   char *command_arg; /**< Argument for command-line option. */
 
   struct config_line_t *Logs; /**< New-style list of configuration lines
diff --git a/src/app/config/tor_cmdline_mode.h b/src/app/config/tor_cmdline_mode.h
new file mode 100644
index 000000000..9bc9a68d5
--- /dev/null
+++ b/src/app/config/tor_cmdline_mode.h
@@ -0,0 +1,32 @@
+/* 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 tor_cmdline_mode.h
+ * \brief Declare the tor_cmdline_mode_t enumeration
+ **/
+
+#ifndef TOR_CMDLINE_MODE_H
+#define TOR_CMDLINE_MODE_H
+
+/**
+ * Enumeration to describe which command Tor is running.  These commands
+ * are controlled by command-line options.
+ **/
+typedef enum tor_cmdline_mode_t {
+  CMD_RUN_TOR=0, /**< The default: run Tor as a daemon. */
+  CMD_LIST_FINGERPRINT, /**< Running --list-fingerprint. */
+  CMD_HASH_PASSWORD, /**< Running --hash-password. */
+  CMD_VERIFY_CONFIG, /**< Running --verify-config. */
+  CMD_DUMP_CONFIG, /**< Running --dump-config. */
+  CMD_KEYGEN, /**< Running --keygen */
+  CMD_KEY_EXPIRATION, /**< Running --key-expiration */
+  CMD_RUN_UNITTESTS, /**< Special value: indicates that we have entered
+                      * the Tor code from the unit tests, not from the
+                      * regular Tor binary at all. */
+} tor_cmdline_mode_t;
+
+#endif /* !defined(TOR_CMDLINE_MODE_H) */
diff --git a/src/core/include.am b/src/core/include.am
index 9b4b251c8..64004da34 100644
--- a/src/core/include.am
+++ b/src/core/include.am
@@ -216,6 +216,7 @@ noinst_HEADERS +=					\
 	src/app/config/or_options_st.h			\
 	src/app/config/or_state_st.h			\
 	src/app/config/statefile.h			\
+	src/app/config/tor_cmdline_mode.h		\
 	src/app/main/main.h				\
 	src/app/main/ntmain.h				\
 	src/app/main/shutdown.h 			\





More information about the tor-commits mailing list