\hypertarget{group__invoke}{}\section{Invoke}
\label{group__invoke}\index{Invoke@{Invoke}}


Functionality to use plugins and invoke functions.  


\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
Elektra\+Invoke\+Handle $\ast$ \hyperlink{group__invoke_gaae89e2497eba478be2043f1b25adbb3c}{elektra\+Invoke\+Initialize} (const char $\ast$elektra\+Plugin\+Name)
\item 
Elektra\+Invoke\+Handle $\ast$ \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open} (const char $\ast$elektra\+Plugin\+Name, Key\+Set $\ast$config, Key $\ast$error\+Key)
\begin{DoxyCompactList}\small\item\em Opens a new handle to invoke functions for a plugin. \end{DoxyCompactList}\item 
const void $\ast$ \hyperlink{group__invoke_ga4531a643a71a63c19c94d87bd8d0b40f}{elektra\+Invoke\+Get\+Function} (Elektra\+Invoke\+Handle $\ast$handle, const char $\ast$elektra\+Plugin\+Function\+Name)
\begin{DoxyCompactList}\small\item\em Get a function pointer. \end{DoxyCompactList}\item 
Key\+Set $\ast$ \hyperlink{group__invoke_gafc090b80f3ba846bf3c3fd8ccd34f2f5}{elektra\+Invoke\+Get\+Plugin\+Config} (Elektra\+Invoke\+Handle $\ast$handle)
\begin{DoxyCompactList}\small\item\em Get the configuration the plugin uses. \end{DoxyCompactList}\item 
const char $\ast$ \hyperlink{group__invoke_ga13bd3afe428624d459239df73641d769}{elektra\+Invoke\+Get\+Plugin\+Name} (Elektra\+Invoke\+Handle $\ast$handle)
\begin{DoxyCompactList}\small\item\em Get the name of the plugin. \end{DoxyCompactList}\item 
void $\ast$ \hyperlink{group__invoke_gac615e211a4d3c77addfa18152c274345}{elektra\+Invoke\+Get\+Plugin\+Data} (Elektra\+Invoke\+Handle $\ast$handle)
\begin{DoxyCompactList}\small\item\em Get the data of the plugin. \end{DoxyCompactList}\item 
Key\+Set $\ast$ \hyperlink{group__invoke_gaf3564011b52e96c9754a7b9bc41ea478}{elektra\+Invoke\+Get\+Modules} (Elektra\+Invoke\+Handle $\ast$handle)
\begin{DoxyCompactList}\small\item\em Get the modules used for invoking. \end{DoxyCompactList}\item 
Key\+Set $\ast$ \hyperlink{group__invoke_ga6ab386aba337d8d3fd7978070d613efe}{elektra\+Invoke\+Get\+Exports} (Elektra\+Invoke\+Handle $\ast$handle)
\begin{DoxyCompactList}\small\item\em Get the exports from the plugin. \end{DoxyCompactList}\item 
int \hyperlink{group__invoke_gaa257d93399c60f73c611205bbfa7c9a0}{elektra\+Invoke2\+Args} (Elektra\+Invoke\+Handle $\ast$handle, const char $\ast$elektra\+Plugin\+Function\+Name, Key\+Set $\ast$ks, Key $\ast$k)
\begin{DoxyCompactList}\small\item\em A convenience function to call a function with two arguments. \end{DoxyCompactList}\item 
void \hyperlink{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}{elektra\+Invoke\+Close} (Elektra\+Invoke\+Handle $\ast$handle, Key $\ast$error\+Key)
\begin{DoxyCompactList}\small\item\em Closes all affairs with the handle. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Functionality to use plugins and invoke functions. 

Allows invoking functions of plugins as needed within applications and plugins inside and outside of the K\+DB.

To use this library, you need to include\+:


\begin{DoxyCode}
\textcolor{preprocessor}{#include <kdbinvoke.h>}`
\end{DoxyCode}


and link against {\ttfamily libelektra-\/invoke}. Then you can use it\+:


\begin{DoxyCode}
ElektraInvokeHandle * handle = \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektraInvokeOpen} (\textcolor{stringliteral}{"dini"}, 0);
\hyperlink{group__invoke_gaa257d93399c60f73c611205bbfa7c9a0}{elektraInvoke2Args} (handle, \textcolor{stringliteral}{"get"}, ks, k);
\hyperlink{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}{elektraInvokeClose} (handle);
\end{DoxyCode}
 

