diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-18 16:19:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-18 16:19:36 +0300 |
commit | 5b74faa8afd04771af7acb918072ea71a3db475f (patch) | |
tree | 47d24a43925e95aea6acb8ff321cb9543600fda4 /src/common/conf.h | |
parent | 1bfb8c1283a0c662902cc8cb94d30159a9bc1183 (diff) | |
parent | 1d2eb6d23519a971db0646a146152fc6f79350f1 (diff) | |
download | hercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.gz hercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.bz2 hercules-5b74faa8afd04771af7acb918072ea71a3db475f.tar.xz hercules-5b74faa8afd04771af7acb918072ea71a3db475f.zip |
Merge pull request #1160 from MishimaHaruna/libconfig
Libconfig: update to 1.5 and various improvements
Diffstat (limited to 'src/common/conf.h')
-rw-r--r-- | src/common/conf.h | 154 |
1 files changed, 83 insertions, 71 deletions
diff --git a/src/common/conf.h b/src/common/conf.h index 19b13c51a..f2bfcac62 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -29,82 +29,94 @@ * The libconfig interface -- specially for plugins, but we enforce it throughout the core to be consistent **/ struct libconfig_interface { - int (*read) (config_t *config, FILE *stream); - void (*write) (const config_t *config, FILE *stream); + int (*read) (struct config_t *config, FILE *stream); + void (*write) (const struct config_t *config, FILE *stream); /* */ - void (*set_auto_convert) (config_t *config, int flag); // TODO: Replace with config_set_options - int (*get_auto_convert) (const config_t *config); // TODO: Replace with config_get_options + void (*set_options) (struct config_t *config, int options); + int (*get_options) (const struct config_t *config); /* */ - int (*read_string) (config_t *config, const char *str); - int (*read_file_src) (config_t *config, const char *filename); - int (*write_file) (config_t *config, const char *filename); - - void (*set_destructor) (config_t *config, void (*destructor)(void *)); - void (*set_include_dir) (config_t *config, const char *include_dir); - - void (*init) (config_t *config); - void (*destroy) (config_t *config); - - int (*setting_get_int) (const config_setting_t *setting); - long long (*setting_get_int64) (const config_setting_t *setting); - double (*setting_get_float) (const config_setting_t *setting); - - int (*setting_get_bool) (const config_setting_t *setting); - - const char * (*setting_get_string) (const config_setting_t *setting); - - int (*setting_lookup_int) (const config_setting_t *setting, const char *name, int *value); - int (*setting_lookup_int64) (const config_setting_t *setting, const char *name, long long *value); - int (*setting_lookup_float) (const config_setting_t *setting, const char *name, double *value); - int (*setting_lookup_bool) (const config_setting_t *setting, const char *name, int *value); - int (*setting_lookup_string) (const config_setting_t *setting, const char *name, const char **value); - int (*setting_set_int) (config_setting_t *setting ,int value); - int (*setting_set_int64) (config_setting_t *setting, long long value); - int (*setting_set_float) (config_setting_t *setting, double value); - int (*setting_set_bool) (config_setting_t *setting, int value); - int (*setting_set_string) (config_setting_t *setting, const char *value); - - int (*setting_set_format) (config_setting_t *setting, short format); - short (*setting_get_format) (const config_setting_t *setting); - - int (*setting_get_int_elem) (const config_setting_t *setting, int idx); - long long (*setting_get_int64_elem) (const config_setting_t *setting, int idx); - double (*setting_get_float_elem) (const config_setting_t *setting, int idx); - int (*setting_get_bool_elem) (const config_setting_t *setting, int idx); - const char * (*setting_get_string_elem) (const config_setting_t *setting, int idx); - config_setting_t * (*setting_set_int_elem) (config_setting_t *setting, int idx, int value); - config_setting_t * (*setting_set_int64_elem) (config_setting_t *setting, int idx, long long value); - config_setting_t * (*setting_set_float_elem) (config_setting_t *setting, int idx, double value); - config_setting_t * (*setting_set_bool_elem) (config_setting_t *setting, int idx, int value); - config_setting_t * (*setting_set_string_elem) (config_setting_t *setting, int idx, const char *value); - - int (*setting_index) (const config_setting_t *setting); - int (*setting_length) (const config_setting_t *setting); - - config_setting_t * (*setting_get_elem) (const config_setting_t *setting, unsigned int idx); - config_setting_t * (*setting_get_member) (const config_setting_t *setting, const char *name); - - config_setting_t * (*setting_add) (config_setting_t *parent, const char *name, int type); - int (*setting_remove) (config_setting_t *parent, const char *name); - - int (*setting_remove_elem) (config_setting_t *parent, unsigned int idx); - void (*setting_set_hook) (config_setting_t *setting, void *hook); - - config_setting_t * (*lookup) (const config_t *config, const char *filepath); - config_setting_t * (*lookup_from) (config_setting_t *setting, const char *filepath); - int (*lookup_int) (const config_t *config, const char *filepath, int *value); - int (*lookup_int64) (const config_t *config, const char *filepath, long long *value); - int (*lookup_float) (const config_t *config, const char *filepath, double *value); - int (*lookup_bool) (const config_t *config, const char *filepath, int *value); - int (*lookup_string) (const config_t *config, const char *filepath, const char **value); + int (*read_string) (struct config_t *config, const char *str); + int (*read_file_src) (struct config_t *config, const char *filename); + int (*write_file) (struct config_t *config, const char *filename); + + void (*set_destructor) (struct config_t *config, void (*destructor)(void *)); + void (*set_include_dir) (struct config_t *config, const char *include_dir); + + void (*init) (struct config_t *config); + void (*destroy) (struct config_t *config); + + int (*setting_get_int) (const struct config_setting_t *setting); + long long (*setting_get_int64) (const struct config_setting_t *setting); + double (*setting_get_float) (const struct config_setting_t *setting); + + int (*setting_get_bool) (const struct config_setting_t *setting); + + const char * (*setting_get_string) (const struct config_setting_t *setting); + + struct config_setting_t * (*setting_lookup) (struct config_setting_t *setting, const char *name); + int (*setting_lookup_int) (const struct config_setting_t *setting, const char *name, int *value); + int (*setting_lookup_int64) (const struct config_setting_t *setting, const char *name, long long *value); + int (*setting_lookup_float) (const struct config_setting_t *setting, const char *name, double *value); + int (*setting_lookup_bool) (const struct config_setting_t *setting, const char *name, int *value); + int (*setting_lookup_string) (const struct config_setting_t *setting, const char *name, const char **value); + int (*setting_set_int) (struct config_setting_t *setting ,int value); + int (*setting_set_int64) (struct config_setting_t *setting, long long value); + int (*setting_set_float) (struct config_setting_t *setting, double value); + int (*setting_set_bool) (struct config_setting_t *setting, int value); + int (*setting_set_string) (struct config_setting_t *setting, const char *value); + + int (*setting_set_format) (struct config_setting_t *setting, short format); + short (*setting_get_format) (const struct config_setting_t *setting); + + int (*setting_get_int_elem) (const struct config_setting_t *setting, int idx); + long long (*setting_get_int64_elem) (const struct config_setting_t *setting, int idx); + double (*setting_get_float_elem) (const struct config_setting_t *setting, int idx); + int (*setting_get_bool_elem) (const struct config_setting_t *setting, int idx); + const char * (*setting_get_string_elem) (const struct config_setting_t *setting, int idx); + struct config_setting_t * (*setting_set_int_elem) (struct config_setting_t *setting, int idx, int value); + struct config_setting_t * (*setting_set_int64_elem) (struct config_setting_t *setting, int idx, long long value); + struct config_setting_t * (*setting_set_float_elem) (struct config_setting_t *setting, int idx, double value); + struct config_setting_t * (*setting_set_bool_elem) (struct config_setting_t *setting, int idx, int value); + struct config_setting_t * (*setting_set_string_elem) (struct config_setting_t *setting, int idx, const char *value); + + int (*setting_index) (const struct config_setting_t *setting); + int (*setting_length) (const struct config_setting_t *setting); + + struct config_setting_t * (*setting_get_elem) (const struct config_setting_t *setting, unsigned int idx); + struct config_setting_t * (*setting_get_member) (const struct config_setting_t *setting, const char *name); + + struct config_setting_t * (*setting_add) (struct config_setting_t *parent, const char *name, int type); + int (*setting_remove) (struct config_setting_t *parent, const char *name); + + int (*setting_remove_elem) (struct config_setting_t *parent, unsigned int idx); + void (*setting_set_hook) (struct config_setting_t *setting, void *hook); + + struct config_setting_t * (*lookup) (const struct config_t *config, const char *filepath); + int (*lookup_int) (const struct config_t *config, const char *filepath, int *value); + int (*lookup_int64) (const struct config_t *config, const char *filepath, long long *value); + int (*lookup_float) (const struct config_t *config, const char *filepath, double *value); + int (*lookup_bool) (const struct config_t *config, const char *filepath, int *value); + int (*lookup_string) (const struct config_t *config, const char *filepath, const char **value); /* those are custom and are from src/common/conf.c */ /* Functions to copy settings from libconfig/contrib */ - int (*read_file) (config_t *config, const char *config_filename); - void (*setting_copy_simple) (config_setting_t *parent, const config_setting_t *src); - void (*setting_copy_elem) (config_setting_t *parent, const config_setting_t *src); - void (*setting_copy_aggregate) (config_setting_t *parent, const config_setting_t *src); - int (*setting_copy) (config_setting_t *parent, const config_setting_t *src); + int (*load_file) (struct config_t *config, const char *config_filename); + void (*setting_copy_simple) (struct config_setting_t *parent, const struct config_setting_t *src); + void (*setting_copy_elem) (struct config_setting_t *parent, const struct config_setting_t *src); + void (*setting_copy_aggregate) (struct config_setting_t *parent, const struct config_setting_t *src); + int (*setting_copy) (struct config_setting_t *parent, const struct config_setting_t *src); + /* Functions to get other types */ + bool (*setting_get_bool_real) (const struct config_setting_t *setting); + uint32 (*setting_get_uint32) (const struct config_setting_t *setting); + uint16 (*setting_get_uint16) (const struct config_setting_t *setting); + int16 (*setting_get_int16) (const struct config_setting_t *setting); + + int (*setting_lookup_bool_real) (const struct config_setting_t *setting, const char *name, bool *value); + int (*setting_lookup_uint32) (const struct config_setting_t *setting, const char *name, uint32 *value); + int (*setting_lookup_uint16) (const struct config_setting_t *setting, const char *name, uint16 *value); + int (*setting_lookup_int16) (const struct config_setting_t *setting, const char *name, int16 *value); + int (*setting_lookup_mutable_string) (const struct config_setting_t *setting, const char *name, char *out, size_t out_size); + int (*lookup_mutable_string) (const struct config_t *config, const char *name, char *out, size_t out_size); }; #ifdef HERCULES_CORE |