#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
+#define IRSSI_ABI_VERSION 1
+
#define DEFAULT_SERVER_ADD_PORT 6667
#ifdef HAVE_CONFIG_H
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)
{
"", 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,
{
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);
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");
enum {
MODULE_ERROR_ALREADY_LOADED,
MODULE_ERROR_LOAD,
+ MODULE_ERROR_VERSION_MISMATCH,
MODULE_ERROR_INVALID
};
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
TXT_MODULE_LOAD_ERROR, rootmodule, submodule, data);
break;
+ case MODULE_ERROR_VERSION_MISMATCH:
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_MODULE_VERSION_MISMATCH, rootmodule, submodule, data);
+ break;
case MODULE_ERROR_INVALID:
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
TXT_MODULE_INVALID, rootmodule, submodule);
{ "module_already_loaded", "Module {hilight $0/$1} already loaded", 2, { 0, 0 } },
{ "module_not_loaded", "Module {hilight $0/$1} is not loaded", 2, { 0, 0 } },
{ "module_load_error", "Error loading module {hilight $0/$1}: $2", 3, { 0, 0, 0 } },
+ { "module_version_mismatch", "{hilight $0/$1} is ABI version $2 but Irssi is version $abiversion, cannot load", 3, { 0, 0, 0 } },
{ "module_invalid", "{hilight $0/$1} isn't Irssi module", 2, { 0, 0 } },
{ "module_loaded", "Loaded module {hilight $0/$1}", 2, { 0, 0 } },
{ "module_unloaded", "Unloaded module {hilight $0/$1}", 2, { 0, 0 } },
TXT_MODULE_ALREADY_LOADED,
TXT_MODULE_NOT_LOADED,
TXT_MODULE_LOAD_ERROR,
+ TXT_MODULE_VERSION_MISMATCH,
TXT_MODULE_INVALID,
TXT_MODULE_LOADED,
TXT_MODULE_UNLOADED,
{
proxy_listen_deinit();
}
+
+void irc_proxy_abicheck(int *version)
+{
+ *version = IRSSI_ABI_VERSION;
+}
signal_remove("script error", (SIGNAL_FUNC) sig_script_error);
PERL_SYS_TERM();
}
+
+void perl_core_abicheck(int *version)
+{
+ *version = IRSSI_ABI_VERSION;
+}
perl_core_print_script_error(TRUE);
}
+
+void fe_perl_abicheck(int *version)
+{
+ *version = IRSSI_ABI_VERSION;
+}