\hypertarget{group__keyname}{}\section{Name Manipulation Methods}
\label{group__keyname}\index{Name Manipulation Methods@{Name Manipulation Methods}}


Methods to do various operations on Key names.  


Collaboration diagram for Name Manipulation Methods\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=291pt]{group__keyname}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Returns a pointer to the abbreviated real internal {\ttfamily key} name. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{key\+Get\+Name\+Size} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Bytes needed to store the key name without owner. \end{DoxyCompactList}\item 
const void $\ast$ \hyperlink{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}{key\+Unescaped\+Name} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Returns a keyname which is null separated and does not use backslash for escaping. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}{key\+Get\+Unescaped\+Name\+Size} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em return size of unescaped name with embedded and terminating null characters \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name} (const Key $\ast$key, char $\ast$returned\+Name, size\+\_\+t max\+Size)
\begin{DoxyCompactList}\small\item\em Get abbreviated key name (without owner name). \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga44a576c7919d5b03f28d3ed3afaa7cd1}{key\+Get\+Unescaped\+Name} (const Key $\ast$key, char $\ast$returned\+Name, size\+\_\+t max\+Size)
\begin{DoxyCompactList}\small\item\em Copies the unescaped name of a key into provided buffer. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name} (Key $\ast$key, const char $\ast$new\+Name)
\begin{DoxyCompactList}\small\item\em Set a new name to a key. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{key\+Add\+Name} (Key $\ast$key, const char $\ast$new\+Name)
\begin{DoxyCompactList}\small\item\em Add an already escaped name to the keyname. \end{DoxyCompactList}\item 
bool \hyperlink{group__keyname_ga26bacb092ebca8f69f3fee72069733d8}{elektra\+Key\+Name\+Validate} (const char $\ast$name, bool is\+Complete)
\begin{DoxyCompactList}\small\item\em Takes an escaped key name and validates it. \end{DoxyCompactList}\item 
void \hyperlink{group__keyname_ga99ef3765a0ea0887c8ab72859ae2592e}{elektra\+Key\+Name\+Canonicalize} (const char $\ast$name, char $\ast$$\ast$canonical\+Name, size\+\_\+t $\ast$canonical\+Size\+Ptr, size\+\_\+t offset, size\+\_\+t $\ast$usize\+Ptr)
\begin{DoxyCompactList}\small\item\em Takes a valid (non-\/)canonical key name and produces its canonical form. \end{DoxyCompactList}\item 
void \hyperlink{group__keyname_ga85dd2a5169e900c6c8371c54c7944edb}{elektra\+Key\+Name\+Unescape} (const char $\ast$canonical\+Name, char $\ast$unescaped\+Name)
\begin{DoxyCompactList}\small\item\em Takes a canonical key name and unescapes it. \end{DoxyCompactList}\item 
const char $\ast$ \hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Returns a pointer to the internal unescaped key name where the {\ttfamily basename} starts. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga1a0b76c5d9e5367c7e72211e6c63d43a}{key\+Get\+Base\+Name\+Size} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Calculates number of bytes needed to store basename of {\ttfamily key}. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}{key\+Get\+Base\+Name} (const Key $\ast$key, char $\ast$returned, size\+\_\+t max\+Size)
\begin{DoxyCompactList}\small\item\em Calculate the basename of a key name and put it in {\ttfamily returned} finalizing the string with N\+U\+LL. \end{DoxyCompactList}\item 
size\+\_\+t \hyperlink{group__keyname_ga35ac22f466de1a74ca72b05e8252980d}{elektra\+Key\+Name\+Escape\+Part} (const char $\ast$part, char $\ast$$\ast$escaped\+Part)
\begin{DoxyCompactList}\small\item\em Takes a single key name part and produces its escaped form. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name} (Key $\ast$key, const char $\ast$base\+Name)
\begin{DoxyCompactList}\small\item\em Adds {\ttfamily base\+Name} (that will be escaped) to the current key name. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name} (Key $\ast$key, const char $\ast$base\+Name)
\begin{DoxyCompactList}\small\item\em Sets {\ttfamily base\+Name} as the new basename for {\ttfamily key}. \end{DoxyCompactList}\item 
\hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace} \hyperlink{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}{key\+Get\+Namespace} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em For currently valid namespaces see \hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace}. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_ga98c1c1307419e689c98e556e5c542073}{key\+Set\+Namespace} (Key $\ast$key, \hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace} ns)
\begin{DoxyCompactList}\small\item\em Changes the namespace of a key. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Methods to do various operations on Key names. 

To use them\+: 
\begin{DoxyCode}
\textcolor{preprocessor}{#include <kdb.h>}
\end{DoxyCode}


These functions make it easier for C programmers to work with key names.

\begin{DoxyParagraph}{Terminology of Key Names}

\begin{DoxyItemize}
\item A {\itshape key name} (see \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} and \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()}) defines the place of a key within the key database. To be unique, it is always absolute and canonical.
\item Key names are composed out of many {\itshape key name parts} split by a separator. These {\itshape key name parts} do not contain an unescaped separator.
\item A {\itshape key base name} (see \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()} and \hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()}) is the last part of the key name.
\item A {\itshape C-\/\+String} is a null terminated sequence of characters. So \textbackslash{}0 (null-\/character) must not occur within a C-\/\+String.
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Namespaces}
A namespace denotes the place the key comes from\+:
\end{DoxyParagraph}

