.TH "Key :: Methods for Making Tests" 3 "Fri Aug 26 2011" "Elektra Projekt" \" -*- nroff -*- .ad l .nh .SH NAME Key :: Methods for Making Tests \- .PP Methods to do various tests on Keys. .SS "Functions" .in +1c .ti -1c .RI "int \fBkeyNeedStat\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyNeedSync\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyNeedRemove\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsSystem\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsUser\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsBelow\fP (const Key *key, const Key *check)" .br .ti -1c .RI "int \fBkeyIsDirectBelow\fP (const Key *key, const Key *check)" .br .ti -1c .RI "int \fBkeyIsInactive\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsDir\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsBinary\fP (const Key *key)" .br .ti -1c .RI "int \fBkeyIsString\fP (const Key *key)" .br .in -1c .SH "Detailed Description" .PP Methods to do various tests on Keys. To use them: .PP .nf #include .fi .PP .SH "Function Documentation" .PP .SS "int keyIsBelow (const Key *key, const Key *check)"Check if the key check is below the key key or not. .PP .PP .nf Example: key user/sw/app check user/sw/app/key returns true because check is below key Example: key user/sw/app check user/sw/app/folder/key returns also true because check is indirect below key .fi .PP .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .br \fIcheck\fP the key to find the relative position of .RE .PP \fBReturns:\fP .RS 4 1 if check is below key .PP 0 if it is not below or if it is the same key .RE .PP \fBSee also:\fP .RS 4 \fBkeySetName()\fP, \fBkeyGetName()\fP, \fBkeyIsDirectBelow()\fP .RE .PP .SS "int keyIsBinary (const Key *key)"Check if a key is binary type. .PP 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. .PP 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. .PP \fBReturns:\fP .RS 4 1 if it is binary .PP 0 if it is not .PP -1 on NULL pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeySetType()\fP for more information on types .PP \fBkeyGetBinary()\fP, \fBkeySetBinary()\fP .RE .PP \fBParameters:\fP .RS 4 \fIkey\fP the key to check .RE .PP .SS "int keyIsDir (const Key *key)"Check if a key is directory key. .PP Folder keys may also have value and comment. They are discern by having a executable bit set. .PP If any executable bit is set it will be recognized as a directory. .PP \fBNote:\fP .RS 4 keyIsDir may return true even though you can't access the directory. .RE .PP To know if you can access the directory, you need to check, if your .IP "\(bu" 2 user ID is equal the key's user ID and the mode & 100 is true .IP "\(bu" 2 group ID is equal the key's group ID and the mode & 010 is true .IP "\(bu" 2 mode & 001 is true .PP .PP Accessing does not mean that you can get any value or comments below, see \fBMode\fP for more information. .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if key is a directory, 0 otherwise .PP -1 on NULL pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeySetDir()\fP, \fBkeySetMode()\fP .RE .PP .SS "int keyIsDirectBelow (const Key *key, const Key *check)"Check if the key check is direct below the key key or not. .PP .PP .nf Example: key user/sw/app check user/sw/app/key returns true because check is below key Example: key user/sw/app check user/sw/app/folder/key does not return true, because there is only a indirect relation .fi .PP .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .br \fIcheck\fP the key to find the relative position of .RE .PP \fBReturns:\fP .RS 4 1 if check is below key .PP 0 if it is not below or if it is the same key .PP -1 on null pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeyIsBelow()\fP, \fBkeySetName()\fP, \fBkeyGetName()\fP .RE .PP .SS "int keyIsInactive (const Key *key)"Check whether a key is inactive or not. .PP 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. .PP 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. .PP Otherwise you should not fetch these keys. .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if the key is inactive, 0 otherwise .PP -1 on NULL pointer or when key has no name .RE .PP .SS "int keyIsString (const Key *key)"Check if a key is string type. .PP The function checks if the keytype is larger or equal KEY_TYPE_STRING. Then it will be considered as string type. .PP 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. .PP \fBReturns:\fP .RS 4 1 if it is string .PP 0 if it is not .PP -1 on NULL pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeySetType\fP for more information on types .PP \fBkeyGetString()\fP, \fBkeySetString()\fP .RE .PP \fBParameters:\fP .RS 4 \fIkey\fP the key to check .RE .PP .SS "int keyIsSystem (const Key *key)"Check whether a key is under the \fCsystem\fP namespace or not .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if key name begins with \fCsystem\fP, 0 otherwise .PP -1 on NULL pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeyIsUser()\fP, \fBkeySetName()\fP, \fBkeyName()\fP .RE .PP .SS "int keyIsUser (const Key *key)"Check whether a key is under the \fCuser\fP namespace or not. .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if key name begins with \fCuser\fP, 0 otherwise .PP -1 on NULL pointer .RE .PP \fBSee also:\fP .RS 4 \fBkeyIsSystem()\fP, \fBkeySetName()\fP, \fBkeyName()\fP .RE .PP .SS "int keyNeedRemove (const Key *key)"Ask if key is marked for permanent remove. .PP Ask if the key will be removed instead of writing in the key database when doing \fBkdbSetKey()\fP or \fBkdbSet()\fP. .PP \fBSee also:\fP .RS 4 \fBkeyRemove()\fP .PP \fBkdbSet()\fP, \fBkdbSetKey()\fP, \fBkdbRemove()\fP .RE .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if it is marked, 0 otherwise .PP -1 on NULL pointer .RE .PP .SS "int keyNeedStat (const Key *key)"Ask if key is marked for stat only. .PP 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. .PP \fBSee also:\fP .RS 4 \fBkeyStat()\fP, \fBkdbGet()\fP .RE .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if it is marked, 0 otherwise .PP -1 on NULL pointer .RE .PP .SS "int keyNeedSync (const Key *key)"Test if a key needs to be synced to backend storage. .PP 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. .PP 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. .PP 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. .PP \fBNote:\fP .RS 4 Note that also changes in the meta data will set that flag. .RE .PP \fBSee also:\fP .RS 4 \fBkeyNew()\fP .RE .PP \fBParameters:\fP .RS 4 \fIkey\fP the key object to work with .RE .PP \fBReturns:\fP .RS 4 1 if \fCkey\fP was changed in memory, 0 otherwise .PP -1 on NULL pointer .RE .PP .SH "Author" .PP Generated automatically by Doxygen for Elektra Projekt from the source code.