diff options
| author | Denis Kenzior <denkenz@gmail.com> | 2020-09-16 16:59:34 -0500 |
|---|---|---|
| committer | Denis Kenzior <denkenz@gmail.com> | 2020-09-16 17:00:46 -0500 |
| commit | e129cb4cd2270f308c1564e75859672643dd902b (patch) | |
| tree | 01d335f18d41d4cf5e01ed913a2ee347d24b46f1 | |
| parent | 1e7d7f933db058161877a88dee4cb9894d0b1901 (diff) | |
plugin: Remove completely
There are now no users of this code, so remove from ell.
| -rw-r--r-- | Makefile.am | 13 | ||||
| -rw-r--r-- | ell/ell.h | 1 | ||||
| -rw-r--r-- | ell/ell.sym | 4 | ||||
| -rw-r--r-- | ell/plugin.c | 219 | ||||
| -rw-r--r-- | ell/plugin.h | 78 | ||||
| -rw-r--r-- | unit/example-plugin.c | 45 | ||||
| -rw-r--r-- | unit/test-plugin.c | 56 |
7 files changed, 0 insertions, 416 deletions
diff --git a/Makefile.am b/Makefile.am index 1f1b50fa..8711db86 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,6 @@ pkginclude_HEADERS = ell/ell.h \ ell/io.h \ ell/ringbuf.h \ ell/log.h \ - ell/plugin.h \ ell/checksum.h \ ell/netlink.h \ ell/genl.h \ @@ -82,7 +81,6 @@ ell_libell_la_SOURCES = $(linux_headers) \ ell/io.c \ ell/ringbuf.c \ ell/log.c \ - ell/plugin.c \ ell/checksum.c \ ell/netlink-private.h \ ell/netlink.c \ @@ -170,7 +168,6 @@ unit_tests = unit/test-unit \ unit/test-main \ unit/test-io \ unit/test-ringbuf \ - unit/test-plugin \ unit/test-checksum \ unit/test-settings \ unit/test-netlink \ @@ -250,9 +247,6 @@ unit_test_io_LDADD = ell/libell-private.la unit_test_ringbuf_LDADD = ell/libell-private.la -unit_test_plugin_LDFLAGS = -Wl,-export-dynamic -unit_test_plugin_LDADD = ell/libell-private.la -ldl - unit_test_checksum_LDADD = ell/libell-private.la unit_test_settings_LDADD = ell/libell-private.la @@ -325,13 +319,6 @@ unit_test_path_LDADD = ell/libell-private.la unit_test_net_LDADD = ell/libell-private.la -if MAINTAINER_MODE -noinst_LTLIBRARIES += unit/example-plugin.la -endif - -unit_example_plugin_la_LDFLAGS = -no-undefined -module -avoid-version \ - -rpath /dummy - unit_test_data_files = unit/settings.test unit/dbus.conf examples = examples/dbus-service examples/https-client-test \ @@ -34,7 +34,6 @@ #include <ell/io.h> #include <ell/ringbuf.h> #include <ell/log.h> -#include <ell/plugin.h> #include <ell/checksum.h> #include <ell/settings.h> #include <ell/hwdb.h> diff --git a/ell/ell.sym b/ell/ell.sym index d33c3211..0d560cda 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -395,10 +395,6 @@ global: /* pkcs5 */ l_pkcs5_pbkdf1; l_pkcs5_pbkdf2; - /* plugin */ - l_plugin_add; - l_plugin_load; - l_plugin_unload; /* getrandom */ l_getrandom; l_getrandom_is_supported; diff --git a/ell/plugin.c b/ell/plugin.c deleted file mode 100644 index 21b81d02..00000000 --- a/ell/plugin.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * - * Embedded Linux library - * - * Copyright (C) 2011-2014 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _GNU_SOURCE -#include <stdio.h> -#include <dlfcn.h> -#include <stdlib.h> -#include <glob.h> - -#include "util.h" -#include "queue.h" -#include "plugin.h" -#include "log.h" -#include "private.h" - -/** - * SECTION:plugin - * @short_description: Plugin framework - * - * Plugin framework - */ - -/** - * l_plugin_desc: - * - * Plugin descriptor. - */ - -static struct l_queue *plugin_list; - -struct plugin { - void *handle; - bool active; - const struct l_plugin_desc *desc; -}; - -static void plugin_destroy(void *user_data) -{ - struct plugin *plugin = user_data; - - if (plugin->active && plugin->desc->exit) - plugin->desc->exit(); - - if (plugin->handle) - dlclose(plugin->handle); - - l_free(plugin); -} - -static int compare_priority(const void *a, const void *b, void *user_data) -{ - const struct plugin *plugin_a = a; - const struct plugin *plugin_b = b; - - return plugin_a->desc->priority - plugin_b->desc->priority; -} - -static bool plugin_add(void *handle, const struct l_plugin_desc *desc, - const char *version) -{ - struct plugin *plugin; - - if (!desc->init) - return false; - - if (version) { - if (!desc->version) - return false; - - if (strcmp(desc->version, version)) - return false; - } - - plugin = l_new(struct plugin, 1); - - plugin->handle = handle; - plugin->active = false; - plugin->desc = desc; - - l_queue_insert(plugin_list, plugin, compare_priority, NULL); - - if (desc->debug_start && desc->debug_stop) - debug_enable(desc->debug_start, desc->debug_stop); - - return true; -} - -static void plugin_start(void *data, void *user_data) -{ - struct plugin *plugin = data; - - if (plugin->desc->init() < 0) - return; - - plugin->active = true; -} - -static void update_debug(void *data, void *user_data) -{ - struct plugin *plugin = data; - - if (plugin->desc->debug_start && plugin->desc->debug_stop) - debug_enable(plugin->desc->debug_start, - plugin->desc->debug_stop); -} - -void plugin_update_debug(void) -{ - l_queue_foreach(plugin_list, update_debug, NULL); -} - -/** - * l_plugin_add: - * @desc: plugin description record - * @version: version string or #NULL - * - * Adds plugin description. - **/ -LIB_EXPORT void l_plugin_add(const struct l_plugin_desc *desc, - const char *version) -{ - if (!plugin_list) - plugin_list = l_queue_new(); - - if (!desc) - return; - - plugin_add(NULL, desc, version); -} - -/** - * l_plugin_load: - * @pattern: file pattern - * @symbol: plugin descriptor symbol - * @version: version string or #NULL - * - * Loads plugins from @pattern location and execute @symbol plugin descriptor. - **/ -LIB_EXPORT void l_plugin_load(const char *pattern, const char *symbol, - const char *version) -{ - glob_t gl; - size_t i; - - if (!plugin_list) - plugin_list = l_queue_new(); - - if (!pattern || !symbol) - goto done; - - if (glob(pattern, GLOB_NOSORT, NULL, &gl)) - goto done; - - for (i = 0; i < gl.gl_pathc; i++) { - void *handle; - struct l_plugin_desc *desc; - - handle = dlopen(gl.gl_pathv[i], RTLD_NOW); - if (!handle) { - l_info("Unable to load %s: %s", - gl.gl_pathv[i], dlerror()); - continue; - } - - desc = dlsym(handle, symbol); - if (!desc) { - dlclose(handle); - continue; - } - - if (!plugin_add(handle, desc, version)) - dlclose(handle); - } - - globfree(&gl); - -done: - l_queue_foreach(plugin_list, plugin_start, NULL); -} - -/** - * l_plugin_unload: - * - * Unload all plugins. - **/ -LIB_EXPORT void l_plugin_unload(void) -{ - if (!plugin_list) - return; - - l_queue_reverse(plugin_list); - - l_queue_destroy(plugin_list, plugin_destroy); - - plugin_list = NULL; -} diff --git a/ell/plugin.h b/ell/plugin.h deleted file mode 100644 index 5ca95dcc..00000000 --- a/ell/plugin.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Embedded Linux library - * - * Copyright (C) 2011-2014 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __ELL_PLUGIN_H -#define __ELL_PLUGIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define L_PLUGIN_PRIORITY_LOW -100 -#define L_PLUGIN_PRIORITY_DEFAULT 0 -#define L_PLUGIN_PRIORITY_HIGH 100 - -struct l_plugin_desc { - const char *name; - const char *description; - const char *version; - int priority; - int (*init) (void); - void (*exit) (void); - void *debug_start; - void *debug_stop; -}; - - -#define L_PLUGIN_DEFINE(symbol, name, description, version, \ - priority, init, exit) \ - extern struct l_plugin_desc symbol \ - __attribute__ ((visibility("default"))); \ - struct l_plugin_desc symbol = { \ - #name, description, version, priority, init, exit, \ - NULL, NULL \ - }; - -#define L_PLUGIN_DEFINE_DEBUG(symbol, name, description, version, \ - priority, init, exit, debug) \ - extern struct l_debug_desc __start_ ##debug[] \ - __attribute__ ((weak, visibility("hidden"))); \ - extern struct l_debug_desc __stop_ ##debug[] \ - __attribute__ ((weak, visibility("hidden"))); \ - extern struct l_plugin_desc symbol \ - __attribute__ ((visibility("default"))); \ - struct l_plugin_desc symbol = { \ - #name, description, version, priority, init, exit, \ - __start_ ##debug, __stop_ ##debug \ - }; - -void l_plugin_add(const struct l_plugin_desc *desc, const char *version); - -void l_plugin_load(const char *pattern, const char *symbol, - const char *version); -void l_plugin_unload(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __ELL_PLUGIN_H */ diff --git a/unit/example-plugin.c b/unit/example-plugin.c deleted file mode 100644 index 644c9d07..00000000 --- a/unit/example-plugin.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Embedded Linux library - * - * Copyright (C) 2011-2014 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <ell/ell.h> - -static int demo_init(void) -{ - l_info("External demo plugin init"); - l_debug("some debug info"); - - return 0; -} - -static void demo_exit(void) -{ - l_info("External demo plugin exit"); - l_debug("some more debug info"); -} - -L_PLUGIN_DEFINE_DEBUG(demo_plugin_desc, demo, "External demo plugin", - VERSION, L_PLUGIN_PRIORITY_DEFAULT, - demo_init, demo_exit, __ell_debug) diff --git a/unit/test-plugin.c b/unit/test-plugin.c deleted file mode 100644 index 89642bd7..00000000 --- a/unit/test-plugin.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Embedded Linux library - * - * Copyright (C) 2011-2014 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <ell/ell.h> - -static int builtin_init(void) -{ - l_info("Builtin demo plugin init"); - - return 0; -} - -static void builtin_exit(void) -{ - l_info("Builtin demo plugin exit"); -} - -L_PLUGIN_DEFINE(__builtin_desc, builtin_demo, "Builtin demo plugin", VERSION, - L_PLUGIN_PRIORITY_DEFAULT, builtin_init, builtin_exit) - -int main(int argc, char *argv[]) -{ - l_log_set_stderr(); - l_debug_enable("*"); - - l_plugin_add(&__builtin_desc, VERSION); - - l_plugin_load("unit/.libs/*.so", "demo_plugin_desc", VERSION); - - l_plugin_unload(); - - return 0; -} |
