1 .TH "Key :: Methods for Making Tests" 3 "30 Jun 2009" "Elektra Projekt" \" -*- nroff -*-
5 Key :: Methods for Making Tests \- Methods to do various tests on Keys.
12 .RI "int \fBkeyNeedStat\fP (const Key *key)"
15 .RI "int \fBkeyNeedSync\fP (const Key *key)"
18 .RI "int \fBkeyNeedRemove\fP (const Key *key)"
21 .RI "int \fBkeyIsSystem\fP (const Key *key)"
24 .RI "int \fBkeyIsUser\fP (const Key *key)"
27 .RI "int \fBkeyIsBelow\fP (const Key *key, const Key *check)"
30 .RI "int \fBkeyIsDirectBelow\fP (const Key *key, const Key *check)"
33 .RI "int \fBkeyIsInactive\fP (const Key *key)"
36 .RI "int \fBkeyIsDir\fP (const Key *key)"
39 .RI "int \fBkeyIsBinary\fP (const Key *key)"
42 .RI "int \fBkeyIsString\fP (const Key *key)"
45 .SH "Detailed Description"
47 Methods to do various tests on Keys.
57 .SH "Function Documentation"
59 .SS "int keyIsBelow (const Key * key, const Key * check)"
61 Check if the key check is below the key key or not.
69 returns true because check is below key
73 check user/sw/app/folder/key
75 returns also true because check is indirect below key
81 \fIkey\fP the key object to work with
83 \fIcheck\fP the key to find the relative position of
88 1 if check is below key
90 0 if it is not below or if it is the same key
95 \fBkeySetName()\fP, \fBkeyGetName()\fP, \fBkeyIsDirectBelow()\fP
99 .SS "int keyIsBinary (const Key * key)"
101 Check if a key is binary type.
103 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.
105 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.
118 \fBkeySetType()\fP for more information on types
120 \fBkeyGetBinary()\fP, \fBkeySetBinary()\fP
125 \fIkey\fP the key to check
129 .SS "int keyIsDir (const Key * key)"
131 Check if a key is directory key.
133 Folder keys may also have value and comment. They are discern by having a executable bit set.
135 If any executable bit is set it will be recognized as a directory.
139 keyIsDir may return true even though you can't access the directory.
142 To know if you can access the directory, you need to check, if your
144 user ID is equal the key's user ID and the mode & 100 is true
146 group ID is equal the key's group ID and the mode & 010 is true
151 Accessing does not mean that you can get any value or comments below, see \fBMode\fP for more information.
155 \fIkey\fP the key object to work with
160 1 if key is a directory, 0 otherwise
167 \fBkeySetDir()\fP, \fBkeySetMode()\fP
171 .SS "int keyIsDirectBelow (const Key * key, const Key * check)"
173 Check if the key check is direct below the key key or not.
179 check user/sw/app/key
181 returns true because check is below key
185 check user/sw/app/folder/key
187 does not return true, because there is only a indirect relation
193 \fIkey\fP the key object to work with
195 \fIcheck\fP the key to find the relative position of
200 1 if check is below key
202 0 if it is not below or if it is the same key
209 \fBkeyIsBelow()\fP, \fBkeySetName()\fP, \fBkeyGetName()\fP
213 .SS "int keyIsInactive (const Key * key)"
215 Check whether a key is inactive or not.
217 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.
219 To remove a whole hierarchy in elektra, don't forget to pass option_t::KDB_O_INACTIVE to \fBkdbGet()\fP to receive the inactive keys in order to remove them.
221 Otherwise you should not fetch these keys.
225 \fIkey\fP the key object to work with
230 1 if the key is inactive, 0 otherwise
232 -1 on NULL pointer or when key has no name
236 .SS "int keyIsString (const Key * key)"
238 Check if a key is string type.
240 The function checks if the keytype is larger or equal KEY_TYPE_STRING. Then it will be considered as string type.
242 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.
255 \fBkeySetType\fP for more information on types
257 \fBkeyGetString()\fP, \fBkeySetString()\fP
262 \fIkey\fP the key to check
266 .SS "int keyIsSystem (const Key * key)"
268 Check whether a key is under the \fCsystem\fP namespace or not
272 \fIkey\fP the key object to work with
277 1 if key name begins with \fCsystem\fP, 0 otherwise
284 \fBkeyIsUser()\fP, \fBkeySetName()\fP, \fBkeyName()\fP
288 .SS "int keyIsUser (const Key * key)"
290 Check whether a key is under the \fCuser\fP namespace or not.
294 \fIkey\fP the key object to work with
299 1 if key name begins with \fCuser\fP, 0 otherwise
306 \fBkeyIsSystem()\fP, \fBkeySetName()\fP, \fBkeyName()\fP
310 .SS "int keyNeedRemove (const Key * key)"
312 Ask if key is marked for permanent remove.
314 Ask if the key will be removed instead of writing in the key database when doing \fBkdbSetKey()\fP or \fBkdbSet()\fP.
320 \fBkdbSet()\fP, \fBkdbSetKey()\fP, \fBkdbRemove()\fP
325 \fIkey\fP the key object to work with
330 1 if it is marked, 0 otherwise
336 .SS "int keyNeedStat (const Key * key)"
338 Ask if key is marked for stat only.
340 Ask if the key will be stat instead of get it from the key database completely doing \fBkdbGetKey()\fP or \fBkdbGet()\fP. This is useful if you are not interested in the value, comment or key type.
344 \fBkeyStat()\fP, \fBkdbGet()\fP
349 \fIkey\fP the key object to work with
354 1 if it is marked, 0 otherwise
360 .SS "int keyNeedSync (const Key * key)"
362 Test if a key needs to be synced to backend storage.
364 If any key modification took place the key will be flagged with KEY_FLAG_SYNC so that \fBkdbSet()\fP knows which keys were modified and which not.
366 After \fBkeyNew()\fP the flag will normally be set, but after \fBkdbGet()\fP and \fBkdbSet()\fP the flag will be removed. When you modify the key the flag will be set again.
368 In your application you can make use of that flag to know if you changed something in a key after a \fBkdbGet()\fP or \fBkdbSet()\fP.
372 Note that also changes in the meta data will set that flag.
382 \fIkey\fP the key object to work with
387 1 if \fCkey\fP was changed in memory, 0 otherwise