summaryrefslogtreecommitdiff
path: root/src/lib/confmgt/structvar.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-06-18 20:40:11 -0400
committerNick Mathewson <nickm@torproject.org>2019-06-25 12:51:25 -0400
commit2da188667d37757ae999c8ab24ed35b64e08700c (patch)
treeec4ed14e32c27f81e816a655257b310d0eb04b65 /src/lib/confmgt/structvar.h
parente16b90b88a76fb82702ae26c54834aca6c591d64 (diff)
downloadtor-2da188667d37757ae999c8ab24ed35b64e08700c.tar.gz
tor-2da188667d37757ae999c8ab24ed35b64e08700c.zip
Add new "struct_var_" functions to manipulate struct fields.
These functions exist one level higher than typed_var_t. They describe a type, a name, and an offset within a structure.
Diffstat (limited to 'src/lib/confmgt/structvar.h')
-rw-r--r--src/lib/confmgt/structvar.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/lib/confmgt/structvar.h b/src/lib/confmgt/structvar.h
new file mode 100644
index 0000000000..894098e509
--- /dev/null
+++ b/src/lib/confmgt/structvar.h
@@ -0,0 +1,51 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file structvar.h
+ * @brief Header for lib/confmgt/structvar.c
+ **/
+
+#ifndef TOR_LIB_CONFMGT_STRUCTVAR_H
+#define TOR_LIB_CONFMGT_STRUCTVAR_H
+
+struct struct_magic_decl_t;
+struct struct_member_t;
+struct config_line_t;
+
+#include <stdbool.h>
+
+void struct_set_magic(void *object,
+ const struct struct_magic_decl_t *decl);
+void struct_check_magic(const void *object,
+ const struct struct_magic_decl_t *decl);
+
+void *struct_get_mptr(void *object,
+ const struct struct_member_t *member);
+const void *struct_get_ptr(const void *object,
+ const struct struct_member_t *member);
+
+int struct_var_assign(void *object, const char *value, char **errmsg,
+ const struct struct_member_t *member);
+void struct_var_free(void *object,
+ const struct struct_member_t *member);
+char *struct_var_encode(const void *object,
+ const struct struct_member_t *member);
+int struct_var_copy(void *dest, const void *src,
+ const struct struct_member_t *member);
+bool struct_var_eq(const void *a, const void *b,
+ const struct struct_member_t *member);
+bool struct_var_ok(const void *object,
+ 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);
+struct config_line_t *struct_var_kvencode(
+ const void *object,
+ const struct struct_member_t *member);
+
+#endif /* !defined(TOR_LIB_CONFMGT_STRUCTVAR_H) */