diff options
author | David Goulet <dgoulet@torproject.org> | 2019-09-11 09:42:31 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-09-11 09:42:31 -0400 |
commit | 41261c3b5cd505f5a601c319eb484866903814af (patch) | |
tree | 3264e3e0293865ab9012d53aaf835f3713d8c6ef /src/lib/confmgt | |
parent | 049705fc1c9d1c0cee120dc8cbd1a719c6e45e85 (diff) | |
parent | 478141e617a333ac4d998e3747c073246e04b5ae (diff) | |
download | tor-41261c3b5cd505f5a601c319eb484866903814af.tar.gz tor-41261c3b5cd505f5a601c319eb484866903814af.zip |
Merge branch 'tor-github/pr/1296'
Diffstat (limited to 'src/lib/confmgt')
-rw-r--r-- | src/lib/confmgt/structvar.c | 23 | ||||
-rw-r--r-- | src/lib/confmgt/structvar.h | 5 | ||||
-rw-r--r-- | src/lib/confmgt/type_defs.c | 22 | ||||
-rw-r--r-- | src/lib/confmgt/typedvar.c | 29 | ||||
-rw-r--r-- | src/lib/confmgt/typedvar.h | 4 | ||||
-rw-r--r-- | src/lib/confmgt/var_type_def_st.h | 16 |
6 files changed, 25 insertions, 74 deletions
diff --git a/src/lib/confmgt/structvar.c b/src/lib/confmgt/structvar.c index 75edda2c38..de678d18c8 100644 --- a/src/lib/confmgt/structvar.c +++ b/src/lib/confmgt/structvar.c @@ -211,26 +211,11 @@ struct_var_get_typename(const struct_member_t *member) return def ? def->name : NULL; } -bool -struct_var_is_cumulative(const struct_member_t *member) -{ - const var_type_def_t *def = get_type_def(member); - - return def ? def->is_cumulative : false; -} - -bool -struct_var_is_settable(const struct_member_t *member) -{ - const var_type_def_t *def = get_type_def(member); - - return def ? !def->is_unsettable : true; -} - -bool -struct_var_is_contained(const struct_member_t *member) +/** Return all of the flags set for this struct member. */ +uint32_t +struct_var_get_flags(const struct_member_t *member) { const var_type_def_t *def = get_type_def(member); - return def ? def->is_contained : false; + return def ? def->flags : 0; } diff --git a/src/lib/confmgt/structvar.h b/src/lib/confmgt/structvar.h index 9783d1ec27..bcb4b58c3f 100644 --- a/src/lib/confmgt/structvar.h +++ b/src/lib/confmgt/structvar.h @@ -17,6 +17,7 @@ struct struct_member_t; struct config_line_t; #include <stdbool.h> +#include "lib/cc/torint.h" void struct_set_magic(void *object, const struct struct_magic_decl_t *decl); @@ -41,9 +42,7 @@ void struct_var_mark_fragile(void *object, const char *struct_var_get_name(const struct struct_member_t *member); const char *struct_var_get_typename(const struct struct_member_t *member); -bool struct_var_is_cumulative(const struct struct_member_t *member); -bool struct_var_is_settable(const struct struct_member_t *member); -bool struct_var_is_contained(const struct struct_member_t *member); +uint32_t struct_var_get_flags(const struct struct_member_t *member); int struct_var_kvassign(void *object, const struct config_line_t *line, char **errmsg, diff --git a/src/lib/confmgt/type_defs.c b/src/lib/confmgt/type_defs.c index f8b2681aa0..324b62e56c 100644 --- a/src/lib/confmgt/type_defs.c +++ b/src/lib/confmgt/type_defs.c @@ -725,16 +725,22 @@ static const var_type_def_t type_definitions_table[] = { [CONFIG_TYPE_CSV_INTERVAL] = { .name="TimeInterval", .fns=&legacy_csv_interval_fns, }, [CONFIG_TYPE_LINELIST] = { .name="LineList", .fns=&linelist_fns, - .is_cumulative=true}, + .flags=CFLG_NOREPLACE }, + /* + * A "linelist_s" is a derived view of a linelist_v: inspecting + * it gets part of a linelist_v, and setting it adds to the linelist_v. + */ [CONFIG_TYPE_LINELIST_S] = { .name="Dependent", .fns=&linelist_s_fns, - .is_cumulative=true, - .is_contained=true, }, + .flags=CFLG_NOREPLACE| + /* The operations we disable here are + * handled by the linelist_v. */ + CFLG_NOCOPY|CFLG_NOCMP|CFLG_NODUMP }, [CONFIG_TYPE_LINELIST_V] = { .name="Virtual", .fns=&linelist_v_fns, - .is_cumulative=true, - .is_unsettable=true }, - [CONFIG_TYPE_OBSOLETE] = { .name="Obsolete", .fns=&ignore_fns, - .is_unsettable=true, - .is_contained=true, } + .flags=CFLG_NOREPLACE|CFLG_NOSET }, + [CONFIG_TYPE_OBSOLETE] = { + .name="Obsolete", .fns=&ignore_fns, + .flags=CFLG_GROUP_OBSOLETE, + } }; /** diff --git a/src/lib/confmgt/typedvar.c b/src/lib/confmgt/typedvar.c index 43040e1e05..219a2d15bc 100644 --- a/src/lib/confmgt/typedvar.c +++ b/src/lib/confmgt/typedvar.c @@ -225,32 +225,3 @@ typed_var_mark_fragile(void *value, const var_type_def_t *def) if (def->fns->mark_fragile) def->fns->mark_fragile(value, def->params); } - -/** - * Return true iff multiple assignments to a variable will extend its - * value, rather than replacing it. - **/ -bool -var_type_is_cumulative(const var_type_def_t *def) -{ - return def->is_cumulative; -} - -/** - * Return true iff this variable type is always contained in another variable, - * and as such doesn't need to be dumped or copied independently. - **/ -bool -var_type_is_contained(const var_type_def_t *def) -{ - return def->is_contained; -} - -/** - * Return true iff this type can not be assigned directly by the user. - **/ -bool -var_type_is_settable(const var_type_def_t *def) -{ - return ! def->is_unsettable; -} diff --git a/src/lib/confmgt/typedvar.h b/src/lib/confmgt/typedvar.h index 23fd8c13e4..22f2e3c58e 100644 --- a/src/lib/confmgt/typedvar.h +++ b/src/lib/confmgt/typedvar.h @@ -35,8 +35,4 @@ struct config_line_t *typed_var_kvencode(const char *key, const void *value, void typed_var_mark_fragile(void *value, const var_type_def_t *def); -bool var_type_is_cumulative(const var_type_def_t *def); -bool var_type_is_contained(const var_type_def_t *def); -bool var_type_is_settable(const var_type_def_t *def); - #endif /* !defined(TOR_LIB_CONFMGT_TYPEDVAR_H) */ diff --git a/src/lib/confmgt/var_type_def_st.h b/src/lib/confmgt/var_type_def_st.h index 4157cb8ff6..f1131ff116 100644 --- a/src/lib/confmgt/var_type_def_st.h +++ b/src/lib/confmgt/var_type_def_st.h @@ -151,17 +151,11 @@ struct var_type_def_t { * calling the functions in this type's function table. */ const void *params; - - /** True iff a variable of this type can never be set directly by name. */ - bool is_unsettable; - /** True iff a variable of this type is always contained in another - * variable, and as such doesn't need to be dumped or copied - * independently. */ - bool is_contained; - /** True iff a variable of this type can be set more than once without - * destroying older values. Such variables should implement "mark_fragile". - */ - bool is_cumulative; + /** + * A bitwise OR of one or more VTFLAG_* values, describing properties + * for all values of this type. + **/ + uint32_t flags; }; #endif /* !defined(TOR_LIB_CONFMGT_VAR_TYPE_DEF_ST_H) */ |