From b91309c62971ecb1484a5010779fb95e185199d8 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Sat, 21 Jul 2007 16:32:53 +0100 Subject: [PATCH] Added ABI checking when loading plugins. --- src/includes/teleport.h | 2 ++ src/plugin.c | 13 +++++++++++++ src/plugins/beagle.c | 5 +++++ src/plugins/tracker.c | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/src/includes/teleport.h b/src/includes/teleport.h index 8fbca6c..3e371bf 100644 --- a/src/includes/teleport.h +++ b/src/includes/teleport.h @@ -28,6 +28,8 @@ #include #include +#define TELEPORT_ABI 20070721 + typedef struct _TeleportAction TeleportAction; typedef struct _TeleportPlugin TeleportPlugin; diff --git a/src/plugin.c b/src/plugin.c index 576dd1c..06e3ac7 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -50,9 +50,22 @@ teleport_load_plugin (const gchar* name) if (dlm) { GetVTableProc getVTable; + int (*getAbi)(); g_log (NULL, G_LOG_LEVEL_DEBUG, "%s: Loaded", name); + if (!g_module_symbol(dlm, "teleport_get_abi", (gpointer)(&getAbi)) + || (*getAbi)() != TELEPORT_ABI) + { + g_log (NULL, G_LOG_LEVEL_DEBUG, "%s: ABI mismatch, recompile the plugin", name); + g_module_close (dlm); + g_free (pluginPath); + g_free (plug); + + return NULL; + + } + if (!g_module_symbol(dlm, "teleportGetVTable", (gpointer)(&getVTable))) { g_log (NULL, G_LOG_LEVEL_DEBUG, "%s: Unable to find teleportGetVTable", name); diff --git a/src/plugins/beagle.c b/src/plugins/beagle.c index 2c78444..49f5244 100644 --- a/src/plugins/beagle.c +++ b/src/plugins/beagle.c @@ -129,6 +129,11 @@ TeleportPluginVTable beagleVTable = { beagle_cancel_query }; +int teleport_get_abi () +{ + return TELEPORT_ABI; +} + TeleportPluginVTable* teleportGetVTable () { return &beagleVTable; diff --git a/src/plugins/tracker.c b/src/plugins/tracker.c index 067701d..a53771a 100644 --- a/src/plugins/tracker.c +++ b/src/plugins/tracker.c @@ -128,6 +128,11 @@ TeleportPluginVTable trackerVTable = { tracker_cancel_query }; +int teleport_get_abi () +{ + return TELEPORT_ABI; +} + TeleportPluginVTable* teleportGetVTable () { return &trackerVTable; -- 2.11.4.GIT