Annotation of embedaddon/confuse/doc/html/simple_8c-example.html, revision 1.1.1.2

1.1.1.2 ! misho       1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        !             2: <html xmlns="http://www.w3.org/1999/xhtml">
1.1       misho       3: <head>
1.1.1.2 ! misho       4: <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        !             5: <meta http-equiv="X-UA-Compatible" content="IE=9"/>
        !             6: <meta name="generator" content="Doxygen 1.8.17"/>
        !             7: <title>confuse: simple.c</title>
        !             8: <link href="tabs.css" rel="stylesheet" type="text/css"/>
        !             9: <script type="text/javascript" src="jquery.js"></script>
        !            10: <script type="text/javascript" src="dynsections.js"></script>
        !            11: <link href="search/search.css" rel="stylesheet" type="text/css"/>
        !            12: <script type="text/javascript" src="search/searchdata.js"></script>
        !            13: <script type="text/javascript" src="search/search.js"></script>
        !            14: <link href="doxygen.css" rel="stylesheet" type="text/css" />
1.1       misho      15: </head>
                     16: <body>
1.1.1.2 ! misho      17: <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
        !            18: <div id="titlearea">
        !            19: <table cellspacing="0" cellpadding="0">
        !            20:  <tbody>
        !            21:  <tr style="height: 56px;">
        !            22:   <td id="projectalign" style="padding-left: 0.5em;">
        !            23:    <div id="projectname">confuse
        !            24:    &#160;<span id="projectnumber">3.3</span>
        !            25:    </div>
        !            26:   </td>
        !            27:  </tr>
        !            28:  </tbody>
        !            29: </table>
        !            30: </div>
        !            31: <!-- end header part -->
        !            32: <!-- Generated by Doxygen 1.8.17 -->
        !            33: <script type="text/javascript">
        !            34: /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
        !            35: var searchBox = new SearchBox("searchBox", "search",false,'Search');
        !            36: /* @license-end */
        !            37: </script>
        !            38: <script type="text/javascript" src="menudata.js"></script>
        !            39: <script type="text/javascript" src="menu.js"></script>
        !            40: <script type="text/javascript">
        !            41: /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
        !            42: $(function() {
        !            43:   initMenu('',true,false,'search.php','Search');
        !            44:   $(document).ready(function() { init_search(); });
        !            45: });
        !            46: /* @license-end */</script>
        !            47: <div id="main-nav"></div>
        !            48: </div><!-- top -->
        !            49: <!-- window showing the filter options -->
        !            50: <div id="MSearchSelectWindow"
        !            51:      onmouseover="return searchBox.OnSearchSelectShow()"
        !            52:      onmouseout="return searchBox.OnSearchSelectHide()"
        !            53:      onkeydown="return searchBox.OnSearchSelectKey(event)">
1.1       misho      54: </div>
                     55: 
1.1.1.2 ! misho      56: <!-- iframe showing the search results (closed by default) -->
        !            57: <div id="MSearchResultsWindow">
        !            58: <iframe src="javascript:void(0)" frameborder="0" 
        !            59:         name="MSearchResults" id="MSearchResults">
        !            60: </iframe>
        !            61: </div>
