\hypertarget{group__plugin}{
\section{Plugins :: Elektra framework for plugins}
\label{group__plugin}\index{Plugins :: Elektra framework for plugins@{Plugins :: Elektra framework for plugins}}
}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{struct__Plugin}{Plugin} $\ast$ \hyperlink{group__plugin_ga8dd092048e972a3f0c9c9f54eb41576e}{elektraPluginExport} (const char $\ast$pluginName,...)
\item 
\hyperlink{struct__KeySet}{KeySet} $\ast$ \hyperlink{group__plugin_ga644bead796506c172817724051c977c9}{elektraPluginGetConfig} (\hyperlink{struct__Plugin}{Plugin} $\ast$handle)
\item 
void \hyperlink{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{elektraPluginSetData} (\hyperlink{struct__Plugin}{Plugin} $\ast$plugin, void $\ast$data)
\item 
void $\ast$ \hyperlink{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}{elektraPluginGetData} (\hyperlink{struct__Plugin}{Plugin} $\ast$plugin)
\item 
int \hyperlink{group__plugin_ga1e2cbea1275fc0d39a00a74eb69e12d8}{elektraDocOpen} (\hyperlink{struct__Plugin}{Plugin} $\ast$handle, \hyperlink{struct__Key}{Key} $\ast$errorKey)
\item 
int \hyperlink{group__plugin_gafb66a15abe15f79c9c5b3a928b42147d}{elektraDocClose} (\hyperlink{struct__Plugin}{Plugin} $\ast$handle, \hyperlink{struct__Key}{Key} $\ast$errorKey)
\item 
int \hyperlink{group__plugin_gacb69f3441c6d84241b4362f958fbe313}{elektraDocGet} (\hyperlink{struct__Plugin}{Plugin} $\ast$handle, \hyperlink{struct__KeySet}{KeySet} $\ast$returned, \hyperlink{struct__Key}{Key} $\ast$parentKey)
\item 
int \hyperlink{group__plugin_gae65781a1deb34efc79c8cb9d9174842c}{elektraDocSet} (\hyperlink{struct__Plugin}{Plugin} $\ast$handle, \hyperlink{struct__KeySet}{KeySet} $\ast$returned, \hyperlink{struct__Key}{Key} $\ast$parentKey)
\item 
\hyperlink{struct__Plugin}{Plugin} $\ast$ \hyperlink{group__plugin_gabe78724d2d477eef39997fd9b85bff16}{ELEKTRA\_\-PLUGIN\_\-EXPORT} (doc)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
\hypertarget{group__plugin_history}{}\subsection{History}\label{group__plugin_history}
\begin{DoxySince}{Since}
Since version 0.4.9, Elektra can dynamically load different key storage plugins.

Since version 0.7.0 Elektra can have multiple backends, mounted at any place in the key database.

Since version 0.8.0 Elektra backends are composed out of multiple plugins.
\end{DoxySince}
\hypertarget{index_overview}{}\subsection{Overview}\label{index_overview}
There are different types of plugins for different concerns. The types of plugins handled in this document:
\begin{DoxyItemize}
\item file storage plugins (also called just storage plugins here)
\item filter plugins
\end{DoxyItemize}

See \href{http://www.libelektra.org/ftp/elektra/thesis.pdf}{\tt http://www.libelektra.org/ftp/elektra/thesis.pdf} for an detailed explanation and description of other types of plugins.

A plugin can implement anything related to configuration. There are 5 possible entry points, as described in this document:
\begin{DoxyItemize}
\item \hyperlink{group__plugin_ga1e2cbea1275fc0d39a00a74eb69e12d8}{elektraDocOpen()}
\item \hyperlink{group__plugin_gafb66a15abe15f79c9c5b3a928b42147d}{elektraDocClose()}
\item \hyperlink{group__plugin_gacb69f3441c6d84241b4362f958fbe313}{elektraDocGet()}
\item \hyperlink{group__plugin_gae65781a1deb34efc79c8cb9d9174842c}{elektraDocSet()}
\item elektraDocError() (not needed by storage or filter plugins)
\end{DoxyItemize}

Depending of the type of plugin you need not to implement all of them.

\begin{DoxyNote}{Note}
that the Doc within the name is just because the plugin described here is called doc (see src/plugins/doc/doc.c). Always replace Doc with the name of the plugin you are going to implement.
\end{DoxyNote}
See the descriptions below what each of them is supposed to do.\hypertarget{group__plugin_storage}{}\subsubsection{Storage Plugins}\label{group__plugin_storage}
A filter plugin is a plugin which already receives some keys. It may process or change the keyset. Or it may reject specific keysets which do not meet some criteria.\hypertarget{group__plugin_filter}{}\subsubsection{Filter Plugins}\label{group__plugin_filter}
A storage plugin gets an empty keyset and constructs the information out from a file.

Other persistent storage then a file is not handled within this document because it involves many other issues. For files the resolver plugin already takes care for transactions and rollback.\hypertarget{group__plugin_error}{}\subsection{Error and Wanrings}\label{group__plugin_error}
In any case of trouble, use ELEKTRA\_\-SET\_\-ERROR and return with -\/1. You might add warnings with ELEKTRA\_\-ADD\_\-WARNING if you think it is appropriate. 

\subsection{Function Documentation}
\hypertarget{group__plugin_gabe78724d2d477eef39997fd9b85bff16}{
\index{plugin@{plugin}!ELEKTRA\_\-PLUGIN\_\-EXPORT@{ELEKTRA\_\-PLUGIN\_\-EXPORT}}
\index{ELEKTRA\_\-PLUGIN\_\-EXPORT@{ELEKTRA\_\-PLUGIN\_\-EXPORT}!plugin@{plugin}}
\subsubsection[{ELEKTRA\_\-PLUGIN\_\-EXPORT}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Plugin}$\ast$ ELEKTRA\_\-PLUGIN\_\-EXPORT (
\begin{DoxyParamCaption}
\item[{doc}]{}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gabe78724d2d477eef39997fd9b85bff16}
All KDB methods implemented by the plugin can have random names, except ELEKTRA\_\-PLUGIN\_\-EXPORT. This is the single symbol that will be looked up when loading the plugin, and the first method of the backend implementation that will be called.

You need to use a macro so that both dynamic and static loading of the plugin works.

The first paramter is the name of the plugin. Then every plugin should have: {\ttfamily ELEKTRA\_\-PLUGIN\_\-OPEN}, {\ttfamily ELEKTRA\_\-PLUGIN\_\-CLOSE}, {\ttfamily ELEKTRA\_\-PLUGIN\_\-GET}, {\ttfamily ELEKTRA\_\-PLUGIN\_\-SET} and optionally {\ttfamily ELEKTRA\_\-PLUGIN\_\-ERROR}.

The list is terminated with {\ttfamily ELEKTRA\_\-PLUGIN\_\-END}.

You must use static \char`\"{}char arrays\char`\"{} in a read only segment. Don't allocate storage, it won't be freed.

\begin{DoxyReturn}{Returns}
Plugin 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__plugin_ga8dd092048e972a3f0c9c9f54eb41576e}{elektraPluginExport()} 
\end{DoxySeeAlso}
\hypertarget{group__plugin_gafb66a15abe15f79c9c5b3a928b42147d}{
\index{plugin@{plugin}!elektraDocClose@{elektraDocClose}}
\index{elektraDocClose@{elektraDocClose}!plugin@{plugin}}
\subsubsection[{elektraDocClose}]{\setlength{\rightskip}{0pt plus 5cm}int elektraDocClose (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ handle, }
\item[{{\bf Key} $\ast$}]{ errorKey}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gafb66a15abe15f79c9c5b3a928b42147d}
Finalize the plugin.

Called prior to unloading the plugin dynamic module. Should ensure that no functions or static/global variables from the module will ever be accessed again.

Make sure to free all memory that your plugin requested at runtime.

After this call, libelektra.so will unload the plugin library, so this is the point to shutdown any affairs with the storage.


\begin{DoxyParams}{Parameters}
\item[{\em handle}]contains internal information of the plugin \item[{\em errorKey}]is needed to add warnings using ELEKTRA\_\-ADD\_\-WARNING\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
\item[{\em 0}]on success \end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose()} 

\hyperlink{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}{elektraPluginGetData()}, \hyperlink{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{elektraPluginSetData()} and \hyperlink{group__plugin_ga644bead796506c172817724051c977c9}{elektraPluginGetConfig()} 
\end{DoxySeeAlso}
\hypertarget{group__plugin_gacb69f3441c6d84241b4362f958fbe313}{
\index{plugin@{plugin}!elektraDocGet@{elektraDocGet}}
\index{elektraDocGet@{elektraDocGet}!plugin@{plugin}}
\subsubsection[{elektraDocGet}]{\setlength{\rightskip}{0pt plus 5cm}int elektraDocGet (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ handle, }
\item[{{\bf KeySet} $\ast$}]{ returned, }
\item[{{\bf Key} $\ast$}]{ parentKey}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gacb69f3441c6d84241b4362f958fbe313}
Retrieve information from a permanent storage to construct a keyset.\hypertarget{group__plugin_intro}{}\subsection{Introduction}\label{group__plugin_intro}
The \hyperlink{group__plugin_gacb69f3441c6d84241b4362f958fbe313}{elektraDocGet()} function handle everything related to receiving keys.\hypertarget{group__plugin_storage}{}\subsubsection{Storage Plugins}\label{group__plugin_storage}
For storage plugins the filename is written in the value of the parentKey. So the first task of the plugin is to open that file. Then it should parse its content and construct a keyset with all information of that file.

You need to be able to reconstruct the same file with the information of the keyset. So be sure to copy all comments, whitespaces and so on into some metadata of the keys. Otherwise the information is lost after writing the file the next time.

Now lets look at an example how the typical \hyperlink{group__plugin_gacb69f3441c6d84241b4362f958fbe313}{elektraDocGet()} might be implemented. To explain we introduce some pseudo functions which do all the work with the storage (which is of course 90\% of the work for a real plugin):
\begin{DoxyItemize}
\item parse\_\-key will parse a key and a value from an open file handle
\end{DoxyItemize}

The typical loop for a storage plugin will be like: 
\begin{DoxyCode}
int elektraDocGet(Plugin *handle, KeySet *returned, const Key *parentKey)
{
        // contract handling, see below

        FILE *fp = fopen (keyString(parentKey), "r");
        char *key;
        char *value;

        while ((n = parse_key(fp, &key, &value)) >= 1)
        {
                Key *read = keyNew(0);
                if (keySetName(read, key) == -1)
                {
                        fclose (fp);
                        keyDel (read);
                        ELEKTRA_SET_ERROR(59, parentKey, key);
                        return -1;
                }
                keySetString(read, value);

                ksAppendKey (returned, read);
                free (key);
                free (value);
        }

        if (feof(fp) == 0)
        {
                fclose (fp);
                ELEKTRA_SET_ERROR(60, parentKey, "not at the end of file");
                return -1;
        }

        fclose (fp);

        return 1; // success
}
\end{DoxyCode}
\hypertarget{group__plugin_filter}{}\subsubsection{Filter Plugins}\label{group__plugin_filter}
For filter plugins the actual task is rather unspecified. You basically can do anything with the keyset. To get roundtrip properties you might want to undo any changes you did in \hyperlink{group__plugin_gae65781a1deb34efc79c8cb9d9174842c}{elektraDocSet()}.

The pseudo functions (which do the real work) are:
\begin{DoxyItemize}
\item do\_\-action() which processes every key in this filter
\end{DoxyItemize}


\begin{DoxyCode}
int elektraDocGet(Plugin *handle, KeySet *returned, Key *parentKey)
{
        // contract handling

        Key *k;
        ksRewind (returned);
        while ((k = ksNext (returned)) != 0)
        {
                do_action(k);
        }

        return 1; // success
}
\end{DoxyCode}
\hypertarget{group__plugin_conditions}{}\subsection{Conditions}\label{group__plugin_conditions}
\begin{Desc}
\item[\hyperlink{todo__todo000002}{Todo}]needs some updates\end{Desc}


\begin{DoxyPrecond}{Precondition}
The caller \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} will make sure before you are called that the parentKey:
\begin{DoxyItemize}
\item is a valid key (means that it is a system or user key).
\item is below (see \hyperlink{group__keytest_ga03332b5d97c76a4fd2640aca4762b8df}{keyIsBelow()}) your mountpoint and that your plugin is responsible for it. and that the returned:
\item is a valid keyset.
\item has {\ttfamily all} keys with the flag KEY\_\-FLAG\_\-SYNC set.
\item contains only valid keys direct below (see \hyperlink{group__keytest_ga4f175aafd98948ce6c774f3bd92b72ca}{keyIsDirectBelow()}) your parentKey. That also means, that the parentKey will not be in that keyset.
\item is in a sorted order, see ksSort(). and that the handle:
\begin{DoxyItemize}
\item is a valid KDB for your plugin.
\item that elektraPluginhGetBackendHandle() contains the same handle for lifetime \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen()} until elektraPluginClose() was called.
\end{DoxyItemize}
\end{DoxyItemize}

The caller \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} will make sure that afterwards you were called, whenever the user requested it with the options, that:
\begin{DoxyItemize}
\item hidden keys they will be thrown away.
\item dirs or only dirs \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} will remove the other.
\item you will be called again recursively with all subdirectories.
\item the keyset will be sorted when needed.
\item the keys in returned having KEY\_\-FLAG\_\-SYNC will be sorted out.
\end{DoxyItemize}
\end{DoxyPrecond}
\begin{DoxyInvariant}{Invariant}
There are no global variables and \hyperlink{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{elektraPluginSetData()} stores all information. The handle is to be guaranteed to be the same if it is the same plugin.
\end{DoxyInvariant}
\begin{DoxyPostcond}{Postcondition}
The keyset {\ttfamily returned} has the {\ttfamily parentKey} and all keys direct below (\hyperlink{group__keytest_ga4f175aafd98948ce6c774f3bd92b72ca}{keyIsDirectBelow()}) with all information from the storage. Make sure to return all keys, all directories and also all hidden keys. If some of them are not wished, the caller \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} will drop these keys, see above.
\end{DoxyPostcond}
\hypertarget{group__plugin_updating}{}\subsection{Updating}\label{group__plugin_updating}
To get all keys out of the storage over and over again can be very inefficient. You might know a more efficient method to know if the key needs update or not, e.g. by stating it or by an external time stamp info. For file storage plugins this is automatically done for you. For other types (e.g. databases) you need to implement your own resolver doing this.

