YAML: Move plugin contract into separate function
/* -- Imports --------------------------------------------------------------------------------------------------------------------------- */
#include "yaml.h"
+
#include <kdbhelper.h>
+#include <kdblogger.h>
/* -- Functions ------------------------------------------------------------------------------------------------------------------------- */
+// ===========
+// = Private =
+// ===========
+
+/**
+ * @brief This function returns a key set containing the contract of this plugin.
+ *
+ * @return A contract describing the functionality of this plugin.
+ */
+static inline KeySet * contractYaml ()
+{
+ return ksNew (30, keyNew ("system/elektra/modules/yaml", KEY_VALUE, "yaml plugin waits for your orders", KEY_END),
+ keyNew ("system/elektra/modules/yaml/exports", KEY_END),
+ keyNew ("system/elektra/modules/yaml/exports/get", KEY_FUNC, elektraYamlGet, KEY_END),
+ keyNew ("system/elektra/modules/yaml/exports/set", KEY_FUNC, elektraYamlSet, KEY_END),
+#include ELEKTRA_README (yaml)
+ keyNew ("system/elektra/modules/yaml/infos/version", KEY_VALUE, PLUGINVERSION, KEY_END), KS_END);
+}
+
// ====================
// = Plugin Interface =
// ====================
@@ -23,13 +44,8 @@ int elektraYamlGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN
{
if (!elektraStrCmp (keyName (parentKey), "system/elektra/modules/yaml"))
{
- KeySet * contract =
- ksNew (30, keyNew ("system/elektra/modules/yaml", KEY_VALUE, "yaml plugin waits for your orders", KEY_END),
- keyNew ("system/elektra/modules/yaml/exports", KEY_END),
- keyNew ("system/elektra/modules/yaml/exports/get", KEY_FUNC, elektraYamlGet, KEY_END),
- keyNew ("system/elektra/modules/yaml/exports/set", KEY_FUNC, elektraYamlSet, KEY_END),
-#include ELEKTRA_README (yaml)
- keyNew ("system/elektra/modules/yaml/infos/version", KEY_VALUE, PLUGINVERSION, KEY_END), KS_END);
+ ELEKTRA_LOG_DEBUG ("Retrieve plugin contract");
+ KeySet * contract = contractYaml ();
ksAppend (returned, contract);
ksDel (contract);