\begin{DoxyItemize}
\item {\ttfamily spec\+:/something} for specification of other keys.
\item {\ttfamily proc\+:/something} for in-\/memory keys, e.\+g. commandline.
\item {\ttfamily dir\+:/something} for dir keys in current working directory
\item {\ttfamily system\+:/something} for system keys in /etc or /
\item {\ttfamily user\+:/something} for user keys in home directory
\item {\ttfamily user\+:username/something} for other users (deprecated\+: \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()} + \hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()} currently unsupported)
\item {\ttfamily /something} for cascading keys (actually refers to one of the above, see also \hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()})

\begin{DoxyNote}{Note}
The rules are currently not formally specified and are subject of change in the next major release. So, always prefer\+:
\begin{DoxyItemize}
\item To use \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} and \hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{key\+Add\+Name()} to get the canonified version of the keyname
\item To use \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()} and \hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()} to get an escaped key name part.
\item Not to escape or canonify with your own algorithms!
\item To use \hyperlink{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}{key\+Unescaped\+Name()} and \hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()} to have access to the key name without escape sequences (key name parts are null terminated)
\item Not to unescape the strings yourself!
\end{DoxyItemize}
\end{DoxyNote}
\begin{DoxyParagraph}{Syntax for Key Names}
Key names and key name parts have following goals\+:
\begin{DoxyItemize}
\item The C-\/\+String passed to \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} and \hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{key\+Add\+Name()} may be any C-\/\+String.
\item The {\itshape key name parts} (e.\+g. \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()}, \hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()}) may be any C-\/\+String. Escaping is needed to achieve both goals.
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Semantics for Key Name Parts}

\begin{DoxyItemize}
\item \% denotes an empty key name part.
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Canonicalization for Key Names}

\begin{DoxyItemize}
\item / (slash) is the separator between key name parts.
\item // is shortened to /
\item trailing / (slashes) are removed
\item . (dot) and .. (dot-\/dot) is removed in an canonical key name, with following rules\+:
\begin{DoxyItemize}
\item /./ is shortened to /
\item \+\_\+/../ is shortened to \+\_\+
\end{DoxyItemize}
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Conventions for key names}

\begin{DoxyItemize}
\item Key name parts starting with \# are array elements. Then only \+\_\+ (underscore) followed by 0-\/9 is allowed. So we have the regular expression \#\mbox{[}\+\_\+\mbox{]}$\ast$\mbox{[}0-\/9\mbox{]}+ with the further limitation that the number of \+\_\+ is defined by the number of digits-\/1.
\item Key name parts starting with \+\_\+ are reserved for special purposes (if you use this within a plugin you still have to make sure \+\_\+ is escaped properly)
\item Key name parts starting with @ are reserved for special purposes (if you use this within a plugin you still have to make sure @ is escaped properly)
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Escaping rules}

\begin{DoxyItemize}
\item \textbackslash{} (backslash) is the escape character for the situations as described here (and only these). The \textbackslash{} character must only be escaped, when one of the following rules apply.
\item Stray escape characters are only possible in the end of the string.
\item \textbackslash{}/ allows one to escape / (any uneven number of \textbackslash{}). Does not introduce a new part.
\item Any uneven number N of \textbackslash{} before / allows you to escape / with the N/2 of \textbackslash{} prefixed. Does not introduce a new part.
\item \textbackslash{}\textbackslash{}/ allows one to use \textbackslash{} as character before / and introduces a new part.
\item Any even number N of \textbackslash{} before / allows you to have N/2 of \textbackslash{} prefixed before a / which introduces a new part.
\item Use \textbackslash{}. and \textbackslash{}.. if you want your key name part to represent . and ..
\item \textbackslash{}\textbackslash{}. and \textbackslash{}\textbackslash{}.. allows us to use \textbackslash{} as character before . and .. (and so on)
\item Use \textbackslash{}\% if you want your key name part to start with \% (and does not represent an empty name)
\item Using \textbackslash{}\textbackslash{}\% allows one to use \textbackslash{} as character before \% (and so on)
\end{DoxyItemize}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Semantics for Key Name Specifications}

\begin{DoxyItemize}
\item \+\_\+ denotes that the key name part is arbitrary (syntax as described above).
\item \# denotes that the key name part has array syntax.
\item names surrounded by \% (e.\+g. \%profile\%) denotes a placeholder. 
\end{DoxyItemize}
\end{DoxyParagraph}

\end{DoxyItemize}

\subsection{Function Documentation}
\mbox{\Hypertarget{group__keyname_ga99ef3765a0ea0887c8ab72859ae2592e}\label{group__keyname_ga99ef3765a0ea0887c8ab72859ae2592e}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!elektra\+Key\+Name\+Canonicalize@{elektra\+Key\+Name\+Canonicalize}}
\index{elektra\+Key\+Name\+Canonicalize@{elektra\+Key\+Name\+Canonicalize}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{elektra\+Key\+Name\+Canonicalize()}{elektraKeyNameCanonicalize()}}
{\footnotesize\ttfamily void elektra\+Key\+Name\+Canonicalize (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name,  }\item[{char $\ast$$\ast$}]{canonical\+Name,  }\item[{size\+\_\+t $\ast$}]{canonical\+Size\+Ptr,  }\item[{size\+\_\+t}]{offset,  }\item[{size\+\_\+t $\ast$}]{usize\+Ptr }\end{DoxyParamCaption})}



Takes a valid (non-\/)canonical key name and produces its canonical form. 

