\hypertarget{internal_8c}{}\section{internal.\+c File Reference}
\label{internal_8c}\index{internal.c@{internal.c}}


Internal methods for Elektra.  


{\ttfamily \#include \char`\"{}kdbinternal.\+h\char`\"{}}\newline
{\ttfamily \#include $<$kdbassert.\+h$>$}\newline
Include dependency graph for internal.\+c\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{internal_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
ssize\+\_\+t \mbox{\hyperlink{internal_8c_a6360a1271f6410f25fbb9b95e346da1a}{elektra\+Memcpy}} (Key $\ast$$\ast$array1, Key $\ast$$\ast$array2, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Internal Methods for Elektra. \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{internal_8c_abc60bdbe5d252a99734b0122687560be}{elektra\+Memmove}} (Key $\ast$$\ast$array1, Key $\ast$$\ast$array2, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Copies the key array2 into where array1 points. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_a2a0aa7edaa79853ac26703f270e8f3a1}{elektra\+Str\+Cmp}} (const char $\ast$s1, const char $\ast$s2)
\begin{DoxyCompactList}\small\item\em Compare Strings. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_ad443a7b664ade6b5ee6688570e95843a}{elektra\+Str\+N\+Cmp}} (const char $\ast$s1, const char $\ast$s2, size\+\_\+t n)
\begin{DoxyCompactList}\small\item\em Compare Strings up to a maximum length. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_a686ccc3bc298a5b38c2bac0192551acd}{elektra\+Str\+Case\+Cmp}} (const char $\ast$s1, const char $\ast$s2)
\begin{DoxyCompactList}\small\item\em Compare Strings ignoring case. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_ae23e483a23e6801078db43e7c533f64c}{elektra\+Str\+N\+Case\+Cmp}} (const char $\ast$s1, const char $\ast$s2, size\+\_\+t n)
\begin{DoxyCompactList}\small\item\em Compare Strings ignoring case up to a maximum length. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_aa39061cc72a17effc6b6777a899ae09d}{elektra\+Mem\+Case\+Cmp}} (const char $\ast$s1, const char $\ast$s2, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Compare two memory regions but make cmp chars uppercase before comparison. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_ab0432d6765c40a5408a204c43747f4d4}{elektra\+Realloc}} (void $\ast$$\ast$buffer, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Reallocate Storage in a save way. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektra\+Malloc}} (size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Allocate memory for Elektra. \end{DoxyCompactList}\item 
void $\ast$ \mbox{\hyperlink{internal_8c_a848ed030434c76176167fac6ab79429c}{elektra\+Calloc}} (size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Allocate memory for Elektra. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}{elektra\+Free}} (void $\ast$ptr)
\begin{DoxyCompactList}\small\item\em Free memory of Elektra or its backends. \end{DoxyCompactList}\item 
char $\ast$ \mbox{\hyperlink{internal_8c_abe50f54adaf932e177a100fe4fddad26}{elektra\+Str\+Dup}} (const char $\ast$s)
\begin{DoxyCompactList}\small\item\em Copy string into new allocated memory. \end{DoxyCompactList}\item 
char $\ast$ \mbox{\hyperlink{internal_8c_a04ad42d215b2ce5ed83e1a9354f6ba94}{elektra\+Str\+N\+Dup}} (const char $\ast$s, size\+\_\+t l)
\begin{DoxyCompactList}\small\item\em Copy buffer into new allocated memory. \end{DoxyCompactList}\item 
size\+\_\+t \mbox{\hyperlink{internal_8c_afd676487565d083a6ad5a1381095acd8}{elektra\+Str\+Len}} (const char $\ast$s)
\begin{DoxyCompactList}\small\item\em Calculates the length in bytes of a string. \end{DoxyCompactList}\item 
char $\ast$ \mbox{\hyperlink{internal_8c_a1a64d23660e0724a517dad25409f69e0}{elektra\+Format}} (const char $\ast$format,...)
\begin{DoxyCompactList}\small\item\em Does string formatting in fresh allocated memory. \end{DoxyCompactList}\item 
char $\ast$ \mbox{\hyperlink{internal_8c_abf1d4e3e507c0422bf4cc29a9fe92679}{elektra\+V\+Format}} (const char $\ast$format, va\+\_\+list arg\+\_\+list)
\begin{DoxyCompactList}\small\item\em Does string formatting in fresh allocated memory. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{internal_8c_a7126bbb84c75bb98c1e3641dcdf32c6b}{elektra\+Validate\+Key\+Name}} (const char $\ast$name, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Validates whether the supplied keyname is valid. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Internal methods for Elektra. 

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


\subsection{Function Documentation}
\mbox{\Hypertarget{internal_8c_a848ed030434c76176167fac6ab79429c}\label{internal_8c_a848ed030434c76176167fac6ab79429c}} 
\index{internal.c@{internal.c}!elektraCalloc@{elektraCalloc}}
\index{elektraCalloc@{elektraCalloc}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraCalloc()}{elektraCalloc()}}
{\footnotesize\ttfamily void$\ast$ elektra\+Calloc (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Allocate memory for Elektra. 

Memory will be set to 0.


\begin{DoxyParams}{Parameters}
{\em size} & the requested size \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektra\+Malloc}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{internal_8c_a1a64d23660e0724a517dad25409f69e0}\label{internal_8c_a1a64d23660e0724a517dad25409f69e0}} 
\index{internal.c@{internal.c}!elektraFormat@{elektraFormat}}
\index{elektraFormat@{elektraFormat}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraFormat()}{elektraFormat()}}
{\footnotesize\ttfamily char$\ast$ elektra\+Format (\begin{DoxyParamCaption}\item[{const char $\ast$}]{format,  }\item[{}]{... }\end{DoxyParamCaption})}