\begin{DoxyNote}{Note}
If any calls you use change errno, make sure to restore the old errno.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} for caller.
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
\item[{\em handle}]contains internal information of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{opened } key database \item[{\em returned}]contains a keyset where the function need to append the keys got from the storage. There might be also some keys inside it, see conditions. You may use them to support efficient updating of keys, see \hyperlink{group__plugin_updating}{Updating}. \item[{\em parentKey}]contains the information below which key the keys should be gotten.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 on success 

0 when nothing was to do 

-\/1 on failure, the current key in returned shows the position. use ELEKTRA\_\-SET\_\-ERROR of kdberrors.h to define the error code 
\end{DoxyReturn}
\hypertarget{group__plugin_ga1e2cbea1275fc0d39a00a74eb69e12d8}{
\index{plugin@{plugin}!elektraDocOpen@{elektraDocOpen}}
\index{elektraDocOpen@{elektraDocOpen}!plugin@{plugin}}
\subsubsection[{elektraDocOpen}]{\setlength{\rightskip}{0pt plus 5cm}int elektraDocOpen (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ handle, }
\item[{{\bf Key} $\ast$}]{ errorKey}
\end{DoxyParamCaption}
)}}
\label{group__plugin_ga1e2cbea1275fc0d39a00a74eb69e12d8}
Initialize the plugin.