As a side-\/effect it can also calculate the size of the corresponding unescaped key name.


\begin{DoxyParams}{Parameters}
{\em name} & The key name that is processed \\
\hline
{\em canonical\+Name} & Output buffer for the canonical name \\
\hline
{\em canonical\+Size\+Ptr} & Pointer to size of {\ttfamily canonical\+Name} \\
\hline
{\em offset} & Offset into {\ttfamily canonical\+Name} \\
\hline
{\em usize\+Ptr} & Output variable for the size of the unescaped name\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily name} M\+U\+ST be a valid (non-\/)canonical key name. If it is not, the result is undefined 

{\ttfamily canonical\+Name} M\+U\+ST be a valid first argument for \hyperlink{internal_8c_ab0432d6765c40a5408a204c43747f4d4}{elektra\+Realloc()} when cast to void$\ast$$\ast$ 

{\ttfamily canonical\+Size\+Ptr} $>$= {\ttfamily offset} 

{\ttfamily offset} M\+U\+ST be 0 or {\ttfamily $\ast$canonical\+Name + offset} M\+U\+ST point to the zero-\/termintor of a valid canonical key name that starts at {\ttfamily $\ast$canonical\+Name} 

if {\ttfamily offset} is 0 then {\ttfamily $\ast$usize\+Ptr} M\+U\+ST 0, otherwise {\ttfamily $\ast$usize\+Ptr} M\+U\+ST be the correct unescaped size of the existing canonical name in {\ttfamily $\ast$canonical\+Name}
\end{DoxyPrecond}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga26bacb092ebca8f69f3fee72069733d8}{elektra\+Key\+Name\+Validate} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_ga35ac22f466de1a74ca72b05e8252980d}\label{group__keyname_ga35ac22f466de1a74ca72b05e8252980d}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!elektra\+Key\+Name\+Escape\+Part@{elektra\+Key\+Name\+Escape\+Part}}
\index{elektra\+Key\+Name\+Escape\+Part@{elektra\+Key\+Name\+Escape\+Part}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{elektra\+Key\+Name\+Escape\+Part()}{elektraKeyNameEscapePart()}}
{\footnotesize\ttfamily size\+\_\+t elektra\+Key\+Name\+Escape\+Part (\begin{DoxyParamCaption}\item[{const char $\ast$}]{part,  }\item[{char $\ast$$\ast$}]{escaped\+Part }\end{DoxyParamCaption})}



Takes a single key name part and produces its escaped form. 


\begin{DoxyParams}{Parameters}
{\em part} & A single key name part, i.\+e. contained \textquotesingle{}/\textquotesingle{} will be escaped, \textquotesingle{}\textbackslash{}0\textquotesingle{} terminates part \\
\hline
{\em escaped\+Part} & Output buffer for the escaped form\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily escaped\+Part} M\+U\+ST be a valid first argument for \hyperlink{internal_8c_ab0432d6765c40a5408a204c43747f4d4}{elektra\+Realloc()} when cast to {\ttfamily void$\ast$$\ast$}
\end{DoxyPrecond}
\begin{DoxyReturn}{Returns}
The size of the escaped form excluding the zero terminator 
\end{DoxyReturn}
\mbox{\Hypertarget{group__keyname_ga85dd2a5169e900c6c8371c54c7944edb}\label{group__keyname_ga85dd2a5169e900c6c8371c54c7944edb}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!elektra\+Key\+Name\+Unescape@{elektra\+Key\+Name\+Unescape}}
\index{elektra\+Key\+Name\+Unescape@{elektra\+Key\+Name\+Unescape}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{elektra\+Key\+Name\+Unescape()}{elektraKeyNameUnescape()}}
{\footnotesize\ttfamily void elektra\+Key\+Name\+Unescape (\begin{DoxyParamCaption}\item[{const char $\ast$}]{canonical\+Name,  }\item[{char $\ast$}]{unescaped\+Name }\end{DoxyParamCaption})}



Takes a canonical key name and unescapes it. 


\begin{DoxyParams}{Parameters}
{\em canonical\+Name} & The canonical name to unescape \\
\hline
{\em unescaped\+Name} & Output buffer for the unescaped name\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily canonical\+Name} M\+U\+ST be a canonical key name. If this is not the case, the result is undefined. 

{\ttfamily unescaped\+Name} M\+U\+ST be allocated to the correct size.
\end{DoxyPrecond}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga99ef3765a0ea0887c8ab72859ae2592e}{elektra\+Key\+Name\+Canonicalize} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_ga26bacb092ebca8f69f3fee72069733d8}\label{group__keyname_ga26bacb092ebca8f69f3fee72069733d8}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!elektra\+Key\+Name\+Validate@{elektra\+Key\+Name\+Validate}}
\index{elektra\+Key\+Name\+Validate@{elektra\+Key\+Name\+Validate}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{elektra\+Key\+Name\+Validate()}{elektraKeyNameValidate()}}
{\footnotesize\ttfamily bool elektra\+Key\+Name\+Validate (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name,  }\item[{bool}]{is\+Complete }\end{DoxyParamCaption})}



Takes an escaped key name and validates it. 

Complete key names must inlcude a namespace or a leading slash.


