Annotation of embedaddon/confuse/doc/html/reread_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: reread.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">reread.c</div>  </div>
        !            66: </div><!--header-->
        !            67: <div class="contents">
        !            68: <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;err.h&gt;</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;signal.h&gt;</span></div>
        !            71: <div class="line"><span class="preprocessor">#include &lt;unistd.h&gt;</span></div>
        !            72: <div class="line"><span class="preprocessor">#include &lt;locale.h&gt;</span></div>
        !            73: <div class="line"><span class="preprocessor">#include &quot;<a class="code" href="confuse_8h.html">confuse.h</a>&quot;</span></div>
        !            74: <div class="line"> </div>
        !            75: <div class="line"><a name="_a0"></a><a class="code" href="structcfg__t.html">cfg_t</a> *cfg = 0;</div>
        !            76: <div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> *config_filename = <span class="stringliteral">&quot;./reread.conf&quot;</span>;</div>
        !            77: <div class="line"> </div>
        !            78: <div class="line"><span class="keywordtype">void</span> read_config(<span class="keywordtype">void</span>)</div>
        !            79: <div class="line">{</div>
        !            80: <div class="line">    <span class="keyword">static</span> <a name="_a1"></a><a class="code" href="structcfg__opt__t.html">cfg_opt_t</a> arg_opts[] = {</div>
        !            81: <div class="line">        <a name="a2"></a><a class="code" href="confuse_8h.html#a963e2ee16396dcf36f6d1937faa00f0c">CFG_STR</a>(<span class="stringliteral">&quot;value&quot;</span>, <span class="stringliteral">&quot;default&quot;</span>, <a name="a3"></a><a class="code" href="confuse_8h.html#a65df72d236bcc3e7f22c5b2b5c24bded">CFGF_NONE</a>),</div>
        !            82: <div class="line">        <a name="a4"></a><a class="code" href="confuse_8h.html#a6b29dd8a4c6cd3d392d4ab6b2e535597">CFG_END</a>()</div>
        !            83: <div class="line">    };</div>
        !            84: <div class="line">    <a class="code" href="structcfg__opt__t.html">cfg_opt_t</a> opts[] = {</div>
        !            85: <div class="line">        <a name="a5"></a><a class="code" href="confuse_8h.html#ac2b17561e944264c594ea0802e56d308">CFG_INT</a>(<span class="stringliteral">&quot;delay&quot;</span>, 3, <a class="code" href="confuse_8h.html#a65df72d236bcc3e7f22c5b2b5c24bded">CFGF_NONE</a>),</div>
        !            86: <div class="line">        <a class="code" href="confuse_8h.html#a963e2ee16396dcf36f6d1937faa00f0c">CFG_STR</a>(<span class="stringliteral">&quot;message&quot;</span>, <span class="stringliteral">&quot;This is a message&quot;</span>, <a class="code" href="confuse_8h.html#a65df72d236bcc3e7f22c5b2b5c24bded">CFGF_NONE</a>),</div>
        !            87: <div class="line">        <a name="a6"></a><a class="code" href="confuse_8h.html#a043d5c79624269e5f60f59a698e461a6">CFG_SEC</a>(<span class="stringliteral">&quot;argument&quot;</span>, arg_opts, <a name="a7"></a><a class="code" href="confuse_8h.html#a86b522a5daef5c07066b28f1585d2d77">CFGF_MULTI</a> | <a name="a8"></a><a class="code" href="confuse_8h.html#a65d20dbd5b778dd1bf3b3895206b4497">CFGF_TITLE</a>),</div>
        !            88: <div class="line">        <a class="code" href="confuse_8h.html#a6b29dd8a4c6cd3d392d4ab6b2e535597">CFG_END</a>()</div>
        !            89: <div class="line">    };</div>
        !            90: <div class="line"> </div>
        !            91: <div class="line">    <span class="keywordtype">char</span> *buf = <span class="stringliteral">&quot;&quot;</span></div>
        !            92: <div class="line">        <span class="stringliteral">&quot; delay = 3\n&quot;</span> <span class="stringliteral">&quot;# message = \&quot;asdfasfasfd tersf\&quot;\n&quot;</span> <span class="stringliteral">&quot; argument one { value = 1 }\n&quot;</span> <span class="stringliteral">&quot; argument two { value=foo}\n&quot;</span>;</div>
        !            93: <div class="line"> </div>
        !            94: <div class="line">    <a name="a9"></a><a class="code" href="confuse_8h.html#aae5e08626bf53514a6ebf250580feba3">cfg_free</a>(cfg);</div>
        !            95: <div class="line"> </div>
        !            96: <div class="line">    cfg = <a name="a10"></a><a class="code" href="confuse_8h.html#aec07794916564c8ab437e030ac618aa8">cfg_init</a>(opts, 0);</div>
        !            97: <div class="line">    <span class="keywordflow">if</span> (<a name="a11"></a><a class="code" href="confuse_8h.html#a6da020721a065f359cf343f014e7834c">cfg_parse_buf</a>(cfg, buf) != <a name="a12"></a><a class="code" href="confuse_8h.html#a66a1002180229809620b9bf2d3b888a6">CFG_SUCCESS</a>)</div>
        !            98: <div class="line">        errx(1, <span class="stringliteral">&quot;Failed parsing configuration!\n&quot;</span>);</div>
        !            99: <div class="line"> </div>
        !           100: <div class="line">    <a name="a13"></a><a class="code" href="confuse_8h.html#a0fca327466956c5580199e24397d49fe">cfg_parse</a>(cfg, config_filename);</div>
        !           101: <div class="line">}</div>
        !           102: <div class="line"> </div>
        !           103: <div class="line"><span class="keywordtype">void</span> sighandler(<span class="keywordtype">int</span> sig)</div>
        !           104: <div class="line">{</div>
        !           105: <div class="line">    read_config();</div>
        !           106: <div class="line">    signal(SIGHUP, sighandler);</div>
        !           107: <div class="line">}</div>
        !           108: <div class="line"> </div>
        !           109: <div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> loop = 1;</div>
        !           110: <div class="line"> </div>
        !           111: <div class="line"><span class="keywordtype">void</span> usr1handler(<span class="keywordtype">int</span> sig)</div>
        !           112: <div class="line">{</div>
        !           113: <div class="line">    loop = 0;</div>
        !           114: <div class="line">}</div>
        !           115: <div class="line"> </div>
        !           116: <div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div>
        !           117: <div class="line">{</div>
        !           118: <div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;</div>
        !           119: <div class="line"> </div>
        !           120: <div class="line">    <span class="comment">/* Localize messages &amp; types according to environment, since v2.9 */</span></div>
        !           121: <div class="line"><span class="preprocessor">#ifdef LC_MESSAGES</span></div>
        !           122: <div class="line">    setlocale(LC_MESSAGES, <span class="stringliteral">&quot;&quot;</span>);</div>
        !           123: <div class="line">    setlocale(LC_CTYPE, <span class="stringliteral">&quot;&quot;</span>);</div>
        !           124: <div class="line"><span class="preprocessor">#endif</span></div>
        !           125: <div class="line"> </div>
        !           126: <div class="line">    read_config();</div>
        !           127: <div class="line">    signal(SIGHUP, sighandler);</div>
        !           128: <div class="line">    signal(SIGUSR1, usr1handler);</div>
        !           129: <div class="line"> </div>
        !           130: <div class="line">    <span class="keywordflow">while</span> (loop) {</div>
        !           131: <div class="line">        printf(<span class="stringliteral">&quot;Message: %s&quot;</span>, <a name="a14"></a><a class="code" href="confuse_8h.html#a4a9c34acc55cca63649c088d98053905">cfg_getstr</a>(cfg, <span class="stringliteral">&quot;message&quot;</span>));</div>
        !           132: <div class="line">        <span class="keywordflow">for</span> (i = 0; i &lt; <a name="a15"></a><a class="code" href="confuse_8h.html#acb8b2b9aa7d9e2e3c0eca67ea27bed15">cfg_size</a>(cfg, <span class="stringliteral">&quot;argument&quot;</span>); i++) {</div>
        !           133: <div class="line">            <a class="code" href="structcfg__t.html">cfg_t</a> *arg = <a name="a16"></a><a class="code" href="confuse_8h.html#ad5e8eea765588892053b73eed4017edd">cfg_getnsec</a>(cfg, <span class="stringliteral">&quot;argument&quot;</span>, i);</div>
        !           134: <div class="line"> </div>
        !           135: <div class="line">            printf(<span class="stringliteral">&quot;, %s&quot;</span>, <a class="code" href="confuse_8h.html#a4a9c34acc55cca63649c088d98053905">cfg_getstr</a>(arg, <span class="stringliteral">&quot;value&quot;</span>));</div>
        !           136: <div class="line">        }</div>
        !           137: <div class="line">        printf(<span class="stringliteral">&quot;\n&quot;</span>);</div>
        !           138: <div class="line"> </div>
        !           139: <div class="line">        sleep(<a name="a17"></a><a class="code" href="confuse_8h.html#aaa50eb2942ae8e7cb7f9ccbfe002b3cd">cfg_getint</a>(cfg, <span class="stringliteral">&quot;delay&quot;</span>));</div>
        !           140: <div class="line">    }</div>
        !           141: <div class="line"> </div>
        !           142: <div class="line">    <a class="code" href="confuse_8h.html#aae5e08626bf53514a6ebf250580feba3">cfg_free</a>(cfg);</div>
        !           143: <div class="line">    cfg = 0;</div>
        !           144: <div class="line"> </div>
        !           145: <div class="line">    <span class="keywordflow">return</span> 0;</div>
        !           146: <div class="line">}</div>
        !           147: </div><!-- fragment --> </div><!-- contents -->
        !           148: <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>
        !           149: <div class="ttc" id="aconfuse_8h_html_ac2b17561e944264c594ea0802e56d308"><div class="ttname"><a href="confuse_8h.html#ac2b17561e944264c594ea0802e56d308">CFG_INT</a></div><div class="ttdeci">#define CFG_INT(name, def, flags)</div><div class="ttdoc">Initialize an integer option.</div><div class="ttdef"><b>Definition:</b> confuse.h:421</div></div>
        !           150: <div class="ttc" id="aconfuse_8h_html_acb8b2b9aa7d9e2e3c0eca67ea27bed15"><div class="ttname"><a href="confuse_8h.html#acb8b2b9aa7d9e2e3c0eca67ea27bed15">cfg_size</a></div><div class="ttdeci">DLLIMPORT unsigned int __export cfg_size(cfg_t *cfg, const char *name)</div><div class="ttdoc">Return the number of values this option has.</div><div class="ttdef"><b>Definition:</b> confuse.c:406</div></div>
        !           151: <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>
        !           152: <div class="ttc" id="aconfuse_8h_html_a963e2ee16396dcf36f6d1937faa00f0c"><div class="ttname"><a href="confuse_8h.html#a963e2ee16396dcf36f6d1937faa00f0c">CFG_STR</a></div><div class="ttdeci">#define CFG_STR(name, def, flags)</div><div class="ttdoc">Initialize a string option.</div><div class="ttdef"><b>Definition:</b> confuse.h:340</div></div>
        !           153: <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>
        !           154: <div class="ttc" id="aconfuse_8h_html_a65d20dbd5b778dd1bf3b3895206b4497"><div class="ttname"><a href="confuse_8h.html#a65d20dbd5b778dd1bf3b3895206b4497">CFGF_TITLE</a></div><div class="ttdeci">#define CFGF_TITLE</div><div class="ttdoc">option has a title (only applies to sections)</div><div class="ttdef"><b>Definition:</b> confuse.h:90</div></div>
        !           155: <div class="ttc" id="aconfuse_8h_html_a6da020721a065f359cf343f014e7834c"><div class="ttname"><a href="confuse_8h.html#a6da020721a065f359cf343f014e7834c">cfg_parse_buf</a></div><div class="ttdeci">DLLIMPORT int __export cfg_parse_buf(cfg_t *cfg, const char *buf)</div><div class="ttdoc">Same as cfg_parse() above, but takes a character buffer as argument.</div><div class="ttdef"><b>Definition:</b> confuse.c:1777</div></div>
        !           156: <div class="ttc" id="aconfuse_8h_html_ad5e8eea765588892053b73eed4017edd"><div class="ttname"><a href="confuse_8h.html#ad5e8eea765588892053b73eed4017edd">cfg_getnsec</a></div><div class="ttdeci">DLLIMPORT cfg_t *__export cfg_getnsec(cfg_t *cfg, const char *name, unsigned int index)</div><div class="ttdoc">Indexed version of cfg_getsec(), used for sections with the CFGF_MULTI flag set.</div><div class="ttdef"><b>Definition:</b> confuse.c:563</div></div>
        !           157: <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>
        !           158: <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>
        !           159: <div class="ttc" id="aconfuse_8h_html_a043d5c79624269e5f60f59a698e461a6"><div class="ttname"><a href="confuse_8h.html#a043d5c79624269e5f60f59a698e461a6">CFG_SEC</a></div><div class="ttdeci">#define CFG_SEC(name, opts, flags)</div><div class="ttdoc">Initialize a section.</div><div class="ttdef"><b>Definition:</b> confuse.h:527</div></div>
        !           160: <div class="ttc" id="aconfuse_8h_html_a65df72d236bcc3e7f22c5b2b5c24bded"><div class="ttname"><a href="confuse_8h.html#a65df72d236bcc3e7f22c5b2b5c24bded">CFGF_NONE</a></div><div class="ttdeci">#define CFGF_NONE</div><div class="ttdoc">Flags.</div><div class="ttdef"><b>Definition:</b> confuse.h:86</div></div>
        !           161: <div class="ttc" id="aconfuse_8h_html_a86b522a5daef5c07066b28f1585d2d77"><div class="ttname"><a href="confuse_8h.html#a86b522a5daef5c07066b28f1585d2d77">CFGF_MULTI</a></div><div class="ttdeci">#define CFGF_MULTI</div><div class="ttdoc">option may be specified multiple times (only applies to sections)</div><div class="ttdef"><b>Definition:</b> confuse.h:87</div></div>
        !           162: <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>
        !           163: <div class="ttc" id="aconfuse_8h_html_aaa50eb2942ae8e7cb7f9ccbfe002b3cd"><div class="ttname"><a href="confuse_8h.html#aaa50eb2942ae8e7cb7f9ccbfe002b3cd">cfg_getint</a></div><div class="ttdeci">DLLIMPORT long int __export cfg_getint(cfg_t *cfg, const char *name)</div><div class="ttdoc">Returns the value of an integer option.</div><div class="ttdef"><b>Definition:</b> confuse.c:444</div></div>
        !           164: <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>
        !           165: <div class="ttc" id="aconfuse_8h_html_a66a1002180229809620b9bf2d3b888a6"><div class="ttname"><a href="confuse_8h.html#a66a1002180229809620b9bf2d3b888a6">CFG_SUCCESS</a></div><div class="ttdeci">#define CFG_SUCCESS</div><div class="ttdoc">Return codes from cfg_parse(), cfg_parse_boolean(), and cfg_set*() functions.</div><div class="ttdef"><b>Definition:</b> confuse.h:105</div></div>
        !           166: <div class="ttc" id="aconfuse_8h_html_a4a9c34acc55cca63649c088d98053905"><div class="ttname"><a href="confuse_8h.html#a4a9c34acc55cca63649c088d98053905">cfg_getstr</a></div><div class="ttdeci">DLLIMPORT char *__export cfg_getstr(cfg_t *cfg, const char *name)</div><div class="ttdoc">Returns the value of a string option.</div><div class="ttdef"><b>Definition:</b> confuse.c:519</div></div>
        !           167: <!-- start footer part -->
        !           168: <hr class="footer"/><address class="footer"><small>
        !           169: Generated by &#160;<a href="http://www.doxygen.org/index.html">
        !           170: <img class="footer" src="doxygen.png" alt="doxygen"/>
        !           171: </a> 1.8.17
        !           172: </small></address>
        !           173: </body>
1.1       misho     174: </html>

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