tor  0.4.2.1-alpha-dev
Functions
structvar.c File Reference
#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

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

◆ 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 48 of file structvar.c.

References struct_magic_decl_t::magic_offset, STRUCT_VAR_P, and tor_assert().

Referenced by 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 65 of file structvar.c.

References struct_member_t::offset, STRUCT_VAR_P, and tor_assert().

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 76 of file structvar.c.

References struct_member_t::offset, STRUCT_VAR_P, and tor_assert().

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 36 of file structvar.c.

References struct_magic_decl_t::magic_offset, struct_magic_decl_t::magic_val, STRUCT_VAR_P, and tor_assert().

◆ 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 113 of file structvar.c.

References get_type_def(), struct_get_mptr(), struct_get_ptr(), and typed_var_copy().

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 127 of file structvar.c.

References get_type_def(), struct_get_ptr(), and typed_var_eq().

Referenced by config_get_changes().

◆ 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 100 of file structvar.c.

References get_type_def(), struct_get_mptr(), and typed_var_free().

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 216 of file structvar.c.

References var_type_def_t::flags, and get_type_def().

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 194 of file structvar.c.

References struct_member_t::name.

◆ 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 207 of file structvar.c.

References get_type_def(), and var_type_def_t::name.

◆ 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 154 of file structvar.c.

References get_type_def(), struct_get_mptr(), and typed_var_kvassign().

Referenced by config_assign_value().

◆ 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 169 of file structvar.c.

References get_type_def(), struct_member_t::name, struct_get_ptr(), and typed_var_kvencode().

◆ 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 183 of file structvar.c.

References get_type_def(), struct_get_mptr(), and typed_var_mark_fragile().

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 141 of file structvar.c.

References get_type_def(), struct_get_ptr(), and typed_var_ok().

Referenced by config_check_ok().