diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/expandos.c | 9 | ||||
-rw-r--r-- | src/core/modules-load.c | 26 | ||||
-rw-r--r-- | src/core/modules.h | 1 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/core/expandos.c b/src/core/expandos.c index 1fc517af..67aea837 100644 --- a/src/core/expandos.c +++ b/src/core/expandos.c @@ -414,6 +414,13 @@ static char *expando_releasetime(SERVER_REC *server, void *item, int *free_ret) return g_strdup_printf("%04d", IRSSI_VERSION_TIME); } +/* client abi */ +static char *expando_abiversion(SERVER_REC *server, void *item, int *free_ret) +{ + *free_ret = TRUE; + return g_strdup_printf("%d", IRSSI_ABI_VERSION); +} + /* current working directory */ static char *expando_workdir(SERVER_REC *server, void *item, int *free_ret) { @@ -658,6 +665,8 @@ void expandos_init(void) "", EXPANDO_NEVER, NULL); expando_create("versiontime", expando_releasetime, "", EXPANDO_NEVER, NULL); + expando_create("abiversion", expando_abiversion, + "", EXPANDO_NEVER, NULL); expando_create("W", expando_workdir, NULL); expando_create("Y", expando_realname, "window changed", EXPANDO_ARG_NONE, diff --git a/src/core/modules-load.c b/src/core/modules-load.c index 6086d9ae..9baac1d7 100644 --- a/src/core/modules-load.c +++ b/src/core/modules-load.c @@ -160,11 +160,14 @@ static int module_load_name(const char *path, const char *rootmodule, { void (*module_init) (void); void (*module_deinit) (void); + void (*module_version) (int *); GModule *gmodule; MODULE_REC *module; MODULE_FILE_REC *rec; + gpointer value_version = NULL; gpointer value1, value2 = NULL; - char *initfunc, *deinitfunc; + char *versionfunc, *initfunc, *deinitfunc; + int module_abi_version = 0; int found; gmodule = module_open(path, &found); @@ -176,6 +179,27 @@ static int module_load_name(const char *path, const char *rootmodule, return found ? 0 : -1; } + /* get the module's irssi abi version and bail out on mismatch */ + versionfunc = module_get_func(rootmodule, submodule, "abicheck"); + if (!g_module_symbol(gmodule, versionfunc, &value_version)) { + g_free(versionfunc); + module_error(MODULE_ERROR_VERSION_MISMATCH, "0", + rootmodule, submodule); + g_module_close(gmodule); + return 0; + } + g_free(versionfunc); + module_version = value_version; + module_version(&module_abi_version); + if (module_abi_version != IRSSI_ABI_VERSION) { + char *module_abi_versionstr = g_strdup_printf("%d", module_abi_version); + module_error(MODULE_ERROR_VERSION_MISMATCH, module_abi_versionstr, + rootmodule, submodule); + g_free(module_abi_versionstr); + g_module_close(gmodule); + return 0; + } + /* get the module's init() and deinit() functions */ initfunc = module_get_func(rootmodule, submodule, "init"); deinitfunc = module_get_func(rootmodule, submodule, "deinit"); diff --git a/src/core/modules.h b/src/core/modules.h index 75a77c77..b2fa2fa4 100644 --- a/src/core/modules.h +++ b/src/core/modules.h @@ -27,6 +27,7 @@ enum { MODULE_ERROR_ALREADY_LOADED, MODULE_ERROR_LOAD, + MODULE_ERROR_VERSION_MISMATCH, MODULE_ERROR_INVALID }; |