summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-config.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-01-24 16:50:20 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-01-24 16:50:20 +0100
commited26a0389c06250f02329fa477d2cffe7df59b5e (patch)
treeecfade4a588ba8c8dcd31d0894afabe8fbad5aad /src/plugins/irc/irc-config.c
parent25c5bc64217bce570afc36e57b0e838f54f08465 (diff)
downloadweechat-ed26a0389c06250f02329fa477d2cffe7df59b5e.zip
Add of "modifier" hook, migration of charset plugin to new API, SIGHUP signal catched (reload all config files), better config files reloading
Diffstat (limited to 'src/plugins/irc/irc-config.c')
-rw-r--r--src/plugins/irc/irc-config.c129
1 files changed, 60 insertions, 69 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index f163e84a9..ff56751be 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -208,6 +208,64 @@ irc_config_change_notify_levels ()
}
/*
+ * irc_config_reload: reload IRC configuration file
+ */
+
+int
+irc_config_reload (struct t_config_file *config_file)
+{
+ struct t_irc_server *ptr_server, *next_server;
+ int rc;
+
+ /* make C compiler happy */
+ (void) config_file;
+
+ irc_config_server = NULL;
+ irc_config_reload_flag = 1;
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ ptr_server->reloaded_from_config = 0;
+ }
+
+ rc = weechat_config_reload (irc_config_file);
+
+ if (rc == 0)
+ {
+
+ if (irc_config_server)
+ irc_server_init_with_config_options (irc_config_server,
+ irc_config_section_server,
+ irc_config_reload_flag);
+
+ ptr_server = irc_servers;
+ while (ptr_server)
+ {
+ next_server = ptr_server->next_server;
+
+ if (!ptr_server->reloaded_from_config)
+ {
+ if (ptr_server->is_connected)
+ {
+ weechat_printf (NULL,
+ _("%s%s: warning: server \"%s\" not found "
+ "in configuration file, not deleted in "
+ "memory because it's currently used"),
+ weechat_prefix ("error"), "irc",
+ ptr_server->name);
+ }
+ else
+ irc_server_free (ptr_server);
+ }
+
+ ptr_server = next_server;
+ }
+ }
+
+ return rc;
+}
+
+/*
* irc_config_read_server_line: read a server line in configuration file
*/
@@ -410,7 +468,8 @@ irc_config_init ()
{
struct t_config_section *ptr_section;
- irc_config_file = weechat_config_new (IRC_CONFIG_FILENAME);
+ irc_config_file = weechat_config_new (IRC_CONFIG_FILENAME,
+ &irc_config_reload);
if (!irc_config_file)
return 0;
@@ -727,74 +786,6 @@ irc_config_read ()
}
/*
- * irc_config_reload_cb: read IRC configuration file
- */
-
-int
-irc_config_reload_cb (void *data, char *event, void *pointer)
-{
- struct t_irc_server *ptr_server, *next_server;
- int rc;
-
- /* make C compiler happy */
- (void) data;
- (void) event;
- (void) pointer;
-
- irc_config_server = NULL;
- irc_config_reload_flag = 1;
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- ptr_server->reloaded_from_config = 0;
- }
-
- rc = weechat_config_reload (irc_config_file);
-
- if (rc == 0)
- {
-
- if (irc_config_server)
- irc_server_init_with_config_options (irc_config_server,
- irc_config_section_server,
- irc_config_reload_flag);
-
- ptr_server = irc_servers;
- while (ptr_server)
- {
- next_server = ptr_server->next_server;
-
- if (!ptr_server->reloaded_from_config)
- {
- if (ptr_server->is_connected)
- {
- weechat_printf (NULL,
- _("%s%s: warning: server \"%s\" not found "
- "in configuration file. It has not been "
- "deleted because it's used now."),
- weechat_prefix ("info"), "irc",
- ptr_server->name);
- }
- else
- irc_server_free (ptr_server);
- }
-
- ptr_server = next_server;
- }
-
- weechat_printf (NULL,
- _("%s%s: configuration file reloaded"),
- weechat_prefix ("info"), "irc");
- return WEECHAT_RC_OK;
- }
-
- weechat_printf (NULL,
- _("%s%s: failed to reload configuration file"),
- weechat_prefix ("error"), "irc");
- return WEECHAT_RC_ERROR;
-}
-
-/*
* irc_config_write: write IRC configuration file
* return: 0 if ok
* < 0 if error