From 8193ab130d383015697c992694c625862d873c14 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 29 Jan 2007 15:08:52 +0100 Subject: [PATCH] src/plugin.[ch]: Provide unregister-functions for plugins to remove certain functions. --- src/plugin.c | 39 +++++++++++++++++++++++++++++++++++++++ src/plugin.h | 6 ++++++ 2 files changed, 45 insertions(+) diff --git a/src/plugin.c b/src/plugin.c index b40d62a1..df2eb6b5 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -77,6 +77,20 @@ static int register_callback (llist_t **list, const char *name, void *callback) return (0); } /* int register_callback */ +static int plugin_unregister (llist_t *list, const char *name) +{ + llentry_t *e; + + e = llist_search (list, name); + + if (e == NULL) + return (-1); + + llist_remove (list, e); + + return (0); +} /* int plugin_unregister */ + /* * (Try to) load the shared object `file'. Won't complain if it isn't a shared * object, but it will bitch about a shared object not having a @@ -235,6 +249,31 @@ int plugin_register_data_set (const data_set_t *ds) return (register_callback (&list_data_set, ds->type, (void *) ds)); } /* int plugin_register_data_set */ +int plugin_unregister_init (const char *name) +{ + return (plugin_unregister (list_init, name)); +} + +int plugin_unregister_read (const char *name) +{ + return (plugin_unregister (list_read, name)); +} + +int plugin_unregister_write (const char *name) +{ + return (plugin_unregister (list_write, name)); +} + +int plugin_unregister_shutdown (const char *name) +{ + return (plugin_unregister (list_shutdown, name)); +} + +int plugin_unregister_data_set (const char *name) +{ + return (plugin_unregister (list_data_set, name)); +} + void plugin_init_all (void) { int (*callback) (void); diff --git a/src/plugin.h b/src/plugin.h index 107078e7..b0bdbee1 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -138,6 +138,12 @@ int plugin_register_shutdown (char *name, int (*callback) (void)); int plugin_register_data_set (const data_set_t *ds); +int plugin_unregister_init (const char *name); +int plugin_unregister_read (const char *name); +int plugin_unregister_write (const char *name); +int plugin_unregister_shutdown (const char *name); +int plugin_unregister_data_set (const char *name); + /* * NAME * plugin_dispatch_values -- 2.11.0