\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_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_gab65dc9d43d3ee08d5e936a20ebbddd23}{key\+Get\+Full\+Name\+Size} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Bytes needed to store the key name including user domain and ending N\+U\+LL. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name} (const Key $\ast$key, char $\ast$returned\+Name, size\+\_\+t max\+Size)
\begin{DoxyCompactList}\small\item\em Get key full name, including the user domain name. \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 
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_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 
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}\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_gaa34fc43a081e6b01e4120daa6c112004}{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)
\item If any key name part starts with . (dot) it means the key is inactive, see \hyperlink{group__keytest_gaa25f699f592031c1a0abc1504d14e13e}{key\+Is\+Inactive()}.
\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_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}
\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
\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_gga91fb3178848bd682000958089abbaf40aa8adb6fcb92dec58fb19410eacfdd403}{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_gga91fb3178848bd682000958089abbaf40aa8adb6fcb92dec58fb19410eacfdd403}{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{DoxySince}{Since}
0.\+8.\+11
\end{DoxySince}

\begin{DoxyRetVals}{Return values}
{\em size} & of the new key \\
\hline
{\em -\/1} & if key is a null pointer or did not have a valid name before \\
\hline
{\em -\/1} & if new\+Name is not a valid escaped name \\
\hline
{\em -\/1} & on allocation errors \\
\hline
{\em -\/1} & if key was inserted to a keyset before \\
\hline
{\em 0} & if nothing was done because new\+Name had only slashes, is too short, is empty or is null \\
\hline
\end{DoxyRetVals}
\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 

\hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner()} to get a pointer to the owner 
\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_gaaba1494a5ffc976e0e56c43f4334a23c}\label{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Full\+Name@{key\+Get\+Full\+Name}}
\index{key\+Get\+Full\+Name@{key\+Get\+Full\+Name}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Full\+Name()}{keyGetFullName()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Full\+Name (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{char $\ast$}]{returned\+Name,  }\item[{size\+\_\+t}]{max\+Size }\end{DoxyParamCaption})}



Get key full name, including the user domain name. 

\begin{DoxyReturn}{Returns}
number of bytes written 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & on empty name \\
\hline
{\em -\/1} & on N\+U\+LL pointers \\
\hline
{\em -\/1} & if max\+Size is 0 or larger than S\+S\+I\+Z\+E\+\_\+\+M\+AX \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em key} & the key object \\
\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}
\mbox{\Hypertarget{group__keyname_gab65dc9d43d3ee08d5e936a20ebbddd23}\label{group__keyname_gab65dc9d43d3ee08d5e936a20ebbddd23}} 
\index{Name Manipulation Methods@{Name Manipulation Methods}!key\+Get\+Full\+Name\+Size@{key\+Get\+Full\+Name\+Size}}
\index{key\+Get\+Full\+Name\+Size@{key\+Get\+Full\+Name\+Size}!Name Manipulation Methods@{Name Manipulation Methods}}
\subsubsection{\texorpdfstring{key\+Get\+Full\+Name\+Size()}{keyGetFullNameSize()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Full\+Name\+Size (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Bytes needed to store the key name including user domain and ending N\+U\+LL. 


\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes needed to store key name including user domain 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & on empty name \\
\hline
{\em -\/1} & on N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()}, \hyperlink{group__keyname_gabdbcfa51ed8a387e47ead207affa2d2e}{key\+Get\+Name\+Size()} 
\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()}, \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()}, \hyperlink{group__keyname_gab65dc9d43d3ee08d5e936a20ebbddd23}{key\+Get\+Full\+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_gab65dc9d43d3ee08d5e936a20ebbddd23}{key\+Get\+Full\+Name\+Size()} 

\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}. 

\begin{DoxySince}{Since}
0.\+8.\+10 Added method to \hyperlink{kdbproposal_8h}{kdbproposal.\+h}
\end{DoxySince}
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_ggaec3b8d6f430ae49b91bafe8a86310a68a33d6c53529b4e6921d0b1d6565df2f1f}{KEY\_NS\_EMPTY}:
        printf (\textcolor{stringliteral}{"empty name\(\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 = \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ae06281f94c2b7a221115afbaa1e0ff45}{KEY\_NS\_FIRST}; ns <= 
      \hyperlink{group__key_ggaec3b8d6f430ae49b91bafe8a86310a68ad4d0f219a657517ddd50cd06c8190310}{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_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()}.

The name will be without owner, see \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()} if you need the name with its owner.


\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_gaa34fc43a081e6b01e4120daa6c112004}{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 (a 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_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()}, \hyperlink{group__keyname_gab65dc9d43d3ee08d5e936a20ebbddd23}{key\+Get\+Full\+Name\+Size()} to get the full name 

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

\hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner()} to get a pointer to owner 

\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.

All text after the last {\ttfamily \textquotesingle{}/\textquotesingle{}} in the {\ttfamily key} keyname is erased and {\ttfamily base\+Name} is appended.

So 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 empty or N\+U\+LL, the resulting key name will be {\ttfamily \char`\"{}system/dir1/dir2\char`\"{}}.

This function does proper escaping on the supplied name argument.

You can use all names to set as basename (e.\+g. . (dot), .. (dot-\/dot), \% and \char`\"{}\char`\"{} (empty)). They will be properly escaped.

A simple example is\+: 
\begin{DoxyCodeInclude}
\end{DoxyCodeInclude}
 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.

To add an inactive key name, use\+: 
\begin{DoxyCodeInclude}
        \hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{keySetName} (k, \textcolor{stringliteral}{"system/valid"});
        \hyperlink{group__keyname_ga6e804bd453f98c28b0ff51430d1df407}{keySetBaseName} (k, \textcolor{stringliteral}{".hiddenkey"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (k), \textcolor{stringliteral}{"system/.hiddenkey"});
        succeed\_if\_same\_string (\hyperlink{group__keyname_gaaff35e7ca8af5560c47e662ceb9465f5}{keyBaseName} (k), \textcolor{stringliteral}{".hiddenkey"});
\end{DoxyCodeInclude}
 When you want to add an array item, use\+: 
\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}
 \begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname}{Name Manipulation Methods} for more details on special names
\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 \\
\hline
{\em -\/1} & if key was inserted to a keyset before \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_gaa942091fc4bd5c2699e49ddc50829524}{key\+Add\+Base\+Name()} 

\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()} to set a new name 
\end{DoxySeeAlso}
\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_gaa34fc43a081e6b01e4120daa6c112004}{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{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{key\+Set\+Owner()} 

\hyperlink{group__keyname_gab29a850168d9b31c9529e90cf9ab68be}{key\+Get\+Name()}, \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+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_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}