\begin{DoxyParams}{Parameters}
{\em name} & The escaped key name to check \\
\hline
{\em is\+Complete} & Whether or not {\ttfamily name} is supposed to be a complete key name\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em \#true} & If {\ttfamily name} is a valid key name. \\
\hline
{\em \#false} & Otherwise \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}\label{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Add\+Base\+Name@{key\+Add\+Base\+Name}}
\index{key\+Add\+Base\+Name@{key\+Add\+Base\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Add\+Base\+Name()}{keyAddBaseName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Add\+Base\+Name (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{const char $\ast$}]{base\+Name }\end{DoxyParamCaption})}



Adds {\ttfamily base\+Name} (that will be escaped) to the current key name. 

A new base\+Name will be added, no other part of the key name will be affected.

Assumes that {\ttfamily key} is a directory and will append {\ttfamily base\+Name} to it. The function adds the path separator for concatenating.

So if {\ttfamily key} has name {\ttfamily \char`\"{}system\+:/dir1/dir2\char`\"{}} and this method is called with {\ttfamily base\+Name} {\ttfamily \char`\"{}mykey\char`\"{}}, the resulting key will have the name {\ttfamily \char`\"{}system\+:/dir1/dir2/mykey\char`\"{}}.

When {\ttfamily base\+Name} is 0 nothing will happen and the size of the name is returned.

The escaping rules apply as in \hyperlink{group__keyname}{above }.

A simple example is\+: 
\begin{DoxyCodeInclude}
Key * k = \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user:/my/long"}, \hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END});
\hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{keyAddBaseName} (k, \textcolor{stringliteral}{"myname"});
printf (\textcolor{stringliteral}{"%s\(\backslash\)n"}, \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k)); \textcolor{comment}{// will print user:/my/long/myname}
\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel} (k);
\end{DoxyCodeInclude}
 E.\+g. if you add . it will be escaped\+: 
\begin{DoxyCodeInclude}
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{"system:/valid"});
        succeed\_if (\hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{keyAddBaseName} (k, \textcolor{stringliteral}{"."}) >= 0, \textcolor{stringliteral}{"could not add a base name"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k), \textcolor{stringliteral}{"system:/valid/\(\backslash\)\(\backslash\)."});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{"."});
\end{DoxyCodeInclude}
 \begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()} to set a base name 

\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} to set a new name.
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
{\em base\+Name} & the string to append to the name \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the size in bytes of the new key name including the ending N\+U\+LL 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & if the key had no name \\
\hline
{\em -\/1} & on N\+U\+LL pointers \\
\hline
{\em -\/1} & if key was inserted to a keyset before \\
\hline
{\em -\/1} & on allocation errors \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}\label{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Add\+Name@{key\+Add\+Name}}
\index{key\+Add\+Name@{key\+Add\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Add\+Name()}{keyAddName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Add\+Name (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{const char $\ast$}]{new\+Name }\end{DoxyParamCaption})}



Add an already escaped name to the keyname. 

The same way as in \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} this method finds the canonical pathname\+:
\begin{DoxyItemize}
\item it will ignore /./
\item it will remove a level when /../ is used
\item it will remove multiple slashes ////
\end{DoxyItemize}

For example\+: 
\begin{DoxyCodeInclude}
Key * k = \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user:/x/r"}, \hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END});
\hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{keyAddName} (k, \textcolor{stringliteral}{"../y/a//././z"});
assert (!strcmp (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k), \textcolor{stringliteral}{"user:/x/y/a/z"}));
\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel} (k);
\end{DoxyCodeInclude}
 Unlike \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} it adds relative to the previous name and cannot change the namespace of a key. For example\+: 
\begin{DoxyCodeInclude}
Key * n = \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user:/away"}, \hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END});
\hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{keyAddName} (n, \textcolor{stringliteral}{"../../../new/name"});
assert (!strcmp (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (n), \textcolor{stringliteral}{"user:/new/name"}));
\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel} (n);
\end{DoxyCodeInclude}
 The passed name needs to be valid according the \hyperlink{group__keyname}{key name rules }. It is not allowed to\+:
\begin{DoxyItemize}
\item be empty
\item end with unequal number of \textbackslash{}
\end{DoxyItemize}


\begin{DoxyParams}{Parameters}
{\em key} & the key where a name should be added \\
\hline
{\em new\+Name} & the new name to append\\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily key} M\+U\+ST be a valid \#\+Key
\end{DoxyPrecond}
\begin{DoxySince}{Since}
0.\+8.\+11
\end{DoxySince}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & if {\ttfamily key == N\+U\+LL}, {\ttfamily key} is read-\/only, {\ttfamily new\+Name == N\+U\+LL} or {\ttfamily new\+Name} is not a valid escaped name \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
new size of the escaped name of {\ttfamily key} 
\end{DoxyReturn}
\mbox{\Hypertarget{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}\label{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Base\+Name@{key\+Base\+Name}}
\index{key\+Base\+Name@{key\+Base\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Base\+Name()}{keyBaseName()}}
{\footnotesize\ttfamily const char$\ast$ key\+Base\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Returns a pointer to the internal unescaped key name where the {\ttfamily basename} starts. 

This is a much more efficient version of \hyperlink{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}{key\+Get\+Base\+Name()} and you should use it if you are responsible enough to not mess up things. The name might change or even point to a wrong place after a \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}. So make sure to copy the memory before the name changes.

\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()} returns \char`\"{}\char`\"{} when there is no key\+Base\+Name. The reason is 
\begin{DoxyCodeInclude}
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{""});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{""});
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{"user:/"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{""});
\end{DoxyCodeInclude}
 And there is also support for really empty basenames\+: 
