1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

config changes, CONFIG_REC is now required parameter for

config_node_set_int/bool() and config_node_add_list()


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@886 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-11-26 10:24:30 +00:00 committed by cras
parent a392b41f2f
commit 0d8239e40e
12 changed files with 39 additions and 36 deletions

View File

@ -77,7 +77,7 @@ static void channel_setup_save(CHANNEL_SETUP_REC *channel)
iconfig_node_set_str(node, "name", channel->name); iconfig_node_set_str(node, "name", channel->name);
iconfig_node_set_str(node, "chatnet", channel->chatnet); iconfig_node_set_str(node, "chatnet", channel->chatnet);
if (channel->autojoin) if (channel->autojoin)
config_node_set_bool(node, "autojoin", TRUE); iconfig_node_set_bool(node, "autojoin", TRUE);
iconfig_node_set_str(node, "password", channel->password); iconfig_node_set_str(node, "password", channel->password);
iconfig_node_set_str(node, "botmasks", channel->botmasks); iconfig_node_set_str(node, "botmasks", channel->botmasks);
iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd); iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd);

View File

@ -220,13 +220,13 @@ static void ignore_set_config(IGNORE_REC *rec)
g_free(levelstr); g_free(levelstr);
} }
iconfig_node_set_str(node, "pattern", rec->pattern); iconfig_node_set_str(node, "pattern", rec->pattern);
if (rec->regexp) config_node_set_bool(node, "regexp", TRUE); if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
if (rec->fullword) config_node_set_bool(node, "fullword", TRUE); if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
if (rec->replies) config_node_set_bool(node, "replies", TRUE); if (rec->replies) iconfig_node_set_bool(node, "replies", TRUE);
if (rec->channels != NULL && *rec->channels != NULL) { if (rec->channels != NULL && *rec->channels != NULL) {
node = config_node_section(node, "channels", NODE_TYPE_LIST); node = config_node_section(node, "channels", NODE_TYPE_LIST);
config_node_add_list(node, rec->channels); iconfig_node_add_list(node, rec->channels);
} }
} }

View File

@ -319,7 +319,7 @@ static void log_update_config(LOG_REC *log)
node = config_node_section(node, log->fname, NODE_TYPE_BLOCK); node = config_node_section(node, log->fname, NODE_TYPE_BLOCK);
if (log->autoopen) if (log->autoopen)
config_node_set_bool(node, "auto_open", TRUE); iconfig_node_set_bool(node, "auto_open", TRUE);
else else
iconfig_node_set_str(node, "auto_open", NULL); iconfig_node_set_str(node, "auto_open", NULL);

View File

@ -351,12 +351,12 @@ static void server_setup_save(SERVER_SETUP_REC *rec)
iconfig_node_set_str(node, "address", rec->address); iconfig_node_set_str(node, "address", rec->address);
iconfig_node_set_str(node, "chatnet", rec->chatnet); iconfig_node_set_str(node, "chatnet", rec->chatnet);
config_node_set_int(node, "port", rec->port); iconfig_node_set_int(node, "port", rec->port);
iconfig_node_set_str(node, "password", rec->password); iconfig_node_set_str(node, "password", rec->password);
iconfig_node_set_str(node, "own_host", rec->own_host); iconfig_node_set_str(node, "own_host", rec->own_host);
if (rec->autoconnect) if (rec->autoconnect)
config_node_set_bool(node, "autoconnect", TRUE); iconfig_node_set_bool(node, "autoconnect", TRUE);
signal_emit("server setup saved", 2, rec, node); signal_emit("server setup saved", 2, rec, node);
} }

View File