\subsection{Function Documentation}
\mbox{\Hypertarget{group__invoke_gaa257d93399c60f73c611205bbfa7c9a0}\label{group__invoke_gaa257d93399c60f73c611205bbfa7c9a0}} 
\index{Invoke@{Invoke}!elektra\+Invoke2\+Args@{elektra\+Invoke2\+Args}}
\index{elektra\+Invoke2\+Args@{elektra\+Invoke2\+Args}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke2\+Args()}{elektraInvoke2Args()}}
{\footnotesize\ttfamily int elektra\+Invoke2\+Args (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle,  }\item[{const char $\ast$}]{elektra\+Plugin\+Function\+Name,  }\item[{Key\+Set $\ast$}]{ks,  }\item[{Key $\ast$}]{k }\end{DoxyParamCaption})}



A convenience function to call a function with two arguments. 


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with \\
\hline
{\em elektra\+Plugin\+Function\+Name} & the function to call, e.\+g. \char`\"{}get\char`\"{} \\
\hline
{\em ks} & the keyset to be used as first parameter \\
\hline
{\em k} & the key to be used as second parameter\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
the return value of the invoked function (i.\+e. -\/1, 0, or 1) 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/2} & if the function was not found. \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}\label{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Close@{elektra\+Invoke\+Close}}
\index{elektra\+Invoke\+Close@{elektra\+Invoke\+Close}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Close()}{elektraInvokeClose()}}
{\footnotesize\ttfamily void elektra\+Invoke\+Close (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle,  }\item[{Key $\ast$}]{error\+Key }\end{DoxyParamCaption})}



Closes all affairs with the handle. 

The close function of the plugin will be called.


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with \\
\hline
{\em error\+Key} & a key where error messages will be stored\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()} 
\end{DoxyPrecond}
\mbox{\Hypertarget{group__invoke_ga6ab386aba337d8d3fd7978070d613efe}\label{group__invoke_ga6ab386aba337d8d3fd7978070d613efe}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Exports@{elektra\+Invoke\+Get\+Exports}}
\index{elektra\+Invoke\+Get\+Exports@{elektra\+Invoke\+Get\+Exports}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Exports()}{elektraInvokeGetExports()}}
{\footnotesize\ttfamily Key\+Set$\ast$ elektra\+Invoke\+Get\+Exports (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle }\end{DoxyParamCaption})}



Get the exports from the plugin. 


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with.\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
the exports of the plugin. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_ga4531a643a71a63c19c94d87bd8d0b40f}\label{group__invoke_ga4531a643a71a63c19c94d87bd8d0b40f}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Function@{elektra\+Invoke\+Get\+Function}}
\index{elektra\+Invoke\+Get\+Function@{elektra\+Invoke\+Get\+Function}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Function()}{elektraInvokeGetFunction()}}
{\footnotesize\ttfamily const void$\ast$ elektra\+Invoke\+Get\+Function (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle,  }\item[{const char $\ast$}]{elektra\+Plugin\+Function\+Name }\end{DoxyParamCaption})}



Get a function pointer. 


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to use \\
\hline
{\em elektra\+Plugin\+Function\+Name} & the name of the function to use, e.\+g., get/set\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
Example\+:


\begin{DoxyCode}
\textcolor{keyword}{typedef} int (*elektra2Args) (KeySet*, Key *);
elektra2Args func = *(elektra2Args *)\hyperlink{group__invoke_ga4531a643a71a63c19c94d87bd8d0b40f}{elektraInvokeGetFunction} (handle, 
      elektraPluginFunctionName);
\textcolor{keywordflow}{if} (!func) exit(1);   \textcolor{comment}{// no function found, handle error}
func (ks, k);         \textcolor{comment}{// otherwise, call function}
\end{DoxyCode}


\begin{DoxySeeAlso}{See also}
\hyperlink{group__invoke_gaa257d93399c60f73c611205bbfa7c9a0}{elektra\+Invoke2\+Args()} a convenience function to be used for Key\+Set,Key arguments.
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
a function pointer for the specified function. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_gaf3564011b52e96c9754a7b9bc41ea478}\label{group__invoke_gaf3564011b52e96c9754a7b9bc41ea478}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Modules@{elektra\+Invoke\+Get\+Modules}}
\index{elektra\+Invoke\+Get\+Modules@{elektra\+Invoke\+Get\+Modules}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Modules()}{elektraInvokeGetModules()}}
{\footnotesize\ttfamily Key\+Set$\ast$ elektra\+Invoke\+Get\+Modules (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle }\end{DoxyParamCaption})}



Get the modules used for invoking. 

\begin{DoxyWarning}{Warning}
The modules are closed within \hyperlink{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}{elektra\+Invoke\+Close()}. It is {\itshape not} enough to \hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()} the keyset, you must not call \hyperlink{group__invoke_ga684a21daa0b3c20783c55184a9157b3b}{elektra\+Invoke\+Close()} if you want to reuse the modules.
\end{DoxyWarning}

