Tor 0.4.9.0-alpha-dev
Functions
structvar.c File Reference

Functions to manipulate named and typed elements of a structure. More...

#include "orconfig.h"
#include "lib/confmgt/structvar.h"
#include "lib/cc/compat_compiler.h"
#include "lib/conf/conftypes.h"
#include "lib/confmgt/type_defs.h"
#include "lib/confmgt/typedvar.h"
#include "lib/log/util_bug.h"
#include "lib/confmgt/var_type_def_st.h"
#include <stddef.h>

Go to the source code of this file.

Functions

static bool magic_is_null (const struct_magic_decl_t *decl)
 
void struct_set_magic (void *object, const struct_magic_decl_t *decl)
 
void struct_check_magic (const void *object, const struct_magic_decl_t *decl)
 
void * struct_get_mptr (void *object, const struct_member_t *member)
 
const void * struct_get_ptr (const void *object, const struct_member_t *member)
 
static const var_type_def_tget_type_def (const struct_member_t *member)
 
void struct_var_free (void *object, const struct_member_t *member)
 
int struct_var_copy (void *dest, const void *src, const struct_member_t *member)
 
bool struct_var_eq (const void *a, const void *b, const struct_member_t *member)
 
bool struct_var_ok (const void *object, const struct_member_t *member)
 
int struct_var_kvassign (void *object, const struct config_line_t *line, char **errmsg, const struct_member_t *member)
 
struct config_line_tstruct_var_kvencode (const void *object, const struct_member_t *member)
 
void struct_var_mark_fragile (void *object, const struct_member_t *member)
 
const char * struct_var_get_name (const struct_member_t *member)
 
const char * struct_var_get_typename (const struct_member_t *member)
 
uint32_t struct_var_get_flags (const struct_member_t *member)
 

Detailed Description

Functions to manipulate named and typed elements of a structure.

These functions represent a low-level API for accessing a member of a structure. They use typedvar.c to work, and they are used in turn by the configuration system to examine and set fields in configuration objects used by individual modules.

Almost no code should call these directly.

Definition in file structvar.c.

Function Documentation

◆ get_type_def()

static const var_type_def_t * get_type_def ( const struct_member_t member)
static

◆ magic_is_null()

static bool magic_is_null ( const struct_magic_decl_t decl)
inlinestatic

Return true iff all fields on decl are NULL or 0, indicating that there is no object or no magic number to check.

Definition at line 37 of file structvar.c.

Referenced by struct_check_magic(), and struct_set_magic().

◆ struct_check_magic()

void struct_check_magic ( const void *  object,
const struct_magic_decl_t decl 
)

Assert that the 'magic number' on object to corresponds to decl.

Definition at line 63 of file structvar.c.

Referenced by config_check_toplevel_magic(), and config_mgr_assert_magic_ok().

◆ struct_get_mptr()

void * struct_get_mptr ( void *  object,
const struct_member_t member 
)

Return a mutable pointer to the member of object described by member.

Definition at line 83 of file structvar.c.

Referenced by struct_var_copy(), struct_var_free(), struct_var_kvassign(), and struct_var_mark_fragile().

◆ struct_get_ptr()

const void * struct_get_ptr ( const void *  object,
const struct_member_t member 
)

Return a const pointer to the member of object described by member.

Definition at line 94 of file structvar.c.

Referenced by struct_var_copy(), struct_var_eq(), struct_var_kvencode(), and struct_var_ok().

◆ struct_set_magic()

void struct_set_magic ( void *  object,
const struct_magic_decl_t decl 
)

Set the 'magic number' on object to correspond to decl.

Definition at line 48 of file structvar.c.

◆ struct_var_copy()

int struct_var_copy ( void *  dest,
const void *  src,
const struct_member_t member 
)

(As typed_var_copy, but copy from src to dest the member defined by member.)

Definition at line 131 of file structvar.c.

Referenced by config_dup().

◆ struct_var_eq()

bool struct_var_eq ( const void *  a,
const void *  b,
const struct_member_t member 
)

(As typed_var_eq, but compare the members of a and b defined by member.)

Definition at line 145 of file structvar.c.

Referenced by config_get_changes(), and config_is_same().

◆ struct_var_free()

void struct_var_free ( void *  object,
const struct_member_t member 
)

(As typed_var_free, but free and clear the member of object defined by member.)

Definition at line 118 of file structvar.c.

Referenced by config_clear().

◆ struct_var_get_flags()

uint32_t struct_var_get_flags ( const struct_member_t member)

Return all of the flags set for this struct member.

Definition at line 234 of file structvar.c.

Referenced by config_var_has_flag().

◆ struct_var_get_name()

const char * struct_var_get_name ( const struct_member_t member)

Return the official name of this struct member.

Definition at line 212 of file structvar.c.

◆ struct_var_get_typename()

const char * struct_var_get_typename ( const struct_member_t member)

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.

Definition at line 225 of file structvar.c.

◆ struct_var_kvassign()

int struct_var_kvassign ( void *  object,
const struct config_line_t line,
char **  errmsg,
const struct_member_t member 
)

(As typed_var_kvassign, but assign a value to the member of object defined by member.)

Definition at line 172 of file structvar.c.

◆ struct_var_kvencode()

struct config_line_t * struct_var_kvencode ( const void *  object,
const struct_member_t member 
)

(As typed_var_kvencode, but encode the value of the member of object defined by member.)

Definition at line 187 of file structvar.c.

◆ struct_var_mark_fragile()

void struct_var_mark_fragile ( void *  object,
const struct_member_t member 
)

Mark the field in object determined by member – a variable that ordinarily would be extended by assignment – as "fragile", so that it will get replaced by the next assignment instead.

Definition at line 201 of file structvar.c.

Referenced by config_mark_lists_fragile().

◆ struct_var_ok()

bool struct_var_ok ( const void *  object,
const struct_member_t member 
)

(As typed_var_ok, but validate the member of object defined by member.)

Definition at line 159 of file structvar.c.

Referenced by config_check_ok().