\hypertarget{group__key}{}\doxysection{Key}
\label{group__key}\index{Key@{Key}}


Key is an essential class that encapsulates key \mbox{\hyperlink{group__keyname}{name }}, \mbox{\hyperlink{group__keyvalue}{value }} and \mbox{\hyperlink{group__keymeta}{metainfo }}.  


Collaboration diagram for Key\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=309pt]{group__key}
\end{center}
\end{figure}
\doxysubsection*{Modules}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__keymeta}{Meta Info Manipulation Methods}}
\begin{DoxyCompactList}\small\item\em Methods to do various operations on Key metadata. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__keytest}{Methods for Making Tests}}
\begin{DoxyCompactList}\small\item\em Methods to do various tests on Keys. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__keyname}{Name Manipulation Methods}}
\begin{DoxyCompactList}\small\item\em Methods to do various operations on Key names. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__keyvalue}{Value Manipulation Methods}}
\begin{DoxyCompactList}\small\item\em Methods to do various operations on Key values. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__key_gad19f92d6d37dc439d1727ca10263c9cc}{KDB\+\_\+\+PATH\+\_\+\+SEPARATOR}}~\textquotesingle{}/\textquotesingle{}
\begin{DoxyCompactList}\small\item\em {\ttfamily /} is used to separate key names. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{group__key_ga6d24980bc81c4276367f4e80725a8b61}{KDB\+\_\+\+PATH\+\_\+\+ESCAPE}}~\textquotesingle{}\textbackslash{}\textbackslash{}\textquotesingle{}
\begin{DoxyCompactList}\small\item\em {\ttfamily \textbackslash{}} is used as escape character in the key name. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \mbox{\hyperlink{group__key_ga9b703ca49f48b482def322b77d3e6bc8}{elektra\+Key\+Flags}} \{ \newline
\mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\+\_\+\+VALUE}} = 1 $<$$<$ 1
, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a4b83f86a07a7a0d6e24ecafe43cfea1b}{KEY\+\_\+\+FLAGS}} = 3
, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\+\_\+\+BINARY}} = 1 $<$$<$ 4
, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\+\_\+\+SIZE}} = 1 $<$$<$ 11
, \newline
\mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\+\_\+\+META}} = 1 $<$$<$ 15
, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ab089c5e7977d6e58737eb586ee153b7f}{KEY\+\_\+\+NULL}} = 1 $<$$<$ 16
, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\+\_\+\+END}} = 0
 \}
\begin{DoxyCompactList}\small\item\em Allows \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} to determine which information comes next. \end{DoxyCompactList}\item 
enum \mbox{\hyperlink{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}{elektra\+Copy\+Flags}} \{ \newline
\mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735ab41d70eb97ae5480333e85759318b5a9}{KEY\+\_\+\+CP\+\_\+\+NAME}} = 1 $<$$<$ 0
, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}{KEY\+\_\+\+CP\+\_\+\+STRING}} = 1 $<$$<$ 1
, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}{KEY\+\_\+\+CP\+\_\+\+VALUE}} = 1 $<$$<$ 2
, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a6b8bdcae98a0f29d66a6b3d1651cbac6}{KEY\+\_\+\+CP\+\_\+\+META}} = 1 $<$$<$ 3
, \newline
\mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\+\_\+\+CP\+\_\+\+ALL}} = KEY\+\_\+\+CP\+\_\+\+NAME $\vert$ KEY\+\_\+\+CP\+\_\+\+VALUE $\vert$ KEY\+\_\+\+CP\+\_\+\+META
 \}
\begin{DoxyCompactList}\small\item\em Copy options. \end{DoxyCompactList}\item 
enum \mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}} \{ \mbox{\hyperlink{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4813b0cfdefeb676e35f599ef763c265}{KEY\+\_\+\+LOCK\+\_\+\+NAME}} = 1 $<$$<$ 17
, \mbox{\hyperlink{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4ed4895f3f243287f7adef621815d7e6}{KEY\+\_\+\+LOCK\+\_\+\+VALUE}} = 1 $<$$<$ 18
, \mbox{\hyperlink{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4f1b7ee5af7539286d8989a9a5658958}{KEY\+\_\+\+LOCK\+\_\+\+META}} = 1 $<$$<$ 19
 \}
\begin{DoxyCompactList}\small\item\em Lock options. \end{DoxyCompactList}\item 
enum \mbox{\hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace}} \{ \newline
\mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a3659698b0a07454ca8055ab693e8efd1}{KEY\+\_\+\+NS\+\_\+\+NONE}} = 0
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2c9133e3095dccbcde5ca3bb13987b5d}{KEY\+\_\+\+NS\+\_\+\+CASCADING}} = 1
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ac5fbf2c3a7ae79fa2d60c48ae3e72688}{KEY\+\_\+\+NS\+\_\+\+META}} = 2
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2be047b124b1ca0e92b5ef124169f0d2}{KEY\+\_\+\+NS\+\_\+\+SPEC}} = 3
, \newline
\mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a470ecc9254fcdfccf9923a3e526c9c11}{KEY\+\_\+\+NS\+\_\+\+PROC}} = 4
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68aa0006cf27dbb2586bafba6ff1ae4f4ec}{KEY\+\_\+\+NS\+\_\+\+DIR}} = 5
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a8ce23c70010e8ac8bb540b0947e03a4e}{KEY\+\_\+\+NS\+\_\+\+USER}} = 6
, \mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a61adca2f9dff47e65dfcdb492ffa7a20}{KEY\+\_\+\+NS\+\_\+\+SYSTEM}} = 7
, \newline
\mbox{\hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ad6792ab14711ed6d6e507ca3d10b05e7}{KEY\+\_\+\+NS\+\_\+\+DEFAULT}} = 8
 \}
