Skip to content

Commit

Permalink
add checkconf example to template plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
petermax2 committed May 17, 2016
1 parent 81a3b5e commit 9542f02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/tools/src/backendbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void BackendBuilder::addPlugin (PluginSpec const & plugin)
{
ckdb::Key * errorKey = ckdb::keyNew (0);
int checkResult = checkConfFunction (errorKey, newPlugin.getConfig ().getKeySet ());
if (checkResult != 0)
if (checkResult != 1)
{
throw PluginConfigInvalid (errorKey);
}
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/template/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int elektraTemplateGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTR
keyNew ("system/elektra/modules/template/exports/get", KEY_FUNC, elektraTemplateGet, KEY_END),
keyNew ("system/elektra/modules/template/exports/set", KEY_FUNC, elektraTemplateSet, KEY_END),
keyNew ("system/elektra/modules/template/exports/error", KEY_FUNC, elektraTemplateError, KEY_END),
keyNew ("system/elektra/modules/template/exports/checkconf", KEY_FUNC, elektraTemplateCheckConfig, KEY_END),
#include ELEKTRA_README (template)
keyNew ("system/elektra/modules/template/infos/version", KEY_VALUE, PLUGINVERSION, KEY_END), KS_END);
ksAppend (returned, contract);
Expand All @@ -64,6 +65,15 @@ int elektraTemplateError (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEK
return 1; // success
}

int elektraTemplateCheckConfig (Key * errorKey, KeySet * conf)
{
// validate plugin configuration
// this function is optional
// if the export symbol "exports/checkconf" is provided, the function will be called during the mount phase

return 1; // success
}

Plugin * ELEKTRA_PLUGIN_EXPORT (template)
{
// clang-format off
Expand Down
1 change: 1 addition & 0 deletions src/plugins/template/template.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int elektraTemplateClose (Plugin * handle, Key * errorKey);
int elektraTemplateGet (Plugin * handle, KeySet * ks, Key * parentKey);
int elektraTemplateSet (Plugin * handle, KeySet * ks, Key * parentKey);
int elektraTemplateError (Plugin * handle, KeySet * ks, Key * parentKey);
int elektraTemplateCheckConfig (Key * errorKey, KeySet * conf);

Plugin * ELEKTRA_PLUGIN_EXPORT (template);

Expand Down

0 comments on commit 9542f02

Please sign in to comment.