diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-06-18 20:40:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-06-25 12:51:25 -0400 |
commit | 2da188667d37757ae999c8ab24ed35b64e08700c (patch) | |
tree | ec4ed14e32c27f81e816a655257b310d0eb04b65 /src/lib/conf | |
parent | e16b90b88a76fb82702ae26c54834aca6c591d64 (diff) | |
download | tor-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/conf')
-rw-r--r-- | src/lib/conf/conftypes.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/conf/conftypes.h b/src/lib/conf/conftypes.h index e66ab3d5aa..cddfeff2fd 100644 --- a/src/lib/conf/conftypes.h +++ b/src/lib/conf/conftypes.h @@ -63,8 +63,48 @@ typedef enum config_type_t { CONFIG_TYPE_ROUTERSET, /**< A list of router names, addrs, and fps, * parsed into a routerset_t. */ CONFIG_TYPE_OBSOLETE, /**< Obsolete (ignored) option. */ + CONFIG_TYPE_EXTENDED, /**< Extended type; definition will appear in + * pointer. */ } config_type_t; +/* Forward delcaration for var_type_def_t, for extended types. */ +struct var_type_def_t; + +/** Structure to specify a named, typed member within a structure. */ +typedef struct struct_member_t { + /** Name of the field. */ + const char *name; + /** Type of the field, according to the config_type_t enumeration. + * + * This value is CONFIG_TYPE_EXTENDED for any type not listed in + * config_type_t. + **/ + config_type_t type; + /** + * Pointer to a type definition for the type of this field. Overrides + * <b>type</b> if not NULL. + **/ + const struct var_type_def_t *type_def; + /** + * Offset of this field within the structure. Compute this with + * offsetof(structure, fieldname). + **/ + int offset; +} struct_member_t; + +/** + * Structure to describe the location and preferred value of a "magic number" + * field within a structure. + * + * These 'magic numbers' are 32-bit values used to tag objects to make sure + * that they have the correct type. + */ +typedef struct struct_magic_decl_t { + const char *typename; + uint32_t magic_val; + int magic_offset; +} struct_magic_decl_t; + #ifdef TOR_UNIT_TESTS /** * Union used when building in test mode typechecking the members of a type |