\begin{DoxyCompactList}\small\item\em Elektra currently supported Key namespaces. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
Key $\ast$ \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New}} (const char $\ast$name,...)
\begin{DoxyCompactList}\small\item\em A practical way to fully create a Key object in one step. \end{DoxyCompactList}\item 
Key $\ast$ \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy}} (Key $\ast$dest, const Key $\ast$source, \mbox{\hyperlink{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}{elektra\+Copy\+Flags}} flags)
\begin{DoxyCompactList}\small\item\em Copy or clear a key. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del}} (Key $\ast$key)
\begin{DoxyCompactList}\small\item\em A destructor for Key objects. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__key_gab2242311a36bbc0520e0d36895107ec1}{key\+Clear}} (Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Will clear all internal data of a Key. \end{DoxyCompactList}\item 
uint16\+\_\+t \mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref}} (Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Increment the reference counter of a Key object. \end{DoxyCompactList}\item 
uint16\+\_\+t \mbox{\hyperlink{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}{key\+Dec\+Ref}} (Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Decrement the reference counter of a Key object. \end{DoxyCompactList}\item 
uint16\+\_\+t \mbox{\hyperlink{group__key_ga0d82ce48529821aa43d82c035ba30c4f}{key\+Get\+Ref}} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Return the current reference counter value of a Key object. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}{key\+Lock}} (Key $\ast$key, \mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}} what)
\begin{DoxyCompactList}\small\item\em Permanently lock parts of a Key. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__key_ga769882e86e34a95cefcf8f260ef97e06}{key\+Is\+Locked}} (const Key $\ast$key, \mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}} what)
\begin{DoxyCompactList}\small\item\em Checks which parts of a Key are locked. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Key is an essential class that encapsulates key \mbox{\hyperlink{group__keyname}{name }}, \mbox{\hyperlink{group__keyvalue}{value }} and \mbox{\hyperlink{group__keymeta}{metainfo }}. 

To use it include\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <kdb.h>}}

\end{DoxyCode}


Key properties are\+:
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__keyname}{Key name }}
\item \mbox{\hyperlink{group__keyvalue}{Key value }}
\item \mbox{\hyperlink{group__keymeta}{Key metadata }}, including but not limited to\+:
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__meta_gafb89735689929ff717cc9f2d0d0b46a2}{Key comment }}
\item \mbox{\hyperlink{}{Key owner }}
\item \mbox{\hyperlink{group__keymeta}{UID, GID and filesystem-\/like mode permissions }}
\item \mbox{\hyperlink{group__keymeta}{Mode, change and modification times }}
\end{DoxyItemize}
\end{DoxyItemize}

\begin{DoxyParagraph}{ABI}
Due to ABI compatibility, the {\ttfamily Key} structure is not defined in kdb.\+h, only declared. So you can only declare {\ttfamily pointers} to {\ttfamily Keys} in your program, and allocate and free memory for them with \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} and \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} respectively.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Reference Counting}
Every key has its reference counter (see \mbox{\hyperlink{group__key_ga0d82ce48529821aa43d82c035ba30c4f}{key\+Get\+Ref()}} for longer explanation) that will be initialized with 0, that means a subsequent call of \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} will delete the key. If you append the key to a keyset the reference counter will be incremented by one (see \mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}}) and the key can\textquotesingle{}t be deleted by a \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}.
\end{DoxyParagraph}
\begin{DoxyParagraph}{}
As you can imagine this refcounting allows you to put the Key in your own data structures. It can be a very powerful feature, e.\+g. if you need your own-\/defined ordering or different Models of your configuration.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Copy-\/\+On-\/\+Write}
Keys employ copy-\/on-\/write techniques to minimize memory footprint. If keys are copied or duplicated, they will point at the same name and value as the source key. Only if this data is changed, additional memory is allocated. 
\end{DoxyParagraph}


\doxysubsection{Macro Definition Documentation}
\mbox{\Hypertarget{group__key_ga6d24980bc81c4276367f4e80725a8b61}\label{group__key_ga6d24980bc81c4276367f4e80725a8b61}} 
\index{Key@{Key}!KDB\_PATH\_ESCAPE@{KDB\_PATH\_ESCAPE}}
\index{KDB\_PATH\_ESCAPE@{KDB\_PATH\_ESCAPE}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{KDB\_PATH\_ESCAPE}{KDB\_PATH\_ESCAPE}}
{\footnotesize\ttfamily \#define KDB\+\_\+\+PATH\+\_\+\+ESCAPE~\textquotesingle{}\textbackslash{}\textbackslash{}\textquotesingle{}}



{\ttfamily \textbackslash{}} is used as escape character in the key name. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyname}{description about key names }}. 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_gad19f92d6d37dc439d1727ca10263c9cc}\label{group__key_gad19f92d6d37dc439d1727ca10263c9cc}} 
\index{Key@{Key}!KDB\_PATH\_SEPARATOR@{KDB\_PATH\_SEPARATOR}}
\index{KDB\_PATH\_SEPARATOR@{KDB\_PATH\_SEPARATOR}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{KDB\_PATH\_SEPARATOR}{KDB\_PATH\_SEPARATOR}}
{\footnotesize\ttfamily \#define KDB\+\_\+\+PATH\+\_\+\+SEPARATOR~\textquotesingle{}/\textquotesingle{}}



{\ttfamily /} is used to separate key names. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyname}{description about key names }}. 
\end{DoxySeeAlso}


