From bf6a4a577408aa6192c40f9a789788badb1a386a Mon Sep 17 00:00:00 2001 From: Alok Barsode Date: Tue, 17 Mar 2009 18:56:21 +0530 Subject: Adding version check for plugins. --- audio/main.c | 2 +- input/main.c | 2 +- network/main.c | 2 +- plugins/echo.c | 2 +- plugins/hal.c | 2 +- plugins/netlink.c | 2 +- plugins/service.c | 2 +- plugins/storage.c | 2 +- serial/main.c | 2 +- src/main.c | 2 +- src/plugin.c | 5 +++++ src/plugin.h | 5 +++-- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/audio/main.c b/audio/main.c index 1678b58d..f5eb7dde 100644 --- a/audio/main.c +++ b/audio/main.c @@ -171,4 +171,4 @@ static void audio_exit(void) dbus_connection_unref(connection); } -BLUETOOTH_PLUGIN_DEFINE("audio", audio_init, audio_exit) +BLUETOOTH_PLUGIN_DEFINE("audio", VERSION, audio_init, audio_exit) diff --git a/input/main.c b/input/main.c index 31e2ef64..010b7312 100644 --- a/input/main.c +++ b/input/main.c @@ -82,4 +82,4 @@ static void input_exit(void) dbus_connection_unref(connection); } -BLUETOOTH_PLUGIN_DEFINE("input", input_init, input_exit) +BLUETOOTH_PLUGIN_DEFINE("input", VERSION, input_init, input_exit) diff --git a/network/main.c b/network/main.c index 4744185a..5f96d4b6 100644 --- a/network/main.c +++ b/network/main.c @@ -55,4 +55,4 @@ static void network_exit(void) dbus_connection_unref(connection); } -BLUETOOTH_PLUGIN_DEFINE("network", network_init, network_exit) +BLUETOOTH_PLUGIN_DEFINE("network", VERSION, network_init, network_exit) diff --git a/plugins/echo.c b/plugins/echo.c index 3486ef1f..832bf8b0 100644 --- a/plugins/echo.c +++ b/plugins/echo.c @@ -163,4 +163,4 @@ static void echo_exit(void) btd_unregister_adapter_driver(&echo_server); } -BLUETOOTH_PLUGIN_DEFINE("echo", echo_init, echo_exit) +BLUETOOTH_PLUGIN_DEFINE("echo", VERSION, echo_init, echo_exit) diff --git a/plugins/hal.c b/plugins/hal.c index f066a5ab..219b46ec 100644 --- a/plugins/hal.c +++ b/plugins/hal.c @@ -158,4 +158,4 @@ static void hal_exit(void) btd_unregister_adapter_driver(&hal_driver); } -BLUETOOTH_PLUGIN_DEFINE("hal", hal_init, hal_exit) +BLUETOOTH_PLUGIN_DEFINE("hal", VERSION, hal_init, hal_exit) diff --git a/plugins/netlink.c b/plugins/netlink.c index 78a18aa1..f777cf9f 100644 --- a/plugins/netlink.c +++ b/plugins/netlink.c @@ -123,4 +123,4 @@ static void netlink_exit(void) nl_handle_destroy(handle); } -BLUETOOTH_PLUGIN_DEFINE("netlink", netlink_init, netlink_exit) +BLUETOOTH_PLUGIN_DEFINE("netlink", VERSION, netlink_init, netlink_exit) diff --git a/plugins/service.c b/plugins/service.c index 4a872348..b4d405b7 100644 --- a/plugins/service.c +++ b/plugins/service.c @@ -859,4 +859,4 @@ static void service_exit(void) dbus_connection_unref(connection); } -BLUETOOTH_PLUGIN_DEFINE("service", service_init, service_exit) +BLUETOOTH_PLUGIN_DEFINE("service", VERSION, service_init, service_exit) diff --git a/plugins/storage.c b/plugins/storage.c index 733c4798..c4dbe167 100644 --- a/plugins/storage.c +++ b/plugins/storage.c @@ -39,4 +39,4 @@ static void storage_exit(void) { } -BLUETOOTH_PLUGIN_DEFINE("storage", storage_init, storage_exit) +BLUETOOTH_PLUGIN_DEFINE("storage", VERSION, storage_init, storage_exit) diff --git a/serial/main.c b/serial/main.c index bb2a28c4..5db389c6 100644 --- a/serial/main.c +++ b/serial/main.c @@ -55,4 +55,4 @@ static void serial_exit(void) dbus_connection_unref(connection); } -BLUETOOTH_PLUGIN_DEFINE("serial", serial_init, serial_exit) +BLUETOOTH_PLUGIN_DEFINE("serial", VERSION, serial_init, serial_exit) diff --git a/src/main.c b/src/main.c index 3c7d70bb..53034444 100644 --- a/src/main.c +++ b/src/main.c @@ -695,7 +695,7 @@ int main(int argc, char *argv[]) umask(0077); - start_logging("bluetoothd", "Bluetooth daemon"); + start_logging("bluetoothd", "Bluetooth daemon %s", VERSION); memset(&sa, 0, sizeof(sa)); sa.sa_flags = SA_NOCLDSTOP; diff --git a/src/plugin.c b/src/plugin.c index 4559c77b..051c33c0 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -53,6 +53,11 @@ static gboolean add_plugin(void *handle, struct bluetooth_plugin_desc *desc) if (desc->init == NULL) return FALSE; + if (g_str_equal(desc->version, VERSION) == FALSE) { + DBG("version mismatch for %s", desc->name); + return FALSE; + } + plugin = g_try_new0(struct bluetooth_plugin, 1); if (plugin == NULL) return FALSE; diff --git a/src/plugin.h b/src/plugin.h index 31bcce87..62d5f758 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -23,13 +23,14 @@ struct bluetooth_plugin_desc { const char *name; + const char *version; int (*init) (void); void (*exit) (void); }; -#define BLUETOOTH_PLUGIN_DEFINE(name,init,exit) \ +#define BLUETOOTH_PLUGIN_DEFINE(name,version,init,exit) \ extern struct bluetooth_plugin_desc bluetooth_plugin_desc \ __attribute__ ((visibility("default"))); \ struct bluetooth_plugin_desc bluetooth_plugin_desc = { \ - name, init, exit \ + name, version, init, exit \ }; -- cgit