<!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/html;charset=UTF-8"/> <title>util-vserver (libvserver): Helper functions</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.0 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> </div> <div class="contents"> <h1>Helper functions</h1><table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Data Structures</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">struct </td><td class="memItemRight" valign="bottom"><a class="el" href="structvc__err__listparser.html">vc_err_listparser</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Information about parsing errors. <a href="structvc__err__listparser.html#_details">More...</a><br/></td></tr> <tr><td colspan="2"><h2>Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga149e0447f068d7db45a8b2dba571e1e1"></a><!-- doxytag: member="helper::vc_get_nb_ipv4root" ref="ga149e0447f068d7db45a8b2dba571e1e1" args="() VC_ATTR_CONST VC_ATTR_PURE" --> size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__helper.html#ga149e0447f068d7db45a8b2dba571e1e1">vc_get_nb_ipv4root</a> () VC_ATTR_CONST VC_ATTR_PURE</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the value of NB_IPV4ROOT.This function returns the value of NB_IPV4ROOT which was used when the library was built, but <b>not</b> the value which is used by the currently running kernel. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__helper.html#ga5f6ba0153739c8f698d9139863b68822">vc_parseLimit</a> (char const *str, <a class="el" href="vserver_8h.html#a66d303232685b6d8714633059cfabc75">vc_limit_t</a> *res) VC_ATTR_NONNULL((1</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Parses a string describing a limitThis function parses <em>str</em> and interprets special words like <code>"inf"</code> or suffixes. Valid suffixes are</p> <ul> <li><code>k</code> ... 1000</li> <li><code>m</code> ... 1000000</li> <li><code>K</code> ... 1024</li> <li><code>M</code> ... 1048576. </li> </ul> <a href="#ga5f6ba0153739c8f698d9139863b68822"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">uint_least64_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__helper.html#ga183222921dcd4c7bfd1ec196d563cc47">vc_text2bcap</a> (char const *str, size_t len)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Converts a single string into bcapability. <a href="#ga183222921dcd4c7bfd1ec196d563cc47"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">char const * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__helper.html#ga8fd4a2af15945412f740d245c7625eb3">vc_lobcap2text</a> (uint_least64_t *val) VC_ATTR_NONNULL((1))</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Converts the lowest bit of a bcapability or the entire value (when possible) to a textual representation. <a href="#ga8fd4a2af15945412f740d245c7625eb3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__helper.html#ga5332c1edcfa6781f731a55e4f75678ae">vc_list2bcap</a> (char const *str, size_t len, struct <a class="el" href="structvc__err__listparser.html">vc_err_listparser</a> *err, struct <a class="el" href="structvc__ctx__caps.html">vc_ctx_caps</a> *cap) VC_ATTR_NONNULL((1</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Converts a string into a bcapability-bitmaskSyntax of <em>str:</em>. <a href="#ga5332c1edcfa6781f731a55e4f75678ae"></a><br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Functions which are doing general helper tasks like parameter parsing. </p> <hr/><h2>Function Documentation</h2> <a class="anchor" id="ga5332c1edcfa6781f731a55e4f75678ae"></a><!-- doxytag: member="vserver.h::vc_list2bcap" ref="ga5332c1edcfa6781f731a55e4f75678ae" args="(char const *str, size_t len, struct vc_err_listparser *err, struct vc_ctx_caps *cap) VC_ATTR_NONNULL((1" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int vc_list2bcap </td> <td>(</td> <td class="paramtype">char const * </td> <td class="paramname"> <em>str</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"> <em>len</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structvc__err__listparser.html">vc_err_listparser</a> * </td> <td class="paramname"> <em>err</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">struct <a class="el" href="structvc__ctx__caps.html">vc_ctx_caps</a> * </td> <td class="paramname"> <em>cap</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Converts a string into a bcapability-bitmaskSyntax of <em>str:</em>. </p> <div class="fragment"><pre class="fragment">LIST <- ELEM | ELEM ',' LIST ELEM <- '~' ELEM | MASK | NAME MASK <- NUMBER | '^' NUMBER NUMBER <- 0[0-7]* | [1-9][0-9]* | 0x[0-9,a-f]+ NAME <- <literal name> | "all" | "any" | "none" </pre></div><p>When the <code>`~'</code> prefix is used, the bits will be unset and a `~' after another `~' will cancel both ones. The <code>`^'</code> prefix specifies a bitnumber instead of a bitmask.</p> <p>"literal name" is everything which will be accepted by the <a class="el" href="group__helper.html#ga183222921dcd4c7bfd1ec196d563cc47" title="Converts a single string into bcapability.">vc_text2bcap()</a> function. The special values for <code>NAME</code> will be recognized case insensitively</p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>str</em> </td><td>The string to be parsed </td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>The length of the string, or <code>0</code> for automatic detection </td></tr> <tr><td valign="top"></td><td valign="top"><em>err</em> </td><td>Pointer to a structure for error-information, or <code>NULL</code>. </td></tr> <tr><td valign="top"></td><td valign="top"><em>cap</em> </td><td>Pointer to a <a class="el" href="structvc__ctx__caps.html" title="Capabilities of process-contexts.">vc_ctx_caps</a> structure holding the results; only the <em>bcaps</em> and <em>bmask</em> fields will be changed and already set values will not be honored. When an error occured, <em>cap</em> will have the value of all processed valid <code>BCAP</code> parts.</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, -1 on error. In error case, <em>err</em> will hold position and length of the first not understood BCAP part </dd></dl> <dl class="pre"><dt><b>Precondition:</b></dt><dd><em>str</em> != 0 && <em>cap</em> != 0; <em>cap->bcaps</em> and <em>cap->bmask</em> must be initialized </dd></dl> </div> </div> <a class="anchor" id="ga8fd4a2af15945412f740d245c7625eb3"></a><!-- doxytag: member="vserver.h::vc_lobcap2text" ref="ga8fd4a2af15945412f740d245c7625eb3" args="(uint_least64_t *val) VC_ATTR_NONNULL((1))" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char const* vc_lobcap2text </td> <td>(</td> <td class="paramtype">uint_least64_t * </td> <td class="paramname"> <em>val</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Converts the lowest bit of a bcapability or the entire value (when possible) to a textual representation. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>val</em> </td><td>The string to be converted; on success, the detected bit(s) will be unset, in errorcase only the lowest set bit</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>A textual representation of <em>val</em> resp. of its lowest set bit; or <code>NULL</code> in errorcase. </dd></dl> <dl class="pre"><dt><b>Precondition:</b></dt><dd><em>val!=0</em> </dd></dl> <dl class="post"><dt><b>Postcondition:</b></dt><dd><em>*val<sub>old</sub></em> <code>!=</code> 0 <code><--></code> <em>*val<sub>old</sub></em> > <em>*val<sub>new</sub></em> </dd> <dd> <em>*val<sub>old</sub></em> <code>==</code> 0 <code>---></code> <em>result</em> == 0 </dd></dl> </div> </div> <a class="anchor" id="ga5f6ba0153739c8f698d9139863b68822"></a><!-- doxytag: member="vserver.h::vc_parseLimit" ref="ga5f6ba0153739c8f698d9139863b68822" args="(char const *str, vc_limit_t *res) VC_ATTR_NONNULL((1" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool vc_parseLimit </td> <td>(</td> <td class="paramtype">char const * </td> <td class="paramname"> <em>str</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="vserver_8h.html#a66d303232685b6d8714633059cfabc75">vc_limit_t</a> * </td> <td class="paramname"> <em>res</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Parses a string describing a limitThis function parses <em>str</em> and interprets special words like <code>"inf"</code> or suffixes. Valid suffixes are</p> <ul> <li><code>k</code> ... 1000</li> <li><code>m</code> ... 1000000</li> <li><code>K</code> ... 1024</li> <li><code>M</code> ... 1048576. </li> </ul> </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>str</em> </td><td>The string which shall be parsed </td></tr> <tr><td valign="top"></td><td valign="top"><em>res</em> </td><td>Will be filled with the interpreted value; in errorcase, this value is undefined.</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd><em>true</em>, iff the string <em>str</em> could be parsed. <em>res</em> will be filled with the interpreted value in this case.</dd></dl> <dl class="pre"><dt><b>Precondition:</b></dt><dd><em>str!=0</em> && <em>res!=0</em> </dd></dl> </div> </div> <a class="anchor" id="ga183222921dcd4c7bfd1ec196d563cc47"></a><!-- doxytag: member="vserver.h::vc_text2bcap" ref="ga183222921dcd4c7bfd1ec196d563cc47" args="(char const *str, size_t len)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">uint_least64_t vc_text2bcap </td> <td>(</td> <td class="paramtype">char const * </td> <td class="paramname"> <em>str</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"> <em>len</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Converts a single string into bcapability. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>str</em> </td><td>The string to be parsed; both "CAP_xxx" and "xxx" will be accepted </td></tr> <tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>The length of the string, or <code>0</code> for automatic detection</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on error; a bitmask on success </dd></dl> <dl class="pre"><dt><b>Precondition:</b></dt><dd><em>str</em> != 0 </dd></dl> </div> </div> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Aug 23 09:52:10 2009 for util-vserver (libvserver) by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.0 </small></address> </body> </html>