\doxysubsection{Enumeration Type Documentation}
\mbox{\Hypertarget{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}\label{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}} 
\index{Key@{Key}!elektraCopyFlags@{elektraCopyFlags}}
\index{elektraCopyFlags@{elektraCopyFlags}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{elektraCopyFlags}{elektraCopyFlags}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}{elektra\+Copy\+Flags}}}



Copy options. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} 
\end{DoxySeeAlso}
\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_CP\_NAME@{KEY\_CP\_NAME}!Key@{Key}}\index{Key@{Key}!KEY\_CP\_NAME@{KEY\_CP\_NAME}}}\mbox{\Hypertarget{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735ab41d70eb97ae5480333e85759318b5a9}\label{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735ab41d70eb97ae5480333e85759318b5a9}} 
KEY\+\_\+\+CP\+\_\+\+NAME&Flag for copying the key name \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_CP\_STRING@{KEY\_CP\_STRING}!Key@{Key}}\index{Key@{Key}!KEY\_CP\_STRING@{KEY\_CP\_STRING}}}\mbox{\Hypertarget{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}\label{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}} 
KEY\+\_\+\+CP\+\_\+\+STRING&Flag for copying the key value, if it is a string \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_CP\_VALUE@{KEY\_CP\_VALUE}!Key@{Key}}\index{Key@{Key}!KEY\_CP\_VALUE@{KEY\_CP\_VALUE}}}\mbox{\Hypertarget{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}\label{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}} 
KEY\+\_\+\+CP\+\_\+\+VALUE&Flag for copying the key value \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_CP\_META@{KEY\_CP\_META}!Key@{Key}}\index{Key@{Key}!KEY\_CP\_META@{KEY\_CP\_META}}}\mbox{\Hypertarget{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a6b8bdcae98a0f29d66a6b3d1651cbac6}\label{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a6b8bdcae98a0f29d66a6b3d1651cbac6}} 
KEY\+\_\+\+CP\+\_\+\+META&Flag for copying the key metadata \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_CP\_ALL@{KEY\_CP\_ALL}!Key@{Key}}\index{Key@{Key}!KEY\_CP\_ALL@{KEY\_CP\_ALL}}}\mbox{\Hypertarget{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}\label{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}} 
KEY\+\_\+\+CP\+\_\+\+ALL&Shorthand for copying name, value and metadata \\
\hline

\end{DoxyEnumFields}
\mbox{\Hypertarget{group__key_ga9b703ca49f48b482def322b77d3e6bc8}\label{group__key_ga9b703ca49f48b482def322b77d3e6bc8}} 
\index{Key@{Key}!elektraKeyFlags@{elektraKeyFlags}}
\index{elektraKeyFlags@{elektraKeyFlags}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{elektraKeyFlags}{elektraKeyFlags}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{group__key_ga9b703ca49f48b482def322b77d3e6bc8}{elektra\+Key\+Flags}}}



Allows \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} to determine which information comes next. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} 
\end{DoxySeeAlso}
\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_VALUE@{KEY\_VALUE}!Key@{Key}}\index{Key@{Key}!KEY\_VALUE@{KEY\_VALUE}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}} 
KEY\+\_\+\+VALUE&Flag for the key data \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_FLAGS@{KEY\_FLAGS}!Key@{Key}}\index{Key@{Key}!KEY\_FLAGS@{KEY\_FLAGS}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8a4b83f86a07a7a0d6e24ecafe43cfea1b}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8a4b83f86a07a7a0d6e24ecafe43cfea1b}} 
KEY\+\_\+\+FLAGS&Allows to define multiple flags at once. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_BINARY@{KEY\_BINARY}!Key@{Key}}\index{Key@{Key}!KEY\_BINARY@{KEY\_BINARY}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}} 
KEY\+\_\+\+BINARY&Flag if the key is binary \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_SIZE@{KEY\_SIZE}!Key@{Key}}\index{Key@{Key}!KEY\_SIZE@{KEY\_SIZE}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}} 
KEY\+\_\+\+SIZE&Flag for maximum size to limit value \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_META@{KEY\_META}!Key@{Key}}\index{Key@{Key}!KEY\_META@{KEY\_META}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}} 
KEY\+\_\+\+META&Flag for metadata \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NULL@{KEY\_NULL}!Key@{Key}}\index{Key@{Key}!KEY\_NULL@{KEY\_NULL}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8ab089c5e7977d6e58737eb586ee153b7f}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8ab089c5e7977d6e58737eb586ee153b7f}} 
KEY\+\_\+\+NULL&Is {\itshape not} a flag, only as return value \begin{DoxyRefDesc}{Deprecated}
\item[\mbox{\hyperlink{deprecated__deprecated000001}{Deprecated}}]do not use \end{DoxyRefDesc}
\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_END@{KEY\_END}!Key@{Key}}\index{Key@{Key}!KEY\_END@{KEY\_END}}}\mbox{\Hypertarget{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}\label{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}} 
KEY\+\_\+\+END&Used as a parameter terminator to \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} \\
\hline