@ -30,9 +30,12 @@ typedef struct {
#define iconfig_node_traverse(a, b) config_node_traverse(mainconfig, a, b) #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_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)
#define iconfig_node_set_bool(a, b, c) config_node_set_bool(mainconfig, a, b, c)
#define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b) #define iconfig_node_list_remove(a, b) config_node_list_remove(mainconfig, a, b)
#define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b) #define iconfig_node_remove(a, b) config_node_remove(mainconfig, a, b)
#define iconfig_node_clear(a) config_node_clear(mainconfig, a) #define iconfig_node_clear(a) config_node_clear(mainconfig, a)
#define iconfig_node_add_list(a, b) config_node_add_list(mainconfig, a, b)
extern CONFIG_REC *mainconfig; extern CONFIG_REC *mainconfig;

View File

@ -50,16 +50,16 @@ static void hilight_add_config(HILIGHT_REC *rec)
node = config_node_section(node, NULL, NODE_TYPE_BLOCK); node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
iconfig_node_set_str(node, "text", rec->text); iconfig_node_set_str(node, "text", rec->text);
if (rec->level > 0) config_node_set_int(node, "level", rec->level); 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->color) iconfig_node_set_str(node, "color", rec->color);
if (rec->nick) config_node_set_bool(node, "nick", TRUE); if (rec->nick) iconfig_node_set_bool(node, "nick", TRUE);
if (rec->nickmask) config_node_set_bool(node, "mask", TRUE); if (rec->nickmask) iconfig_node_set_bool(node, "mask", TRUE);
if (rec->fullword) config_node_set_bool(node, "fullword", TRUE); if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
if (rec->regexp) config_node_set_bool(node, "regexp", TRUE); if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
if (rec->channels != NULL && *rec->channels != NULL) { if (rec->channels != NULL && *rec->channels != NULL) {
node = config_node_section(node, "channels", NODE_TYPE_LIST); node = config_node_section(node, "channels", NODE_TYPE_LIST);
config_node_add_list(node, rec->channels); iconfig_node_add_list(node, rec->channels);
} }
} }

View File

@ -112,7 +112,7 @@ static void botuser_config_save(USER_REC *user)
g_free_not_null(str); g_free_not_null(str);
config_node_set_str(userconfig, node, "password", user->password); config_node_set_str(userconfig, node, "password", user->password);
config_node_set_int(node, "last_modify", (int) user->last_modify); iconfig_node_set_int(node, "last_modify", (int) user->last_modify);
/* Save masks */ /* Save masks */
if (user->masks == NULL) if (user->masks == NULL)

View File

@ -59,18 +59,18 @@ static void ircnet_save(IRC_CHATNET_REC *rec)
node = chatnet_save((CHATNET_REC *) rec, node); node = chatnet_save((CHATNET_REC *) rec, node);
if (rec->max_cmds_at_once > 0) if (rec->max_cmds_at_once > 0)
config_node_set_int(node, "cmdmax", rec->max_cmds_at_once); iconfig_node_set_int(node, "cmdmax", rec->max_cmds_at_once);
if (rec->cmd_queue_speed > 0) if (rec->cmd_queue_speed > 0)
config_node_set_int(node, "cmdspeed", rec->cmd_queue_speed); iconfig_node_set_int(node, "cmdspeed", rec->cmd_queue_speed);
if (rec->max_kicks > 0) if (rec->max_kicks > 0)
config_node_set_int(node, "max_kicks", rec->max_kicks); iconfig_node_set_int(node, "max_kicks", rec->max_kicks);
if (rec->max_msgs > 0) if (rec->max_msgs > 0)
config_node_set_int(node, "max_msgs", rec->max_msgs); iconfig_node_set_int(node, "max_msgs", rec->max_msgs);
if (rec->max_modes > 0) if (rec->max_modes > 0)
config_node_set_int(node, "max_modes", rec->max_modes); iconfig_node_set_int(node, "max_modes", rec->max_modes);
if (rec->max_whois > 0) if (rec->max_whois > 0)
config_node_set_int(node, "max_whois", rec->max_whois); iconfig_node_set_int(node, "max_whois", rec->max_whois);
} }
static void ircnet_remove(IRC_CHATNET_REC *rec) static void ircnet_remove(IRC_CHATNET_REC *rec)

View File

@ -166,9 +166,9 @@ static void sig_server_setup_saved(IRC_SERVER_SETUP_REC *rec,
return; return;
if (rec->max_cmds_at_once > 0) if (rec->max_cmds_at_once > 0)
config_node_set_int(node, "cmds_max_at_once", rec->max_cmds_at_once); iconfig_node_set_int(node, "cmds_max_at_once", rec->max_cmds_at_once);
if (rec->cmd_queue_speed > 0) if (rec->cmd_queue_speed > 0)
config_node_set_int(node, "cmd_queue_speed", rec->cmd_queue_speed); iconfig_node_set_int(node, "cmd_queue_speed", rec->cmd_queue_speed);
} }
void irc_servers_setup_init(void) void irc_servers_setup_init(void)

View File

