summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/channels-setup.c2
-rw-r--r--src/core/chatnets.c2
-rw-r--r--src/core/ignore.c6
-rw-r--r--src/core/log.c8
-rw-r--r--src/core/servers-setup.c2
-rw-r--r--src/core/session.c14
-rw-r--r--src/core/settings.c14
-rw-r--r--src/core/settings.h2
-rw-r--r--src/fe-common/core/completion.c4
-rw-r--r--src/fe-common/core/hilight-text.c6
-rw-r--r--src/fe-common/core/keyboard.c2
-rw-r--r--src/fe-common/core/themes.c4
-rw-r--r--src/fe-common/core/windows-layout.c9
-rw-r--r--src/fe-text/irssi.c3
-rw-r--r--src/fe-text/mainwindows-layout.c3
-rw-r--r--src/fe-text/statusbar-config.c20
-rw-r--r--src/irc/core/irc-session.c4
-rw-r--r--src/irc/notifylist/notify-setup.c6
-rw-r--r--src/lib-config/get.c60
-rw-r--r--src/lib-config/iconfig.h4
-rw-r--r--src/lib-config/parse.c4
-rw-r--r--src/lib-config/set.c6
22 files changed, 119 insertions, 66 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 beca1427..e70b741b 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 35e42544..8306d2df 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 e88e85c7..90a447d4 100644
--- a/src/core/servers-setup.c
+++ b/src/core/servers-setup.c
@@ -433,7 +433,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 e49162b2..17d80076 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);
@@ -188,7 +188,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)) {
@@ -224,7 +224,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 2c43fd10..b34a5766 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 c607a884..312e417c 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 beb4ed7a..87c5d467 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 eac8525b..f138d4e2 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 0ef98fee..58e7b557 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..8ebcc12d 100644
--- a/src/fe-common/core/windows-layout.c
+++ b/src/fe-common/core/windows-layout.c
@@ -127,6 +127,7 @@ static void sig_layout_restore(void)
for (; tmp != NULL; tmp = config_node_next(tmp)) {
CONFIG_NODE *node = tmp->data;
+ if (node->key == NULL) continue;
window = window_find_refnum(atoi(node->key));
if (window == NULL)
window = window_create(NULL, TRUE);
@@ -143,7 +144,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 +161,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 +186,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 +196,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/irssi.c b/src/fe-text/irssi.c
index 77033d7a..6d5b9b13 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -310,6 +310,7 @@ int main(int argc, char **argv)
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL },
{ NULL }
};
+ int loglev;
#ifdef USE_GC
g_mem_set_vtable(&gc_mem_table);
@@ -352,6 +353,7 @@ int main(int argc, char **argv)
you have to call setlocale(LC_ALL, "") */
setlocale(LC_ALL, "");
+ loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK | G_LOG_LEVEL_CRITICAL);
textui_init();
if (!dummy && !term_init()) {
@@ -360,6 +362,7 @@ int main(int argc, char **argv)
return 1;
}
+ g_log_set_always_fatal(loglev);
textui_finish_init();
main_loop = g_main_new(TRUE);
diff --git a/src/fe-text/mainwindows-layout.c b/src/fe-text/mainwindows-layout.c
index 28fae924..020969e6 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);
@@ -179,6 +179,7 @@ static void sig_layout_restore(void)
lower_window = NULL; lower_size = 0;
for (i = 0, tmp = sorted_config; i < windows_count; tmp = tmp->next, i++) {
CONFIG_NODE *node = tmp->data;
+ if (node->key == NULL) continue;
/* create a new window + mainwindow */
signal_emit("gui window create override", 1,
diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c
index 7b3fe252..a47a709e 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..53d744da 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;
@@ -54,7 +54,6 @@ CONFIG_NODE *config_node_section_index(CONFIG_NODE *parent, const char *key,
node = key == NULL ? NULL : config_node_find(parent, key);
if (node != NULL) {
- g_return_val_if_fail(new_type == -1 || new_type == node->type, NULL);
nindex = g_slist_index(parent->value, node);
if (index >= 0 && nindex != index &&
nindex <= g_slist_length(parent->value)) {
@@ -62,7 +61,25 @@ CONFIG_NODE *config_node_section_index(CONFIG_NODE *parent, const char *key,
parent->value = g_slist_remove(parent->value, node);
parent->value = g_slist_insert(parent->value, node, index);
}
- return node;
+ if (!is_node_list(node)) {
+ int show_error = 0;
+
+ if (new_type != -1) {
+ config_node_remove(rec, parent, node);
+ node = NULL;
+ show_error = 1;
+ } else if (!g_hash_table_contains(rec->cache_nodes, node)) {
+ g_hash_table_insert(rec->cache_nodes, node, NULL);
+ show_error = 1;
+ }
+ if (show_error)
+ g_critical("Expected %s node at `..%s/%s' was of scalar type. Corrupt config?",
+ new_type == NODE_TYPE_LIST ? "list" : new_type == NODE_TYPE_BLOCK ? "block" : "section",
+ parent->key, key);
+ } else {
+ g_return_val_if_fail(new_type == -1 || new_type == node->type, NULL);
+ return node;
+ }
}
if (new_type == -1)
@@ -91,7 +108,21 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea
/* check if it already exists in cache */
node = g_hash_table_lookup(rec->cache, section);
- if (node != NULL) return node;
+ if (node != NULL) {
+ if (create) {
+ const char *path = strrchr(section, '/');
+ if (path == NULL) path = section;
+ else path++;
+ new_type = *path == '(' ? NODE_TYPE_LIST : NODE_TYPE_BLOCK;
+ if (node->type != new_type) {
+ g_critical("Expected %s node at `%s' was of %s type. Corrupt config?",
+ new_type == NODE_TYPE_LIST ? "list" : "block", section,
+ node->type == NODE_TYPE_LIST ? "list" : "block");
+ node->type = new_type;
+ }
+ }
+ return node;
+ }
new_type = -1;
@@ -99,9 +130,18 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea
list = g_strsplit(section, "/", -1);
for (tmp = list; *tmp != NULL; tmp++) {
is_list = **tmp == '(';
- if (create) new_type = is_list ? NODE_TYPE_LIST : NODE_TYPE_BLOCK;
+ if (create) {
+ CONFIG_NODE *tmpnode;
+
+ new_type = is_list ? NODE_TYPE_LIST : NODE_TYPE_BLOCK;
+ tmpnode = config_node_find(node, *tmp + is_list);
+ if (tmpnode != NULL && tmpnode->type != new_type) {
+ g_critical("Expected %s node at `%s' was of scalar type. Corrupt config?", is_list ? "list" : "block", section);
+ config_node_remove(rec, node, tmpnode);
+ }
+ }
- 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;
@@ -109,9 +149,9 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea
}
g_strfreev(list);
- if (!is_node_list(node)) {
+ if (!is_node_list(node)) {
/* Will die. Better to not corrupt the config further in this case. */
- g_error("Attempt to use non-list node as list. Corrupt config?");
+ g_critical("Attempt to use non-list node `%s' as list. Corrupt config?", section);
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);
diff --git a/src/lib-config/set.c b/src/lib-config/set.c
index 3d6001e1..7ca55871 100644
--- a/src/lib-config/set.c
+++ b/src/lib-config/set.c
@@ -104,6 +104,12 @@ void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key,
return;
}
+ if (node != NULL && !has_node_value(node)) {
+ g_critical("Expected scalar node at `..%s/%s' was of complex type. Corrupt config?",
+ parent->key, key);
+ config_node_remove(rec, parent, node);
+ node = NULL;
+ }
if (node != NULL) {
if (g_strcmp0(node->value, value) == 0)
return;