Added PLUGIN_NOOP to separate PLUGIN_PROVIDE from previous CALLBACK/REGISTER entries
This commit is contained in:
@@ -326,7 +326,8 @@ bool plugin_feature_load(plugin_t *plugin, plugin_feature_t *feature,
|
|||||||
}
|
}
|
||||||
if (reg->kind == FEATURE_CALLBACK)
|
if (reg->kind == FEATURE_CALLBACK)
|
||||||
{
|
{
|
||||||
if (reg->arg.cb.f(plugin, feature, TRUE, reg->arg.cb.data))
|
if (!reg->arg.cb.f ||
|
||||||
|
reg->arg.cb.f(plugin, feature, TRUE, reg->arg.cb.data))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -409,7 +410,8 @@ bool plugin_feature_unload(plugin_t *plugin, plugin_feature_t *feature,
|
|||||||
}
|
}
|
||||||
if (reg->kind == FEATURE_CALLBACK)
|
if (reg->kind == FEATURE_CALLBACK)
|
||||||
{
|
{
|
||||||
if (reg->arg.cb.f(plugin, feature, FALSE, reg->arg.cb.data))
|
if (!reg->arg.cb.f ||
|
||||||
|
reg->arg.cb.f(plugin, feature, FALSE, reg->arg.cb.data))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,17 +51,19 @@ typedef bool (*plugin_feature_callback_t)(plugin_t *plugin,
|
|||||||
* features provided by the plugin, hard (DEPENDS) or soft (SDEPEND) dependency
|
* features provided by the plugin, hard (DEPENDS) or soft (SDEPEND) dependency
|
||||||
* specified is related to the previously defined PROVIDE feature.
|
* specified is related to the previously defined PROVIDE feature.
|
||||||
* If a plugin feature requires to hook in functionality into the library
|
* If a plugin feature requires to hook in functionality into the library
|
||||||
* or a daemon, it can use REGISTER or CALLBACK entries. Each PROVIDED feature
|
* or a daemon, it can use REGISTER or CALLBACK entries. Each PROVIDE feature
|
||||||
* uses the REGISTER/CALLBACK entry defined previously. The REGISTER entry
|
* uses the REGISTER/CALLBACK entry defined previously. The REGISTER entry
|
||||||
* defines a common feature registration function directly passed to the
|
* defines a common feature registration function directly passed to the
|
||||||
* associated manager or factory (crypto/credential factory etc.). A callback
|
* associated manager or factory (crypto/credential factory etc.). A callback
|
||||||
* function is more generic allows the loader to invoke a callback to do
|
* function is more generic allows the loader to invoke a callback to do
|
||||||
* the registration.
|
* the registration. PROVIDE features that do not use a registration or callback
|
||||||
|
* function must be listed before any REGISTER/CALLBACK entry, or use the NOOP
|
||||||
|
* helper macro.
|
||||||
*
|
*
|
||||||
* To conviently create feature lists, use the four macros PLUGIN_REGISTER,
|
* To conveniently create feature lists, use the macros PLUGIN_REGISTER,
|
||||||
* PLUGIN_CALLBACK, PLUGIN_PROVIDE, PLUGIN_DEPENDS and PLUGIN_SDEPEND. Use
|
* PLUGIN_CALLBACK, PLUGIN_NOOP, PLUGIN_PROVIDE, PLUGIN_DEPENDS and
|
||||||
* identation to show how the registration functions and dependencies are
|
* PLUGIN_SDEPEND. Use indentation to show how the registration functions
|
||||||
* related to a provided feature, such as:
|
* and dependencies are related to a provided feature, such as:
|
||||||
*
|
*
|
||||||
* @verbatim
|
* @verbatim
|
||||||
// two features, one with two dependencies, both use a callback to register
|
// two features, one with two dependencies, both use a callback to register
|
||||||
@@ -75,7 +77,8 @@ typedef bool (*plugin_feature_callback_t)(plugin_t *plugin,
|
|||||||
PLUGIN_PROVIDE(...),
|
PLUGIN_PROVIDE(...),
|
||||||
PLUGIN_DEPENDS(...),
|
PLUGIN_DEPENDS(...),
|
||||||
// feature that does not use a registration function
|
// feature that does not use a registration function
|
||||||
PLUGIN_PROVIDE(...),
|
PLUGIN_NOOP,
|
||||||
|
PLUGIN_PROVIDE(...),
|
||||||
@endverbatim
|
@endverbatim
|
||||||
*/
|
*/
|
||||||
struct plugin_feature_t {
|
struct plugin_feature_t {
|
||||||
@@ -231,6 +234,11 @@ struct plugin_feature_t {
|
|||||||
*/
|
*/
|
||||||
#define PLUGIN_CALLBACK(cb, data) _PLUGIN_FEATURE_CALLBACK(cb, data)
|
#define PLUGIN_CALLBACK(cb, data) _PLUGIN_FEATURE_CALLBACK(cb, data)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The upcoming features use neither a callback nor a register function.
|
||||||
|
*/
|
||||||
|
#define PLUGIN_NOOP _PLUGIN_FEATURE_CALLBACK(NULL, NULL)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define a feature the plugin provides.
|
* Define a feature the plugin provides.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user