\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with.\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
the modules used for invoking. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_gafc090b80f3ba846bf3c3fd8ccd34f2f5}\label{group__invoke_gafc090b80f3ba846bf3c3fd8ccd34f2f5}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Plugin\+Config@{elektra\+Invoke\+Get\+Plugin\+Config}}
\index{elektra\+Invoke\+Get\+Plugin\+Config@{elektra\+Invoke\+Get\+Plugin\+Config}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Plugin\+Config()}{elektraInvokeGetPluginConfig()}}
{\footnotesize\ttfamily Key\+Set$\ast$ elektra\+Invoke\+Get\+Plugin\+Config (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle }\end{DoxyParamCaption})}



Get the configuration the plugin uses. 


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to use\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
the config of the plugin. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_gac615e211a4d3c77addfa18152c274345}\label{group__invoke_gac615e211a4d3c77addfa18152c274345}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Plugin\+Data@{elektra\+Invoke\+Get\+Plugin\+Data}}
\index{elektra\+Invoke\+Get\+Plugin\+Data@{elektra\+Invoke\+Get\+Plugin\+Data}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Plugin\+Data()}{elektraInvokeGetPluginData()}}
{\footnotesize\ttfamily void$\ast$ elektra\+Invoke\+Get\+Plugin\+Data (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle }\end{DoxyParamCaption})}



Get the data of the plugin. 


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with.\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
a pointer to the plugin\textquotesingle{}s data. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_ga13bd3afe428624d459239df73641d769}\label{group__invoke_ga13bd3afe428624d459239df73641d769}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Get\+Plugin\+Name@{elektra\+Invoke\+Get\+Plugin\+Name}}
\index{elektra\+Invoke\+Get\+Plugin\+Name@{elektra\+Invoke\+Get\+Plugin\+Name}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Get\+Plugin\+Name()}{elektraInvokeGetPluginName()}}
{\footnotesize\ttfamily const char$\ast$ elektra\+Invoke\+Get\+Plugin\+Name (\begin{DoxyParamCaption}\item[{Elektra\+Invoke\+Handle $\ast$}]{handle }\end{DoxyParamCaption})}



Get the name of the plugin. 

The name might differ from the name as passed with elektra\+Invoke\+Open when symlinks are used.


\begin{DoxyParams}{Parameters}
{\em handle} & the handle to work with.\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
handle must be as returned from \hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
the name of the plugin 
\end{DoxyReturn}
\mbox{\Hypertarget{group__invoke_gaae89e2497eba478be2043f1b25adbb3c}\label{group__invoke_gaae89e2497eba478be2043f1b25adbb3c}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Initialize@{elektra\+Invoke\+Initialize}}
\index{elektra\+Invoke\+Initialize@{elektra\+Invoke\+Initialize}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Initialize()}{elektraInvokeInitialize()}}
{\footnotesize\ttfamily Elektra\+Invoke\+Handle$\ast$ elektra\+Invoke\+Initialize (\begin{DoxyParamCaption}\item[{const char $\ast$}]{elektra\+Plugin\+Name }\end{DoxyParamCaption})}

\begin{DoxyRefDesc}{Deprecated}
\item[\hyperlink{deprecated__deprecated000013}{Deprecated}]Do not use.\end{DoxyRefDesc}


Use {\ttfamily elektra\+Invoke\+Open (name, 0, 0)} instead.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}{elektra\+Invoke\+Open()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}\label{group__invoke_ga3eb20131e9a8fc9a6cebf126927c09bc}} 
\index{Invoke@{Invoke}!elektra\+Invoke\+Open@{elektra\+Invoke\+Open}}
\index{elektra\+Invoke\+Open@{elektra\+Invoke\+Open}!Invoke@{Invoke}}
\subsubsection{\texorpdfstring{elektra\+Invoke\+Open()}{elektraInvokeOpen()}}
{\footnotesize\ttfamily Elektra\+Invoke\+Handle$\ast$ elektra\+Invoke\+Open (\begin{DoxyParamCaption}\item[{const char $\ast$}]{elektra\+Plugin\+Name,  }\item[{Key\+Set $\ast$}]{config,  }\item[{Key $\ast$}]{error\+Key }\end{DoxyParamCaption})}



Opens a new handle to invoke functions for a plugin. 

When opening the plugin, it calls the \char`\"{}open\char`\"{} function of the plugin.


\begin{DoxyParams}{Parameters}
{\em elektra\+Plugin\+Name} & the plugin on which we want to invoke functions. \\
\hline
{\em config} & the config to be passed to the plugin. \\
\hline
{\em error\+Key} & a key where error messages will be stored\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the handle 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & on errors \\
\hline
\end{DoxyRetVals}