\end{DoxyEnumFields}
\mbox{\Hypertarget{group__key_gafa3306030b1d06b06c3cba24c516f5ec}\label{group__key_gafa3306030b1d06b06c3cba24c516f5ec}} 
\index{Key@{Key}!elektraLockFlags@{elektraLockFlags}}
\index{elektraLockFlags@{elektraLockFlags}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{elektraLockFlags}{elektraLockFlags}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}}}



Lock options. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}{key\+Lock()}}, \mbox{\hyperlink{group__key_ga769882e86e34a95cefcf8f260ef97e06}{key\+Is\+Locked()}} 
\end{DoxySeeAlso}
\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_LOCK\_NAME@{KEY\_LOCK\_NAME}!Key@{Key}}\index{Key@{Key}!KEY\_LOCK\_NAME@{KEY\_LOCK\_NAME}}}\mbox{\Hypertarget{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4813b0cfdefeb676e35f599ef763c265}\label{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4813b0cfdefeb676e35f599ef763c265}} 
KEY\+\_\+\+LOCK\+\_\+\+NAME&lock the name of a key \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_LOCK\_VALUE@{KEY\_LOCK\_VALUE}!Key@{Key}}\index{Key@{Key}!KEY\_LOCK\_VALUE@{KEY\_LOCK\_VALUE}}}\mbox{\Hypertarget{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4ed4895f3f243287f7adef621815d7e6}\label{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4ed4895f3f243287f7adef621815d7e6}} 
KEY\+\_\+\+LOCK\+\_\+\+VALUE&lock the value of a key \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_LOCK\_META@{KEY\_LOCK\_META}!Key@{Key}}\index{Key@{Key}!KEY\_LOCK\_META@{KEY\_LOCK\_META}}}\mbox{\Hypertarget{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4f1b7ee5af7539286d8989a9a5658958}\label{group__key_ggafa3306030b1d06b06c3cba24c516f5eca4f1b7ee5af7539286d8989a9a5658958}} 
KEY\+\_\+\+LOCK\+\_\+\+META&lock the meta data of a key \\
\hline

\end{DoxyEnumFields}
\mbox{\Hypertarget{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}\label{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}} 
\index{Key@{Key}!elektraNamespace@{elektraNamespace}}
\index{elektraNamespace@{elektraNamespace}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{elektraNamespace}{elektraNamespace}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace}}}



Elektra currently supported Key namespaces. 

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}}, \mbox{\hyperlink{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}{key\+Get\+Namespace()}} 
\end{DoxySeeAlso}
\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_NONE@{KEY\_NS\_NONE}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_NONE@{KEY\_NS\_NONE}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a3659698b0a07454ca8055ab693e8efd1}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a3659698b0a07454ca8055ab693e8efd1}} 
KEY\+\_\+\+NS\+\_\+\+NONE&no key given as parameter to \mbox{\hyperlink{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}{key\+Get\+Namespace()}} \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_CASCADING@{KEY\_NS\_CASCADING}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_CASCADING@{KEY\_NS\_CASCADING}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2c9133e3095dccbcde5ca3bb13987b5d}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2c9133e3095dccbcde5ca3bb13987b5d}} 
KEY\+\_\+\+NS\+\_\+\+CASCADING&cascading key, starts with /, abstract name for any of the namespaces below \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_META@{KEY\_NS\_META}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_META@{KEY\_NS\_META}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ac5fbf2c3a7ae79fa2d60c48ae3e72688}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ac5fbf2c3a7ae79fa2d60c48ae3e72688}} 
KEY\+\_\+\+NS\+\_\+\+META&metakey, i.\+e. any key name not under other categories \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_SPEC@{KEY\_NS\_SPEC}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_SPEC@{KEY\_NS\_SPEC}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2be047b124b1ca0e92b5ef124169f0d2}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2be047b124b1ca0e92b5ef124169f0d2}} 
KEY\+\_\+\+NS\+\_\+\+SPEC&spec contains the specification of the other namespaces \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_PROC@{KEY\_NS\_PROC}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_PROC@{KEY\_NS\_PROC}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a470ecc9254fcdfccf9923a3e526c9c11}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a470ecc9254fcdfccf9923a3e526c9c11}} 
KEY\+\_\+\+NS\+\_\+\+PROC&proc contains process-\/specific configuration \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_DIR@{KEY\_NS\_DIR}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_DIR@{KEY\_NS\_DIR}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68aa0006cf27dbb2586bafba6ff1ae4f4ec}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68aa0006cf27dbb2586bafba6ff1ae4f4ec}} 
KEY\+\_\+\+NS\+\_\+\+DIR&dir contains configuration from a specific directory \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_USER@{KEY\_NS\_USER}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_USER@{KEY\_NS\_USER}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a8ce23c70010e8ac8bb540b0947e03a4e}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a8ce23c70010e8ac8bb540b0947e03a4e}} 
KEY\+\_\+\+NS\+\_\+\+USER&user key in the home directory of the current user \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_SYSTEM@{KEY\_NS\_SYSTEM}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_SYSTEM@{KEY\_NS\_SYSTEM}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a61adca2f9dff47e65dfcdb492ffa7a20}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a61adca2f9dff47e65dfcdb492ffa7a20}} 
KEY\+\_\+\+NS\+\_\+\+SYSTEM&system key is shared for a computer system \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{KEY\_NS\_DEFAULT@{KEY\_NS\_DEFAULT}!Key@{Key}}\index{Key@{Key}!KEY\_NS\_DEFAULT@{KEY\_NS\_DEFAULT}}}\mbox{\Hypertarget{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ad6792ab14711ed6d6e507ca3d10b05e7}\label{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ad6792ab14711ed6d6e507ca3d10b05e7}} 
KEY\+\_\+\+NS\+\_\+\+DEFAULT&default key used as a fallback if no other key is found \\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__key_gab2242311a36bbc0520e0d36895107ec1}\label{group__key_gab2242311a36bbc0520e0d36895107ec1}} 
\index{Key@{Key}!keyClear@{keyClear}}
\index{keyClear@{keyClear}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyClear()}{keyClear()}}
{\footnotesize\ttfamily int key\+Clear (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key }\end{DoxyParamCaption})}