Does string formatting in fresh allocated memory. 


\begin{DoxyParams}{Parameters}
{\em format} & as in printf() \\
\hline
{\em ...} & as in printf()\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
new allocated memory (free with elektra\+Free) 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}\label{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}} 
\index{internal.c@{internal.c}!elektraFree@{elektraFree}}
\index{elektraFree@{elektraFree}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraFree()}{elektraFree()}}
{\footnotesize\ttfamily void elektra\+Free (\begin{DoxyParamCaption}\item[{void $\ast$}]{ptr }\end{DoxyParamCaption})}



Free memory of Elektra or its backends. 


\begin{DoxyParams}{Parameters}
{\em ptr} & the pointer to free\\
\hline
\end{DoxyParams}
If ptr is N\+U\+LL, no operation is performed.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektra\+Malloc}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}\label{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}} 
\index{internal.c@{internal.c}!elektraMalloc@{elektraMalloc}}
\index{elektraMalloc@{elektraMalloc}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraMalloc()}{elektraMalloc()}}
{\footnotesize\ttfamily void$\ast$ elektra\+Malloc (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Allocate memory for Elektra. 


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if} ((buffer = \mbox{\hyperlink{internal_8c_a35cdc2e5caed3454cb73b4fc7f37858c}{elektraMalloc}} (length)) == 0) \{}
\DoxyCodeLine{        \textcolor{comment}{// here comes the failure handler}}
\DoxyCodeLine{        \textcolor{comment}{// no allocation happened here, so don't use buffer}}
\DoxyCodeLine{\textcolor{preprocessor}{\#if DEBUG}}
\DoxyCodeLine{        fprintf (stderr, \textcolor{stringliteral}{"Allocation error"});}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{        \textcolor{comment}{// return with error}}
\DoxyCodeLine{\}}
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em size} & the requested size\\
\hline
\end{DoxyParams}
This function is compatible to A\+N\+S\+I-\/C malloc \begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}{elektra\+Free}} 

\mbox{\hyperlink{internal_8c_a848ed030434c76176167fac6ab79429c}{elektra\+Calloc}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{internal_8c_aa39061cc72a17effc6b6777a899ae09d}\label{internal_8c_aa39061cc72a17effc6b6777a899ae09d}} 
\index{internal.c@{internal.c}!elektraMemCaseCmp@{elektraMemCaseCmp}}
\index{elektraMemCaseCmp@{elektraMemCaseCmp}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraMemCaseCmp()}{elektraMemCaseCmp()}}
{\footnotesize\ttfamily int elektra\+Mem\+Case\+Cmp (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s1,  }\item[{const char $\ast$}]{s2,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Compare two memory regions but make cmp chars uppercase before comparison. 


\begin{DoxyParams}{Parameters}
{\em s1} & The first string to be compared \\
\hline
{\em s2} & The second string to be compared \\
\hline
{\em size} & to be compared\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a negative number if s1 is less than s2 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if s1 matches s2 \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
a positive number if s1 is greater than s2 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_a6360a1271f6410f25fbb9b95e346da1a}\label{internal_8c_a6360a1271f6410f25fbb9b95e346da1a}} 
\index{internal.c@{internal.c}!elektraMemcpy@{elektraMemcpy}}
\index{elektraMemcpy@{elektraMemcpy}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraMemcpy()}{elektraMemcpy()}}
{\footnotesize\ttfamily ssize\+\_\+t elektra\+Memcpy (\begin{DoxyParamCaption}\item[{Key $\ast$$\ast$}]{array1,  }\item[{Key $\ast$$\ast$}]{array2,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Internal Methods for Elektra. 

To use them\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{kdbinternal_8h}{kdbinternal.h}}>}}
\end{DoxyCode}


There are some areas where libraries have to reimplement some basic functions to archive support for non-\/standard systems, for testing purposes or to provide a little more convenience.\+Copies the key array2 into where array1 points. It copies size elements.

Overlapping is prohibited, use \mbox{\hyperlink{internal_8c_abc60bdbe5d252a99734b0122687560be}{elektra\+Memmove()}} instead.


\begin{DoxyParams}{Parameters}
{\em array1} & the destination \\
\hline
{\em array2} & the source \\
\hline
{\em size} & how many pointer to Keys to copy \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on null pointers \\
\hline
{\em 0} & if nothing was done \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
size how many keys were copied 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_abc60bdbe5d252a99734b0122687560be}\label{internal_8c_abc60bdbe5d252a99734b0122687560be}} 
\index{internal.c@{internal.c}!elektraMemmove@{elektraMemmove}}
\index{elektraMemmove@{elektraMemmove}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraMemmove()}{elektraMemmove()}}
{\footnotesize\ttfamily ssize\+\_\+t elektra\+Memmove (\begin{DoxyParamCaption}\item[{Key $\ast$$\ast$}]{array1,  }\item[{Key $\ast$$\ast$}]{array2,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Copies the key array2 into where array1 points. 

It copies size elements.

Overlapping is ok. If they do not overlap consider \mbox{\hyperlink{internal_8c_a6360a1271f6410f25fbb9b95e346da1a}{elektra\+Memcpy()}} instead.


\begin{DoxyParams}{Parameters}
{\em array1} & the destination \\
\hline
{\em array2} & the source \\
\hline
{\em size} & how many pointer to Keys to copy \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on null pointers \\
\hline
{\em 0} & if nothing was done \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
size how many keys were copied 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_ab0432d6765c40a5408a204c43747f4d4}\label{internal_8c_ab0432d6765c40a5408a204c43747f4d4}} 
\index{internal.c@{internal.c}!elektraRealloc@{elektraRealloc}}
\index{elektraRealloc@{elektraRealloc}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraRealloc()}{elektraRealloc()}}
{\footnotesize\ttfamily int elektra\+Realloc (\begin{DoxyParamCaption}\item[{void $\ast$$\ast$}]{buffer,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Reallocate Storage in a save way. 


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if} (\mbox{\hyperlink{internal_8c_ab0432d6765c40a5408a204c43747f4d4}{elektraRealloc}} ((\textcolor{keywordtype}{void} **) \& buffer, new\_length) < 0) \{}
\DoxyCodeLine{        \textcolor{comment}{// here comes the failure handler}}
\DoxyCodeLine{        \textcolor{comment}{// you can still use the old buffer}}
\DoxyCodeLine{\textcolor{preprocessor}{\#if DEBUG}}
\DoxyCodeLine{        fprintf (stderr, \textcolor{stringliteral}{"Reallocation error\(\backslash\)n"});}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{        \mbox{\hyperlink{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}{elektraFree}} (buffer);}
\DoxyCodeLine{        buffer = 0;}
\DoxyCodeLine{        \textcolor{comment}{// return with error}}
\DoxyCodeLine{\}}
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em buffer} & is a pointer to a elektra\+Malloc \\
\hline
{\em size} & is the new size for the memory \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em -\/1} & on failure \\
\hline
{\em 0} & on success \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{internal_8c_a686ccc3bc298a5b38c2bac0192551acd}\label{internal_8c_a686ccc3bc298a5b38c2bac0192551acd}} 
\index{internal.c@{internal.c}!elektraStrCaseCmp@{elektraStrCaseCmp}}
\index{elektraStrCaseCmp@{elektraStrCaseCmp}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrCaseCmp()}{elektraStrCaseCmp()}}
{\footnotesize\ttfamily int elektra\+Str\+Case\+Cmp (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s1,  }\item[{const char $\ast$}]{s2 }\end{DoxyParamCaption})}



Compare Strings ignoring case. 


\begin{DoxyParams}{Parameters}
{\em s1} & The first string to be compared \\
\hline
{\em s2} & The second string to be compared\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a negative number if s1 is less than s2 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if s1 matches s2 \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
a positive number if s1 is greater than s2 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_a2a0aa7edaa79853ac26703f270e8f3a1}\label{internal_8c_a2a0aa7edaa79853ac26703f270e8f3a1}} 
\index{internal.c@{internal.c}!elektraStrCmp@{elektraStrCmp}}
\index{elektraStrCmp@{elektraStrCmp}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrCmp()}{elektraStrCmp()}}
{\footnotesize\ttfamily int elektra\+Str\+Cmp (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s1,  }\item[{const char $\ast$}]{s2 }\end{DoxyParamCaption})}



Compare Strings. 


\begin{DoxyParams}{Parameters}
{\em s1} & The first string to be compared \\
\hline
{\em s2} & The second string to be compared\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a negative number if s1 is less than s2 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if s1 matches s2 \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
a positive number if s1 is greater than s2 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_abe50f54adaf932e177a100fe4fddad26}\label{internal_8c_abe50f54adaf932e177a100fe4fddad26}} 
\index{internal.c@{internal.c}!elektraStrDup@{elektraStrDup}}
\index{elektraStrDup@{elektraStrDup}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrDup()}{elektraStrDup()}}
{\footnotesize\ttfamily char$\ast$ elektra\+Str\+Dup (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s }\end{DoxyParamCaption})}



Copy string into new allocated memory. 

You need to free the memory yourself.

\begin{DoxyNote}{Note}
that size is determined at runtime. So if you have a size information, don\textquotesingle{}t use that function.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em s} & the null-\/terminated string to duplicate\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if out of memory, a pointer otherwise 
\end{DoxyReturn}
\begin{DoxyPrecond}{Precondition}
s must be a c-\/string. 
\end{DoxyPrecond}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{internal_8c_a7f572149d2e0bfe18023a6ac969f195c}{elektra\+Free}} 

\mbox{\hyperlink{internal_8c_afd676487565d083a6ad5a1381095acd8}{elektra\+Str\+Len}} 

