diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-06-19 10:46:07 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-06-25 12:51:25 -0400 |
commit | a91ed23403ae28974639a9bdb67530c5c07a0ce6 (patch) | |
tree | edd344d236ef0c4f3784611c8e146c0e433837c5 /src/lib/confmgt | |
parent | 53e969c137cb39bed432cd165d3d7e3825b1a2a9 (diff) | |
download | tor-a91ed23403ae28974639a9bdb67530c5c07a0ce6.tar.gz tor-a91ed23403ae28974639a9bdb67530c5c07a0ce6.zip |
Use structvar to find the types for config vars.
Diffstat (limited to 'src/lib/confmgt')
-rw-r--r-- | src/lib/confmgt/structvar.c | 26 | ||||
-rw-r--r-- | src/lib/confmgt/structvar.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/confmgt/structvar.c b/src/lib/confmgt/structvar.c index 7ea00fbde9..38f8e5dd7a 100644 --- a/src/lib/confmgt/structvar.c +++ b/src/lib/confmgt/structvar.c @@ -25,6 +25,8 @@ #include "lib/confmgt/typedvar.h" #include "lib/log/util_bug.h" +#include "lib/confmgt/var_type_def_st.h" + #include <stddef.h> /** @@ -198,3 +200,27 @@ struct_var_kvencode(const void *object, const struct_member_t *member) return typed_var_kvencode_ex(member->name, p, def); } + +/** + * Return the official name of this struct member. + **/ +const char * +struct_var_get_name(const struct_member_t *member) +{ + return member->name; +} + +/** + * Return the type name for this struct member. + * + * Do not use the output of this function to inspect a type within Tor. It is + * suitable for debugging, informing the controller or user of a variable's + * type, etc. + **/ +const char * +struct_var_get_typename(const struct_member_t *member) +{ + const var_type_def_t *def = get_type_def(member); + + return def ? def->name : NULL; +} diff --git a/src/lib/confmgt/structvar.h b/src/lib/confmgt/structvar.h index 894098e509..92b9b6fc71 100644 --- a/src/lib/confmgt/structvar.h +++ b/src/lib/confmgt/structvar.h @@ -41,6 +41,9 @@ bool struct_var_eq(const void *a, const void *b, bool struct_var_ok(const void *object, const struct struct_member_t *member); +const char *struct_var_get_name(const struct struct_member_t *member); +const char *struct_var_get_typename(const struct struct_member_t *member); + int struct_var_kvassign(void *object, const struct config_line_t *line, char **errmsg, const struct struct_member_t *member); |