1 \section{Key :: Methods for Making Tests}
2 \label{group__keytest}\index{Key :: Methods for Making Tests@{Key :: Methods for Making Tests}}
3 Methods to do various tests on Keys.
4 \subsection*{Functions}
7 int {\bf keyNeedStat} (const Key $\ast$key)
9 int {\bf keyNeedSync} (const Key $\ast$key)
11 int {\bf keyNeedRemove} (const Key $\ast$key)
13 int {\bf keyIsSystem} (const Key $\ast$key)
15 int {\bf keyIsUser} (const Key $\ast$key)
17 int {\bf keyIsBelow} (const Key $\ast$key, const Key $\ast$check)
19 int {\bf keyIsDirectBelow} (const Key $\ast$key, const Key $\ast$check)
21 int {\bf keyIsInactive} (const Key $\ast$key)
23 int {\bf keyIsDir} (const Key $\ast$key)
25 int {\bf keyIsBinary} (const Key $\ast$key)
27 int {\bf keyIsString} (const Key $\ast$key)
31 \subsection{Detailed Description}
32 Methods to do various tests on Keys.
36 \begin{Code}\begin{verbatim}#include <kdb.h>
42 \subsection{Function Documentation}
43 \index{keytest@{keytest}!keyIsBelow@{keyIsBelow}}
44 \index{keyIsBelow@{keyIsBelow}!keytest@{keytest}}
45 \subsubsection[keyIsBelow]{\setlength{\rightskip}{0pt plus 5cm}int keyIsBelow (const Key $\ast$ {\em key}, \/ const Key $\ast$ {\em check})}\label{group__keytest_g03332b5d97c76a4fd2640aca4762b8df}
48 Check if the key check is below the key key or not.
52 \begin{Code}\begin{verbatim}Example:
56 returns true because check is below key
60 check user/sw/app/folder/key
62 returns also true because check is indirect below key
71 \item[{\em key}]the key object to work with \item[{\em check}]the key to find the relative position of \end{description}
74 \item[Returns:]1 if check is below key
76 0 if it is not below or if it is the same key \end{Desc}
78 \item[See also:]\doxyref{keySetName()}{p.}{group__keyname_g7699091610e7f3f43d2949514a4b35d9}, \doxyref{keyGetName()}{p.}{group__keyname_gb29a850168d9b31c9529e90cf9ab68be}, \doxyref{keyIsDirectBelow()}{p.}{group__keytest_g4f175aafd98948ce6c774f3bd92b72ca} \end{Desc}
79 \index{keytest@{keytest}!keyIsBinary@{keyIsBinary}}
80 \index{keyIsBinary@{keyIsBinary}!keytest@{keytest}}
81 \subsubsection[keyIsBinary]{\setlength{\rightskip}{0pt plus 5cm}int keyIsBinary (const Key $\ast$ {\em key})}\label{group__keytest_g9526b371087564e43e3dff8ad0dac949}
84 Check if a key is binary type.
86 The function checks if the keytype is in the range between KEY\_\-TYPE\_\-BINARY and less than excluding KEY\_\-TYPE\_\-STRING. Then it will be interpreted as binary.
88 Make sure to use this function and don't test the binary type another way to ensure compatibility and to write less error prone programs.
91 \item[Returns:]1 if it is binary
95 -1 on NULL pointer \end{Desc}
97 \item[See also:]\doxyref{keySetType()}{p.}{group__keymeta_gb92003db4b938594df48807c16766bf7} for more information on types
99 \doxyref{keyGetBinary()}{p.}{group__keyvalue_g4c0d8a4a11174197699c231e0b5c3c84}, \doxyref{keySetBinary()}{p.}{group__keyvalue_ga50a5358fd328d373a45f395fa1b99e7} \end{Desc}
103 \item[{\em key}]the key to check \end{description}
105 \index{keytest@{keytest}!keyIsDir@{keyIsDir}}
106 \index{keyIsDir@{keyIsDir}!keytest@{keytest}}
107 \subsubsection[keyIsDir]{\setlength{\rightskip}{0pt plus 5cm}int keyIsDir (const Key $\ast$ {\em key})}\label{group__keytest_gc0a10c602d52a35f81347e8a32312017}
110 Check if a key is directory key.
112 Folder keys may also have value and comment. They are discern by having a executable bit set.
114 If any executable bit is set it will be recognized as a directory.
117 \item[Note:]keyIsDir may return true even though you can't access the directory.\end{Desc}
118 To know if you can access the directory, you need to check, if your\begin{itemize}
119 \item user ID is equal the key's user ID and the mode \& 100 is true\item group ID is equal the key's group ID and the mode \& 010 is true\item mode \& 001 is true\end{itemize}
122 Accessing does not mean that you can get any value or comments below, see \doxyref{Mode}{p.}{group__backend_mode} for more information.
127 \item[{\em key}]the key object to work with \end{description}
130 \item[Returns:]1 if key is a directory, 0 otherwise
132 -1 on NULL pointer \end{Desc}
134 \item[See also:]\doxyref{keySetDir()}{p.}{group__keymeta_gae575bd86a628a15ee45baa860522e75}, \doxyref{keySetMode()}{p.}{group__keymeta_g8803037e35b9da1ce492323a88ff6bc3} \end{Desc}
135 \index{keytest@{keytest}!keyIsDirectBelow@{keyIsDirectBelow}}
136 \index{keyIsDirectBelow@{keyIsDirectBelow}!keytest@{keytest}}
137 \subsubsection[keyIsDirectBelow]{\setlength{\rightskip}{0pt plus 5cm}int keyIsDirectBelow (const Key $\ast$ {\em key}, \/ const Key $\ast$ {\em check})}\label{group__keytest_g4f175aafd98948ce6c774f3bd92b72ca}
140 Check if the key check is direct below the key key or not.
144 \begin{Code}\begin{verbatim}Example:
146 check user/sw/app/key
148 returns true because check is below key
152 check user/sw/app/folder/key
154 does not return true, because there is only a indirect relation
163 \item[{\em key}]the key object to work with \item[{\em check}]the key to find the relative position of \end{description}
166 \item[Returns:]1 if check is below key
168 0 if it is not below or if it is the same key
170 -1 on null pointer \end{Desc}
172 \item[See also:]\doxyref{keyIsBelow()}{p.}{group__keytest_g03332b5d97c76a4fd2640aca4762b8df}, \doxyref{keySetName()}{p.}{group__keyname_g7699091610e7f3f43d2949514a4b35d9}, \doxyref{keyGetName()}{p.}{group__keyname_gb29a850168d9b31c9529e90cf9ab68be} \end{Desc}
173 \index{keytest@{keytest}!keyIsInactive@{keyIsInactive}}
174 \index{keyIsInactive@{keyIsInactive}!keytest@{keytest}}
175 \subsubsection[keyIsInactive]{\setlength{\rightskip}{0pt plus 5cm}int keyIsInactive (const Key $\ast$ {\em key})}\label{group__keytest_ga25f699f592031c1a0abc1504d14e13e}
178 Check whether a key is inactive or not.
180 In elektra terminology any key is inactive if the it's basename starts with '.'. Inactive keys must not have any meaning to applications, they are reserved for users and administrators.
182 To remove a whole hierarchy in elektra, don't forget to pass option\_\-t::KDB\_\-O\_\-INACTIVE to \doxyref{kdbGet()}{p.}{group__kdb_g37b44bda1b83bc0144916bf21a86c1b5} to receive the inactive keys in order to remove them.
184 Otherwise you should not fetch these keys.
189 \item[{\em key}]the key object to work with \end{description}
192 \item[Returns:]1 if the key is inactive, 0 otherwise
194 -1 on NULL pointer or when key has no name \end{Desc}
195 \index{keytest@{keytest}!keyIsString@{keyIsString}}
196 \index{keyIsString@{keyIsString}!keytest@{keytest}}
197 \subsubsection[keyIsString]{\setlength{\rightskip}{0pt plus 5cm}int keyIsString (const Key $\ast$ {\em key})}\label{group__keytest_gea7670778abd07fee0fe8ac12a149190}
200 Check if a key is string type.
202 The function checks if the keytype is larger or equal KEY\_\-TYPE\_\-STRING. Then it will be considered as string type.
204 Make sure to use this function and don't test the string type another way to ensure compatibility and to write less error prone programs.
207 \item[Returns:]1 if it is string
211 -1 on NULL pointer \end{Desc}
213 \item[See also:]\doxyref{keySetType}{p.}{group__keymeta_gb92003db4b938594df48807c16766bf7} for more information on types
215 \doxyref{keyGetString()}{p.}{group__keyvalue_g41b9fac5ccddafe407fc0ae1e2eb8778}, \doxyref{keySetString()}{p.}{group__keyvalue_g622bde1eb0e0c4994728331326340ef2} \end{Desc}
219 \item[{\em key}]the key to check \end{description}
221 \index{keytest@{keytest}!keyIsSystem@{keyIsSystem}}
222 \index{keyIsSystem@{keyIsSystem}!keytest@{keytest}}
223 \subsubsection[keyIsSystem]{\setlength{\rightskip}{0pt plus 5cm}int keyIsSystem (const Key $\ast$ {\em key})}\label{group__keytest_gfe49cfb61c2accb3073131c23a56fb14}
226 Check whether a key is under the {\tt system} namespace or not
231 \item[{\em key}]the key object to work with \end{description}
234 \item[Returns:]1 if key name begins with {\tt system}, 0 otherwise
236 -1 on NULL pointer \end{Desc}
238 \item[See also:]\doxyref{keyIsUser()}{p.}{group__keytest_g373acc20c6209357045891f4b0c70041}, \doxyref{keySetName()}{p.}{group__keyname_g7699091610e7f3f43d2949514a4b35d9}, \doxyref{keyName()}{p.}{group__keyname_g8e805c726a60da921d3736cda7813513} \end{Desc}
239 \index{keytest@{keytest}!keyIsUser@{keyIsUser}}
240 \index{keyIsUser@{keyIsUser}!keytest@{keytest}}
241 \subsubsection[keyIsUser]{\setlength{\rightskip}{0pt plus 5cm}int keyIsUser (const Key $\ast$ {\em key})}\label{group__keytest_g373acc20c6209357045891f4b0c70041}
244 Check whether a key is under the {\tt user} namespace or not.
249 \item[{\em key}]the key object to work with \end{description}
252 \item[Returns:]1 if key name begins with {\tt user}, 0 otherwise
254 -1 on NULL pointer \end{Desc}
256 \item[See also:]\doxyref{keyIsSystem()}{p.}{group__keytest_gfe49cfb61c2accb3073131c23a56fb14}, \doxyref{keySetName()}{p.}{group__keyname_g7699091610e7f3f43d2949514a4b35d9}, \doxyref{keyName()}{p.}{group__keyname_g8e805c726a60da921d3736cda7813513} \end{Desc}
257 \index{keytest@{keytest}!keyNeedRemove@{keyNeedRemove}}
258 \index{keyNeedRemove@{keyNeedRemove}!keytest@{keytest}}
259 \subsubsection[keyNeedRemove]{\setlength{\rightskip}{0pt plus 5cm}int keyNeedRemove (const Key $\ast$ {\em key})}\label{group__keytest_gae91159815480fbb3b3d9d7fa85e77b9}
262 Ask if key is marked for permanent remove.
264 Ask if the key will be removed instead of writing in the key database when doing \doxyref{kdbSetKey()}{p.}{group__kdbhighlevel_g23b2f5fead4cddeb5542051a197ddc20} or \doxyref{kdbSet()}{p.}{group__kdb_g953cf29721e6000c2516cd6b5d36f571}.
267 \item[See also:]\doxyref{keyRemove()}{p.}{group__keymeta_g6e14e5f1de26e1318100631a149f2984}
269 \doxyref{kdbSet()}{p.}{group__kdb_g953cf29721e6000c2516cd6b5d36f571}, \doxyref{kdbSetKey()}{p.}{group__kdbhighlevel_g23b2f5fead4cddeb5542051a197ddc20}, \doxyref{kdbRemove()}{p.}{group__kdbhighlevel_gf9adbbeb3f49c63fb2f89930445c8060} \end{Desc}
273 \item[{\em key}]the key object to work with \end{description}
276 \item[Returns:]1 if it is marked, 0 otherwise
278 -1 on NULL pointer \end{Desc}
279 \index{keytest@{keytest}!keyNeedStat@{keyNeedStat}}
280 \index{keyNeedStat@{keyNeedStat}!keytest@{keytest}}
281 \subsubsection[keyNeedStat]{\setlength{\rightskip}{0pt plus 5cm}int keyNeedStat (const Key $\ast$ {\em key})}\label{group__keytest_g3908b6511648a950f37cd0005bfea5d5}
284 Ask if key is marked for stat only.
286 Ask if the key will be stat instead of get it from the key database completely doing \doxyref{kdbGetKey()}{p.}{group__kdbhighlevel_ga62877888f0cad395898859395e6635f} or \doxyref{kdbGet()}{p.}{group__kdb_g37b44bda1b83bc0144916bf21a86c1b5}. This is useful if you are not interested in the value, comment or key type.
289 \item[See also:]\doxyref{keyStat()}{p.}{group__keymeta_gb8189add5e562bdb148675ee595bd95b}, \doxyref{kdbGet()}{p.}{group__kdb_g37b44bda1b83bc0144916bf21a86c1b5} \end{Desc}
293 \item[{\em key}]the key object to work with \end{description}
296 \item[Returns:]1 if it is marked, 0 otherwise
298 -1 on NULL pointer \end{Desc}
299 \index{keytest@{keytest}!keyNeedSync@{keyNeedSync}}
300 \index{keyNeedSync@{keyNeedSync}!keytest@{keytest}}
301 \subsubsection[keyNeedSync]{\setlength{\rightskip}{0pt plus 5cm}int keyNeedSync (const Key $\ast$ {\em key})}\label{group__keytest_gf247df0de7aca04b32ef80e39ef12950}
304 Test if a key needs to be synced to backend storage.
306 If any key modification took place the key will be flagged with KEY\_\-FLAG\_\-SYNC so that \doxyref{kdbSet()}{p.}{group__kdb_g953cf29721e6000c2516cd6b5d36f571} knows which keys were modified and which not.
308 After \doxyref{keyNew()}{p.}{group__key_gf6893c038b3ebee90c73a9ea8356bebf} the flag will normally be set, but after \doxyref{kdbGet()}{p.}{group__kdb_g37b44bda1b83bc0144916bf21a86c1b5} and \doxyref{kdbSet()}{p.}{group__kdb_g953cf29721e6000c2516cd6b5d36f571} the flag will be removed. When you modify the key the flag will be set again.
310 In your application you can make use of that flag to know if you changed something in a key after a \doxyref{kdbGet()}{p.}{group__kdb_g37b44bda1b83bc0144916bf21a86c1b5} or \doxyref{kdbSet()}{p.}{group__kdb_g953cf29721e6000c2516cd6b5d36f571}.
313 \item[Note:]Note that also changes in the meta data will set that flag.\end{Desc}
315 \item[See also:]\doxyref{keyNew()}{p.}{group__key_gf6893c038b3ebee90c73a9ea8356bebf} \end{Desc}
319 \item[{\em key}]the key object to work with \end{description}
322 \item[Returns:]1 if {\tt key} was changed in memory, 0 otherwise
324 -1 on NULL pointer \end{Desc}