\mbox{\hyperlink{internal_8c_a04ad42d215b2ce5ed83e1a9354f6ba94}{elektra\+Str\+N\+Dup}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{internal_8c_afd676487565d083a6ad5a1381095acd8}\label{internal_8c_afd676487565d083a6ad5a1381095acd8}} 
\index{internal.c@{internal.c}!elektraStrLen@{elektraStrLen}}
\index{elektraStrLen@{elektraStrLen}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrLen()}{elektraStrLen()}}
{\footnotesize\ttfamily size\+\_\+t elektra\+Str\+Len (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s }\end{DoxyParamCaption})}



Calculates the length in bytes of a string. 

This function differs from strlen() because it is Unicode and multibyte chars safe. While strlen() counts characters and ignores the final N\+U\+LL, \mbox{\hyperlink{internal_8c_afd676487565d083a6ad5a1381095acd8}{elektra\+Str\+Len()}} count bytes including the ending N\+U\+LL.

It must not be used to search for / in the name, because it does not consider escaping. Instead use the unescaped name.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyname_ga6fe6af4c27b35d911a533f4ae4d698bb}{key\+Unescaped\+Name()}}
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em s} & the string to get the length from \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes used by the string, including the final N\+U\+LL. 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_ae23e483a23e6801078db43e7c533f64c}\label{internal_8c_ae23e483a23e6801078db43e7c533f64c}} 
\index{internal.c@{internal.c}!elektraStrNCaseCmp@{elektraStrNCaseCmp}}
\index{elektraStrNCaseCmp@{elektraStrNCaseCmp}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrNCaseCmp()}{elektraStrNCaseCmp()}}
{\footnotesize\ttfamily int elektra\+Str\+N\+Case\+Cmp (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s1,  }\item[{const char $\ast$}]{s2,  }\item[{size\+\_\+t}]{n }\end{DoxyParamCaption})}



