mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
Merge pull request #393 from ailin-nemui/moduleversion-perl
forward ABI to perl modules
This commit is contained in:
commit
62cab9d662
11 changed files with 59 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
enum {
|
||||
MODULE_ERROR_ALREADY_LOADED,
|
||||
MODULE_ERROR_LOAD,
|
||||
MODULE_ERROR_VERSION_MISMATCH,
|
||||
MODULE_ERROR_INVALID
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue