mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Start moving types that will be used for config vars to lib/conf
This will be a lower-level module than anything that actually sets or handles configuration variables. Part of 30864.
This commit is contained in:
parent
81d16d8d0c
commit
246599abb4
@ -13,70 +13,7 @@
|
||||
#ifndef TOR_CONFPARSE_H
|
||||
#define TOR_CONFPARSE_H
|
||||
|
||||
/** Enumeration of types which option values can take */
|
||||
typedef enum config_type_t {
|
||||
CONFIG_TYPE_STRING = 0, /**< An arbitrary string. */
|
||||
CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
|
||||
CONFIG_TYPE_POSINT, /**< A non-negative integer less than MAX_INT */
|
||||
CONFIG_TYPE_INT, /**< Any integer. */
|
||||
CONFIG_TYPE_UINT64, /**< A value in range 0..UINT64_MAX */
|
||||
CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
|
||||
CONFIG_TYPE_MSEC_INTERVAL,/**< A number of milliseconds, with optional
|
||||
* units */
|
||||
CONFIG_TYPE_MEMUNIT, /**< A number of bytes, with optional units*/
|
||||
CONFIG_TYPE_DOUBLE, /**< A floating-point value */
|
||||
CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
|
||||
CONFIG_TYPE_AUTOBOOL, /**< A boolean+auto value, expressed 0 for false,
|
||||
* 1 for true, and -1 for auto */
|
||||
CONFIG_TYPE_ISOTIME, /**< An ISO-formatted time relative to UTC. */
|
||||
CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and
|
||||
* optional whitespace. */
|
||||
CONFIG_TYPE_CSV_INTERVAL, /**< A list of strings, separated by commas and
|
||||
* optional whitespace, representing intervals in
|
||||
* seconds, with optional units. We allow
|
||||
* multiple values here for legacy reasons, but
|
||||
* ignore every value after the first. */
|
||||
CONFIG_TYPE_LINELIST, /**< Uninterpreted config lines */
|
||||
CONFIG_TYPE_LINELIST_S, /**< Uninterpreted, context-sensitive config lines,
|
||||
* mixed with other keywords. */
|
||||
CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize
|
||||
* context-sensitive config lines when fetching.
|
||||
*/
|
||||
CONFIG_TYPE_ROUTERSET, /**< A list of router names, addrs, and fps,
|
||||
* parsed into a routerset_t. */
|
||||
CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */
|
||||
} config_type_t;
|
||||
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
/**
|
||||
* Union used when building in test mode typechecking the members of a type
|
||||
* used with confparse.c. See CONF_CHECK_VAR_TYPE for a description of how
|
||||
* it is used. */
|
||||
typedef union {
|
||||
char **STRING;
|
||||
char **FILENAME;
|
||||
int *POSINT; /* yes, really: Even though the confparse type is called
|
||||
* "POSINT", it still uses the C int type -- it just enforces that
|
||||
* the values are in range [0,INT_MAX].
|
||||
*/
|
||||
uint64_t *UINT64;
|
||||
int *INT;
|
||||
int *PORT;
|
||||
int *INTERVAL;
|
||||
int *MSEC_INTERVAL;
|
||||
uint64_t *MEMUNIT;
|
||||
double *DOUBLE;
|
||||
int *BOOL;
|
||||
int *AUTOBOOL;
|
||||
time_t *ISOTIME;
|
||||
smartlist_t **CSV;
|
||||
int *CSV_INTERVAL;
|
||||
struct config_line_t **LINELIST;
|
||||
struct config_line_t **LINELIST_S;
|
||||
struct config_line_t **LINELIST_V;
|
||||
routerset_t **ROUTERSET;
|
||||
} confparse_dummy_values_t;
|
||||
#endif /* defined(TOR_UNIT_TESTS) */
|
||||
#include "lib/conf/conftypes.h"
|
||||
|
||||
/** An abbreviation for a configuration option allowed on the command line. */
|
||||
typedef struct config_abbrev_t {
|
||||
|
@ -5,6 +5,7 @@ include src/lib/err/include.am
|
||||
include src/lib/cc/include.am
|
||||
include src/lib/ctime/include.am
|
||||
include src/lib/compress/include.am
|
||||
include src/lib/conf/include.am
|
||||
include src/lib/container/include.am
|
||||
include src/lib/crypt_ops/include.am
|
||||
include src/lib/defs/include.am
|
||||
|
2
src/lib/conf/.may_include
Normal file
2
src/lib/conf/.may_include
Normal file
@ -0,0 +1,2 @@
|
||||
orconfig.h
|
||||
lib/cc/*.h
|
83
src/lib/conf/conftypes.h
Normal file
83
src/lib/conf/conftypes.h
Normal file
@ -0,0 +1,83 @@
|
||||
/* 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 conftypes.h
|
||||
* @brief Types used to specify configurable options.
|
||||
**/
|
||||
|
||||
#ifndef TOR_SRC_LIB_CONF_CONFTYPES_H
|
||||
#define TOR_SRC_LIB_CONF_CONFTYPES_H
|
||||
|
||||
#include "lib/cc/torint.h"
|
||||
|
||||
/** Enumeration of types which option values can take */
|
||||
typedef enum config_type_t {
|
||||
CONFIG_TYPE_STRING = 0, /**< An arbitrary string. */
|
||||
CONFIG_TYPE_FILENAME, /**< A filename: some prefixes get expanded. */
|
||||
CONFIG_TYPE_POSINT, /**< A non-negative integer less than MAX_INT */
|
||||
CONFIG_TYPE_INT, /**< Any integer. */
|
||||
CONFIG_TYPE_UINT64, /**< A value in range 0..UINT64_MAX */
|
||||
CONFIG_TYPE_INTERVAL, /**< A number of seconds, with optional units*/
|
||||
CONFIG_TYPE_MSEC_INTERVAL,/**< A number of milliseconds, with optional
|
||||
* units */
|
||||
CONFIG_TYPE_MEMUNIT, /**< A number of bytes, with optional units*/
|
||||
CONFIG_TYPE_DOUBLE, /**< A floating-point value */
|
||||
CONFIG_TYPE_BOOL, /**< A boolean value, expressed as 0 or 1. */
|
||||
CONFIG_TYPE_AUTOBOOL, /**< A boolean+auto value, expressed 0 for false,
|
||||
* 1 for true, and -1 for auto */
|
||||
CONFIG_TYPE_ISOTIME, /**< An ISO-formatted time relative to UTC. */
|
||||
CONFIG_TYPE_CSV, /**< A list of strings, separated by commas and
|
||||
* optional whitespace. */
|
||||
CONFIG_TYPE_CSV_INTERVAL, /**< A list of strings, separated by commas and
|
||||
* optional whitespace, representing intervals in
|
||||
* seconds, with optional units. We allow
|
||||
* multiple values here for legacy reasons, but
|
||||
* ignore every value after the first. */
|
||||
CONFIG_TYPE_LINELIST, /**< Uninterpreted config lines */
|
||||
CONFIG_TYPE_LINELIST_S, /**< Uninterpreted, context-sensitive config lines,
|
||||
* mixed with other keywords. */
|
||||
CONFIG_TYPE_LINELIST_V, /**< Catch-all "virtual" option to summarize
|
||||
* context-sensitive config lines when fetching.
|
||||
*/
|
||||
// XXXX this doesn't belong at this level of abstraction.
|
||||
CONFIG_TYPE_ROUTERSET, /**< A list of router names, addrs, and fps,
|
||||
* parsed into a routerset_t. */
|
||||
CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */
|
||||
} config_type_t;
|
||||
|
||||
#ifdef TOR_UNIT_TESTS
|
||||
/**
|
||||
* Union used when building in test mode typechecking the members of a type
|
||||
* used with confparse.c. See CONF_CHECK_VAR_TYPE for a description of how
|
||||
* it is used. */
|
||||
typedef union {
|
||||
char **STRING;
|
||||
char **FILENAME;
|
||||
int *POSINT; /* yes, really: Even though the confparse type is called
|
||||
* "POSINT", it still uses the C int type -- it just enforces
|
||||
* that the values are in range [0,INT_MAX].
|
||||
*/
|
||||
uint64_t *UINT64;
|
||||
int *INT;
|
||||
int *INTERVAL;
|
||||
int *MSEC_INTERVAL;
|
||||
uint64_t *MEMUNIT;
|
||||
double *DOUBLE;
|
||||
int *BOOL;
|
||||
int *AUTOBOOL;
|
||||
time_t *ISOTIME;
|
||||
struct smartlist_t **CSV;
|
||||
int *CSV_INTERVAL;
|
||||
struct config_line_t **LINELIST;
|
||||
struct config_line_t **LINELIST_S;
|
||||
struct config_line_t **LINELIST_V;
|
||||
// XXXX this doesn't belong at this level of abstraction.
|
||||
struct routerset_t **ROUTERSET;
|
||||
} confparse_dummy_values_t;
|
||||
#endif /* defined(TOR_UNIT_TESTS) */
|
||||
|
||||
#endif /* !defined(TOR_SRC_LIB_CONF_CONFTYPES_H) */
|
4
src/lib/conf/include.am
Normal file
4
src/lib/conf/include.am
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
# ADD_C_FILE: INSERT HEADERS HERE.
|
||||
noinst_HEADERS += \
|
||||
src/lib/conf/conftypes.h
|
Loading…
Reference in New Issue
Block a user