Exemple #1
0
static void hilight_add_config(HILIGHT_REC *rec)
{
    CONFIG_NODE *node;

    g_return_if_fail(rec != NULL);

    node = iconfig_node_traverse("(hilights", TRUE);
    node = config_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);
    if (rec->color) iconfig_node_set_str(node, "color", rec->color);
    if (rec->act_color) iconfig_node_set_str(node, "act_color", rec->act_color);
    if (rec->priority > 0) iconfig_node_set_int(node, "priority", rec->priority);
    iconfig_node_set_bool(node, "nick", rec->nick);
    iconfig_node_set_bool(node, "word", rec->word);
    if (rec->nickmask) iconfig_node_set_bool(node, "mask", TRUE);
    if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
    if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
    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);
        iconfig_node_add_list(node, rec->channels);
    }
}
Exemple #2
0
static void ignore_set_config(IGNORE_REC *rec)
{
	CONFIG_NODE *node;
	char *levelstr;

	if (rec->level == 0 && rec->except_level == 0)
		return;

	if (rec->time > 0)
		return;

	node = iconfig_node_traverse("(ignores", TRUE);
	node = config_node_section(node, NULL, NODE_TYPE_BLOCK);

	if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask);
	if (rec->level) {
		levelstr = bits2level(rec->level);
		iconfig_node_set_str(node, "level", levelstr);
		g_free(levelstr);
	}
	if (rec->except_level) {
		levelstr = bits2level(rec->except_level);
		iconfig_node_set_str(node, "except_level", levelstr);
		g_free(levelstr);
	}
	iconfig_node_set_str(node, "pattern", rec->pattern);
	if (rec->regexp) config_node_set_bool(node, "regexp", TRUE);
	if (rec->fullword) config_node_set_bool(node, "fullword", TRUE);
	if (rec->replies) config_node_set_bool(node, "replies", TRUE);

	if (rec->channels != NULL && *rec->channels != NULL) {
		node = config_node_section(node, "channels", NODE_TYPE_LIST);
		config_node_add_list(node, rec->channels);
	}
}
Exemple #3
0
static CONFIG_NODE *statusbar_items_section(CONFIG_NODE *parent)
{
	STATUSBAR_CONFIG_REC *bar;
        CONFIG_NODE *node;
        GSList *tmp;

	node = config_node_section(parent, "items", -1);
	if (node != NULL)
		return node;

        /* find the statusbar configuration from memory */
	bar = statusbar_config_find(active_statusbar_group, parent->key);
	if (bar == NULL) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			    TXT_STATUSBAR_NOT_FOUND, parent->key);
                return NULL;
	}

	/* 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);
	for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
		SBAR_ITEM_CONFIG_REC *rec = tmp->data;

		node = config_node_section(parent, rec->name,
					   NODE_TYPE_BLOCK);
		if (rec->priority != 0)
                        iconfig_node_set_int(node, "priority", rec->priority);
		if (rec->right_alignment)
                        iconfig_node_set_str(node, "alignment", "right");
	}

        return parent;
}
Exemple #4
0
static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node)
{
	CONFIG_NODE *subnode;
	GSList *tmp;
	const char *type;

	node = config_node_section(node, "items", NODE_TYPE_LIST);
	for (tmp = window->items; tmp != NULL; tmp = tmp->next) {
		WI_ITEM_REC *rec = tmp->data;
		SERVER_REC *server = rec->server;

		type = module_find_id_str("WINDOW ITEM TYPE", rec->type);
		if (type == NULL) continue;

		subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);

		iconfig_node_set_str(subnode, "type", type);
		type = chat_protocol_find_id(rec->chat_type)->name;
		iconfig_node_set_str(subnode, "chat_type", type);
		iconfig_node_set_str(subnode, "name", rec->name);

		if (server != NULL)
			iconfig_node_set_str(subnode, "tag", server->tag);
		else if (IS_QUERY(rec)) {
			iconfig_node_set_str(subnode, "tag",
					     QUERY(rec)->server_tag);
		}
	}
}
Exemple #5
0
static void botuser_config_read_user(CONFIG_NODE *node)
{
	USER_REC *user;
	USER_CHAN_REC *userchan;
	USER_MASK_REC *usermask;
	CONFIG_NODE *subnode;
	GSList *tmp;
	char *value;

	g_return_if_fail(node != NULL);

	/* nick = { ... } */
	if (node->key == NULL || node->value == NULL)
		return;

	/* Add new user */
	user = g_new0(USER_REC, 1);
	user->nick = g_strdup(node->key);
	g_hash_table_insert(users, user->nick, user);

	/* password, flags, modify time */
	user->password = g_strdup(config_node_get_str(node, "password", NULL));
	user->flags = botuser_flags2value(config_node_get_str(node, "flags", ""));
	user->last_modify = (time_t) config_node_get_int(node, "last_modify", 0);

	/* get masks */
        user->masks = NULL;
	subnode = config_node_section(node, "masks", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next) {
		subnode = tmp->data;

		value = config_node_get_str(subnode, "mask", NULL);
		if (value == NULL) continue; /* mask is required */

		usermask = botuser_create_mask(user, value);
		value = config_node_get_str(subnode, "not_flags", "");
		usermask->not_flags = botuser_flags2value(value);
	}

	/* get channels - must be last, messes up pvalue */
	user->channels = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal);
	subnode = config_node_section(node, "channels", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next) {
		subnode = tmp->data;

		value = config_node_get_str(subnode, "channel", NULL);
		if (value == NULL) continue; /* channel is required */

		/* create user channel specific record */
		userchan = g_new0(USER_CHAN_REC, 1);
		userchan->channel = g_strdup(value);
		g_hash_table_insert(user->channels, userchan->channel, userchan);

		value = config_node_get_str(subnode, "flags", "");
		userchan->flags = botuser_flags2value(value);
	}
}
Exemple #6
0
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);
	for (tmp = log->items; tmp != NULL; tmp = tmp->next) {
		LOG_ITEM_REC *rec = tmp->data;

                node = config_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);
	}
}
Exemple #7
0
void windows_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		CONFIG_NODE *node = tmp->data;

		window = window_create(NULL, TRUE);
		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("window restore", 2, window, node);
	}

	signal_emit("windows restored", 0);
}
Exemple #8
0
static void session_save_server(SERVER_REC *server, CONFIG_REC *config,
				CONFIG_NODE *node)
{
	int handle;

	node = config_node_section(node, NULL, NODE_TYPE_BLOCK);

	config_node_set_str(config, node, "chat_type",
			    chat_protocol_find_id(server->chat_type)->name);
	config_node_set_str(config, node, "address", server->connrec->address);
	config_node_set_int(config, node, "port", server->connrec->port);
	config_node_set_str(config, node, "chatnet", server->connrec->chatnet);
	config_node_set_str(config, node, "password", server->connrec->password);
	config_node_set_str(config, node, "nick", server->nick);

	config_node_set_bool(config, node, "use_ssl", server->connrec->use_ssl);

	handle = g_io_channel_unix_get_fd(net_sendbuffer_handle(server->handle));
	config_node_set_int(config, node, "handle", handle);

	signal_emit("session save server", 3, server, config, node);

	/* fake the server disconnection */
	g_io_channel_unref(net_sendbuffer_handle(server->handle));
	net_sendbuffer_destroy(server->handle, FALSE);
	server->handle = NULL;

	server->connection_lost = TRUE;
        server->no_reconnect = TRUE;
        server_disconnect(server);
}
Exemple #9
0
static CONFIG_NODE *config_sbar_node(CONFIG_REC *config, const char *name, gboolean create)
{
	CONFIG_NODE *node;

	node = config_node_traverse(config, "statusbar", create);
	if (node != NULL) {
		node = config_node_section(config, node, active_statusbar_group->name,
		                           create ? NODE_TYPE_BLOCK : -1);
	}

	if (node != NULL) {
		node = config_node_section(config, node, name, create ? NODE_TYPE_BLOCK : -1);
	}

	return node;
}
Exemple #10
0
/* find the section with the whole path.
   create the path if necessary `create' is TRUE. */
CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int create)
{
	CONFIG_NODE *node;
	char **list, **tmp, *str;
	int is_list, new_type;

	g_return_val_if_fail(rec != NULL, NULL);

	if (section == NULL || *section == '\0')
		return rec->mainnode;

	/* check if it already exists in cache */
	node = g_hash_table_lookup(rec->cache, section);
	if (node != NULL) return node;

        new_type = -1;

	node = rec->mainnode;
	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;

		node = config_node_section(node, *tmp + is_list, new_type);
		if (node == NULL) return NULL;
	}
	g_strfreev(list);

	/* save to cache */
        str = g_strdup(section);
	g_hash_table_insert(rec->cache, str, node);
	g_hash_table_insert(rec->cache_nodes, node, str);
	return node;
}
Exemple #11
0
static void module_save(const char *module, MODULE_THEME_REC *rec,
                        THEME_SAVE_REC *data)
{
	CONFIG_NODE *fnode, *node;
	FORMAT_REC *formats;
	int n;

        formats = g_hash_table_lookup(default_formats, rec->name);
	if (formats == NULL) return;

	fnode = config_node_traverse(data->config, "formats", TRUE);

	node = config_node_section(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,
                                            rec->formats[n]);
		} else if (data->save_all && formats[n].tag != NULL) {
                        config_node_set_str(data->config, node, formats[n].tag,
                                            formats[n].def);
		}
        }

        if (node->value == NULL) {
                /* not modified, don't keep the empty section */
                config_node_remove(data->config, fnode, node);
		if (fnode->value == NULL) {
			config_node_remove(data->config,
					   data->config->mainnode, fnode);
		}
        }
}
Exemple #12
0
static void sig_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		CONFIG_NODE *node = tmp->data;

		window = window_find_refnum(atoi(node->key));
		if (window == NULL)
			window = window_create(NULL, TRUE);

		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
                window->immortal = config_node_get_bool(node, "immortal", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_history(window, config_node_get_str(node, "history_name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("layout restore window", 2, window, node);
	}
}
Exemple #13
0
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);

	if (window->sticky_refnum)
		iconfig_node_set_bool(node, "sticky_refnum", TRUE);

	if (window->immortal)
		iconfig_node_set_bool(node, "immortal", TRUE);

	if (window->name != NULL)
		iconfig_node_set_str(node, "name", window->name);

	if (window->history_name != NULL)
		iconfig_node_set_str(node, "history_name", window->history_name);

	if (window->servertag != NULL)
		iconfig_node_set_str(node, "servertag", window->servertag);
	if (window->level != 0) {
                char *level = bits2level(window->level);
		iconfig_node_set_str(node, "level", level);
		g_free(level);
	}
	if (window->theme_name != NULL)
		iconfig_node_set_str(node, "theme", window->theme_name);

	if (window->items != NULL)
		window_save_items(window, node);

	signal_emit("layout save window", 2, window, node);
}
Exemple #14
0
static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item,
				 CONFIG_NODE *node)
{
	CONFIG_NODE *subnode;
        CHAT_PROTOCOL_REC *proto;
	const char *type;

	type = module_find_id_str("WINDOW ITEM TYPE", item->type);
	if (type == NULL)
		return;

	subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);

	iconfig_node_set_str(subnode, "type", type);
	proto = item->chat_type == 0 ? NULL :
		chat_protocol_find_id(item->chat_type);
	if (proto != NULL)
		iconfig_node_set_str(subnode, "chat_type", proto->name);
	iconfig_node_set_str(subnode, "name", item->visible_name);

	if (item->server != NULL)
		iconfig_node_set_str(subnode, "tag", item->server->tag);
	else if (IS_QUERY(item)) {
		iconfig_node_set_str(subnode, "tag", QUERY(item)->server_tag);
	}
}
Exemple #15
0
static void read_ignores(void)
{
	IGNORE_REC *rec;
	CONFIG_NODE *node;
	GSList *tmp;

	while (ignores != NULL)
                ignore_destroy(ignores->data);

	node = iconfig_node_traverse("ignores", FALSE);
	if (node == NULL) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		node = tmp->data;

		if (node->type != NODE_TYPE_BLOCK)
			continue;

		rec = g_new0(IGNORE_REC, 1);
		ignores = g_slist_append(ignores, rec);

		rec->mask = g_strdup(config_node_get_str(node, "mask", NULL));
		rec->pattern = g_strdup(config_node_get_str(node, "pattern", NULL));
		rec->level = level2bits(config_node_get_str(node, "level", ""));
		rec->except_level = level2bits(config_node_get_str(node, "except_level", ""));
		rec->regexp = config_node_get_bool(node, "regexp", FALSE);
		rec->fullword = config_node_get_bool(node, "fullword", FALSE);
		rec->replies = config_node_get_bool(node, "replies", FALSE);

		node = config_node_section(node, "channels", -1);
		if (node != NULL) rec->channels = config_node_get_list(node);
	}
}
Exemple #16
0
static void log_update_config(LOG_REC *log)
{
	CONFIG_NODE *node;
	char *levelstr;

	if (log->temp)
		return;

	node = iconfig_node_traverse("logs", TRUE);
	node = config_node_section(node, log->fname, NODE_TYPE_BLOCK);

	if (log->autoopen)
		iconfig_node_set_bool(node, "auto_open", TRUE);
	else
		iconfig_node_set_str(node, "auto_open", NULL);

	levelstr = bits2level(log->level);
	iconfig_node_set_str(node, "level", levelstr);
	g_free(levelstr);

	iconfig_node_set_str(node, "items", NULL);

	if (log->items != NULL)
		log_items_update_config(log, node);

	signal_emit("log config save", 2, log, node);
}
Exemple #17
0
static void botuser_config_save(USER_REC *user)
{
	CONFIG_NODE *node, *subnode, *noderec;
	GSList *tmp;
	char *str;

	user->last_modify = time(NULL);

	node = config_node_traverse(userconfig, "users", TRUE);
	node = config_node_section(node, user->nick, NODE_TYPE_BLOCK);

	str = user->flags == 0 ? NULL :
		botuser_value2flags(user->flags);
	config_node_set_str(userconfig, node, "flags", str);
	g_free_not_null(str);

	config_node_set_str(userconfig, node, "password", user->password);
	config_node_set_int(userconfig, node, "last_modify", (int) user->last_modify);

	/* Save masks */
	if (user->masks == NULL)
		config_node_set_str(userconfig, node, "masks", NULL);
	else {
		subnode = config_node_section(node, "masks", NODE_TYPE_LIST);

		for (tmp = user->masks; tmp != NULL; tmp = tmp->next) {
			USER_MASK_REC *rec = tmp->data;

                        noderec = config_node_section(subnode, NULL, NODE_TYPE_BLOCK);
			config_node_set_str(userconfig, noderec, "mask", rec->mask);

			str = user->flags == 0 ? NULL :
				botuser_value2flags(rec->not_flags);
			config_node_set_str(userconfig, noderec, "not_flags", str);
			g_free_not_null(str);
		}
	}

	/* Save channels */
	if (g_hash_table_size(user->channels) == 0)
		config_node_set_str(userconfig, node, "channels", NULL);
	else {
		subnode = config_node_section(node, "channels", NODE_TYPE_LIST);
		g_hash_table_foreach(user->channels, (GHFunc) botuser_save_chan, subnode);
	}
}
Exemple #18
0
static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node)
{
	GSList *tmp;

	node = config_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);
}
Exemple #19
0
static void read_hilight_config(void)
{
    CONFIG_NODE *node;
    HILIGHT_REC *rec;
    GSList *tmp;
    char *text, *color;

    hilights_destroy_all();

    node = iconfig_node_traverse("hilights", FALSE);
    if (node == NULL) {
        reset_cache();
        return;
    }

    tmp = config_node_first(node->value);
    for (; tmp != NULL; tmp = config_node_next(tmp)) {
        node = tmp->data;

        if (node->type != NODE_TYPE_BLOCK)
            continue;

        text = config_node_get_str(node, "text", NULL);
        if (text == NULL || *text == '\0')
            continue;

        rec = g_new0(HILIGHT_REC, 1);
        hilights = g_slist_append(hilights, rec);

        rec->text = g_strdup(text);

        color = config_node_get_str(node, "color", NULL);
        rec->color = color == NULL || *color == '\0' ? NULL :
                     g_strdup(color);

        color = config_node_get_str(node, "act_color", NULL);
        rec->act_color = color == NULL || *color == '\0' ? NULL :
                         g_strdup(color);

        rec->level = config_node_get_int(node, "level", 0);
        rec->priority = config_node_get_int(node, "priority", 0);
        rec->nick = config_node_get_bool(node, "nick", TRUE);
        rec->word = config_node_get_bool(node, "word", TRUE);

        rec->nickmask = config_node_get_bool(node, "mask", FALSE);
        rec->fullword = config_node_get_bool(node, "fullword", FALSE);
        rec->regexp = config_node_get_bool(node, "regexp", FALSE);
        rec->servertag = config_node_get_str(node, "servertag", NULL);
        hilight_init_rec(rec);

        node = config_node_section(node, "channels", -1);
        if (node != NULL) rec->channels = config_node_get_list(node);
    }

    reset_cache();
}
Exemple #20
0
static void cmd_statusbar(const char *data)
{
        CONFIG_NODE *node;
	char *name, *cmd, *params, *signal;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
			    &name, &cmd, &params))
		return;

	if (*name == '\0') {
		/* list all statusbars */
                cmd_statusbar_list();
		cmd_params_free(free_arg);
                return;
	}

	if (*cmd == '\0') {
		/* print statusbar info */
                cmd_statusbar_print_info(name);
		cmd_params_free(free_arg);
                return;
	}

        /* lookup/create the statusbar node */
	node = iconfig_node_traverse("statusbar", TRUE);
	node = config_node_section(node, active_statusbar_group->name,
				   NODE_TYPE_BLOCK);
	node = config_node_section(node, name, NODE_TYPE_BLOCK);

	/* call the subcommand */
	signal = g_strconcat("command statusbar ", cmd, NULL);
        g_strdown(signal);
	if (!signal_emit(signal, 4, params, NULL, NULL, node)) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			    TXT_STATUSBAR_UNKNOWN_COMMAND, cmd);
	} else {
                read_statusbar_config();
	}
	g_free(signal);

	cmd_params_free(free_arg);
}
Exemple #21
0
/* SYNTAX: STATUSBAR <name> RESET */
static void cmd_statusbar_reset(const char *data, void *server,
				void *item, CONFIG_NODE *node)
{
	CONFIG_NODE *parent;

	parent = iconfig_node_traverse("statusbar", TRUE);
	parent = config_node_section(parent, active_statusbar_group->name,
				     NODE_TYPE_BLOCK);

        iconfig_node_set_str(parent, node->key, NULL);
}
Exemple #22
0
static void session_save_server_channels(SERVER_REC *server,
					 CONFIG_REC *config,
					 CONFIG_NODE *node)
{
	GSList *tmp;

	/* save channels */
	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);
}
Exemple #23
0
static void session_save_channel_nicks(CHANNEL_REC *channel, CONFIG_REC *config,
				       CONFIG_NODE *node)
{
	GSList *tmp, *nicks;

	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);
        g_slist_free(nicks);
}
Exemple #24
0
/* verify that all settings in config file for `module' are actually found
   from /SET list */