This is the first method called after dynamically loading this plugin.

This method is responsible for:
\begin{DoxyItemize}
\item plugin's specific configuration gathering
\item all plugin's internal structs initialization
\item if unavoidable initial setup of all I/O details such as opening a file, connecting to a database, setup connection to a server, etc.
\end{DoxyItemize}

You may also read the configuration you can get with \hyperlink{group__plugin_ga644bead796506c172817724051c977c9}{elektraPluginGetConfig()} and transform it into other structures used by your plugin.

\begin{DoxyNote}{Note}
The plugin must not have any global variables. If you do Elektra will not be threadsafe. It is not a good assumption that your plugin will be opened only once.
\end{DoxyNote}
Instead you can use \hyperlink{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}{elektraPluginGetData()} and \hyperlink{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{elektraPluginSetData()} to store and get any information related to your plugin.

The correct substitute for global variables will be: 
\begin{DoxyCode}
struct _GlobalData{ int global; };
typedef struct _GlobalData GlobalData;
int elektraDocOpen(Plugin *handle, Key *errorKey)
{
        GlobalData *data;
        data=malloc(sizeof(GlobalData));
        data.global = 20;
        elektraPluginSetData(handle,data);
}
\end{DoxyCode}


\begin{DoxyNote}{Note}
Make sure to free everything you allocate here within \hyperlink{group__plugin_gafb66a15abe15f79c9c5b3a928b42147d}{elektraDocClose()}.
\end{DoxyNote}
\begin{DoxyReturn}{Returns}
0 on success 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
\item[{\em handle}]contains internal information of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{opened } key database \item[{\em errorKey}]defines an errorKey \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen()} which will call \hyperlink{group__plugin_ga1e2cbea1275fc0d39a00a74eb69e12d8}{elektraDocOpen()} 

