From: Sebastian Harl Date: Tue, 1 Jul 2014 19:56:02 +0000 (+0200) Subject: plugin: Added sdb_plugin_current(). X-Git-Tag: sysdb-0.2.0~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=373b92482bfded14f0aa9669fedb58722b32a489;p=sysdb.git plugin: Added sdb_plugin_current(). This function returns the plugin information for the plugin from which the current call into the core originated. --- 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