void settings_check_module(const char *module)
{
        SETTINGS_REC *set;
	CONFIG_NODE *node, *parent;
        GString *errors;
	GSList *tmp, *next;
        int count;

        g_return_if_fail(module != NULL);

	node = iconfig_node_traverse("settings", FALSE);
	node = node == NULL ? NULL : config_node_section(node, module, -1);
	if (node == NULL) return;

        errors = g_string_new(NULL);
	g_string_sprintf(errors, "Unknown settings in configuration "
			 "file for module %s:", module);

        count = 0;
	parent = node;
	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = next) {
		node = tmp->data;
		next = config_node_next(tmp);

		set = g_hash_table_lookup(settings, node->key);
		if (backwards_compatibility(module, node, parent))
			continue;

		if (set == NULL || strcmp(set->module, module) != 0) {
			g_string_sprintfa(errors, " %s", node->key);
                        count++;
		}
	}
	if (count > 0) {
		if (gslist_find_icase_string(last_invalid_modules,
					     module) == NULL) {
                        /* mark this module having invalid settings */
			last_invalid_modules =
				g_slist_append(last_invalid_modules,
					       g_strdup(module));
		}
		if (fe_initialized)
                        signal_emit("settings errors", 1, errors->str);
		else {
			if (last_errors == NULL)
				last_errors = g_string_new(NULL);
			else
				g_string_append_c(last_errors, '\n');
                        g_string_append(last_errors, errors->str);
		}
	}
        g_string_free(errors, TRUE);
}
Exemple #25
0
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);

	config_node_set_str(config, node, "nick", nick->nick);
	config_node_set_bool(config, node, "op", nick->op);
	config_node_set_bool(config, node, "halfop", nick->halfop);
	config_node_set_bool(config, node, "voice", nick->voice);

	signal_emit("session save nick", 4, channel, nick, config, node);
}
Exemple #26
0
static void session_restore_server_channels(SERVER_REC *server,
					    CONFIG_NODE *node)
{
	GSList *tmp;

	/* restore channels */
	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))
			session_restore_channel(server, tmp->data);
	}
}
Exemple #27
0
static void keyconfig_save(const char *id, const char *key, const char *data)
{
	CONFIG_NODE *node;

	g_return_if_fail(id != NULL);
	g_return_if_fail(key != NULL);

	/* remove old keyboard settings */
	node = iconfig_node_traverse("keyboard", TRUE);
	node = config_node_section(node, id, NODE_TYPE_BLOCK);

	iconfig_node_set_str(node, key, data == NULL ? "" : data);
}
Exemple #28
0
static void log_read_config(void)
{
	CONFIG_NODE *node;
	LOG_REC *log;
	GSList *tmp, *next, *fnames;

	/* close old logs, save list of open logs */
	fnames = NULL;
	for (tmp = logs; tmp != NULL; tmp = next) {
		log = tmp->data;

		next = tmp->next;
		if (log->temp)
			continue;

		if (log->handle != -1)
			fnames = g_slist_append(fnames, g_strdup(log->fname));
		log_destroy(log);
	}

	node = iconfig_node_traverse("logs", FALSE);
	if (node == NULL) return;

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		node = tmp->data;

		if (node->type != NODE_TYPE_BLOCK)
			continue;

		log = g_new0(LOG_REC, 1);
		logs = g_slist_append(logs, log);

		log->handle = -1;
		log->fname = g_strdup(node->key);
		log->autoopen = config_node_get_bool(node, "auto_open", FALSE);
		log->level = level2bits(config_node_get_str(node, "level", 0));

		signal_emit("log config read", 2, log, node);

		node = config_node_section(node, "items", -1);
		if (node != NULL)
			log_items_read_config(node, log);

		if (log->autoopen || gslist_find_string(fnames, log->fname))
			log_start_logging(log);
	}

	g_slist_foreach(fnames, (GFunc) g_free, NULL);
	g_slist_free(fnames);
}
Exemple #29
0
static void botnet_config_read_botnet(CONFIG_NODE *node)
{
	CONFIG_NODE *subnode;
	BOTNET_REC *botnet;
	GSList *tmp;

	g_return_if_fail(node != NULL);

	if (node->key == NULL || node->value == NULL)
		return;

	/* New botnet */
	botnet = g_new0(BOTNET_REC, 1);
	botnet->name = g_strdup(node->key);
	botnet->nick = g_strdup(config_node_get_str(node, "nick", "bot"));
	botnet->priority = config_node_get_int(node, "priority", DEFAULT_BOTNET_PRIORITY);
	botnet->autoconnect = config_node_get_bool(node, "autoconnect", FALSE);

	botnet->addr = g_strdup(config_node_get_str(node, "listen_addr", NULL));
	botnet->port = config_node_get_int(node, "listen_port", DEFAULT_BOTNET_PORT);

	botnet->listen_handle = -1;
	botnet->listen_tag = -1;

	/* read uplinks */
	subnode = config_node_section(node, "uplinks", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next)
		botnet_config_read_uplink(botnet, tmp->data);

	/* read downlinks */
	subnode = config_node_section(node, "downlinks", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next)
		botnet_config_read_downlink(botnet, tmp->data);

	botnets = g_slist_append(botnets, botnet);
}
Exemple #30
0
static void botnet_config_read_ips(BOT_DOWNLINK_REC *rec, CONFIG_NODE *node)
{
	GSList *tmp;

	g_return_if_fail(rec != NULL);
	g_return_if_fail(node != NULL);

	node = config_node_section(node, "valid_addrs", -1);
	tmp = node == NULL ? NULL : node->value;
	for (; tmp != NULL; tmp = tmp->next) {
		node = tmp->data;
		rec->valid_addrs = g_slist_append(rec->valid_addrs, g_strdup(node->value));
	}
}