\begin{DoxyCodeInclude}
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{"system:/valid"});
        succeed\_if (\hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{keyAddBaseName} (k, \textcolor{stringliteral}{""}) >= 0, \textcolor{stringliteral}{"could not add a base name"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k), \textcolor{stringliteral}{"system:/valid/%"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{""});
\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
You must never use the pointer returned by \hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()} method to change the name, but you should use \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()} instead.

Do not assume that \hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()} points to the same region as \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} does.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em key} & the object to obtain the basename from \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to the basename 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em \char`\"{}\char`\"{}} & when the key has no (base)name \\
\hline
{\em 0} & on N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}{key\+Get\+Base\+Name()}, \hyperlink{group__keyname_ga1a0b76c5d9e5367c7e72211e6c63d43a}{key\+Get\+Base\+Name\+Size()} 

\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} to get a pointer to the name 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}\label{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Base\+Name@{key\+Get\+Base\+Name}}
\index{key\+Get\+Base\+Name@{key\+Get\+Base\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Base\+Name()}{keyGetBaseName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Base\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{char $\ast$}]{returned,  }\item[{size\+\_\+t}]{max\+Size }\end{DoxyParamCaption})}



Calculate the basename of a key name and put it in {\ttfamily returned} finalizing the string with N\+U\+LL. 

Some examples\+:
\begin{DoxyItemize}
\item basename of {\ttfamily system\+:/some/keyname} is {\ttfamily keyname} 
\item basename of {\ttfamily \char`\"{}user\+:/tmp/some key\char`\"{}} is {\ttfamily \char`\"{}some key\char`\"{}} 
\end{DoxyItemize}


\begin{DoxyParams}{Parameters}
{\em key} & the key to extract basename from \\
\hline
{\em returned} & a pre-\/allocated buffer to store the basename \\
\hline
{\em max\+Size} & size of the {\ttfamily returned} buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes copied to {\ttfamily returned} 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & on empty name \\
\hline
{\em -\/1} & on N\+U\+LL pointers \\
\hline
{\em -\/1} & when max\+Size is 0 or larger than S\+S\+I\+Z\+E\+\_\+\+M\+AX \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()}, \hyperlink{group__keyname_ga1a0b76c5d9e5367c7e72211e6c63d43a}{key\+Get\+Base\+Name\+Size()} 

\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()}, \hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()}, \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_ga1a0b76c5d9e5367c7e72211e6c63d43a}\label{group__keyname_ga1a0b76c5d9e5367c7e72211e6c63d43a}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Base\+Name\+Size@{key\+Get\+Base\+Name\+Size}}
\index{key\+Get\+Base\+Name\+Size@{key\+Get\+Base\+Name\+Size}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Base\+Name\+Size()}{keyGetBaseNameSize()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Base\+Name\+Size (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Calculates number of bytes needed to store basename of {\ttfamily key}. 

Key names that have only root names (e.\+g. {\ttfamily \char`\"{}system\+:/\char`\"{}} or {\ttfamily \char`\"{}user\+:/\char`\"{}} or {\ttfamily \char`\"{}user\+:domain\char`\"{}} ) does not have basenames, thus the function will return 1 bytes to store \char`\"{}\char`\"{}.

Basenames are denoted as\+:
\begin{DoxyItemize}
\item {\ttfamily system\+:/some/thing/basename} -\/$>$ {\ttfamily basename} 
\item {\ttfamily user\+:domain/some/thing/base\textbackslash{}/name} $>$ {\ttfamily base\textbackslash{}/name} 
\end{DoxyItemize}


\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
size in bytes of {\ttfamily key\textquotesingle{}s} basename including ending N\+U\+LL 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{key\+Base\+Name()}, \hyperlink{group__keyname_ga0992d26bcfca767cb8e77053a483eb64}{key\+Get\+Base\+Name()} 

\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()}, \hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()}, \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}\label{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Name@{key\+Get\+Name}}
\index{key\+Get\+Name@{key\+Get\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Name()}{keyGetName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{char $\ast$}]{returned\+Name,  }\item[{size\+\_\+t}]{max\+Size }\end{DoxyParamCaption})}



Get abbreviated key name (without owner name). 

When there is not enough space to write the name, nothing will be written and -\/1 will be returned.

max\+Size is limited to S\+S\+I\+Z\+E\+\_\+\+M\+AX. When this value is exceeded -\/1 will be returned. The reason for that is that any value higher is just a negative return value passed by accident. Of course elektra\+Malloc is not as failure tolerant and will try to allocate.


\begin{DoxyCode}
\textcolor{keywordtype}{char} *getBack = \hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektraMalloc} (\hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{keyGetNameSize}(key));
\hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{keyGetName}(key, getBack, \hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{keyGetNameSize}(key));
\end{DoxyCode}


