7 #ifndef TOR_CONFPARSE_H 8 #define TOR_CONFPARSE_H 11 typedef enum config_type_t {
12 CONFIG_TYPE_STRING = 0,
19 CONFIG_TYPE_MSEC_INTERVAL,
29 CONFIG_TYPE_CSV_INTERVAL,
35 CONFIG_TYPE_LINELIST_S,
37 CONFIG_TYPE_LINELIST_V,
40 CONFIG_TYPE_ROUTERSET,
71 routerset_t **ROUTERSET;
72 } confparse_dummy_values_t;
77 const char *abbreviated;
85 const char *why_deprecated;
90 #define PLURAL(tok) { #tok, #tok "s", 0, 0 } 100 #ifdef TOR_UNIT_TESTS 103 confparse_dummy_values_t var_ptr_dummy;
110 #ifdef TOR_UNIT_TESTS 129 #define CONF_CHECK_VAR_TYPE(tp, conftype, member) \ 130 { . conftype = &tp ## _dummy . member } 131 #define CONF_TEST_MEMBERS(tp, conftype, member) \ 132 , CONF_CHECK_VAR_TYPE(tp, conftype, member) 133 #define END_OF_CONFIG_VARS \ 134 { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL, { .INT=NULL } } 135 #define DUMMY_TYPECHECK_INSTANCE(tp) \ 136 static tp tp ## _dummy 138 #define CONF_TEST_MEMBERS(tp, conftype, member) 139 #define END_OF_CONFIG_VARS { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL } 141 #define DUMMY_TYPECHECK_INSTANCE(tp) \ 142 struct tor_semicolon_eater 148 typedef int (*validate_fn_t)(
void*,
void*,
void*,int,
char**);
171 #define CONFIG_CHECK(fmt, cfg) STMT_BEGIN \ 172 tor_assert(fmt && cfg); \ 173 tor_assert((fmt)->magic == \ 174 *(uint32_t*)STRUCT_VAR_P(cfg,fmt->magic_offset)); \ 177 #define CAL_USE_DEFAULTS (1u<<0) 178 #define CAL_CLEAR_FIRST (1u<<1) 179 #define CAL_WARN_DEPRECATIONS (1u<<2) 183 #define config_free(fmt, options) do { \ 184 config_free_((fmt), (options)); \ 189 const void *options,
const char *key,
192 const void *o1,
const void *o2,
197 const void *options,
int minimal,
198 int comment_defaults);
201 unsigned flags,
char **msg);
210 int command_line,
int warn_obsolete);
211 void warn_deprecated_option(
const char *what,
const char *why);
214 #define CFG_EQ_BOOL(a,b,opt) ((a)->opt == (b)->opt) 215 #define CFG_EQ_INT(a,b,opt) ((a)->opt == (b)->opt) 216 #define CFG_EQ_STRING(a,b,opt) (!strcmp_opt((a)->opt, (b)->opt)) 217 #define CFG_EQ_SMARTLIST(a,b,opt) smartlist_strings_eq((a)->opt, (b)->opt) 218 #define CFG_EQ_LINELIST(a,b,opt) config_lines_eq((a)->opt, (b)->opt) 219 #define CFG_EQ_ROUTERSET(a,b,opt) routerset_equal((a)->opt, (b)->opt) void config_init(const config_format_t *fmt, void *options)
Definition: confparse.c:909
Definition: confline.h:23
Definition: confparse.h:93
config_type_t type
Definition: confparse.h:95
const char * config_expand_abbrev(const config_format_t *fmt, const char *option, int command_line, int warn_obsolete)
Definition: confparse.c:55
Definition: container.h:18
char * config_dump(const config_format_t *fmt, const void *default_options, const void *options, int minimal, int comment_defaults)
Definition: confparse.c:928
config_line_t * config_get_assigned_option(const config_format_t *fmt, const void *options, const char *key, int escape_val)
Definition: confparse.c:517
const config_var_t * config_find_option(const config_format_t *fmt, const char *key)
Definition: confparse.c:134
config_var_t * config_find_option_mutable(config_format_t *fmt, const char *key)
Definition: confparse.c:103
void * config_dup(const config_format_t *fmt, const void *old)
Definition: confparse.c:880
void config_free_(const config_format_t *fmt, void *options)
Definition: confparse.c:838
Definition: confparse.h:83
const char * config_find_deprecation(const config_format_t *fmt, const char *key)
Definition: confparse.c:85
const char * initvalue
Definition: confparse.h:98
int config_is_same(const config_format_t *fmt, const void *o1, const void *o2, const char *name)
Definition: confparse.c:861
off_t var_offset
Definition: confparse.h:97
int config_assign(const config_format_t *fmt, void *options, config_line_t *list, unsigned config_assign_flags, char **msg)
Definition: confparse.c:703
const char * name
Definition: confparse.h:94
Definition: confparse.h:76
void * config_new(const config_format_t *fmt)
Definition: confparse.c:37