tor  0.4.2.0-alpha-dev
Typedefs | Functions
typedvar.h File Reference
#include <stdbool.h>

Go to the source code of this file.

Typedefs

typedef struct var_type_fns_t var_type_fns_t
 
typedef struct var_type_def_t var_type_def_t
 

Functions

int typed_var_assign (void *target, const char *value, char **errmsg, const var_type_def_t *def)
 
void typed_var_free (void *target, const var_type_def_t *def)
 
char * typed_var_encode (const void *value, const var_type_def_t *def)
 
int typed_var_copy (void *dest, const void *src, const var_type_def_t *def)
 
bool typed_var_eq (const void *a, const void *b, const var_type_def_t *def)
 
bool typed_var_ok (const void *value, const var_type_def_t *def)
 
int typed_var_kvassign (void *target, const struct config_line_t *line, char **errmsg, const var_type_def_t *def)
 
struct config_line_ttyped_var_kvencode (const char *key, const void *value, const var_type_def_t *def)
 
void typed_var_mark_fragile (void *value, const var_type_def_t *def)
 

Detailed Description

Header for lib/confmgt/typedvar.c.

Definition in file typedvar.h.

Function Documentation

◆ typed_var_assign()

int typed_var_assign ( void *  target,
const char *  value,
char **  errmsg,
const var_type_def_t def 
)

Try to parse a string in value that encodes an object of the type defined by def.

On success, adjust the lvalue pointed to by target to hold that value, and return 0. On failure, set *errmsg to a newly allocated string holding an error message, and return -1.

Definition at line 43 of file typedvar.c.

◆ typed_var_copy()

int typed_var_copy ( void *  dest,
const void *  src,
const var_type_def_t def 
)

Set dest to contain the same value as src. Both types must be as defined by def.

Return 0 on success, and -1 on failure.

Definition at line 145 of file typedvar.c.

Referenced by struct_var_copy().

◆ typed_var_encode()

char* typed_var_encode ( const void *  value,
const var_type_def_t def 
)

Encode a value of type def pointed to by value, and return its result in a newly allocated string. The string may need to be escaped.

Returns NULL if this option has a NULL value, or on internal error.

Definition at line 102 of file typedvar.c.

◆ typed_var_eq()

bool typed_var_eq ( const void *  a,
const void *  b,
const var_type_def_t def 
)

Return true if a and b are semantically equivalent. Both types must be as defined by def.

Definition at line 178 of file typedvar.c.

Referenced by struct_var_eq().

◆ typed_var_free()

void typed_var_free ( void *  target,
const var_type_def_t def 
)

Release storage held by a variable in target of type defined by def, and set target to a reasonable default.

Definition at line 86 of file typedvar.c.

Referenced by struct_var_free().

◆ typed_var_kvencode()

struct config_line_t* typed_var_kvencode ( const char *  key,
const void *  value,
const var_type_def_t def 
)

As typed_var_encode(), but returns a newly allocated config_line_t object. The provided key is used as the key of the lines, unless the type is one (line a linelist) that encodes its own keys.

This function may return a list of multiple lines.

Returns NULL if there are no lines to encode, or on internal error.

Definition at line 120 of file typedvar.c.

Referenced by struct_var_kvencode().

◆ typed_var_mark_fragile()

void typed_var_mark_fragile ( void *  value,
const var_type_def_t def 
)

Mark value – 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 219 of file typedvar.c.

Referenced by struct_var_mark_fragile().

◆ typed_var_ok()

bool typed_var_ok ( const void *  value,
const var_type_def_t def 
)

Check whether value encodes a valid value according to the type definition in def.

Definition at line 202 of file typedvar.c.

Referenced by struct_var_ok().