Will clear all internal data of a Key. 

After this call you will receive a fresh Key -\/ with no value, metadata or name.

The reference counter will stay unmodified.

\begin{DoxyNote}{Note}
that you might also clear() all aliases with this operation.
\end{DoxyNote}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordtype}{int} f (Key *k)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gab2242311a36bbc0520e0d36895107ec1}{keyClear}} (k);}
\DoxyCodeLine{        \textcolor{comment}{// you have a fresh Key k here}}
\DoxyCodeLine{        \mbox{\hyperlink{group__keyvalue_ga622bde1eb0e0c4994728331326340ef2}{keySetString}} (k, \textcolor{stringliteral}{"{}value"{}});}
\DoxyCodeLine{        \textcolor{comment}{// the caller will get an empty Key k with an value}}
\DoxyCodeLine{\}}

\end{DoxyCode}


\begin{DoxyPostcond}{Postcondition}
{\ttfamily key\textquotesingle{}s} name is \char`\"{}/\char`\"{} 

{\ttfamily key\textquotesingle{}s} metadata is empty
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em key} & the Key that should be cleared\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & on success \\
\hline
{\em -\/1} & on NULL pointer\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} for completely deleting a Key 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga505575ebef060066984fe0f590081e37}\label{group__key_ga505575ebef060066984fe0f590081e37}} 
\index{Key@{Key}!keyCopy@{keyCopy}}
\index{keyCopy@{keyCopy}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyCopy()}{keyCopy()}}
{\footnotesize\ttfamily Key$\ast$ key\+Copy (\begin{DoxyParamCaption}\item[{Key $\ast$}]{dest,  }\item[{const Key $\ast$}]{source,  }\item[{\mbox{\hyperlink{group__key_ga9ff42b1e9a97222562bfda3dd1f8c735}{elektra\+Copy\+Flags}}}]{flags }\end{DoxyParamCaption})}



Copy or clear a key. 

Depending on the chosen {\ttfamily flags} \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} only copies certain parts of {\ttfamily source} into {\ttfamily dest}.


\begin{DoxyItemize}
\item If \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735ab41d70eb97ae5480333e85759318b5a9}{KEY\+\_\+\+CP\+\_\+\+NAME}} is set, the key name will be copied from {\ttfamily source} to {\ttfamily dest}.
\item If \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a6b8bdcae98a0f29d66a6b3d1651cbac6}{KEY\+\_\+\+CP\+\_\+\+META}} is set, the meta keys will be copied from {\ttfamily source} to {\ttfamily dest}.
\item If \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}{KEY\+\_\+\+CP\+\_\+\+VALUE}} is set, the key value will be copied from {\ttfamily source} to {\ttfamily dest}. Additionally, if {\ttfamily source} is a binary key (\mbox{\hyperlink{group__keytest_ga9526b371087564e43e3dff8ad0dac949}{key\+Is\+Binary()}}), {\ttfamily dest} will also be marked as binary. This means that even if \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a6b8bdcae98a0f29d66a6b3d1651cbac6}{KEY\+\_\+\+CP\+\_\+\+META}} is not set, the {\ttfamily binary} meta key will be copied with \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}{KEY\+\_\+\+CP\+\_\+\+VALUE}}.
\item If \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}{KEY\+\_\+\+CP\+\_\+\+STRING}} is set, the key value will be copied from {\ttfamily source} to {\ttfamily dest}, but only, if {\ttfamily source} is {\itshape not} a binary key (\mbox{\hyperlink{group__keytest_ga9526b371087564e43e3dff8ad0dac949}{key\+Is\+Binary()}}). If {\ttfamily source} is binary, \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} fails. If {\ttfamily dest} is binary, it will still be marked as binary after the copy. This cannot be used together with \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}{KEY\+\_\+\+CP\+\_\+\+VALUE}}. The main purpose of \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}{KEY\+\_\+\+CP\+\_\+\+STRING}} is for copying {\itshape into} known string keys. It ensure that you don\textquotesingle{}t accidentally convert string keys into binary keys.
\end{DoxyItemize}

There is also the shorthand \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\+\_\+\+CP\+\_\+\+ALL}}. It is equivalent to {\ttfamily KEY\+\_\+\+CP\+\_\+\+NAME $\vert$ KEY\+\_\+\+CP\+\_\+\+VALUE $\vert$ KEY\+\_\+\+CP\+\_\+\+META}, i.\+e. all key data supported by \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} will be copied from {\ttfamily source} to {\ttfamily dest}.

Use this function when you need to copy into an existing key, e.\+g. because it was passed by a pointer in a function you can do so\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{keyCopy}} (copy, orig, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\_CP\_ALL}});}

\end{DoxyCodeInclude}
 Most often you will want to duplicate an existing key. For this purpose the alias key\+Dup() exists. Calling


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{copy = keyDup (orig, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\_CP\_ALL}});}

