confparse: Add a function to check the magic of a toplevel object.

This commit is contained in:
Nick Mathewson 2019-10-25 08:08:43 -04:00
parent 94853b4ab6
commit aa6b4b62db
2 changed files with 13 additions and 0 deletions

View File

@ -334,6 +334,17 @@ config_mgr_list_deprecated_vars(const config_mgr_t *mgr)
return result;
}
/**
* Check the magic number on <b>object</b> to make sure it's a valid toplevel
* object, created with <b>mgr</b>. Exit with an assertion if it isn't.
**/
void
config_check_toplevel_magic(const config_mgr_t *mgr,
const void *object)
{
struct_check_magic(object, &mgr->toplevel_magic);
}
/** Assert that the magic fields in <b>options</b> and its subsidiary
* objects are all okay. */
static void

View File

@ -232,6 +232,8 @@ void *config_dup(const config_mgr_t *mgr, const void *old);
char *config_dump(const config_mgr_t *mgr, const void *default_options,
const void *options, int minimal,
int comment_defaults);
void config_check_toplevel_magic(const config_mgr_t *mgr,
const void *object);
bool config_check_ok(const config_mgr_t *mgr, const void *options,
int severity);
int config_assign(const config_mgr_t *mgr, void *options,