\hyperlink{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}{elektraPluginGetData()}, \hyperlink{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{elektraPluginSetData()} and \hyperlink{group__plugin_ga644bead796506c172817724051c977c9}{elektraPluginGetConfig()} 
\end{DoxySeeAlso}
\hypertarget{group__plugin_gae65781a1deb34efc79c8cb9d9174842c}{
\index{plugin@{plugin}!elektraDocSet@{elektraDocSet}}
\index{elektraDocSet@{elektraDocSet}!plugin@{plugin}}
\subsubsection[{elektraDocSet}]{\setlength{\rightskip}{0pt plus 5cm}int elektraDocSet (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ handle, }
\item[{{\bf KeySet} $\ast$}]{ returned, }
\item[{{\bf Key} $\ast$}]{ parentKey}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gae65781a1deb34efc79c8cb9d9174842c}
Store a keyset permanently.

This function does everything related to set and remove keys in a plugin. There is only one function for that purpose to make implementation and locking much easier.

The keyset {\ttfamily returned} was filled in with information from the application using elektra and the task of this function is to store it in a permanent way so that a subsequent call of elektraPluginGet() can rebuild the keyset as it was before. See the live cycle of a comment to understand: 
\begin{DoxyCode}
void usercode (Key *key)
{
        keySetComment (key, "mycomment"); // the usercode stores a comment for th
      e key
        ksAppendKey(keyset, key); // append the key to the keyset
        kdbSet (handle, keyset, 0, 0);
}

// so now kdbSet is called
int kdbSet(KDB *handle, KeySet *keyset, Key *parentKey, options)
{
        // find appropriate plugin
        elektraPluginSet (handle, keyset, 0); // the keyset with the key will be 
      passed to this function
}

// so now elektraPluginSet(), which is the function described here, is called
elektraPluginSet(KDB *handle, KeySet *keyset, Key *parentKey)
{
        // the task of elektraPluginSet is now to store the comment
        Key *key = ksCurrent (keyset); // get out the key where the user set the 
      comment before
        char *comment = allocate(size);
        keyGetComment (key, comment, size);
        savetodisc (comment);
}
\end{DoxyCode}
 Of course not only the comment, but all information of every key in the keyset {\ttfamily returned} need to be stored permanetly. So this specification needs to give an exhaustive list of information present in a key.

\begin{DoxyPrecond}{Precondition}
The keyset {\ttfamily returned} holds all keys which must be saved permanently for this keyset. The keyset is sorted and rewinded. All keys having children must be true for \hyperlink{group__keytest_gac0a10c602d52a35f81347e8a32312017}{keyIsDir()}.

The {\ttfamily parentKey} is the key which is the ancestor for all other keys in the keyset. The first key of the keyset {\ttfamily returned} has the same keyname. The parentKey is below the mountpoint, see kdbhGetMountpoint().

The caller kdbSet will fulfill following parts:
\begin{DoxyItemize}
\item If the user does not want hidden keys they will be thrown away. All keys in {\ttfamily returned} need to be stored permanently.
\item If the user does not want dirs or only dirs \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} will remove the other.
\item Sorting of the keyset. It is not important in which order the keys are appended. So make sure to set all keys, all directories and also all hidden keys. If some of them are not wished, the caller \hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdbSet()} will sort them out.
\end{DoxyItemize}
\end{DoxyPrecond}
\begin{DoxyInvariant}{Invariant}
There are no global variables and kdbhGetBackendData() only stores information which can be regenerated any time. The handle is the same when it is the same plugin.
\end{DoxyInvariant}
\begin{DoxyPostcond}{Postcondition}
The information of the keyset {\ttfamily returned} is stored permanently.
\end{DoxyPostcond}
Lock your permanent storage in an exclusive way, no access of a concurrent elektraPluginSet\_\-plugin() or \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet()} is possible and these methods block until the function has finished. Otherwise declare kdbcGetnoLock().

