summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/HPM.c6
-rw-r--r--src/common/conf.c55
-rw-r--r--src/common/conf.h164
-rw-r--r--src/common/showmsg.c4
-rw-r--r--src/common/showmsg.h2
-rw-r--r--src/common/socket.c4
-rw-r--r--src/common/socket.h2
7 files changed, 120 insertions, 117 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 0cb23019a..f115c886e 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -616,8 +616,8 @@ CMDLINEARG(loadplugin)
* Reads the plugin configuration and loads the plugins as necessary.
*/
void hplugins_config_read(void) {
- config_t plugins_conf;
- config_setting_t *plist = NULL;
+ struct config_t plugins_conf;
+ struct config_setting_t *plist = NULL;
const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name
FILE *fp;
int i;
@@ -633,7 +633,7 @@ void hplugins_config_read(void) {
plist = libconfig->lookup(&plugins_conf, "plugins_list");
for (i = 0; i < VECTOR_LENGTH(HPM->cmdline_load_plugins); i++) {
- config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING);
+ struct config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING);
config_setting_set_string(entry, VECTOR_INDEX(HPM->cmdline_load_plugins, i));
}
diff --git a/src/common/conf.c b/src/common/conf.c
index ca9b7cbbc..25f1013f5 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -43,7 +43,7 @@ struct libconfig_interface *libconfig;
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_load_file(config_t *config, const char *config_filename)
+int config_load_file(struct config_t *config, const char *config_filename)
{
libconfig->init(config);
if (libconfig->read_file_src(config, config_filename) != CONFIG_TRUE) {
@@ -58,12 +58,12 @@ int config_load_file(config_t *config, const char *config_filename)
//
// Functions to copy settings from libconfig/contrib
//
-void config_setting_copy_simple(config_setting_t *parent, const config_setting_t *src) {
+void config_setting_copy_simple(struct config_setting_t *parent, const struct config_setting_t *src)
+{
if (config_setting_is_aggregate(src)) {
libconfig->setting_copy_aggregate(parent, src);
- }
- else {
- config_setting_t *set;
+ } else {
+ struct config_setting_t *set;
if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL )
return;
@@ -87,8 +87,9 @@ void config_setting_copy_simple(config_setting_t *parent, const config_setting_t
}
}
-void config_setting_copy_elem(config_setting_t *parent, const config_setting_t *src) {
- config_setting_t *set = NULL;
+void config_setting_copy_elem(struct config_setting_t *parent, const struct config_setting_t *src)
+{
+ struct config_setting_t *set = NULL;
if (config_setting_is_aggregate(src))
libconfig->setting_copy_aggregate(parent, src);
@@ -107,8 +108,9 @@ void config_setting_copy_elem(config_setting_t *parent, const config_setting_t *
}
}
-void config_setting_copy_aggregate(config_setting_t *parent, const config_setting_t *src) {
- config_setting_t *newAgg;
+void config_setting_copy_aggregate(struct config_setting_t *parent, const struct config_setting_t *src)
+{
+ struct config_setting_t *newAgg;
int i, n;
if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL )
@@ -130,7 +132,8 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin
}
}
-int config_setting_copy(config_setting_t *parent, const config_setting_t *src) {
+int config_setting_copy(struct config_setting_t *parent, const struct config_setting_t *src)
+{
if (!config_setting_is_group(parent) && !config_setting_is_list(parent))
return CONFIG_FALSE;
@@ -150,7 +153,7 @@ int config_setting_copy(config_setting_t *parent, const config_setting_t *src) {
* @return The converted value.
* @retval false in case of failure.
*/
-bool config_setting_get_bool_real(const config_setting_t *setting)
+bool config_setting_get_bool_real(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_BOOL)
return false;
@@ -168,9 +171,9 @@ bool config_setting_get_bool_real(const config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_bool_real(const config_setting_t *setting, const char *name, bool *value)
+int config_setting_lookup_bool_real(const struct config_setting_t *setting, const char *name, bool *value)
{
- config_setting_t *member = config_setting_get_member(setting, name);
+ struct config_setting_t *member = config_setting_get_member(setting, name);
if (!member)
return CONFIG_FALSE;
@@ -191,7 +194,7 @@ int config_setting_lookup_bool_real(const config_setting_t *setting, const char
* @return The converted value.
* @retval 0 in case of failure.
*/
-uint32 config_setting_get_uint32(const config_setting_t *setting)
+uint32 config_setting_get_uint32(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -212,9 +215,9 @@ uint32 config_setting_get_uint32(const config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_uint32(const config_setting_t *setting, const char *name, uint32 *value)
+int config_setting_lookup_uint32(const struct config_setting_t *setting, const char *name, uint32 *value)
{
- config_setting_t *member = config_setting_get_member(setting, name);
+ struct config_setting_t *member = config_setting_get_member(setting, name);
if (!member)
return CONFIG_FALSE;
@@ -235,7 +238,7 @@ int config_setting_lookup_uint32(const config_setting_t *setting, const char *na
* @return The converted value.
* @retval 0 in case of failure.
*/
-uint16 config_setting_get_uint16(const config_setting_t *setting)
+uint16 config_setting_get_uint16(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -258,9 +261,9 @@ uint16 config_setting_get_uint16(const config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_uint16(const config_setting_t *setting, const char *name, uint16 *value)
+int config_setting_lookup_uint16(const struct config_setting_t *setting, const char *name, uint16 *value)
{
- config_setting_t *member = config_setting_get_member(setting, name);
+ struct config_setting_t *member = config_setting_get_member(setting, name);
if (!member)
return CONFIG_FALSE;
@@ -281,7 +284,7 @@ int config_setting_lookup_uint16(const config_setting_t *setting, const char *na
* @return The converted value.
* @retval 0 in case of failure.
*/
-int16 config_setting_get_int16(const config_setting_t *setting)
+int16 config_setting_get_int16(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -304,9 +307,9 @@ int16 config_setting_get_int16(const config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_int16(const config_setting_t *setting, const char *name, int16 *value)
+int config_setting_lookup_int16(const struct config_setting_t *setting, const char *name, int16 *value)
{
- config_setting_t *member = config_setting_get_member(setting, name);
+ struct config_setting_t *member = config_setting_get_member(setting, name);
if (!member)
return CONFIG_FALSE;
@@ -320,7 +323,7 @@ int config_setting_lookup_int16(const config_setting_t *setting, const char *nam
}
/**
- * Looks up a configuration entry of type CONFIG_TYPE_STRING inside a config_setting_t and copies it into a (non-const) char buffer.
+ * Looks up a configuration entry of type CONFIG_TYPE_STRING inside a struct config_setting_t and copies it into a (non-const) char buffer.
*
* @param[in] setting The setting to read.
* @param[in] name The setting name to lookup.
@@ -330,7 +333,7 @@ int config_setting_lookup_int16(const config_setting_t *setting, const char *nam
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_mutable_string(const config_setting_t *setting, const char *name, char *out, size_t out_size)
+int config_setting_lookup_mutable_string(const struct config_setting_t *setting, const char *name, char *out, size_t out_size)
{
const char *str = NULL;
@@ -343,7 +346,7 @@ int config_setting_lookup_mutable_string(const config_setting_t *setting, const
}
/**
- * Looks up a configuration entry of type CONFIG_TYPE_STRING inside a config_t and copies it into a (non-const) char buffer.
+ * Looks up a configuration entry of type CONFIG_TYPE_STRING inside a struct config_t and copies it into a (non-const) char buffer.
*
* @param[in] config The configuration to read.
* @param[in] name The setting name to lookup.
@@ -353,7 +356,7 @@ int config_setting_lookup_mutable_string(const config_setting_t *setting, const
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_lookup_mutable_string(const config_t *config, const char *name, char *out, size_t out_size)
+int config_lookup_mutable_string(const struct config_t *config, const char *name, char *out, size_t out_size)
{
const char *str = NULL;
diff --git a/src/common/conf.h b/src/common/conf.h
index 3bcb4526f..f2bfcac62 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -29,94 +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_options) (config_t *config, int options);
- int (*get_options) (const config_t *config);
+ 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);
-
- config_setting_t * (*setting_lookup) (config_setting_t *setting, const char *name);
- 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);
- 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 (*load_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 config_setting_t *setting);
- uint32 (*setting_get_uint32) (const config_setting_t *setting);
- uint16 (*setting_get_uint16) (const config_setting_t *setting);
- int16 (*setting_get_int16) (const config_setting_t *setting);
-
- int (*setting_lookup_bool_real) (const config_setting_t *setting, const char *name, bool *value);
- int (*setting_lookup_uint32) (const config_setting_t *setting, const char *name, uint32 *value);
- int (*setting_lookup_uint16) (const config_setting_t *setting, const char *name, uint16 *value);
- int (*setting_lookup_int16) (const config_setting_t *setting, const char *name, int16 *value);
- int (*setting_lookup_mutable_string) (const config_setting_t *setting, const char *name, char *out, size_t out_size);
- int (*lookup_mutable_string) (const config_t *config, const char *name, char *out, size_t out_size);
+ 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
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 956222a7d..9e2ff9898 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -799,8 +799,8 @@ void showmsg_showWarning(const char *string, ...)
vShowMessage_(MSG_WARNING, string, ap);
va_end(ap);
}
-void showmsg_showConfigWarning(config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
-void showmsg_showConfigWarning(config_setting_t *config, const char *string, ...)
+void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
+void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...)
{
StringBuf buf;
va_list ap;
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index ed8776fb0..85a1527bd 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -118,7 +118,7 @@ struct showmsg_interface {
void (*showDebug) (const char *, ...) __attribute__((format(printf, 1, 2)));
void (*showError) (const char *, ...) __attribute__((format(printf, 1, 2)));
void (*showFatalError) (const char *, ...) __attribute__((format(printf, 1, 2)));
- void (*showConfigWarning) (config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
+ void (*showConfigWarning) (struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
};
/* the purpose of these macros is simply to not make calling them be an annoyance */
diff --git a/src/common/socket.c b/src/common/socket.c
index be144fd50..1fc1b2bff 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -1686,7 +1686,7 @@ bool socket_trusted_ip_check(uint32 ip)
* @param[in] groupname Current group name, for output/logging reasons.
* @return The amount of entries read, zero in case of errors.
*/
-int socket_net_config_read_sub(config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname)
+int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname)
{
int i, len;
char ipbuf[64], maskbuf[64];
@@ -1722,7 +1722,7 @@ int socket_net_config_read_sub(config_setting_t *t, struct s_subnet_vector *list
*/
void socket_net_config_read(const char *filename)
{
- config_t network_config;
+ struct config_t network_config;
int i;
nullpo_retv(filename);
diff --git a/src/common/socket.h b/src/common/socket.h
index e99278052..5103c3850 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -214,7 +214,7 @@ struct socket_interface {
uint32 (*lan_subnet_check) (uint32 ip, struct s_subnet *info);
bool (*allowed_ip_check) (uint32 ip);
bool (*trusted_ip_check) (uint32 ip);
- int (*net_config_read_sub) (config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname);
+ int (*net_config_read_sub) (struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname);
void (*net_config_read) (const char *filename);
};