#ifndef TOR_CONFPARSE_H
#define TOR_CONFPARSE_H
#include "lib/conf/conftypes.h"
#include "lib/conf/confmacros.h"
#include "lib/testsupport/testsupport.h"
typedef struct config_abbrev_t {
const char *abbreviated;
const char *full;
int commandline_only;
int warn;
} config_abbrev_t;
typedef struct config_deprecation_t {
const char *name;
const char *why_deprecated;
} config_deprecation_t;
#define PLURAL(tok) { #tok, #tok "s", 0, 0 }
typedef int (*validate_fn_t)(void *oldval,
void *newval,
void *default_val,
int from_setconf,
char **msg_out);
struct config_mgr_t;
typedef void (*clear_cfg_fn_t)(const struct config_mgr_t *mgr, void *obj);
typedef struct config_format_t {
size_t size;
struct_magic_decl_t magic;
const config_abbrev_t *abbrevs;
const config_deprecation_t *deprecations;
const config_var_t *vars;
validate_fn_t validate_fn;
clear_cfg_fn_t clear_fn;
const struct_member_t *extra;
ptrdiff_t config_suite_offset;
} config_format_t;
typedef struct config_mgr_t config_mgr_t;
config_mgr_t *config_mgr_new(const config_format_t *toplevel_fmt);
void config_mgr_free_(config_mgr_t *mgr);
int config_mgr_add_format(config_mgr_t *mgr,
const config_format_t *fmt);
void config_mgr_freeze(config_mgr_t *mgr);
#define config_mgr_free(mgr) \
FREE_AND_NULL(config_mgr_t, config_mgr_free_, (mgr))
struct smartlist_t *config_mgr_list_vars(const config_mgr_t *mgr);
struct smartlist_t *config_mgr_list_deprecated_vars(const config_mgr_t *mgr);
typedef struct config_suite_t config_suite_t;
#define CAL_USE_DEFAULTS (1u<<0)
#define CAL_CLEAR_FIRST (1u<<1)
#define CAL_WARN_DEPRECATIONS (1u<<2)
void *config_new(const config_mgr_t *fmt);
void config_free_(const config_mgr_t *fmt, void *options);
#define config_free(mgr, options) do { \
config_free_((mgr), (options)); \
(options) = NULL; \
} while (0)
struct config_line_t *config_get_assigned_option(const config_mgr_t *mgr,
const void *options, const char *key,
int escape_val);
int config_is_same(const config_mgr_t *fmt,
const void *o1, const void *o2,
const char *name);
struct config_line_t *config_get_changes(const config_mgr_t *mgr,
const void *options1, const void *options2);
void config_init(const config_mgr_t *mgr, void *options);
void *config_dup(const config_mgr_t *mgr, const void *old);
char *config_dump(const config_mgr_t *mgr, const void *default_options,
const void *options, int minimal,
int comment_defaults);
bool config_check_ok(const config_mgr_t *mgr, const void *options,
int severity);
int config_assign(const config_mgr_t *mgr, void *options,
struct config_line_t *list,
unsigned flags, char **msg);
const char *config_find_deprecation(const config_mgr_t *mgr,
const char *key);
const char *config_find_option_name(const config_mgr_t *mgr,
const char *key);
const char *config_expand_abbrev(const config_mgr_t *mgr,
const char *option,
int command_line, int warn_obsolete);
void warn_deprecated_option(const char *what, const char *why);
bool config_var_is_settable(const config_var_t *var);
bool config_var_is_listable(const config_var_t *var);
#define CFG_EQ_BOOL(a,b,opt) ((a)->opt == (b)->opt)
#define CFG_EQ_INT(a,b,opt) ((a)->opt == (b)->opt)
#define CFG_EQ_STRING(a,b,opt) (!strcmp_opt((a)->opt, (b)->opt))
#define CFG_EQ_SMARTLIST(a,b,opt) smartlist_strings_eq((a)->opt, (b)->opt)
#define CFG_EQ_LINELIST(a,b,opt) config_lines_eq((a)->opt, (b)->opt)
#define CFG_EQ_ROUTERSET(a,b,opt) routerset_equal((a)->opt, (b)->opt)
#ifdef CONFPARSE_PRIVATE
STATIC void config_reset_line(const config_mgr_t *mgr, void *options,
const char *key, int use_defaults);
STATIC void *config_mgr_get_obj_mutable(const config_mgr_t *mgr,
void *toplevel, int idx);
STATIC const void *config_mgr_get_obj(const config_mgr_t *mgr,
const void *toplevel, int idx);
#endif
#endif