diff options
author | Ailin Nemui <ailin@esf51.localdomain> | 2015-01-07 03:40:34 +0100 |
---|---|---|
committer | Ailin Nemui <ailin@linux.site> | 2015-02-17 09:50:55 +0100 |
commit | 96d4fb9156bcef6fc14dbec43dfa0fcd0226d46f (patch) | |
tree | 27a1023f98d6a1b908fc4ce65995723cc5c56746 /src/core | |
parent | 6b08cbe906bc2f13a34aca3195f8808d709c160c (diff) | |
download | irssi-96d4fb9156bcef6fc14dbec43dfa0fcd0226d46f.zip |
add CONFIG_REC to config_node_section* APIs
this adds the CONFIG_REC * to the config_node_section and
config_node_section_index APIs as they will require access to the config
cache later on to make the config parser more robust.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/channels-setup.c | 2 | ||||
-rw-r--r-- | src/core/chatnets.c | 2 | ||||
-rw-r--r-- | src/core/ignore.c | 6 | ||||
-rw-r--r-- | src/core/log.c | 8 | ||||
-rw-r--r-- | src/core/servers-setup.c | 2 | ||||
-rw-r--r-- | src/core/session.c | 14 | ||||
-rw-r--r-- | src/core/settings.c | 14 | ||||
-rw-r--r-- | src/core/settings.h | 2 |
8 files changed, 26 insertions, 24 deletions
diff --git a/src/core/channels-setup.c b/src/core/channels-setup.c index e1289c23..b2d971dd 100644 --- a/src/core/channels-setup.c +++ b/src/core/channels-setup.c @@ -40,7 +40,7 @@ static void channel_setup_save(CHANNEL_SETUP_REC *channel) parentnode = iconfig_node_traverse("(channels", TRUE); node = config_node_nth(parentnode, index); if (node == NULL) - node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(parentnode, NULL, NODE_TYPE_BLOCK); iconfig_node_clear(node); iconfig_node_set_str(node, "name", channel->name); diff --git a/src/core/chatnets.c b/src/core/chatnets.c index 3c794ab4..dd4d94b3 100644 --- a/src/core/chatnets.c +++ b/src/core/chatnets.c @@ -36,7 +36,7 @@ static void chatnet_config_save(CHATNET_REC *chatnet) CONFIG_NODE *node; node = iconfig_node_traverse("chatnets", TRUE); - node = config_node_section(node, chatnet->name, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, chatnet->name, NODE_TYPE_BLOCK); iconfig_node_clear(node); iconfig_node_set_str(node, "type", chat_protocol_find_id(chatnet->chat_type)->name); diff --git a/src/core/ignore.c b/src/core/ignore.c index 68fae11f..2d18f865 100644 --- a/src/core/ignore.c +++ b/src/core/ignore.c @@ -263,7 +263,7 @@ static void ignore_set_config(IGNORE_REC *rec) return; node = iconfig_node_traverse("(ignores", TRUE); - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK); if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask); if (rec->level) { @@ -281,7 +281,7 @@ static void ignore_set_config(IGNORE_REC *rec) iconfig_node_set_str(node, "servertag", rec->servertag); if (rec->channels != NULL && *rec->channels != NULL) { - node = config_node_section(node, "channels", NODE_TYPE_LIST); + node = iconfig_node_section(node, "channels", NODE_TYPE_LIST); iconfig_node_add_list(node, rec->channels); } } @@ -436,7 +436,7 @@ static void read_ignores(void) rec->unignore_time = config_node_get_int(node, "unignore_time", 0); rec->servertag = g_strdup(config_node_get_str(node, "servertag", 0)); - node = config_node_section(node, "channels", -1); + node = iconfig_node_section(node, "channels", -1); if (node != NULL) rec->channels = config_node_get_list(node); ignore_init_rec(rec); diff --git a/src/core/log.c b/src/core/log.c index d4d3853e..c9732d6d 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -332,11 +332,11 @@ static void log_items_update_config(LOG_REC *log, CONFIG_NODE *parent) GSList *tmp; CONFIG_NODE *node; - parent = config_node_section(parent, "items", NODE_TYPE_LIST); + parent = iconfig_node_section(parent, "items", NODE_TYPE_LIST); for (tmp = log->items; tmp != NULL; tmp = tmp->next) { LOG_ITEM_REC *rec = tmp->data; - node = config_node_section(parent, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(parent, NULL, NODE_TYPE_BLOCK); iconfig_node_set_str(node, "type", log_item_types[rec->type]); iconfig_node_set_str(node, "name", rec->name); iconfig_node_set_str(node, "server", rec->servertag); @@ -352,7 +352,7 @@ static void log_update_config(LOG_REC *log) return; node = iconfig_node_traverse("logs", TRUE); - node = config_node_section(node, log->fname, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, log->fname, NODE_TYPE_BLOCK); if (log->autoopen) iconfig_node_set_bool(node, "auto_open", TRUE); @@ -544,7 +544,7 @@ static void log_read_config(void) signal_emit("log config read", 2, log, node); - node = config_node_section(node, "items", -1); + node = iconfig_node_section(node, "items", -1); if (node != NULL) log_items_read_config(node, log); diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 27d9f1f0..e648eb36 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -430,7 +430,7 @@ static void server_setup_save(SERVER_SETUP_REC *rec) parentnode = iconfig_node_traverse("(servers", TRUE); node = config_node_nth(parentnode, index); if (node == NULL) - node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(parentnode, NULL, NODE_TYPE_BLOCK); iconfig_node_clear(node); iconfig_node_set_str(node, "address", rec->address); diff --git a/src/core/session.c b/src/core/session.c index b3002632..ca3bf22f 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -92,7 +92,7 @@ static void cmd_upgrade(const char *data) static void session_save_nick(CHANNEL_REC *channel, NICK_REC *nick, CONFIG_REC *config, CONFIG_NODE *node) { - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = config_node_section(config, node, NULL, NODE_TYPE_BLOCK); config_node_set_str(config, node, "nick", nick->nick); config_node_set_bool(config, node, "op", nick->op); @@ -109,7 +109,7 @@ static void session_save_channel_nicks(CHANNEL_REC *channel, CONFIG_REC *config, { GSList *tmp, *nicks; - node = config_node_section(node, "nicks", NODE_TYPE_LIST); + node = config_node_section(config, node, "nicks", NODE_TYPE_LIST); nicks = nicklist_getnicks(channel); for (tmp = nicks; tmp != NULL; tmp = tmp->next) session_save_nick(channel, tmp->data, config, node); @@ -119,7 +119,7 @@ static void session_save_channel_nicks(CHANNEL_REC *channel, CONFIG_REC *config, static void session_save_channel(CHANNEL_REC *channel, CONFIG_REC *config, CONFIG_NODE *node) { - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = config_node_section(config, node, NULL, NODE_TYPE_BLOCK); config_node_set_str(config, node, "name", channel->name); config_node_set_str(config, node, "visible_name", channel->visible_name); @@ -138,7 +138,7 @@ static void session_save_server_channels(SERVER_REC *server, GSList *tmp; /* save channels */ - node = config_node_section(node, "channels", NODE_TYPE_LIST); + node = config_node_section(config, node, "channels", NODE_TYPE_LIST); for (tmp = server->channels; tmp != NULL; tmp = tmp->next) session_save_channel(tmp->data, config, node); } @@ -148,7 +148,7 @@ static void session_save_server(SERVER_REC *server, CONFIG_REC *config, { int handle; - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = config_node_section(config, node, NULL, NODE_TYPE_BLOCK); config_node_set_str(config, node, "chat_type", chat_protocol_find_id(server->chat_type)->name); @@ -187,7 +187,7 @@ static void session_restore_channel_nicks(CHANNEL_REC *channel, GSList *tmp; /* restore nicks */ - node = config_node_section(node, "nicks", -1); + node = config_node_section(NULL, node, "nicks", -1); if (node != NULL && node->type == NODE_TYPE_LIST) { tmp = config_node_first(node->value); for (; tmp != NULL; tmp = config_node_next(tmp)) { @@ -223,7 +223,7 @@ static void session_restore_server_channels(SERVER_REC *server, GSList *tmp; /* restore channels */ - node = config_node_section(node, "channels", -1); + node = config_node_section(NULL, node, "channels", -1); if (node != NULL && node->type == NODE_TYPE_LIST) { tmp = config_node_first(node->value); for (; tmp != NULL; tmp = config_node_next(tmp)) diff --git a/src/core/settings.c b/src/core/settings.c index 2296909e..6c536180 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -77,7 +77,7 @@ settings_get_str_type(const char *key, SettingType type) if (rec == NULL) return NULL; node = iconfig_node_traverse("settings", FALSE); - node = node == NULL ? NULL : config_node_section(node, rec->module, -1); + node = node == NULL ? NULL : iconfig_node_section(node, rec->module, -1); return node == NULL ? rec->default_value.v_string : config_node_get_str(node, key, rec->default_value.v_string); @@ -97,7 +97,7 @@ int settings_get_int(const char *key) if (rec == NULL) return 0; node = iconfig_node_traverse("settings", FALSE); - node = node == NULL ? NULL : config_node_section(node, rec->module, -1); + node = node == NULL ? NULL : iconfig_node_section(node, rec->module, -1); return node == NULL ? rec->default_value.v_int : config_node_get_int(node, key, rec->default_value.v_int); @@ -112,7 +112,7 @@ int settings_get_bool(const char *key) if (rec == NULL) return FALSE; node = iconfig_node_traverse("settings", FALSE); - node = node == NULL ? NULL : config_node_section(node, rec->module, -1); + node = node == NULL ? NULL : iconfig_node_section(node, rec->module, -1); return node == NULL ? rec->default_value.v_bool : config_node_get_bool(node, key, rec->default_value.v_bool); @@ -324,7 +324,7 @@ static CONFIG_NODE *settings_get_node(const char *key) } node = iconfig_node_traverse("settings", TRUE); - return config_node_section(node, rec->module, NODE_TYPE_BLOCK); + return iconfig_node_section(node, rec->module, NODE_TYPE_BLOCK); } void settings_set_str(const char *key, const char *value) @@ -420,7 +420,7 @@ static void settings_clean_invalid_module(const char *module) node = iconfig_node_traverse("settings", FALSE); if (node == NULL) return; - node = config_node_section(node, module, -1); + node = iconfig_node_section(node, module, -1); if (node == NULL) return; for (tmp = config_node_first(node->value); tmp != NULL; tmp = next) { @@ -468,7 +468,7 @@ static int backwards_compatibility(const char *module, CONFIG_NODE *node, g_strdup(node->value); new_node = iconfig_node_traverse("settings", FALSE); new_node = new_node == NULL ? NULL : - config_node_section(new_node, new_module, -1); + iconfig_node_section(new_node, new_module, -1); config_node_set_str(mainconfig, new_node, new_key, new_value); @@ -502,7 +502,7 @@ void settings_check_module(const char *module) g_return_if_fail(module != NULL); node = iconfig_node_traverse("settings", FALSE); - node = node == NULL ? NULL : config_node_section(node, module, -1); + node = node == NULL ? NULL : iconfig_node_section(node, module, -1); if (node == NULL) return; errors = g_string_new(NULL); diff --git a/src/core/settings.h b/src/core/settings.h index f8d9f68f..af00cc80 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -36,6 +36,8 @@ typedef struct { #define iconfig_set_int(a, b, c) config_set_int(mainconfig, a, b, c) #define iconfig_set_bool(a, b, c) config_set_bool(mainconfig, a, b, c) +#define iconfig_node_section(a, b, c) config_node_section(mainconfig, a, b, c) +#define iconfig_node_section_index(a, b, c, d) config_node_section_index(mainconfig, a, b, c, d) #define iconfig_node_traverse(a, b) config_node_traverse(mainconfig, a, b) #define iconfig_node_set_str(a, b, c) config_node_set_str(mainconfig, a, b, c) #define iconfig_node_set_int(a, b, c) config_node_set_int(mainconfig, a, b, c) |