Extract the enumeration that tells Tor what command it is running.

This commit is contained in:
Nick Mathewson 2019-10-08 10:41:49 -04:00
parent 7a26f14a37
commit c42a79499a
3 changed files with 35 additions and 6 deletions

View File

@ -15,6 +15,7 @@
#include "lib/cc/torint.h" #include "lib/cc/torint.h"
#include "lib/net/address.h" #include "lib/net/address.h"
#include "app/config/tor_cmdline_mode.h"
struct smartlist_t; struct smartlist_t;
struct config_line_t; struct config_line_t;
@ -31,12 +32,7 @@ struct or_options_t {
uint32_t magic_; uint32_t magic_;
/** What should the tor process actually do? */ /** What should the tor process actually do? */
enum { tor_cmdline_mode_t command;
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;
char *command_arg; /**< Argument for command-line option. */ char *command_arg; /**< Argument for command-line option. */
struct config_line_t *Logs; /**< New-style list of configuration lines struct config_line_t *Logs; /**< New-style list of configuration lines

View File

@ -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) */

View File

@ -216,6 +216,7 @@ noinst_HEADERS += \
src/app/config/or_options_st.h \ src/app/config/or_options_st.h \
src/app/config/or_state_st.h \ src/app/config/or_state_st.h \
src/app/config/statefile.h \ src/app/config/statefile.h \
src/app/config/tor_cmdline_mode.h \
src/app/main/main.h \ src/app/main/main.h \
src/app/main/ntmain.h \ src/app/main/ntmain.h \
src/app/main/shutdown.h \ src/app/main/shutdown.h \