Compare Strings ignoring case up to a maximum length. 


\begin{DoxyParams}{Parameters}
{\em s1} & The first string to be compared \\
\hline
{\em s2} & The second string to be compared \\
\hline
{\em n} & The maximum length to be compared\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a negative number if s1 is less than s2 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if s1 matches s2 \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
a positive number if s1 is greater than s2 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_ad443a7b664ade6b5ee6688570e95843a}\label{internal_8c_ad443a7b664ade6b5ee6688570e95843a}} 
\index{internal.c@{internal.c}!elektraStrNCmp@{elektraStrNCmp}}
\index{elektraStrNCmp@{elektraStrNCmp}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrNCmp()}{elektraStrNCmp()}}
{\footnotesize\ttfamily int elektra\+Str\+N\+Cmp (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s1,  }\item[{const char $\ast$}]{s2,  }\item[{size\+\_\+t}]{n }\end{DoxyParamCaption})}



Compare Strings up to a maximum length. 


\begin{DoxyParams}{Parameters}
{\em s1} & The first string to be compared \\
\hline
{\em s2} & The second string to be compared \\
\hline
{\em n} & The maximum length to be compared\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a negative number if s1 is less than s2 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & if s1 matches s2 \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
a positive number if s1 is greater than s2 
\end{DoxyReturn}
\mbox{\Hypertarget{internal_8c_a04ad42d215b2ce5ed83e1a9354f6ba94}\label{internal_8c_a04ad42d215b2ce5ed83e1a9354f6ba94}} 
\index{internal.c@{internal.c}!elektraStrNDup@{elektraStrNDup}}
\index{elektraStrNDup@{elektraStrNDup}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraStrNDup()}{elektraStrNDup()}}
{\footnotesize\ttfamily char$\ast$ elektra\+Str\+N\+Dup (\begin{DoxyParamCaption}\item[{const char $\ast$}]{s,  }\item[{size\+\_\+t}]{l }\end{DoxyParamCaption})}



Copy buffer into new allocated memory. 

You need to free the memory yourself.

This function also works with \textbackslash{}0 characters in the buffer. The length is taken as given, it must be correct.

\begin{DoxyReturn}{Returns}
0 if out of memory, a pointer otherwise 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em s} & must be an allocated buffer \\
\hline
{\em l} & the length of s \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{internal_8c_a7126bbb84c75bb98c1e3641dcdf32c6b}\label{internal_8c_a7126bbb84c75bb98c1e3641dcdf32c6b}} 
\index{internal.c@{internal.c}!elektraValidateKeyName@{elektraValidateKeyName}}
\index{elektraValidateKeyName@{elektraValidateKeyName}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraValidateKeyName()}{elektraValidateKeyName()}}
{\footnotesize\ttfamily int elektra\+Validate\+Key\+Name (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



Validates whether the supplied keyname is valid. 

The function looks for tangling escape characters in the end and for a minimum length.

Does not check for valid namespaces

\begin{DoxyPrecond}{Precondition}
size must be at least 2
\end{DoxyPrecond}

\begin{DoxyParams}{Parameters}
{\em name} & the key name that is to be checked \\
\hline
{\em size} & a elektra\+Str\+Len of the key name \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em true} & if the supplied keyname part is valid \\
\hline
{\em false} & if its invalid \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{internal_8c_abf1d4e3e507c0422bf4cc29a9fe92679}\label{internal_8c_abf1d4e3e507c0422bf4cc29a9fe92679}} 
\index{internal.c@{internal.c}!elektraVFormat@{elektraVFormat}}
\index{elektraVFormat@{elektraVFormat}!internal.c@{internal.c}}
\subsubsection{\texorpdfstring{elektraVFormat()}{elektraVFormat()}}
{\footnotesize\ttfamily char$\ast$ elektra\+V\+Format (\begin{DoxyParamCaption}\item[{const char $\ast$}]{format,  }\item[{va\+\_\+list}]{arg\+\_\+list }\end{DoxyParamCaption})}



Does string formatting in fresh allocated memory. 


\begin{DoxyParams}{Parameters}
{\em format} & as in vprintf() \\
\hline
{\em arg\+\_\+list} & as in vprintf()\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
new allocated memory (free with elektra\+Free) 
\end{DoxyReturn}