\begin{DoxyReturn}{Returns}
number of bytes written to {\ttfamily returned\+Name} 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & when only a null was written \\
\hline
{\em -\/1} & when keyname is longer then max\+Size or 0 or any N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
{\em returned\+Name} & pre-\/allocated memory to write the key name \\
\hline
{\em max\+Size} & maximum number of bytes that will fit in returned\+Name, including the final N\+U\+LL \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{key\+Get\+Name\+Size()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}\label{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Name\+Size@{key\+Get\+Name\+Size}}
\index{key\+Get\+Name\+Size@{key\+Get\+Name\+Size}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Name\+Size()}{keyGetNameSize()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Name\+Size (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Bytes needed to store the key name without owner. 

For an empty key name you need one byte to store the ending N\+U\+LL. For that reason 1 is returned.


\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes needed, including ending N\+U\+LL, to store key name without owner 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & if there is is no key Name \\
\hline
{\em -\/1} & on N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()} 

\hyperlink{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}{key\+Get\+Unescaped\+Name\+Size} to get size of unescaped name 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}\label{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Namespace@{key\+Get\+Namespace}}
\index{key\+Get\+Namespace@{key\+Get\+Namespace}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Namespace()}{keyGetNamespace()}}
{\footnotesize\ttfamily \hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace} key\+Get\+Namespace (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



For currently valid namespaces see \hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace}. 

To handle every possible cases (including namespaces) a key can have\+: 
\begin{DoxyCodeInclude}
\textcolor{keywordflow}{switch} (\hyperlink{group__keyname_gafc3ca03ed10f87eb59bdc02cf2a0de8d}{keyGetNamespace} (k))
\{
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2be047b124b1ca0e92b5ef124169f0d2}{KEY\_NS\_SPEC}:
        printf (\textcolor{stringliteral}{"spec namespace\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a470ecc9254fcdfccf9923a3e526c9c11}{KEY\_NS\_PROC}:
        printf (\textcolor{stringliteral}{"proc namespace\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68aa0006cf27dbb2586bafba6ff1ae4f4ec}{KEY\_NS\_DIR}:
        printf (\textcolor{stringliteral}{"dir namespace\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a8ce23c70010e8ac8bb540b0947e03a4e}{KEY\_NS\_USER}:
        printf (\textcolor{stringliteral}{"user namespace\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a61adca2f9dff47e65dfcdb492ffa7a20}{KEY\_NS\_SYSTEM}:
        printf (\textcolor{stringliteral}{"system namespace\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a3659698b0a07454ca8055ab693e8efd1}{KEY\_NS\_NONE}:
        printf (\textcolor{stringliteral}{"no key\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ac5fbf2c3a7ae79fa2d60c48ae3e72688}{KEY\_NS\_META}:
        printf (\textcolor{stringliteral}{"metakey\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\textcolor{keywordflow}{case} \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a2c9133e3095dccbcde5ca3bb13987b5d}{KEY\_NS\_CASCADING}:
        printf (\textcolor{stringliteral}{"cascading key\(\backslash\)n"});
        \textcolor{keywordflow}{break};
\}
\end{DoxyCodeInclude}
 To loop over all valid namespaces use\+: 
\begin{DoxyCodeInclude}
\textcolor{keywordflow}{for} (\hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektraNamespace} ns = KEY\_NS\_FIRST; ns <= KEY\_NS\_LAST; ++ns)
\{
        \textcolor{comment}{// work with namespace}
        printf (\textcolor{stringliteral}{"%d\(\backslash\)n"}, ns);
\}
\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
This method might be enhanced. You do not have any guarantee that, when for a specific name \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ac5fbf2c3a7ae79fa2d60c48ae3e72688}{K\+E\+Y\+\_\+\+N\+S\+\_\+\+M\+E\+TA} is returned today, that it still will be returned after the next recompilation. So make sure that your compiler gives you a warning for unhandled switches (gcc\+: -\/\+Wswitch or -\/\+Wswitch-\/enum if you want to handle default) and look out for those warnings.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the namespace of a key. 
\end{DoxyReturn}
\mbox{\Hypertarget{group__keyname_ga44a576c7919d5b03f28d3ed3afaa7cd1}\label{group__keyname_ga44a576c7919d5b03f28d3ed3afaa7cd1}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Unescaped\+Name@{key\+Get\+Unescaped\+Name}}
\index{key\+Get\+Unescaped\+Name@{key\+Get\+Unescaped\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Unescaped\+Name()}{keyGetUnescapedName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Unescaped\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{char $\ast$}]{returned\+Name,  }\item[{size\+\_\+t}]{max\+Size }\end{DoxyParamCaption})}



Copies the unescaped name of a key into provided buffer. 

We will only copy the full name, if the buffer is to small an error code is returned.

To ensure your buffer is big enough, you can use \hyperlink{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}{key\+Get\+Unescaped\+Name\+Size()} to find the correct size.


\begin{DoxyParams}{Parameters}
{\em key} & the Key to extract the unescaped name from \\
\hline
{\em returned\+Name} & output buffer \\
\hline
{\em max\+Size} & maximum bytes that can be copied into {\ttfamily returned\+Name} \\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily key} M\+U\+ST be a valid \#\+Key and {\ttfamily key != N\+U\+LL} 

{\ttfamily returned\+Name} M\+U\+ST be allocated to be at least {\ttfamily max\+Size} bytes big and {\ttfamily returned\+Name != N\+U\+LL}
\end{DoxyPrecond}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & precondition error \\
\hline
{\em -\/2} & the size of the unescaped name is bigger then {\ttfamily max\+Size} \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
otherwise, the actual size of the unescaped name, i.\+e. the number of bytes copied into {\ttfamily returned\+Name} 
\end{DoxyReturn}
\mbox{\Hypertarget{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}\label{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Unescaped\+Name\+Size@{key\+Get\+Unescaped\+Name\+Size}}
\index{key\+Get\+Unescaped\+Name\+Size@{key\+Get\+Unescaped\+Name\+Size}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Unescaped\+Name\+Size()}{keyGetUnescapedNameSize()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Unescaped\+Name\+Size (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



return size of unescaped name with embedded and terminating null characters 


\begin{DoxyParams}{Parameters}
{\em key} & the object to work with\\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}{key\+Unescaped\+Name()} 

\hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{key\+Get\+Name\+Size()} for size of escaped variant 
\end{DoxySeeAlso}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on null pointer \\
\hline
{\em 0} & if no name \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__keyname_ga8e805c726a60da921d3736cda7813513}\label{group__keyname_ga8e805c726a60da921d3736cda7813513}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Name@{key\+Name}}
\index{key\+Name@{key\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Name()}{keyName()}}
{\footnotesize\ttfamily const char$\ast$ key\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Returns a pointer to the abbreviated real internal {\ttfamily key} name. 

This is a much more efficient version of \hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()} and can use it if you are responsible enough to not mess up things. You are not allowed to change anything in the returned array. The content of that string may change after \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} and similar functions. If you need a copy of the name, consider using \hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()}.


\begin{DoxyRetVals}{Return values}
{\em \char`\"{}\char`\"{}} & when there is no key\+Name. The reason is 
\begin{DoxyCode}
key=\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}(0);
\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName}(key,\textcolor{stringliteral}{""});
\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName}(key); \textcolor{comment}{// you would expect "" here}
\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel}(key);
\end{DoxyCode}
\\
\hline
\end{DoxyRetVals}
Valid key names are\+:


\begin{DoxyItemize}
\item {\ttfamily spec\+:/something} for specification of other keys.
\item {\ttfamily proc\+:/something} for in-\/memory keys, e.\+g. commandline.
\item {\ttfamily dir\+:/something} for dir keys in current working directory
\item {\ttfamily system\+:/something} for system keys in /etc or /
\item {\ttfamily user\+:/something} for user keys in home directory
\item {\ttfamily user\+:username/something} for other users (deprecated\+: \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()} + \hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()} currently unsupported)
\item {\ttfamily /something} for cascading keys (actually refers to one of the above, see also \hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()})

\begin{DoxyNote}{Note}
Note that the Key structure keeps its own size field that is calculated by library internal calls, so to avoid inconsistencies, you must never use the pointer returned by \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} method to set a new value. Use \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} instead.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to the keyname which must not be changed. 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em \char`\"{}\char`\"{}} & when there is no (an empty) keyname \\
\hline
{\em 0} & on N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{key\+Get\+Name\+Size()} for the string length 

\hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()} as alternative to get a copy 

