Tor
0.4.7.0-alpha-dev
|
Header for lib/confmgt/typedvar.c. More...
#include <stdbool.h>
Go to the source code of this file.
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_t * | typed_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) |
Header for lib/confmgt/typedvar.c.
Definition in file typedvar.h.
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 44 of file typedvar.c.
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 154 of file typedvar.c.
Referenced by struct_var_copy().
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 111 of file typedvar.c.
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 187 of file typedvar.c.
Referenced by struct_var_eq().
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 95 of file typedvar.c.
Referenced by struct_var_free().
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 129 of file typedvar.c.
Referenced by struct_var_kvencode().
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 228 of file typedvar.c.
Referenced by struct_var_mark_fragile().
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 211 of file typedvar.c.
Referenced by struct_var_ok().