From 57e7d4b1753480c4d93b79e8fa4c57f1b5a71dbd Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 27 Aug 2012 05:49:16 +0200 Subject: [PATCH] added configuration (re)load event --- src/IRCEvents.c | 7 ++++++- src/IRCEvents.h | 7 +++++++ src/main.c | 2 ++ src/modules.c | 4 ++-- src/modules/module.h | 4 ++-- src/version.h | 2 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/IRCEvents.c b/src/IRCEvents.c index 2ef7f3f..b4eba22 100644 --- a/src/IRCEvents.c +++ b/src/IRCEvents.c @@ -48,8 +48,9 @@ static void **binds; #define BIND_TYPE_REGISTERED 16 #define BIND_TYPE_FREEUSER 17 #define BIND_TYPE_FREECHAN 18 +#define BIND_TYPE_RELOAD 19 -#define TOTAL_BIND_TYPES 19 +#define TOTAL_BIND_TYPES 20 void init_bind() { binds = calloc(TOTAL_BIND_TYPES, sizeof(*binds)); @@ -221,3 +222,7 @@ FUNC_EVENT(freeuser, freeuser_func_t, BIND_TYPE_FREEUSER, (struct UserNode *user FUNC_BIND(freechan, freechan_func_t, BIND_TYPE_FREECHAN) FUNC_UNBIND(freechan, freechan_func_t, BIND_TYPE_FREECHAN) FUNC_EVENT(freechan, freechan_func_t, BIND_TYPE_FREECHAN, (struct ChanNode *chan), (chan)) + +FUNC_BIND(reload, reload_func_t, BIND_TYPE_RELOAD) +FUNC_UNBIND(reload, reload_func_t, BIND_TYPE_RELOAD) +FUNC_EVENT(reload, reload_func_t, BIND_TYPE_RELOAD, (int initialization), (initialization)) \ No newline at end of file diff --git a/src/IRCEvents.h b/src/IRCEvents.h index e319037..2b8e947 100644 --- a/src/IRCEvents.h +++ b/src/IRCEvents.h @@ -156,4 +156,11 @@ typedef int freechan_func_t(struct ChanNode *chan); int event_freechan(struct ChanNode *chan); #endif +typedef int reload_func_t(int initialization); +#ifndef DND_FUNCTIONS +/* MODULAR ACCESSIBLE */ int bind_reload(reload_func_t *func, int module_id); +/* MODULAR ACCESSIBLE */ void unbind_reload(reload_func_t *func); +int event_reload(int initialization); +#endif + #endif diff --git a/src/main.c b/src/main.c index 2e0e5f3..3bef6ee 100644 --- a/src/main.c +++ b/src/main.c @@ -209,6 +209,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Unable to load " CONF_FILE "\n"); exit(0); } + event_reload(1); #if HAVE_THREADS THREAD_MUTEX_INIT(log_sync); #endif @@ -412,6 +413,7 @@ void stop_bot() { void reload_config() { loadConfig(CONF_FILE); + event_reload(0); } static int getCurrentSecondsOfDay() { diff --git a/src/modules.c b/src/modules.c index ba3562a..2b722db 100644 --- a/src/modules.c +++ b/src/modules.c @@ -113,8 +113,8 @@ void *global_functions[] = { /* 054 */ (Function) unbind_nick, /* 055 */ (Function) bind_part, /* 056 */ (Function) unbind_part, -/* 057 */ (Function) NULL, /* deprecated */ -/* 058 */ (Function) NULL, /* deprecated */ +/* 057 */ (Function) bind_reload, +/* 058 */ (Function) unbind_reload, /* 059 */ (Function) bind_kick, /* 060 */ (Function) unbind_kick, /* 061 */ (Function) bind_topic, diff --git a/src/modules/module.h b/src/modules/module.h index 50207b5..8d8d196 100644 --- a/src/modules/module.h +++ b/src/modules/module.h @@ -84,8 +84,8 @@ extern int module_id; /* 054 */ #define unbind_nick ((void (*)(nick_func_t *))global[54]) /* 055 */ #define bind_part ((int (*)(part_func_t *, int))global[55]) /* 056 */ #define unbind_part ((void (*)(part_func_t *))global[56]) -/* 057 */ /* deprecated */ -/* 058 */ /* deprecated */ +/* 057 */ #define bind_reload ((int (*)(reload_func_t *, int))global[57]) +/* 058 */ #define unbind_reload ((void (*)(reload_func_t *))global[58]) /* 059 */ #define bind_kick ((int (*)(kick_func_t *, int))global[59]) /* 060 */ #define unbind_kick ((void (*)(kick_func_t *))global[60]) /* 061 */ #define bind_topic ((int (*)(topic_func_t *, int))global[61]) diff --git a/src/version.h b/src/version.h index 26a178b..2b653c2 100644 --- a/src/version.h +++ b/src/version.h @@ -19,7 +19,7 @@ #include "main.h" -#define MODULE_VERSION 5 +#define MODULE_VERSION 6 #ifndef DND_FUNCTIONS extern const char *compilation; -- 2.20.1