Tor  0.4.7.0-alpha-dev
confmacros.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * @file confmacros.h
9  * @brief Macro definitions for declaring configuration variables
10  **/
11 
12 #ifndef TOR_LIB_CONF_CONFMACROS_H
13 #define TOR_LIB_CONF_CONFMACROS_H
14 
15 #include "orconfig.h"
16 #include "lib/conf/conftesting.h"
17 
18 #ifndef COCCI
19 /**
20  * Used to indicate the end of an array of configuration variables.
21  **/
22 #define END_OF_CONFIG_VARS \
23  { .member = { .name = NULL } DUMMY_CONF_TEST_MEMBERS }
24 #endif /* !defined(COCCI) */
25 
26 /**
27  * Declare a config_var_t as a member named <b>membername</b> of the structure
28  * <b>structtype</b>, whose user-visible name is <b>varname</b>, whose
29  * type corresponds to the config_type_t member CONFIG_TYPE_<b>vartype</b>,
30  * and whose initial value is <b>intval</b>.
31  *
32  * Most modules that use this macro should wrap it in a local macro that
33  * sets structtype to the local configuration type.
34  **/
35 #define CONFIG_VAR_ETYPE(structtype, varname, vartype, membername, \
36  varflags, initval) \
37  { .member = \
38  { .name = varname, \
39  .type = CONFIG_TYPE_ ## vartype, \
40  .offset = offsetof(structtype, membername), \
41  }, \
42  .flags = varflags, \
43  .initvalue = initval \
44  CONF_TEST_MEMBERS(structtype, vartype, membername) \
45  }
46 
47 /**
48  * As CONFIG_VAR_ETYPE, but declares a value using an extension type whose
49  * type definition is <b>vartype</b>_type_defn.
50  **/
51 #define CONFIG_VAR_DEFN(structtype, varname, vartype, membername, \
52  varflags, initval) \
53  { .member = \
54  { .name = varname, \
55  .type = CONFIG_TYPE_EXTENDED, \
56  .type_def = &vartype ## _type_defn, \
57  .offset = offsetof(structtype, membername), \
58  }, \
59  .flags = varflags, \
60  .initvalue = initval \
61  CONF_TEST_MEMBERS(structtype, vartype, membername) \
62  }
63 
64 /**
65  * Declare an obsolete configuration variable with a given name.
66  **/
67 #define CONFIG_VAR_OBSOLETE(varname) \
68  { .member = { .name = varname, .type = CONFIG_TYPE_OBSOLETE }, \
69  .flags = CFLG_GROUP_OBSOLETE \
70  }
71 
72 #endif /* !defined(TOR_LIB_CONF_CONFMACROS_H) */
Macro and type declarations for testing.