<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Elektra Projekt: Key :: Methods for Making Tests</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> </ul> </div> </div> <div class="contents"> <h1>Key :: Methods for Making Tests</h1> <p>Methods to do various tests on Keys. <a href="#_details">More...</a></p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#ga3908b6511648a950f37cd0005bfea5d5">keyNeedStat</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gaf247df0de7aca04b32ef80e39ef12950">keyNeedSync</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gaae91159815480fbb3b3d9d7fa85e77b9">keyNeedRemove</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gafe49cfb61c2accb3073131c23a56fb14">keyIsSystem</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#ga373acc20c6209357045891f4b0c70041">keyIsUser</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#ga03332b5d97c76a4fd2640aca4762b8df">keyIsBelow</a> (const Key *key, const Key *check)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#ga4f175aafd98948ce6c774f3bd92b72ca">keyIsDirectBelow</a> (const Key *key, const Key *check)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gaa25f699f592031c1a0abc1504d14e13e">keyIsInactive</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gac0a10c602d52a35f81347e8a32312017">keyIsDir</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#ga9526b371087564e43e3dff8ad0dac949">keyIsBinary</a> (const Key *key)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__keytest.html#gaea7670778abd07fee0fe8ac12a149190">keyIsString</a> (const Key *key)</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Methods to do various tests on Keys. </p> <p>To use them: </p> <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <kdb.h></span> </pre></div> <hr/><h2>Function Documentation</h2> <a class="anchor" id="ga03332b5d97c76a4fd2640aca4762b8df"></a><!-- doxytag: member="keytest.c::keyIsBelow" ref="ga03332b5d97c76a4fd2640aca4762b8df" args="(const Key *key, const Key *check)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsBelow </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>check</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Check if the key check is below the key key or not.</p> <div class="fragment"><pre class="fragment">Example: key user/sw/app check user/sw/app/key returns <span class="keyword">true</span> because check is below key Example: key user/sw/app check user/sw/app/folder/key returns also <span class="keyword">true</span> because check is indirect below key </pre></div><dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> <tr><td valign="top"></td><td valign="top"><em>check</em> </td><td>the key to find the relative position of </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if check is below key </dd> <dd> 0 if it is not below or if it is the same key </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keyname.html#ga7699091610e7f3f43d2949514a4b35d9">keySetName()</a>, <a class="el" href="group__keyname.html#gab29a850168d9b31c9529e90cf9ab68be">keyGetName()</a>, <a class="el" href="group__keytest.html#ga4f175aafd98948ce6c774f3bd92b72ca">keyIsDirectBelow()</a> </dd></dl> </div> </div> <a class="anchor" id="ga9526b371087564e43e3dff8ad0dac949"></a><!-- doxytag: member="keytest.c::keyIsBinary" ref="ga9526b371087564e43e3dff8ad0dac949" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsBinary </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check if a key is binary type.</p> <p>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.</p> <p>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.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if it is binary </dd> <dd> 0 if it is not </dd> <dd> -1 on NULL pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keymeta.html#gab92003db4b938594df48807c16766bf7">keySetType()</a> for more information on types </dd> <dd> <a class="el" href="group__keyvalue.html#ga4c0d8a4a11174197699c231e0b5c3c84">keyGetBinary()</a>, <a class="el" href="group__keyvalue.html#gaa50a5358fd328d373a45f395fa1b99e7">keySetBinary()</a> </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key to check </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="gac0a10c602d52a35f81347e8a32312017"></a><!-- doxytag: member="keytest.c::keyIsDir" ref="gac0a10c602d52a35f81347e8a32312017" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsDir </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check if a key is directory key.</p> <p>Folder keys may also have value and comment. They are discern by having a executable bit set.</p> <p>If any executable bit is set it will be recognized as a directory.</p> <dl class="note"><dt><b>Note:</b></dt><dd>keyIsDir may return true even though you can't access the directory.</dd></dl> <p>To know if you can access the directory, you need to check, if your</p> <ul> <li>user ID is equal the key's user ID and the mode & 100 is true</li> <li>group ID is equal the key's group ID and the mode & 010 is true</li> <li>mode & 001 is true</li> </ul> <p>Accessing does not mean that you can get any value or comments below, see <a class="el" href="group__backend.html#mode">Mode</a> for more information.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if key is a directory, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keymeta.html#gaae575bd86a628a15ee45baa860522e75">keySetDir()</a>, <a class="el" href="group__keymeta.html#ga8803037e35b9da1ce492323a88ff6bc3">keySetMode()</a> </dd></dl> </div> </div> <a class="anchor" id="ga4f175aafd98948ce6c774f3bd92b72ca"></a><!-- doxytag: member="keytest.c::keyIsDirectBelow" ref="ga4f175aafd98948ce6c774f3bd92b72ca" args="(const Key *key, const Key *check)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsDirectBelow </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>check</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Check if the key check is direct below the key key or not.</p> <div class="fragment"><pre class="fragment">Example: key user/sw/app check user/sw/app/key returns <span class="keyword">true</span> because check is below key Example: key user/sw/app check user/sw/app/folder/key does not <span class="keywordflow">return</span> <span class="keyword">true</span>, because there is only a indirect relation </pre></div><dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> <tr><td valign="top"></td><td valign="top"><em>check</em> </td><td>the key to find the relative position of </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if check is below key </dd> <dd> 0 if it is not below or if it is the same key </dd> <dd> -1 on null pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keytest.html#ga03332b5d97c76a4fd2640aca4762b8df">keyIsBelow()</a>, <a class="el" href="group__keyname.html#ga7699091610e7f3f43d2949514a4b35d9">keySetName()</a>, <a class="el" href="group__keyname.html#gab29a850168d9b31c9529e90cf9ab68be">keyGetName()</a> </dd></dl> </div> </div> <a class="anchor" id="gaa25f699f592031c1a0abc1504d14e13e"></a><!-- doxytag: member="keytest.c::keyIsInactive" ref="gaa25f699f592031c1a0abc1504d14e13e" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsInactive </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check whether a key is inactive or not.</p> <p>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.</p> <p>To remove a whole hierarchy in elektra, don't forget to pass option_t::KDB_O_INACTIVE to <a class="el" href="group__kdb.html#ga37b44bda1b83bc0144916bf21a86c1b5">kdbGet()</a> to receive the inactive keys in order to remove them.</p> <p>Otherwise you should not fetch these keys.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if the key is inactive, 0 otherwise </dd> <dd> -1 on NULL pointer or when key has no name </dd></dl> </div> </div> <a class="anchor" id="gaea7670778abd07fee0fe8ac12a149190"></a><!-- doxytag: member="keytest.c::keyIsString" ref="gaea7670778abd07fee0fe8ac12a149190" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsString </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check if a key is string type.</p> <p>The function checks if the keytype is larger or equal KEY_TYPE_STRING. Then it will be considered as string type.</p> <p>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.</p> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if it is string </dd> <dd> 0 if it is not </dd> <dd> -1 on NULL pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keymeta.html#gab92003db4b938594df48807c16766bf7">keySetType</a> for more information on types </dd> <dd> <a class="el" href="group__keyvalue.html#ga41b9fac5ccddafe407fc0ae1e2eb8778">keyGetString()</a>, <a class="el" href="group__keyvalue.html#ga622bde1eb0e0c4994728331326340ef2">keySetString()</a> </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key to check </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="gafe49cfb61c2accb3073131c23a56fb14"></a><!-- doxytag: member="keytest.c::keyIsSystem" ref="gafe49cfb61c2accb3073131c23a56fb14" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsSystem </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check whether a key is under the <code>system</code> namespace or not</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if key name begins with <code>system</code>, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keytest.html#ga373acc20c6209357045891f4b0c70041">keyIsUser()</a>, <a class="el" href="group__keyname.html#ga7699091610e7f3f43d2949514a4b35d9">keySetName()</a>, <a class="el" href="group__keyname.html#ga8e805c726a60da921d3736cda7813513">keyName()</a> </dd></dl> </div> </div> <a class="anchor" id="ga373acc20c6209357045891f4b0c70041"></a><!-- doxytag: member="keytest.c::keyIsUser" ref="ga373acc20c6209357045891f4b0c70041" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyIsUser </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check whether a key is under the <code>user</code> namespace or not.</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if key name begins with <code>user</code>, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keytest.html#gafe49cfb61c2accb3073131c23a56fb14">keyIsSystem()</a>, <a class="el" href="group__keyname.html#ga7699091610e7f3f43d2949514a4b35d9">keySetName()</a>, <a class="el" href="group__keyname.html#ga8e805c726a60da921d3736cda7813513">keyName()</a> </dd></dl> </div> </div> <a class="anchor" id="gaae91159815480fbb3b3d9d7fa85e77b9"></a><!-- doxytag: member="keytest.c::keyNeedRemove" ref="gaae91159815480fbb3b3d9d7fa85e77b9" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyNeedRemove </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Ask if key is marked for permanent remove.</p> <p>Ask if the key will be removed instead of writing in the key database when doing <a class="el" href="group__kdbhighlevel.html#ga23b2f5fead4cddeb5542051a197ddc20">kdbSetKey()</a> or <a class="el" href="group__kdb.html#ga953cf29721e6000c2516cd6b5d36f571">kdbSet()</a>.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keymeta.html#ga6e14e5f1de26e1318100631a149f2984">keyRemove()</a> </dd> <dd> <a class="el" href="group__kdb.html#ga953cf29721e6000c2516cd6b5d36f571">kdbSet()</a>, <a class="el" href="group__kdbhighlevel.html#ga23b2f5fead4cddeb5542051a197ddc20">kdbSetKey()</a>, <a class="el" href="group__kdbhighlevel.html#gaf9adbbeb3f49c63fb2f89930445c8060">kdbRemove()</a> </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if it is marked, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> </div> </div> <a class="anchor" id="ga3908b6511648a950f37cd0005bfea5d5"></a><!-- doxytag: member="keytest.c::keyNeedStat" ref="ga3908b6511648a950f37cd0005bfea5d5" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyNeedStat </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Ask if key is marked for stat only.</p> <p>Ask if the key will be stat instead of get it from the key database completely doing <a class="el" href="group__kdbhighlevel.html#gaa62877888f0cad395898859395e6635f">kdbGetKey()</a> or <a class="el" href="group__kdb.html#ga37b44bda1b83bc0144916bf21a86c1b5">kdbGet()</a>. This is useful if you are not interested in the value, comment or key type.</p> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__keymeta.html#gab8189add5e562bdb148675ee595bd95b">keyStat()</a>, <a class="el" href="group__kdb.html#ga37b44bda1b83bc0144916bf21a86c1b5">kdbGet()</a> </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if it is marked, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> </div> </div> <a class="anchor" id="gaf247df0de7aca04b32ef80e39ef12950"></a><!-- doxytag: member="keytest.c::keyNeedSync" ref="gaf247df0de7aca04b32ef80e39ef12950" args="(const Key *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int keyNeedSync </td> <td>(</td> <td class="paramtype">const Key * </td> <td class="paramname"> <em>key</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Test if a key needs to be synced to backend storage.</p> <p>If any key modification took place the key will be flagged with KEY_FLAG_SYNC so that <a class="el" href="group__kdb.html#ga953cf29721e6000c2516cd6b5d36f571">kdbSet()</a> knows which keys were modified and which not.</p> <p>After <a class="el" href="group__key.html#gaf6893c038b3ebee90c73a9ea8356bebf">keyNew()</a> the flag will normally be set, but after <a class="el" href="group__kdb.html#ga37b44bda1b83bc0144916bf21a86c1b5">kdbGet()</a> and <a class="el" href="group__kdb.html#ga953cf29721e6000c2516cd6b5d36f571">kdbSet()</a> the flag will be removed. When you modify the key the flag will be set again.</p> <p>In your application you can make use of that flag to know if you changed something in a key after a <a class="el" href="group__kdb.html#ga37b44bda1b83bc0144916bf21a86c1b5">kdbGet()</a> or <a class="el" href="group__kdb.html#ga953cf29721e6000c2516cd6b5d36f571">kdbSet()</a>.</p> <dl class="note"><dt><b>Note:</b></dt><dd>Note that also changes in the meta data will set that flag.</dd></dl> <dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="group__key.html#gaf6893c038b3ebee90c73a9ea8356bebf">keyNew()</a> </dd></dl> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>the key object to work with </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>1 if <code>key</code> was changed in memory, 0 otherwise </dd> <dd> -1 on NULL pointer </dd></dl> </div> </div> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on 8 Nov 2009 for Elektra Projekt by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>