From 96d4fb9156bcef6fc14dbec43dfa0fcd0226d46f Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Wed, 7 Jan 2015 03:40:34 +0100 Subject: 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. --- src/core/channels-setup.c | 2 +- src/core/chatnets.c | 2 +- src/core/ignore.c | 6 +++--- src/core/log.c | 8 ++++---- src/core/servers-setup.c | 2 +- src/core/session.c | 14 +++++++------- src/core/settings.c | 14 +++++++------- src/core/settings.h | 2 ++ src/fe-common/core/completion.c | 4 ++-- src/fe-common/core/hilight-text.c | 6 +++--- src/fe-common/core/keyboard.c | 2 +- src/fe-common/core/themes.c | 4 ++-- src/fe-common/core/windows-layout.c | 8 ++++---- src/fe-text/mainwindows-layout.c | 2 +- src/fe-text/statusbar-config.c | 20 ++++++++++---------- src/irc/core/irc-session.c | 4 ++-- src/irc/notifylist/notify-setup.c | 6 +++--- src/lib-config/get.c | 8 ++++---- src/lib-config/iconfig.h | 4 ++-- src/lib-config/parse.c | 4 ++-- 20 files changed, 62 insertions(+), 60 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) diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 31d62e10..2223b5b5 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -51,7 +51,7 @@ static const char *completion_find(const char *key, int automatic) if (node == NULL || node->type != NODE_TYPE_BLOCK) return NULL; - node = config_node_section(node, key, -1); + node = iconfig_node_section(node, key, -1); if (node == NULL) return NULL; @@ -785,7 +785,7 @@ static void cmd_completion(const char *data) } else if (*key != '\0' && *value != '\0') { int automatic = g_hash_table_lookup(optlist, "auto") != NULL; - node = config_node_section(node, key, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, key, NODE_TYPE_BLOCK); iconfig_node_set_str(node, "value", value); if (automatic) iconfig_node_set_bool(node, "auto", TRUE); diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 4b914517..de9a3130 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -66,7 +66,7 @@ static void hilight_add_config(HILIGHT_REC *rec) g_return_if_fail(rec != NULL); node = iconfig_node_traverse("(hilights", TRUE); - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK); iconfig_node_set_str(node, "text", rec->text); if (rec->level > 0) iconfig_node_set_int(node, "level", rec->level); @@ -81,7 +81,7 @@ static void hilight_add_config(HILIGHT_REC *rec) if (rec->servertag) 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); } } @@ -471,7 +471,7 @@ static void read_hilight_config(void) rec->servertag = config_node_get_str(node, "servertag", NULL); hilight_init_rec(rec); - node = config_node_section(node, "channels", -1); + node = iconfig_node_section(node, "channels", -1); if (node != NULL) rec->channels = config_node_get_list(node); } diff --git a/src/fe-common/core/keyboard.c b/src/fe-common/core/keyboard.c index bec1502e..02c8a8d7 100644 --- a/src/fe-common/core/keyboard.c +++ b/src/fe-common/core/keyboard.c @@ -135,7 +135,7 @@ static void keyconfig_save(const char *id, const char *key, const char *data) node = key_config_find(key); if (node == NULL) { node = iconfig_node_traverse("(keyboard", TRUE); - node = config_node_section(node, NULL, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK); } iconfig_node_set_str(node, "key", key); diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index c0741cef..cd4039b9 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -739,7 +739,7 @@ static void theme_read_formats(THEME_REC *theme, const char *module, node = config_node_traverse(config, "formats", FALSE); if (node == NULL) return; - node = config_node_section(node, module, -1); + node = config_node_section(config, node, module, -1); if (node == NULL) return; for (tmp = node->value; tmp != NULL; tmp = tmp->next) { @@ -1177,7 +1177,7 @@ static void module_save(const char *module, MODULE_THEME_REC *rec, fnode = config_node_traverse(data->config, "formats", TRUE); - node = config_node_section(fnode, rec->name, NODE_TYPE_BLOCK); + node = config_node_section(data->config, fnode, rec->name, NODE_TYPE_BLOCK); for (n = 1; formats[n].def != NULL; n++) { if (rec->formats[n] != NULL) { config_node_set_str(data->config, node, formats[n].tag, diff --git a/src/fe-common/core/windows-layout.c b/src/fe-common/core/windows-layout.c index 54d7dcbf..d0606bc9 100644 --- a/src/fe-common/core/windows-layout.c +++ b/src/fe-common/core/windows-layout.c @@ -143,7 +143,7 @@ static void sig_layout_restore(void) if (window->theme_name != NULL) window->theme = theme_load(window->theme_name); - window_add_items(window, config_node_section(node, "items", -1)); + window_add_items(window, iconfig_node_section(node, "items", -1)); signal_emit("layout restore window", 2, window, node); } } @@ -160,7 +160,7 @@ static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item, if (type == NULL) return; - subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK); + subnode = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK); iconfig_node_set_str(subnode, "type", type); proto = item->chat_type == 0 ? NULL : @@ -185,7 +185,7 @@ static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node) { GSList *tmp; - node = config_node_section(node, "items", NODE_TYPE_LIST); + node = iconfig_node_section(node, "items", NODE_TYPE_LIST); for (tmp = window->items; tmp != NULL; tmp = tmp->next) signal_emit("layout save item", 3, window, tmp->data, node); } @@ -195,7 +195,7 @@ static void window_save(WINDOW_REC *window, CONFIG_NODE *node) char refnum[MAX_INT_STRLEN]; ltoa(refnum, window->refnum); - node = config_node_section(node, refnum, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, refnum, NODE_TYPE_BLOCK); if (window->sticky_refnum) iconfig_node_set_bool(node, "sticky_refnum", TRUE); diff --git a/src/fe-text/mainwindows-layout.c b/src/fe-text/mainwindows-layout.c index 28fae924..c53f8f72 100644 --- a/src/fe-text/mainwindows-layout.c +++ b/src/fe-text/mainwindows-layout.c @@ -70,7 +70,7 @@ static void main_window_save(MAIN_WINDOW_REC *window, CONFIG_NODE *node) char num[MAX_INT_STRLEN]; ltoa(num, window->active->refnum); - node = config_node_section(node, num, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, num, NODE_TYPE_BLOCK); iconfig_node_set_int(node, "first_line", window->first_line); iconfig_node_set_int(node, "lines", window->height); diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c index deaa1b5d..e8943dac 100644 --- a/src/fe-text/statusbar-config.c +++ b/src/fe-text/statusbar-config.c @@ -177,7 +177,7 @@ static void statusbar_read(STATUSBAR_GROUP_REC *group, CONFIG_NODE *node) bar->placement = STATUSBAR_TOP; bar->position = config_node_get_int(node, "position", 0); - node = config_node_section(node, "items", -1); + node = iconfig_node_section(node, "items", -1); if (node != NULL) { /* we're overriding the items - destroy the old */ while (bar->items != NULL) @@ -227,7 +227,7 @@ static void read_statusbar_config_from_node(CONFIG_NODE *node) CONFIG_NODE *items; GSList *tmp; - items = config_node_section(node, "items", -1); + items = iconfig_node_section(node, "items", -1); if (items != NULL) statusbar_read_items(items); @@ -369,7 +369,7 @@ static void cmd_statusbar_reset(const char *data, void *server, CONFIG_NODE *parent; parent = iconfig_node_traverse("statusbar", TRUE); - parent = config_node_section(parent, active_statusbar_group->name, + parent = iconfig_node_section(parent, active_statusbar_group->name, NODE_TYPE_BLOCK); iconfig_node_set_str(parent, node->key, NULL); @@ -432,7 +432,7 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) CONFIG_NODE *node; GSList *tmp; - node = config_node_section(parent, "items", -1); + node = iconfig_node_section(parent, "items", -1); if (node != NULL) return node; @@ -446,11 +446,11 @@ static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent) /* since items list in config file overrides defaults, we'll need to copy the whole list. */ - parent = config_node_section(parent, "items", NODE_TYPE_BLOCK); + parent = iconfig_node_section(parent, "items", NODE_TYPE_BLOCK); for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_CONFIG_REC *rec = tmp->data; - node = config_node_section(parent, rec->name, + node = iconfig_node_section(parent, rec->name, NODE_TYPE_BLOCK); if (rec->priority != 0) iconfig_node_set_int(node, "priority", rec->priority); @@ -487,7 +487,7 @@ static void cmd_statusbar_add(const char *data, void *server, if (value != NULL) index = config_node_index(node, value)+1; /* create/move item */ - node = config_node_section_index(node, name, index, NODE_TYPE_BLOCK); + node = iconfig_node_section_index(node, name, index, NODE_TYPE_BLOCK); /* set the options */ value = g_hash_table_lookup(optlist, "priority"); @@ -511,7 +511,7 @@ static void cmd_statusbar_remove(const char *data, void *server, if (node == NULL) return; - if (config_node_section(node, data, -1) != NULL) + if (iconfig_node_section(node, data, -1) != NULL) iconfig_node_set_str(node, data, NULL); else { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, @@ -545,9 +545,9 @@ static void cmd_statusbar(const char *data) /* lookup/create the statusbar node */ node = iconfig_node_traverse("statusbar", TRUE); - node = config_node_section(node, active_statusbar_group->name, + node = iconfig_node_section(node, active_statusbar_group->name, NODE_TYPE_BLOCK); - node = config_node_section(node, name, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, name, NODE_TYPE_BLOCK); /* call the subcommand */ signal = g_strconcat("command statusbar ", cmd, NULL); diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c index 42d82734..ea65d8a5 100644 --- a/src/irc/core/irc-session.c +++ b/src/irc/core/irc-session.c @@ -66,7 +66,7 @@ static void sig_session_save_server(IRC_SERVER_REC *server, CONFIG_REC *config, config_node_set_bool(config, node, "emode_known", server->emode_known); config_node_set_bool(config, node, "isupport_sent", server->isupport_sent); - isupport = config_node_section(node, "isupport", NODE_TYPE_BLOCK); + isupport = config_node_section(config, node, "isupport", NODE_TYPE_BLOCK); isupport_data.config = config; isupport_data.node = isupport; @@ -95,7 +95,7 @@ static void sig_session_restore_server(IRC_SERVER_REC *server, (GCompareFunc) g_istr_equal); } - node = config_node_section(node, "isupport", -1); + node = config_node_section(NULL, node, "isupport", -1); tmp = node == NULL ? NULL : config_node_first(node->value); for (; tmp != NULL; tmp = config_node_next(tmp)) { diff --git a/src/irc/notifylist/notify-setup.c b/src/irc/notifylist/notify-setup.c index d6f91361..9ea481ca 100644 --- a/src/irc/notifylist/notify-setup.c +++ b/src/irc/notifylist/notify-setup.c @@ -30,7 +30,7 @@ void notifylist_add_config(NOTIFYLIST_REC *rec) CONFIG_NODE *node; node = iconfig_node_traverse("notifies", TRUE); - node = config_node_section(node, rec->mask, NODE_TYPE_BLOCK); + node = iconfig_node_section(node, rec->mask, NODE_TYPE_BLOCK); if (rec->away_check) iconfig_node_set_bool(node, "away_check", TRUE); @@ -39,7 +39,7 @@ void notifylist_add_config(NOTIFYLIST_REC *rec) iconfig_node_set_str(node, "ircnets", NULL); if (rec->ircnets != NULL && *rec->ircnets != NULL) { - node = config_node_section(node, "ircnets", NODE_TYPE_LIST); + node = iconfig_node_section(node, "ircnets", NODE_TYPE_LIST); iconfig_node_add_list(node, rec->ircnets); } } @@ -73,7 +73,7 @@ void notifylist_read_config(void) rec->mask = g_strdup(node->key); rec->away_check = config_node_get_bool(node, "away_check", FALSE); - node = config_node_section(node, "ircnets", -1); + node = iconfig_node_section(node, "ircnets", -1); if (node != NULL) rec->ircnets = config_node_get_list(node); } } diff --git a/src/lib-config/get.c b/src/lib-config/get.c index af02b048..52785f63 100644 --- a/src/lib-config/get.c +++ b/src/lib-config/get.c @@ -38,12 +38,12 @@ CONFIG_NODE *config_node_find(CONFIG_NODE *node, const char *key) return NULL; } -CONFIG_NODE *config_node_section(CONFIG_NODE *parent, const char *key, int new_type) +CONFIG_NODE *config_node_section(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int new_type) { - return config_node_section_index(parent, key, -1, new_type); + return config_node_section_index(rec, parent, key, -1, new_type); } -CONFIG_NODE *config_node_section_index(CONFIG_NODE *parent, const char *key, +CONFIG_NODE *config_node_section_index(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int index, int new_type) { CONFIG_NODE *node; @@ -101,7 +101,7 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea is_list = **tmp == '('; if (create) new_type = is_list ? NODE_TYPE_LIST : NODE_TYPE_BLOCK; - node = config_node_section(node, *tmp + is_list, new_type); + node = config_node_section(rec, node, *tmp + is_list, new_type); if (node == NULL) { g_strfreev(list); return NULL; diff --git a/src/lib-config/iconfig.h b/src/lib-config/iconfig.h index 3d9eb931..91583e40 100644 --- a/src/lib-config/iconfig.h +++ b/src/lib-config/iconfig.h @@ -116,8 +116,8 @@ int config_set_bool(CONFIG_REC *rec, const char *section, const char *key, int v CONFIG_NODE *config_node_find(CONFIG_NODE *node, const char *key); /* Find the section from node - if not found create it unless new_type is -1. You can also specify in new_type if it's NODE_TYPE_LIST or NODE_TYPE_BLOCK */ -CONFIG_NODE *config_node_section(CONFIG_NODE *parent, const char *key, int new_type); -CONFIG_NODE *config_node_section_index(CONFIG_NODE *parent, const char *key, +CONFIG_NODE *config_node_section(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int new_type); +CONFIG_NODE *config_node_section_index(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int index, int new_type); /* Find the section with the whole path. Create the path if necessary if `create' is TRUE. */ diff --git a/src/lib-config/parse.c b/src/lib-config/parse.c index 1b20195a..c106fc46 100644 --- a/src/lib-config/parse.c +++ b/src/lib-config/parse.c @@ -173,7 +173,7 @@ static GTokenType config_parse_symbol(CONFIG_REC *rec, CONFIG_NODE *node) if (key == NULL && node->type != NODE_TYPE_LIST) return G_TOKEN_ERROR; - newnode = config_node_section(node, key, NODE_TYPE_BLOCK); + newnode = config_node_section(rec, node, key, NODE_TYPE_BLOCK); config_parse_loop(rec, newnode, (GTokenType) '}'); g_free_not_null(key); @@ -188,7 +188,7 @@ static GTokenType config_parse_symbol(CONFIG_REC *rec, CONFIG_NODE *node) /* list */ if (key == NULL) return G_TOKEN_ERROR; - newnode = config_node_section(node, key, NODE_TYPE_LIST); + newnode = config_node_section(rec, node, key, NODE_TYPE_LIST); config_parse_loop(rec, newnode, (GTokenType) ')'); g_free_not_null(key); -- cgit v1.2.3