\hyperlink{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}{key\+Unescaped\+Name} to get an unescaped \hyperlink{group__key}{Key} name 
\end{DoxySeeAlso}

\end{DoxyItemize}\mbox{\Hypertarget{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}\label{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Set\+Base\+Name@{key\+Set\+Base\+Name}}
\index{key\+Set\+Base\+Name@{key\+Set\+Base\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Set\+Base\+Name()}{keySetBaseName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Set\+Base\+Name (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{const char $\ast$}]{base\+Name }\end{DoxyParamCaption})}



Sets {\ttfamily base\+Name} as the new basename for {\ttfamily key}. 

Only the base\+Name will be affected and no other part of the key.

A simple example is\+: 
\begin{DoxyCodeInclude}
Key * k = \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user:/my/long/name"}, \hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END});
\hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{keySetBaseName} (k, \textcolor{stringliteral}{"myname"});
printf (\textcolor{stringliteral}{"%s\(\backslash\)n"}, \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k)); \textcolor{comment}{// will print user:/my/long/myname}
\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel} (k);
\end{DoxyCodeInclude}
 All text after the last {\ttfamily \textquotesingle{}/\textquotesingle{}} in the {\ttfamily key} keyname is erased and {\ttfamily base\+Name} is appended. If {\ttfamily base\+Name} is 0 (N\+U\+LL), then the last part of the keyname is removed without replacement.

Let us suppose {\ttfamily key} has name {\ttfamily \char`\"{}system\+:/dir1/dir2/key1\char`\"{}}. If {\ttfamily base\+Name} is {\ttfamily \char`\"{}key2\char`\"{}}, the resulting key name will be {\ttfamily \char`\"{}system\+:/dir1/dir2/key2\char`\"{}}. If {\ttfamily base\+Name} is 0 (N\+U\+LL), the resulting key name will be {\ttfamily \char`\"{}system\+:/dir1/dir2\char`\"{}}. If {\ttfamily base\+Name} is empty, the resulting key name will be {\ttfamily \char`\"{}system\+:/dir1/dir2/\%\char`\"{}}, where {\ttfamily \char`\"{}\%\char`\"{}} denotes an empty base name, as also shown in the following code\+:


\begin{DoxyCodeInclude}
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{"system:/valid"});
        \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{keySetBaseName} (k, \textcolor{stringliteral}{""});
        succeed\_if\_same\_string (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k), \textcolor{stringliteral}{"system:/%"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{""});
\end{DoxyCodeInclude}
 \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()} does proper escaping on the supplied name argument.

You can use character sequences as {\ttfamily base\+Name} (e.\+g. {\ttfamily \char`\"{}.\char`\"{}} (dot), {\ttfamily \char`\"{}..\char`\"{}} (dot-\/dot), {\ttfamily \char`\"{}\%\char`\"{}} (empty basename)). They will be properly escaped and will not have their usual meaning.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname}{Name Manipulation Methods} for more details on special names
\end{DoxySeeAlso}
If you want to add and not change the basename, use \hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()} instead. If you do not want escaping, use \hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{key\+Add\+Name()} instead.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()} to add a basename instead of changing it 