1.1       misho      62: 
1.1.1.2 ! misho      63: <div class="header">
        !            64:   <div class="headertitle">
        !            65: <div class="title">simple.c</div>  </div>
        !            66: </div><!--header-->
        !            67: <div class="contents">
        !            68: <div class="fragment"><div class="line"><span class="preprocessor">#define _GNU_SOURCE</span></div>
        !            69: <div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div>
        !            70: <div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div>
        !            71: <div class="line"><span class="preprocessor">#include &lt;locale.h&gt;</span></div>
        !            72: <div class="line"><span class="preprocessor">#include &quot;<a class="code" href="confuse_8h.html">confuse.h</a>&quot;</span></div>
        !            73: <div class="line"> </div>
        !            74: <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div>
        !            75: <div class="line">{</div>
        !            76: <div class="line">    <span class="keyword">static</span> <a class="code" href="confuse_8h.html#a4bce4b6aed9b07489d6a5c70321907e4">cfg_bool_t</a> verbose = cfg_false;</div>
        !            77: <div class="line">    <span class="keyword">static</span> <span class="keywordtype">char</span> *server = NULL;</div>
        !            78: <div class="line">    <span class="keyword">static</span> <span class="keywordtype">double</span> delay = 1.356e-32;</div>
        !            79: <div class="line">    <span class="keyword">static</span> <span class="keywordtype">char</span> *username = NULL;</div>
        !            80: <div class="line"> </div>
        !            81: <div class="line">    <span class="comment">/* Although the macro used to specify an integer option is called</span></div>
        !            82: <div class="line"><span class="comment">     * CFG_SIMPLE_INT(), it actually expects a long int. On a 64 bit system</span></div>
        !            83: <div class="line"><span class="comment">     * where ints are 32 bit and longs 64 bit (such as the x86-64 or amd64</span></div>
        !            84: <div class="line"><span class="comment">     * architectures), you will get weird effects if you use an int here.</span></div>
        !            85: <div class="line"><span class="comment">     *</span></div>
        !            86: <div class="line"><span class="comment">     * If you use the regular (non-&quot;simple&quot;) options, ie CFG_INT() and use</span></div>
        !            87: <div class="line"><span class="comment">     * cfg_getint(), this is not a problem as the data types are implicitly</span></div>
        !            88: <div class="line"><span class="comment">     * cast.</span></div>
        !            89: <div class="line"><span class="comment">     */</span></div>
        !            90: <div class="line">    <span class="keyword">static</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> debug = 1;</div>
        !            91: <div class="line"> </div>
        !            92: <div class="line">    <a name="_a0"></a><a class="code" href="structcfg__opt__t.html">cfg_opt_t</a> opts[] = {</div>
        !            93: <div class="line">        <a name="a1"></a><a class="code" href="confuse_8h.html#a228dc9c22fbcbeabed4d171774662ce8">CFG_SIMPLE_BOOL</a>(<span class="stringliteral">&quot;verbose&quot;</span>, &amp;verbose),</div>
        !            94: <div class="line">        <a name="a2"></a><a class="code" href="confuse_8h.html#ae54fbbc31bd8c7ec8d7f04597a9f749d">CFG_SIMPLE_STR</a>(<span class="stringliteral">&quot;server&quot;</span>, &amp;server),</div>
        !            95: <div class="line">        <a class="code" href="confuse_8h.html#ae54fbbc31bd8c7ec8d7f04597a9f749d">CFG_SIMPLE_STR</a>(<span class="stringliteral">&quot;user&quot;</span>, &amp;username),</div>
        !            96: <div class="line">        <a name="a3"></a><a class="code" href="confuse_8h.html#a88fa2e73a1294c7e8a1f1519b68ce0ff">CFG_SIMPLE_INT</a>(<span class="stringliteral">&quot;debug&quot;</span>, &amp;debug),</div>
        !            97: <div class="line">        <a name="a4"></a><a class="code" href="confuse_8h.html#a073b3b12a5ba4648a1f4f1aa40ff3a2a">CFG_SIMPLE_FLOAT</a>(<span class="stringliteral">&quot;delay&quot;</span>, &amp;delay),</div>
        !            98: <div class="line">        <a name="a5"></a><a class="code" href="confuse_8h.html#a6b29dd8a4c6cd3d392d4ab6b2e535597">CFG_END</a>()</div>
        !            99: <div class="line">    };</div>
        !           100: <div class="line">    <a name="_a6"></a><a class="code" href="structcfg__t.html">cfg_t</a> *cfg;</div>
        !           101: <div class="line"> </div>
        !           102: <div class="line">    <span class="comment">/* Localize messages &amp; types according to environment, since v2.9 */</span></div>
        !           103: <div class="line"><span class="preprocessor">#ifdef LC_MESSAGES</span></div>
        !           104: <div class="line">    setlocale(LC_MESSAGES, <span class="stringliteral">&quot;&quot;</span>);</div>
        !           105: <div class="line">    setlocale(LC_CTYPE, <span class="stringliteral">&quot;&quot;</span>);</div>
        !           106: <div class="line"><span class="preprocessor">#endif</span></div>
        !           107: <div class="line"> </div>
        !           108: <div class="line">    <span class="comment">/* set default value for the server option */</span></div>
        !           109: <div class="line">    server = strdup(<span class="stringliteral">&quot;gazonk&quot;</span>);</div>
        !           110: <div class="line"> </div>
        !           111: <div class="line">    cfg = <a name="a7"></a><a class="code" href="confuse_8h.html#aec07794916564c8ab437e030ac618aa8">cfg_init</a>(opts, 0);</div>
        !           112: <div class="line">    <a name="a8"></a><a class="code" href="confuse_8h.html#a0fca327466956c5580199e24397d49fe">cfg_parse</a>(cfg, <span class="stringliteral">&quot;simple.conf&quot;</span>);</div>
        !           113: <div class="line"> </div>
        !           114: <div class="line">    printf(<span class="stringliteral">&quot;verbose: %s\n&quot;</span>, verbose ? <span class="stringliteral">&quot;true&quot;</span> : <span class="stringliteral">&quot;false&quot;</span>);</div>
        !           115: <div class="line">    printf(<span class="stringliteral">&quot;server: %s\n&quot;</span>, server);</div>
        !           116: <div class="line">    printf(<span class="stringliteral">&quot;username: %s\n&quot;</span>, username);</div>
        !           117: <div class="line">    printf(<span class="stringliteral">&quot;debug: %ld\n&quot;</span>, debug);</div>
        !           118: <div class="line">    printf(<span class="stringliteral">&quot;delay: %G\n&quot;</span>, delay);</div>
        !           119: <div class="line"> </div>
        !           120: <div class="line">    printf(<span class="stringliteral">&quot;setting username to &#39;foo&#39;\n&quot;</span>);</div>
        !           121: <div class="line">    <span class="comment">/* using cfg_setstr here is not necessary at all, the equivalent</span></div>
        !           122: <div class="line"><span class="comment">     * code is:</span></div>
        !           123: <div class="line"><span class="comment">     *   free(username);</span></div>
        !           124: <div class="line"><span class="comment">     *   username = strdup(&quot;foo&quot;);</span></div>
        !           125: <div class="line"><span class="comment">     */</span></div>
        !           126: <div class="line">    <a name="a9"></a><a class="code" href="confuse_8h.html#a523a5eec449362eee5a0d2709645c35b">cfg_setstr</a>(cfg, <span class="stringliteral">&quot;user&quot;</span>, <span class="stringliteral">&quot;foo&quot;</span>);</div>
        !           127: <div class="line">    printf(<span class="stringliteral">&quot;username: %s\n&quot;</span>, username);</div>
        !           128: <div class="line"> </div>
        !           129: <div class="line">    <span class="comment">/* print the parsed values to another file */</span></div>
        !           130: <div class="line">    {</div>
        !           131: <div class="line">        FILE *fp = fopen(<span class="stringliteral">&quot;simple.conf.out&quot;</span>, <span class="stringliteral">&quot;w&quot;</span>);</div>
        !           132: <div class="line"> </div>
        !           133: <div class="line">        <a name="a10"></a><a class="code" href="confuse_8h.html#ac3343e32da22758f76ec50627316c708">cfg_print</a>(cfg, fp);</div>
        !           134: <div class="line">        fclose(fp);</div>
        !           135: <div class="line">    }</div>
        !           136: <div class="line"> </div>
        !           137: <div class="line">    <a name="a11"></a><a class="code" href="confuse_8h.html#aae5e08626bf53514a6ebf250580feba3">cfg_free</a>(cfg);</div>
        !           138: <div class="line"> </div>
        !           139: <div class="line">    <span class="comment">/* You are responsible for freeing string values. */</span></div>
        !           140: <div class="line">    free(server);</div>
        !           141: <div class="line">    free(username);</div>
        !           142: <div class="line"> </div>
        !           143: <div class="line">    <span class="keywordflow">return</span> 0;</div>
        !           144: <div class="line">}</div>
        !           145: </div><!-- fragment --> </div><!-- contents -->
        !           146: <div class="ttc" id="aconfuse_8h_html_aec07794916564c8ab437e030ac618aa8"><div class="ttname"><a href="confuse_8h.html#aec07794916564c8ab437e030ac618aa8">cfg_init</a></div><div class="ttdeci">DLLIMPORT cfg_t *__export cfg_init(cfg_opt_t *opts, cfg_flag_t flags)</div><div class="ttdoc">Create and initialize a cfg_t structure.</div><div class="ttdef"><b>Definition:</b> confuse.c:1816</div></div>
        !           147: <div class="ttc" id="aconfuse_8h_html_a228dc9c22fbcbeabed4d171774662ce8"><div class="ttname"><a href="confuse_8h.html#a228dc9c22fbcbeabed4d171774662ce8">CFG_SIMPLE_BOOL</a></div><div class="ttdeci">#define CFG_SIMPLE_BOOL(name, svalue)</div><div class="ttdoc">Initialize a &quot;simple&quot; boolean option (see documentation for CFG_SIMPLE_STR for more information).</div><div class="ttdef"><b>Definition:</b> confuse.h:511</div></div>
        !           148: <div class="ttc" id="aconfuse_8h_html_a073b3b12a5ba4648a1f4f1aa40ff3a2a"><div class="ttname"><a href="confuse_8h.html#a073b3b12a5ba4648a1f4f1aa40ff3a2a">CFG_SIMPLE_FLOAT</a></div><div class="ttdeci">#define CFG_SIMPLE_FLOAT(name, svalue)</div><div class="ttdoc">Initialize a &quot;simple&quot; floating point option (see documentation for CFG_SIMPLE_STR for more informatio...</div><div class="ttdef"><b>Definition:</b> confuse.h:478</div></div>
        !           149: <div class="ttc" id="aconfuse_8h_html_a523a5eec449362eee5a0d2709645c35b"><div class="ttname"><a href="confuse_8h.html#a523a5eec449362eee5a0d2709645c35b">cfg_setstr</a></div><div class="ttdeci">DLLIMPORT int __export cfg_setstr(cfg_t *cfg, const char *name, const char *value)</div><div class="ttdoc">Set the value of a string option given its name.</div><div class="ttdef"><b>Definition:</b> confuse.c:2211</div></div>
        !           150: <div class="ttc" id="aconfuse_8h_html_a6b29dd8a4c6cd3d392d4ab6b2e535597"><div class="ttname"><a href="confuse_8h.html#a6b29dd8a4c6cd3d392d4ab6b2e535597">CFG_END</a></div><div class="ttdeci">#define CFG_END()</div><div class="ttdoc">Terminate list of options.</div><div class="ttdef"><b>Definition:</b> confuse.h:574</div></div>
        !           151: <div class="ttc" id="aconfuse_8h_html"><div class="ttname"><a href="confuse_8h.html">confuse.h</a></div><div class="ttdoc">A configuration file parser library.</div></div>
        !           152: <div class="ttc" id="aconfuse_8h_html_ae54fbbc31bd8c7ec8d7f04597a9f749d"><div class="ttname"><a href="confuse_8h.html#ae54fbbc31bd8c7ec8d7f04597a9f749d">CFG_SIMPLE_STR</a></div><div class="ttdeci">#define CFG_SIMPLE_STR(name, svalue)</div><div class="ttdoc">Initialize a &quot;simple&quot; string option.</div><div class="ttdef"><b>Definition:</b> confuse.h:410</div></div>
        !           153: <div class="ttc" id="aconfuse_8h_html_ac3343e32da22758f76ec50627316c708"><div class="ttname"><a href="confuse_8h.html#ac3343e32da22758f76ec50627316c708">cfg_print</a></div><div class="ttdeci">DLLIMPORT int __export cfg_print(cfg_t *cfg, FILE *fp)</div><div class="ttdoc">Print the options and values to a file.</div><div class="ttdef"><b>Definition:</b> confuse.c:2548</div></div>
        !           154: <div class="ttc" id="aconfuse_8h_html_a0fca327466956c5580199e24397d49fe"><div class="ttname"><a href="confuse_8h.html#a0fca327466956c5580199e24397d49fe">cfg_parse</a></div><div class="ttdeci">DLLIMPORT int __export cfg_parse(cfg_t *cfg, const char *filename)</div><div class="ttdoc">Parse a configuration file.</div><div class="ttdef"><b>Definition:</b> confuse.c:1746</div></div>
        !           155: <div class="ttc" id="astructcfg__opt__t_html"><div class="ttname"><a href="structcfg__opt__t.html">cfg_opt_t</a></div><div class="ttdoc">Data structure holding information about an option.</div><div class="ttdef"><b>Definition:</b> confuse.h:309</div></div>
        !           156: <div class="ttc" id="astructcfg__t_html"><div class="ttname"><a href="structcfg__t.html">cfg_t</a></div><div class="ttdoc">Data structure holding information about a &quot;section&quot;.</div><div class="ttdef"><b>Definition:</b> confuse.h:252</div></div>
        !           157: <div class="ttc" id="aconfuse_8h_html_aae5e08626bf53514a6ebf250580feba3"><div class="ttname"><a href="confuse_8h.html#aae5e08626bf53514a6ebf250580feba3">cfg_free</a></div><div class="ttdeci">DLLIMPORT int __export cfg_free(cfg_t *cfg)</div><div class="ttdoc">Free a cfg_t context.</div><div class="ttdef"><b>Definition:</b> confuse.c:1962</div></div>
        !           158: <div class="ttc" id="aconfuse_8h_html_a88fa2e73a1294c7e8a1f1519b68ce0ff"><div class="ttname"><a href="confuse_8h.html#a88fa2e73a1294c7e8a1f1519b68ce0ff">CFG_SIMPLE_INT</a></div><div class="ttdeci">#define CFG_SIMPLE_INT(name, svalue)</div><div class="ttdoc">Initialize a &quot;simple&quot; integer option (see documentation for CFG_SIMPLE_STR for more information).</div><div class="ttdef"><b>Definition:</b> confuse.h:445</div></div>
        !           159: <div class="ttc" id="aconfuse_8h_html_a4bce4b6aed9b07489d6a5c70321907e4"><div class="ttname"><a href="confuse_8h.html#a4bce4b6aed9b07489d6a5c70321907e4">cfg_bool_t</a></div><div class="ttdeci">cfg_bool_t</div><div class="ttdoc">Boolean values.</div><div class="ttdef"><b>Definition:</b> confuse.h:232</div></div>
        !           160: <!-- start footer part -->
        !           161: <hr class="footer"/><address class="footer"><small>
        !           162: Generated by &#160;<a href="http://www.doxygen.org/index.html">
        !           163: <img class="footer" src="doxygen.png" alt="doxygen"/>
        !           164: </a> 1.8.17
        !           165: </small></address>
        !           166: </body>
1.1       misho     167: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>