\end{DoxyCodeInclude}
 is equivalent to


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{copy = \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{keyCopy}} (\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}/"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), orig, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\_CP\_ALL}});}

\end{DoxyCodeInclude}
 The reference counter will not be changed for both keys. Affiliation to keysets are also not affected.

Since metadata uses copy-\/on-\/write semantics there is only a constant memory cost to copying metadata.

When you pass a NULL-\/pointer as {\ttfamily source} the pieces of {\ttfamily dest} specified by {\ttfamily flags} will be cleared.

Calling {\ttfamily key\+Copy (dest, NULL, KEY\+\_\+\+CP\+\_\+\+ALL)} is different from calling \mbox{\hyperlink{group__key_gab2242311a36bbc0520e0d36895107ec1}{key\+Clear()}}. The key will not be fully reset, the reference counter and internal flags will remain unchanged. Additionally, \mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} respects \mbox{\hyperlink{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}{key\+Lock()}} state, while \mbox{\hyperlink{group__key_gab2242311a36bbc0520e0d36895107ec1}{key\+Clear()}} always works.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{keyCopy}} (k, NULL, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\_CP\_ALL}});}
\DoxyCodeLine{\textcolor{comment}{// name, value and metadata of k have now been clear}}
\DoxyCodeLine{\textcolor{comment}{// lock flags, reference count, etc. remain unchanged}}

\end{DoxyCodeInclude}
 \begin{DoxyPrecond}{Precondition}
{\ttfamily dest} must be a valid Key (created with key\+New) 

{\ttfamily dest} must not have read-\/only flags set 

{\ttfamily source} must be a valid Key or NULL 
\end{DoxyPrecond}
\begin{DoxyInvariant}{Invariant}
Key name stays valid until delete 
\end{DoxyInvariant}
\begin{DoxyPostcond}{Postcondition}
Value from Key source is written to Key dest
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em dest} & the key which will be written to \\
\hline
{\em source} & the key which should be copied or NULL to clear the data of {\ttfamily dest} \\
\hline
{\em flags} & specifies which parts of the key should be copied\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily dest} 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} & on memory allocation problems \\
\hline
{\em NULL} & when a part of {\ttfamily dest} that should be modified (e.\+g. name, value) was marked read-\/only, e.\+g. the name of {\ttfamily dest} will be read-\/only if {\ttfamily dest} is part of a Key\+Set \\
\hline
{\em NULL} & when {\ttfamily dest} is NULL \\
\hline
{\em NULL} & when both \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3043a92bfbe465ccff7624e54d89bcf8}{KEY\+\_\+\+CP\+\_\+\+VALUE}} and \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}{KEY\+\_\+\+CP\+\_\+\+STRING}} are set in {\ttfamily flags} \\
\hline
{\em NULL} & when both \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a57996652569a901d4e7e58c33f7b3631}{KEY\+\_\+\+CP\+\_\+\+STRING}} is set in {\ttfamily flags} and {\ttfamily source} is a binary key (\mbox{\hyperlink{group__keytest_ga9526b371087564e43e3dff8ad0dac949}{key\+Is\+Binary()}})\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
0.\+9.\+5
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
key\+Dup() for duplicating an existing Key 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}\label{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}} 
\index{Key@{Key}!keyDecRef@{keyDecRef}}
\index{keyDecRef@{keyDecRef}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyDecRef()}{keyDecRef()}}
{\footnotesize\ttfamily uint16\+\_\+t key\+Dec\+Ref (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key }\end{DoxyParamCaption})}



Decrement the reference counter of a Key object. 

As long as the reference counter is non-\/zero, {\ttfamily \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}} operations on {\ttfamily key} will be a no-\/op and return an error code.

\begin{DoxyPostcond}{Postcondition}
{\ttfamily key\textquotesingle{}s} reference counter is $>$= 0 

{\ttfamily key\textquotesingle{}s} reference counter is $<$ SSIZE\+\_\+\+MAX
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em key} & the Key object whose reference counter should get decreased\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the updated value of the reference counter 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em UINT16\+\_\+\+MAX} & on NULL pointer \\
\hline
{\em 0} & when the reference counter already was the minimum value 0, the reference counter will not be modified in this case\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga0d82ce48529821aa43d82c035ba30c4f}{key\+Get\+Ref()}} to retrieve the current reference count 

\mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}} for increasing the reference counter and for a more complete explanation of the reference counting system 

\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} for deleting a Key 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}\label{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}} 
\index{Key@{Key}!keyDel@{keyDel}}
\index{keyDel@{keyDel}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyDel()}{keyDel()}}
{\footnotesize\ttfamily int key\+Del (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key }\end{DoxyParamCaption})}



A destructor for Key objects. 

Every Key created by \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} must be deleted with \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}.

When the reference counter of {\ttfamily key} is non-\/zero, this function will do nothing and simply return the current value of the reference counter.

It is therefore safe to call {\ttfamily key\+Del (k)} on any {\ttfamily Key $\ast$ k}.

\begin{DoxyPostcond}{Postcondition}
all memory related to {\ttfamily key} will be freed
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em key} & the Key object to delete\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & when the Key was freed \\
\hline
{\em -\/1} & on NULL pointers \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
the value of the reference counter, if it was non-\/zero
\end{DoxyReturn}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} for creating a new Key 

\mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}} for more information about the reference counter 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga0d82ce48529821aa43d82c035ba30c4f}\label{group__key_ga0d82ce48529821aa43d82c035ba30c4f}} 
\index{Key@{Key}!keyGetRef@{keyGetRef}}
\index{keyGetRef@{keyGetRef}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyGetRef()}{keyGetRef()}}
{\footnotesize\ttfamily uint16\+\_\+t key\+Get\+Ref (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Return the current reference counter value of a Key object. 


\begin{DoxyParams}{Parameters}
{\em key} & the Key whose reference counter to retrieve\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the value of the {\ttfamily key\textquotesingle{}s} reference counter 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on NULL pointer\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}} for increasing the reference counter and for a more complete explanation of the reference counting system 

\mbox{\hyperlink{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}{key\+Dec\+Ref()}} for decreasing the reference counter 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga0b477b584c8be68519a8d92f90355136}\label{group__key_ga0b477b584c8be68519a8d92f90355136}} 
\index{Key@{Key}!keyIncRef@{keyIncRef}}
\index{keyIncRef@{keyIncRef}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyIncRef()}{keyIncRef()}}
{\footnotesize\ttfamily uint16\+\_\+t key\+Inc\+Ref (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key }\end{DoxyParamCaption})}



Increment the reference counter of a Key object. 

As long as the reference counter is non-\/zero, {\ttfamily \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}} operations on {\ttfamily key} will be a no-\/op and return an error code.

Elektra\textquotesingle{}s system for reference counting is not based on a concept of shared ownership. It is more similar to a shared lock, where the counter is used to keep track of how many clients hold the lock.

Initially, the reference counter will be 0. This is can be interpreted as the lock being unlocked. When you increment the reference counter, the lock becomes locked and {\ttfamily \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}} is blocked and fails. Only when the reference counter is fully decremented back down to 0 again, will {\ttfamily \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}} work again.

\begin{DoxyNote}{Note}
The reference counter can never exceed {\ttfamily UINT16\+\_\+\+MAX -\/ 1}. {\ttfamily UINT16\+\_\+\+MAX} is reserved as an error code.
\end{DoxyNote}
\begin{DoxyPostcond}{Postcondition}
{\ttfamily key\textquotesingle{}s} reference counter is $>$ 0 

{\ttfamily key\textquotesingle{}s} reference counter is $<$= UINT16\+\_\+\+MAX -\/ 1
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em key} & the Key object whose reference counter should be increased\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the updated value of the reference counter 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em UINT16\+\_\+\+MAX} & on NULL pointer \\
\hline
{\em UINT16\+\_\+\+MAX} & when the reference counter already was the maximum value {\ttfamily UINT16\+\_\+\+MAX -\/ 1}, the reference counter will not be modified in this case\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga0d82ce48529821aa43d82c035ba30c4f}{key\+Get\+Ref()}} to retrieve the current reference count 

\mbox{\hyperlink{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}{key\+Dec\+Ref()}} for decreasing the reference counter 

\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} for deleting a Key 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga769882e86e34a95cefcf8f260ef97e06}\label{group__key_ga769882e86e34a95cefcf8f260ef97e06}} 
\index{Key@{Key}!keyIsLocked@{keyIsLocked}}
\index{keyIsLocked@{keyIsLocked}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyIsLocked()}{keyIsLocked()}}
{\footnotesize\ttfamily int key\+Is\+Locked (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{\mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}}}]{what }\end{DoxyParamCaption})}



Checks which parts of a Key are locked. 


\begin{DoxyParams}{Parameters}
{\em key} & the Key that should be checked for locks \\
\hline
{\em what} & the parts of the Key that should checked for locks\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the bits that are locked 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if nothing is locked \\
\hline
{\em -\/1} & on error (NULL pointer)\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}{key\+Lock()}} for locking a Key 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}\label{group__key_ga5e42b653a0f117be7f1f6eb06c569bb8}} 
\index{Key@{Key}!keyLock@{keyLock}}
\index{keyLock@{keyLock}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyLock()}{keyLock()}}
{\footnotesize\ttfamily int key\+Lock (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{\mbox{\hyperlink{group__key_gafa3306030b1d06b06c3cba24c516f5ec}{elektra\+Lock\+Flags}}}]{what }\end{DoxyParamCaption})}



Permanently lock parts of a Key. 

This can be\+:
\begin{DoxyItemize}
\item KEY\+\_\+\+LOCK\+\_\+\+NAME to lock the name
\item KEY\+\_\+\+LOCK\+\_\+\+VALUE to lock the value
\item KEY\+\_\+\+LOCK\+\_\+\+META to lock the metadata
\end{DoxyItemize}

To unlock the Key, duplicate it.

It is also possible to lock the Key when it is created with \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}}.

Some data structures need to lock the Key (most likely its name), so that the ordering does not get confused.

\begin{DoxyPostcond}{Postcondition}
key\+Is\+Locked(key, what) == what
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em key} & the Key that should be locked \\
\hline
{\em what} & the parts of the Key that should be locked (see above)\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the bits that were successfully locked 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if everything was locked before \\
\hline
{\em -\/1} & if it could not be locked (NULL pointer)\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga769882e86e34a95cefcf8f260ef97e06}{key\+Is\+Locked()}} for checking whether a Key is locked 

\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} for creating a new Key 

key\+Dup() for duplicating an existing Key 