\hyperlink{group__keyname_gaa70593a2c772c4b7bc33423b9b10a270}{key\+Add\+Name()} to add a name without escaping 

\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} to set a completely new name
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
{\em base\+Name} & the string used to overwrite the basename of the key \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the size in bytes of the new key name 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on N\+U\+LL pointers in key \\
\hline
{\em -\/1} & if key was inserted to a keyset before \\
\hline
{\em -\/1} & on allocation errors \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}\label{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Set\+Name@{key\+Set\+Name}}
\index{key\+Set\+Name@{key\+Set\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Set\+Name()}{keySetName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Set\+Name (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{const char $\ast$}]{new\+Name }\end{DoxyParamCaption})}



Set a new name to a key. 

A valid name is one of the forms\+:
\begin{DoxyItemize}
\item {\ttfamily spec\+:/something} for specification of other keys.
\item {\ttfamily proc\+:/something} for in-\/memory keys, e.\+g. commandline.
\item {\ttfamily dir\+:/something} for dir keys in current working directory
\item {\ttfamily system\+:/something} for system keys in /etc or /
\item {\ttfamily user\+:/something} for user keys in home directory
\item {\ttfamily user\+:username/something} for other users (deprecated\+: \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()} + \hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()} currently unsupported)
\item {\ttfamily /something} for cascading keys (actually refers to one of the above, see also \hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()})
\end{DoxyItemize}

An invalid name either has an invalid namespace or a wrongly escaped \textbackslash{} at the end of the name.

See \hyperlink{group__keyname}{key names } for the exact rules.

The last form has explicitly set the owner, to let the library know in which user folder to save the key. A owner is a user name. If it is not defined (the second form) current user is used.

You should always follow the guidelines for key tree structure creation.

A private copy of the key name will be stored, and the {\ttfamily new\+Name} parameter can be freed after this call.

.., . and / will be handled as in filesystem paths. A valid name will be build out of the (valid) name what you pass, e.\+g. user\+:///sw/../sw//././\+My\+App -\/$>$ user\+:/sw/\+My\+App

On invalid names, N\+U\+LL or \char`\"{}\char`\"{} the name will be \char`\"{}\char`\"{} afterwards.


\begin{DoxyRetVals}{Return values}
{\em size} & in bytes of this new key name including ending N\+U\+LL \\
\hline
{\em 0} & if new\+Name is an empty string or a N\+U\+LL pointer (name will be empty afterwards) \\
\hline
{\em -\/1} & if new\+Name is invalid (name will be empty afterwards) \\
\hline
{\em -\/1} & if key was inserted to a keyset before \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
{\em new\+Name} & the new key name \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()} 

\hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()}, \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} 

\hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{key\+Set\+Base\+Name()}, \hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()} to manipulate a name 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__keyname_ga98c1c1307419e689c98e556e5c542073}\label{group__keyname_ga98c1c1307419e689c98e556e5c542073}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Set\+Namespace@{key\+Set\+Namespace}}
\index{key\+Set\+Namespace@{key\+Set\+Namespace}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Set\+Namespace()}{keySetNamespace()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Set\+Namespace (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{\hyperlink{group__key_gaec3b8d6f430ae49b91bafe8a86310a68}{elektra\+Namespace}}]{ns }\end{DoxyParamCaption})}



Changes the namespace of a key. 

The rest of the name remains unchanged.


\begin{DoxyParams}{Parameters}
{\em key} & The \#\+Key whose namespace will be changed \\
\hline
{\em ns} & The new namespace of for {\ttfamily key} \\
\hline
\end{DoxyParams}
\begin{DoxyPrecond}{Precondition}
{\ttfamily ns} M\+U\+ST be a valid namespace and not \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68a3659698b0a07454ca8055ab693e8efd1}{K\+E\+Y\+\_\+\+N\+S\+\_\+\+N\+O\+NE} 

{\ttfamily key} M\+U\+ST be a valid \#\+Key, especially {\ttfamily key != N\+U\+LL}
\end{DoxyPrecond}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & precondition error \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
the new size the {\ttfamily }\{key\}\textquotesingle{}s escaped name 
\end{DoxyReturn}
\mbox{\Hypertarget{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}\label{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Unescaped\+Name@{key\+Unescaped\+Name}}
\index{key\+Unescaped\+Name@{key\+Unescaped\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Unescaped\+Name()}{keyUnescapedName()}}
{\footnotesize\ttfamily const void$\ast$ key\+Unescaped\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Returns a keyname which is null separated and does not use backslash for escaping. 

Slashes are replaced with null bytes. So cascading keys start with a null byte. Otherwise escaped characters, e.\+g. non-\/hierarchy slash, will be unescaped.

This name is essential if you want to iterate over parts of the key name, want to compare keynames and want to check relations of keys in the hierarchy.


\begin{DoxyParams}{Parameters}
{\em key} & the object to work with\\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga5e7eff0c77678420199d0d2e8729152b}{key\+Get\+Unescaped\+Name\+Size()} 

\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} for escaped variant 
\end{DoxySeeAlso}

\begin{DoxyRetVals}{Return values}
{\em 0} & on null pointers \\
\hline
{\em \char`\"{}\char`\"{}} & if no name \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
the name in its unescaped form 
\end{DoxyReturn}
