summaryrefslogtreecommitdiff
path: root/src/lib/confmgt/structvar.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-06-19 10:46:07 -0400
committerNick Mathewson <nickm@torproject.org>2019-06-25 12:51:25 -0400
commita91ed23403ae28974639a9bdb67530c5c07a0ce6 (patch)
treeedd344d236ef0c4f3784611c8e146c0e433837c5 /src/lib/confmgt/structvar.c
parent53e969c137cb39bed432cd165d3d7e3825b1a2a9 (diff)
downloadtor-a91ed23403ae28974639a9bdb67530c5c07a0ce6.tar.gz
tor-a91ed23403ae28974639a9bdb67530c5c07a0ce6.zip
Use structvar to find the types for config vars.
Diffstat (limited to 'src/lib/confmgt/structvar.c')
-rw-r--r--src/lib/confmgt/structvar.c26
1 files changed, 26 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;
+}