\begin{DoxySeeAlso}{See also}
\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdbSet()} for caller.
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
\item[{\em handle}]contains internal information of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{opened } key database \item[{\em returned}]contains a keyset with relevant keys \item[{\em parentKey}]contains the information where to set the keys\end{DoxyParams}
\begin{DoxyReturn}{Returns}
When everything works gracefully return the number of keys you set. The cursor position and the keys remaining in the keyset are not important.

Return 0 on success with no changed key in database

Return -\/1 on failure.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
If any calls you use change errno, make sure to restore the old errno.
\end{DoxyNote}
\begin{Desc}
\item[\hyperlink{err__err000001}{Error}]In normal execution cases a positive value will be returned. But in some cases you are not able to set keys and have to return -\/1. If you declare kdbcGetnoError() you are done, but otherwise you have to set the cause of the error. (Will be added with 0.7.1)\end{Desc}


You also have to make sure that \hyperlink{group__keyset_gaffe507ab9281c322eb16c3e992075d29}{ksGetCursor()} shows to the position where the error appeared. \hypertarget{group__plugin_ga8dd092048e972a3f0c9c9f54eb41576e}{
\index{plugin@{plugin}!elektraPluginExport@{elektraPluginExport}}
\index{elektraPluginExport@{elektraPluginExport}!plugin@{plugin}}
\subsubsection[{elektraPluginExport}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Plugin}$\ast$ elektraPluginExport (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{ pluginName, }
\item[{}]{ ...}
\end{DoxyParamCaption}
)}}
\label{group__plugin_ga8dd092048e972a3f0c9c9f54eb41576e}
This function must be called by a plugin's elektraPluginSymbol() to define the plugin's methods that will be exported.

