\hypertarget{owner_8c}{}\section{owner.\+c File Reference}
\label{owner_8c}\index{owner.\+c@{owner.\+c}}


Obsolete owner methods.  


{\ttfamily \#include $<$kdb.\+h$>$}\newline
{\ttfamily \#include $<$kdbconfig.\+h$>$}\newline
{\ttfamily \#include $<$kdbmeta.\+h$>$}\newline
{\ttfamily \#include $<$kdbprivate.\+h$>$}\newline
Include dependency graph for owner.\+c\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{owner_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Return a pointer to the real internal {\ttfamily key} owner. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{owner_8c_a4a4561895741ba2ad10acf007c188593}{key\+Get\+Owner\+Size} (const Key $\ast$key)
\begin{DoxyCompactList}\small\item\em Return the size of the owner of the Key with concluding 0. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner} (const Key $\ast$key, char $\ast$returned\+Owner, size\+\_\+t max\+Size)
\begin{DoxyCompactList}\small\item\em Return the owner of the key. \end{DoxyCompactList}\item 
ssize\+\_\+t \hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{key\+Set\+Owner} (Key $\ast$key, const char $\ast$new\+Owner)
\begin{DoxyCompactList}\small\item\em Set the owner of a key. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Obsolete owner methods. 

\begin{DoxyCopyright}{Copyright}
B\+SD License (see L\+I\+C\+E\+N\+S\+E.\+md or \href{https://www.libelektra.org}{\tt https\+://www.\+libelektra.\+org}) 
\end{DoxyCopyright}


\subsection{Function Documentation}
\mbox{\Hypertarget{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}\label{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}} 
\index{owner.\+c@{owner.\+c}!key\+Get\+Owner@{key\+Get\+Owner}}
\index{key\+Get\+Owner@{key\+Get\+Owner}!owner.\+c@{owner.\+c}}
\subsubsection{\texorpdfstring{key\+Get\+Owner()}{keyGetOwner()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Owner (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key,  }\item[{char $\ast$}]{returned\+Owner,  }\item[{size\+\_\+t}]{max\+Size }\end{DoxyParamCaption})}



Return the owner of the key. 


\begin{DoxyItemize}
\item Given {\ttfamily user\+:someuser/}..... return {\ttfamily someuser} 
\item Given {\ttfamily user\+:some.\+user/}.... return {\ttfamily some.\+user} 
\item Given {\ttfamily user/}.... return the current user
\end{DoxyItemize}

Only {\ttfamily user/}... keys have an owner. For {\ttfamily system/}... keys (that doesn\textquotesingle{}t have a key owner) an empty string (\char`\"{}\char`\"{}) is returned.

Although usually the same, the owner of a key is not related to its U\+ID. Owner are related to W\+H\+E\+RE the key is stored on disk, while U\+I\+Ds are related to mode controls of a key.


\begin{DoxyParams}{Parameters}
{\em key} & the object to work with \\
\hline
{\em returned\+Owner} & a pre-\/allocated space to store the owner \\
\hline
{\em max\+Size} & maximum number of bytes that fit returned \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes written to buffer 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & if there is no owner \\
\hline
{\em -\/1} & on N\+U\+LL pointers \\
\hline
{\em -\/1} & when max\+Size is 0, larger than S\+S\+I\+Z\+E\+\_\+\+M\+AX or too small for ownername \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}, \hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{key\+Set\+Owner()}, \hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner()}, \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{owner_8c_a4a4561895741ba2ad10acf007c188593}\label{owner_8c_a4a4561895741ba2ad10acf007c188593}} 
\index{owner.\+c@{owner.\+c}!key\+Get\+Owner\+Size@{key\+Get\+Owner\+Size}}
\index{key\+Get\+Owner\+Size@{key\+Get\+Owner\+Size}!owner.\+c@{owner.\+c}}
\subsubsection{\texorpdfstring{key\+Get\+Owner\+Size()}{keyGetOwnerSize()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Get\+Owner\+Size (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Return the size of the owner of the Key with concluding 0. 

The returned number can be used to allocate a string. 1 will returned on an empty owner to store the concluding 0 on using \hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()}.


\begin{DoxyCode}
\textcolor{keywordtype}{char} * buffer;
buffer = \hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektraMalloc} (\hyperlink{owner_8c_a4a4561895741ba2ad10acf007c188593}{keyGetOwnerSize} (key));
\textcolor{comment}{// use buffer and keyGetOwnerSize (key) for maxSize}
\end{DoxyCode}


\begin{DoxyNote}{Note}
that -\/1 might be returned on null pointer, so when you directly allocate afterwards its best to check if you will pass a null pointer before.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & if there is no owner \\
\hline
{\em -\/1} & on N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{owner_8c_af6485fb8599714b6bbd830cf915ffea5}\label{owner_8c_af6485fb8599714b6bbd830cf915ffea5}} 
\index{owner.\+c@{owner.\+c}!key\+Owner@{key\+Owner}}
\index{key\+Owner@{key\+Owner}!owner.\+c@{owner.\+c}}
\subsubsection{\texorpdfstring{key\+Owner()}{keyOwner()}}
{\footnotesize\ttfamily const char$\ast$ key\+Owner (\begin{DoxyParamCaption}\item[{const Key $\ast$}]{key }\end{DoxyParamCaption})}



Return a pointer to the real internal {\ttfamily key} owner. 

This is a much more efficient version of \hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()} and you should use it if you are responsible enough to not mess up things. You are not allowed to modify the returned string in any way. If you need a copy of the string, consider to use \hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()} instead.

\hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner()} returns \char`\"{}\char`\"{} when there is no key\+Owner. The reason is 
\begin{DoxyCode}
key=\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}(0);
\hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{keySetOwner}(key,\textcolor{stringliteral}{""});
\hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{keyOwner}(key); \textcolor{comment}{// you would expect "" here}
\hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{keySetOwner}(key,\textcolor{stringliteral}{"system"});
\hyperlink{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{keyOwner}(key); \textcolor{comment}{// you would expect "" here}
\end{DoxyCode}


\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{owner_8c_af6485fb8599714b6bbd830cf915ffea5}{key\+Owner()} method to set a new value. Use \hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{key\+Set\+Owner()} instead.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to internal owner 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em \char`\"{}\char`\"{}} & when there is no (an empty) owner \\
\hline
{\em 0} & iff key is a N\+U\+LL pointer \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{owner_8c_a4a4561895741ba2ad10acf007c188593}{key\+Get\+Owner\+Size()} for the size of the string with concluding 0 

\hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()}, \hyperlink{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}{key\+Set\+Owner()} 

\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{key\+Name()} for name without owner 

\hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()} for name with owner 
\end{DoxySeeAlso}
\mbox{\Hypertarget{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}\label{owner_8c_a88d6ec200ba0707b7c1b4a88133d2be4}} 
\index{owner.\+c@{owner.\+c}!key\+Set\+Owner@{key\+Set\+Owner}}
\index{key\+Set\+Owner@{key\+Set\+Owner}!owner.\+c@{owner.\+c}}
\subsubsection{\texorpdfstring{key\+Set\+Owner()}{keySetOwner()}}
{\footnotesize\ttfamily ssize\+\_\+t key\+Set\+Owner (\begin{DoxyParamCaption}\item[{Key $\ast$}]{key,  }\item[{const char $\ast$}]{new\+Owner }\end{DoxyParamCaption})}



Set the owner of a key. 

an owner is a name of a system user related to a U\+ID. The owner decides on which location on the disc the key goes.

A private copy is stored, so the passed parameter can be freed after the call.


\begin{DoxyParams}{Parameters}
{\em key} & the key object to work with \\
\hline
{\em new\+Owner} & the string which describes the owner of the key \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes actually saved including final N\+U\+LL 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 1} & when owner is freed (by setting 0 or \char`\"{}\char`\"{}) \\
\hline
{\em -\/1} & on null pointer or memory problems \\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}, \hyperlink{owner_8c_a35922a017bee8b4bcb493bbdfad9d6f5}{key\+Get\+Owner()}, \hyperlink{group__keyname_gaaba1494a5ffc976e0e56c43f4334a23c}{key\+Get\+Full\+Name()} 
\end{DoxySeeAlso}