@ -33,19 +33,19 @@ void notifylist_add_config(NOTIFYLIST_REC *rec)
node = config_node_section(node, rec->mask, NODE_TYPE_BLOCK); node = config_node_section(node, rec->mask, NODE_TYPE_BLOCK);
if (rec->away_check) if (rec->away_check)
config_node_set_bool(node, "away_check", TRUE); iconfig_node_set_bool(node, "away_check", TRUE);
else else
iconfig_node_set_str(node, "away_check", NULL); iconfig_node_set_str(node, "away_check", NULL);
if (rec->idle_check_time > 0) if (rec->idle_check_time > 0)
config_node_set_int(node, "idle_check_time", rec->idle_check_time/60); iconfig_node_set_int(node, "idle_check_time", rec->idle_check_time/60);
else else
iconfig_node_set_str(node, "idle_check_time", NULL); iconfig_node_set_str(node, "idle_check_time", NULL);
iconfig_node_set_str(node, "ircnets", NULL); iconfig_node_set_str(node, "ircnets", NULL);
if (rec->ircnets != NULL && *rec->ircnets != NULL) { if (rec->ircnets != NULL && *rec->ircnets != NULL) {
node = config_node_section(node, "ircnets", NODE_TYPE_LIST); node = config_node_section(node, "ircnets", NODE_TYPE_LIST);
config_node_add_list(node, rec->ircnets); iconfig_node_add_list(node, rec->ircnets);
} }
} }

View File

@ -122,15 +122,15 @@ int config_node_get_keyvalue(CONFIG_NODE *node, const char *key, const char *val
/* Return all values from from the list `node' in a g_strsplit() array */ /* Return all values from from the list `node' in a g_strsplit() array */
char **config_node_get_list(CONFIG_NODE *node); char **config_node_get_list(CONFIG_NODE *node);
/* Add all values in `array' to `node' */ /* Add all values in `array' to `node' */
void config_node_add_list(CONFIG_NODE *node, char **array); void config_node_add_list(CONFIG_REC *rec, CONFIG_NODE *node, char **array);
char *config_node_get_str(CONFIG_NODE *parent, const char *key, const char *def); char *config_node_get_str(CONFIG_NODE *parent, const char *key, const char *def);
int config_node_get_int(CONFIG_NODE *parent, const char *key, int def); int config_node_get_int(CONFIG_NODE *parent, const char *key, int def);
int config_node_get_bool(CONFIG_NODE *parent, const char *key, int def); int config_node_get_bool(CONFIG_NODE *parent, const char *key, int def);
void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, const char *value); void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, const char *value);
void config_node_set_int(CONFIG_NODE *parent, const char *key, int value); void config_node_set_int(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int value);
void config_node_set_bool(CONFIG_NODE *parent, const char *key, int value); void config_node_set_bool(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int value);
/* Remove one node from block/list. /* Remove one node from block/list.
..set_str() with value = NULL does the same. */ ..set_str() with value = NULL does the same. */

View File

@ -92,7 +92,7 @@ void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key,
CONFIG_NODE *node; CONFIG_NODE *node;
int no_key; int no_key;
g_return_if_fail(rec != NULL || value != NULL); g_return_if_fail(rec != NULL);
g_return_if_fail(parent != NULL); g_return_if_fail(parent != NULL);
no_key = key == NULL; no_key = key == NULL;
@ -120,17 +120,17 @@ void config_node_set_str(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key,
rec->modifycounter++; rec->modifycounter++;
} }
void config_node_set_int(CONFIG_NODE *parent, const char *key, int value) void config_node_set_int(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int value)
{ {
char str[MAX_INT_STRLEN]; char str[MAX_INT_STRLEN];
g_snprintf(str, sizeof(str), "%d", value); g_snprintf(str, sizeof(str), "%d", value);
config_node_set_str(NULL, parent, key, str); config_node_set_str(rec, parent, key, str);
} }
void config_node_set_bool(CONFIG_NODE *parent, const char *key, int value) void config_node_set_bool(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int value)
{ {
config_node_set_str(NULL, parent, key, value ? "yes" : "no"); config_node_set_str(rec, parent, key, value ? "yes" : "no");
} }
int config_set_str(CONFIG_REC *rec, const char *section, const char *key, const char *value) int config_set_str(CONFIG_REC *rec, const char *section, const char *key, const char *value)
@ -160,10 +160,10 @@ int config_set_bool(CONFIG_REC *rec, const char *section, const char *key, int v
} }
/* Add all values in `array' to `node' */ /* Add all values in `array' to `node' */
void config_node_add_list(CONFIG_NODE *node, char **array) void config_node_add_list(CONFIG_REC *rec, CONFIG_NODE *node, char **array)
{ {
char **tmp; char **tmp;
for (tmp = array; *tmp != NULL; tmp++) for (tmp = array; *tmp != NULL; tmp++)
config_node_set_str(NULL, node, NULL, *tmp); config_node_set_str(rec, node, NULL, *tmp);
} }