From 373b92482bfded14f0aa9669fedb58722b32a489 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 1 Jul 2014 21:56:02 +0200 Subject: [PATCH] plugin: Added sdb_plugin_current(). This function returns the plugin information for the plugin from which the current call into the core originated. --- src/core/plugin.c | 10 ++++++++++ src/include/core/plugin.h | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/core/plugin.c b/src/core/plugin.c index f10a904..806e13c 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -814,6 +814,16 @@ sdb_plugin_set_ctx(sdb_plugin_ctx_t ctx, sdb_plugin_ctx_t *old) return 0; } /* sdb_plugin_set_ctx */ +const sdb_plugin_info_t * +sdb_plugin_current(void) +{ + ctx_t *ctx = ctx_get(); + + if (! ctx) + return NULL; + return &ctx->info; +} /* sdb_plugin_current */ + int sdb_plugin_configure(const char *name, oconfig_item_t *ci) { diff --git a/src/include/core/plugin.h b/src/include/core/plugin.h index e6ea757..f75788a 100644 --- a/src/include/core/plugin.h +++ b/src/include/core/plugin.h @@ -248,6 +248,19 @@ sdb_plugin_get_ctx(void); int sdb_plugin_set_ctx(sdb_plugin_ctx_t ctx, sdb_plugin_ctx_t *old); +/* + * sdb_plugin_current: + * Retrieve information about the plugin (if any) from which the current call + * into the core originated. The return value may not be modified. + * + * Returns: + * - information about the current plugin if we were called from some + * plugin's callback function + * - NULL else + */ +const sdb_plugin_info_t * +sdb_plugin_current(void); + /* * sdb_plugin_configure: * Configure the plugin called 'name' using the config tree 'ci'. The plugin -- 2.30.2