From c42a79499afe45304b9dcdd63357c851f9a6d115 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 8 Oct 2019 10:41:49 -0400 Subject: [PATCH] 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(-) create mode 100644 src/app/config/tor_cmdline_mode.h diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h index 32dcd9fb18..21ddbb18b6 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 0000000000..9bc9a68d56 --- /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 9b4b251c81..64004da342 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 \