\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} appends a Key to a \mbox{\hyperlink{group__keyset}{Key\+Set}} (and locks it) 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__key_gad23c65b44bf48d773759e1f9a4d43b89}\label{group__key_gad23c65b44bf48d773759e1f9a4d43b89}} 
\index{Key@{Key}!keyNew@{keyNew}}
\index{keyNew@{keyNew}!Key@{Key}}
\doxysubsubsection{\texorpdfstring{keyNew()}{keyNew()}}
{\footnotesize\ttfamily Key$\ast$ key\+New (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name,  }\item[{}]{... }\end{DoxyParamCaption})}



A practical way to fully create a Key object in one step. 

To just get a key object, simple do\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create and initialize a key with a name and nothing else}}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/some/example"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel}} (k);}

\end{DoxyCodeInclude}
 \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} allocates memory for a key object and \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} cleans everything up.

If you want the key object to contain a name, value, comment and other meta info read on.

\begin{DoxyNote}{Note}
When you already have a key with similar properties its easier to key\+Dup() the key.
\end{DoxyNote}
You can call \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} in many different ways depending on the attribute tags you pass as parameters. Tags are represented as \mbox{\hyperlink{group__key_ga9b703ca49f48b482def322b77d3e6bc8}{elektra\+Key\+Flags}} values, and tell \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} which Key attribute comes next. The Key attribute tags are the following\+:
\begin{DoxyItemize}
\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\+\_\+\+VALUE}} ~\newline
 Next parameter is a pointer to the value that will be used. If no \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\+\_\+\+BINARY}} was used before, a string is assumed. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create and initialize a key with a name and nothing else}}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex0"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}some data"{}},    \textcolor{comment}{// set a string value}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                  \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}

\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\+\_\+\+SIZE}} ~\newline
 Define a maximum length of the value. This is only used when setting a binary key. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create and initialize a key with a name and nothing else}}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex1"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\_SIZE}}, 4,               \textcolor{comment}{// has no effect on strings}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}some data"{}},    \textcolor{comment}{// set a string value}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                  \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}

\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\+\_\+\+META}} ~\newline
 Next two parameter is a metaname and a metavalue. See \mbox{\hyperlink{group__keymeta_gae1f15546b234ffb6007d8a31178652b9}{key\+Set\+Meta()}}. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex3"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}comment/\#0"{}}, \textcolor{stringliteral}{"{}a comment"{}},  \textcolor{comment}{// with a comment}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}owner"{}}, \textcolor{stringliteral}{"{}root"{}},         \textcolor{comment}{// and an owner}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}special"{}}, \textcolor{stringliteral}{"{}yes"{}},        \textcolor{comment}{// and any other metadata}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                  \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}

\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\+\_\+\+END}} ~\newline
 Must be the last parameter passed to \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}}. It is always required, unless the {\ttfamily key\+Name} is 0.
\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a4b83f86a07a7a0d6e24ecafe43cfea1b}{KEY\+\_\+\+FLAGS}} ~\newline
 Bitwise disjunction of flags, which don\textquotesingle{}t require one or more values. recommended way to set multiple flags. overrides previously defined flags. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex3"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\_BINARY}},                   \textcolor{comment}{// binary key}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\_SIZE}}, 7,                    \textcolor{comment}{// assume binary length 7}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}some data"{}},                \textcolor{comment}{// value that will be truncated in 7 bytes}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                        \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}

\item \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\+\_\+\+BINARY}} ~\newline
 Allows one to change the key to a binary key. Make sure that you also pass \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\+\_\+\+SIZE}} before you set the value. Otherwise it will be cut off with first \textbackslash{}0 in the string. So this flag toggle from \mbox{\hyperlink{group__keyvalue_ga622bde1eb0e0c4994728331326340ef2}{key\+Set\+String()}} to \mbox{\hyperlink{group__keyvalue_gaa50a5358fd328d373a45f395fa1b99e7}{key\+Set\+Binary()}}. If no value (nor size) is given, it will be a NULL key. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create and initialize a key with a name and nothing else}}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex2"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\_BINARY}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\_SIZE}}, 4,               \textcolor{comment}{// now the size is important}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}some data"{}},    \textcolor{comment}{// sets the binary value ("{}some"{})}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                  \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}



\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{Key *k=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/tmp/ex4"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a1ca18d4e094ae7487d35ecedda2235ff}{KEY\_BINARY}},                   \textcolor{comment}{// key type}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a6d531b5c41445d19d0452eebdccbfa01}{KEY\_SIZE}}, 7,                    \textcolor{comment}{// assume binary length 7}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}some data"{}},                \textcolor{comment}{// value that will be truncated in 7 bytes}}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}comment/\#0"{}}, \textcolor{stringliteral}{"{}value is truncated"{}},}
\DoxyCodeLine{        \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});                        \textcolor{comment}{// end of args}}

\end{DoxyCodeInclude}
 \begin{DoxyPrecond}{Precondition}
{\ttfamily name} is a valid Key name 

Variable arguments are a valid combination 
\end{DoxyPrecond}
\begin{DoxyPostcond}{Postcondition}
returns a new, fully initialized Key object with the valid Key name and all data given by variable arguments
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em name} & a valid name to the key (see \mbox{\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}})\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to a new allocated and initialized Key object. 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} & on allocation error or if an invalid {\ttfamily name} was passed (see \mbox{\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}}).\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} for deallocating a created Key object 

\mbox{\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}} for rules about which names are considered valid 
\end{DoxySeeAlso}

\end{DoxyItemize}