See \hyperlink{group__plugin_gabe78724d2d477eef39997fd9b85bff16}{ELEKTRA\_\-PLUGIN\_\-EXPORT()} how to use it for plugins.

The order and number of arguments are flexible (as in \hyperlink{group__key_gaf6893c038b3ebee90c73a9ea8356bebf}{keyNew()} and \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew()}) to let libelektra.so evolve without breaking its ABI compatibility with plugins. So for each method a plugin must export, there is a flag defined by plugin\_\-t. Each flag tells kdbPluginExport() which method comes next. A plugin can have no implementation for a few methods that have default inefficient high-\/level implementations and to use these defaults, simply don't pass anything to kdbPluginExport() about them.


\begin{DoxyParams}{Parameters}
\item[{\em pluginName}]a simple name for this plugin \end{DoxyParams}
\begin{DoxyReturn}{Returns}
an object that contains all plugin informations needed by libelektra.so 
\end{DoxyReturn}
\hypertarget{group__plugin_ga644bead796506c172817724051c977c9}{
\index{plugin@{plugin}!elektraPluginGetConfig@{elektraPluginGetConfig}}
\index{elektraPluginGetConfig@{elektraPluginGetConfig}!plugin@{plugin}}
\subsubsection[{elektraPluginGetConfig}]{\setlength{\rightskip}{0pt plus 5cm}{\bf KeySet}$\ast$ elektraPluginGetConfig (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ handle}
\end{DoxyParamCaption}
)}}
\label{group__plugin_ga644bead796506c172817724051c977c9}
Returns the configuration of that plugin.


\begin{DoxyParams}{Parameters}
\item[{\em handle}]a pointer to the plugin\end{DoxyParams}
\begin{DoxyReturn}{Returns}
keyset to the configuration for that plugin 
\end{DoxyReturn}
\hypertarget{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}{
\index{plugin@{plugin}!elektraPluginGetData@{elektraPluginGetData}}
\index{elektraPluginGetData@{elektraPluginGetData}!plugin@{plugin}}
\subsubsection[{elektraPluginGetData}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ elektraPluginGetData (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ plugin}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gaafcf3216b46292f222b8cc7828b4dd20}
Get a pointer to any plugin related data stored before.


\begin{DoxyParams}{Parameters}
\item[{\em plugin}]a pointer to the plugin \end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to the data 
\end{DoxyReturn}
\hypertarget{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}{
\index{plugin@{plugin}!elektraPluginSetData@{elektraPluginSetData}}
\index{elektraPluginSetData@{elektraPluginSetData}!plugin@{plugin}}
\subsubsection[{elektraPluginSetData}]{\setlength{\rightskip}{0pt plus 5cm}void elektraPluginSetData (
\begin{DoxyParamCaption}
\item[{{\bf Plugin} $\ast$}]{ plugin, }
\item[{void $\ast$}]{ data}
\end{DoxyParamCaption}
)}}
\label{group__plugin_gaf4b941a52ff55d0ca2a9158d90208ef2}
Store a pointer to any plugin related data.


\begin{DoxyParams}{Parameters}
\item[{\em plugin}]a pointer to the plugin \item[{\em data}]the pointer to the data \end{DoxyParams}
