aboutsummaryrefslogtreecommitdiff
path: root/src/lib/conf
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-12-15 18:40:12 -0500
committerNick Mathewson <nickm@torproject.org>2019-12-19 07:54:56 -0500
commit9082a6db3f31c768ba862ed22f0824e99b4e0e22 (patch)
treebd78488cd81b8f47c8984cd5c91cff49ad3fe2e0 /src/lib/conf
parent5e2318165dba782f6daa6620b17e0fa1e72b4b11 (diff)
downloadtor-9082a6db3f31c768ba862ed22f0824e99b4e0e22.tar.gz
tor-9082a6db3f31c768ba862ed22f0824e99b4e0e22.zip
Support a flag to indicate that a config var is disabled
Like "obsolete" variables, these variables produce a warning when you try to set them, but the warning says that the relevant module doesn't have support. The confdecl macros now have a CONF_CONTEXT that you can define to make all the modules in a given table disabled.
Diffstat (limited to 'src/lib/conf')
-rw-r--r--src/lib/conf/confdecl.h22
-rw-r--r--src/lib/conf/conftypes.h12
2 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/conf/confdecl.h b/src/lib/conf/confdecl.h
index 064ab324f8..723aea1878 100644
--- a/src/lib/conf/confdecl.h
+++ b/src/lib/conf/confdecl.h
@@ -135,6 +135,28 @@
.initvalue = initval \
},
/**@}*/
+
+/* @defgroup STUB_TABLE_MACROS Internal macros: stub table declarations,
+ * for use when a module is disabled.
+ * Implementation helpers: the regular confdecl macros expand to these
+ * when CONF_CONTEXT is defined to LL_TABLE. Don't use them directly.
+ * @{*/
+#define BEGIN_CONF_STRUCT__STUB_TABLE(structname) \
+ static const config_var_t structname##_vars[] = {
+#define END_CONF_STRUCT__STUB_TABLE(structname) \
+ { .member = { .name = NULL } } \
+ };
+#define CONF_VAR__STUB_TABLE(varname, vartype, varflags, initval) \
+ { \
+ .member = \
+ { .name = #varname, \
+ .type = CONFIG_TYPE_IGNORE, \
+ .offset = -1, \
+ }, \
+ .flags = CFLG_GROUP_DISABLED, \
+ },
+/**@}*/
+
#endif /* !defined(COCCI) */
/** Type aliases for the "commonly used" configuration types.
diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h
index 19ea997316..44171068a1 100644
--- a/src/lib/conf/conftypes.h
+++ b/src/lib/conf/conftypes.h
@@ -199,6 +199,11 @@ typedef struct struct_magic_decl_t {
* whenever the user tries to use it.
**/
#define CFLG_WARN_OBSOLETE (1u<<7)
+/**
+ * Flag to indicate that we should warn that an option applies only to
+ * a disabled module, whenever the user tries to use it.
+ **/
+#define CFLG_WARN_DISABLED (1u<<8)
/**
* A group of flags that should be set on all obsolete options and types.
@@ -207,6 +212,13 @@ typedef struct struct_magic_decl_t {
(CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST|\
CFLG_WARN_OBSOLETE)
+/**
+ * A group of fflags that should be set on all disabled options.
+ **/
+#define CFLG_GROUP_DISABLED \
+ (CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP|CFLG_NOSET|CFLG_NOLIST|\
+ CFLG_WARN_DISABLED)
+
/** A variable allowed in the configuration file or on the command line. */
typedef struct config_var_t {
struct_member_t member; /** A struct member corresponding to this