Annotation of embedaddon/confuse/doc/tutorial-html/ar01s08.html, revision 1.1.1.2
1.1.1.2 ! misho 1: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
! 2: <!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>8. Functions</title><link rel="stylesheet" type="text/css" href="tutorial.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="home" href="index.html" title="libConfuse tutorial" /><link rel="up" href="index.html" title="libConfuse tutorial" /><link rel="prev" href="ar01s07.html" title="7. Value parsing callback" /><link rel="next" href="ar01s09.html" title="9. Saving configuration files" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">8. Functions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s07.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s09.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="idm138"></a>8. Functions</h2></div></div></div><p>
1.1 misho 3: libConfuse supports functions to parse options that does not fit
4: well in the general syntax. Functions can be called with a variable
5: number of arguments. No data from the function or any arguments are
6: stored by libConfuse after the function has run. It is up to the caller
7: to process and/or save the data.
8: </p><p>
9: A function is defined with a <code class="function">CFG_FUNC</code> macro.
10: It takes two arguments: the name of the function and a function
11: callback. The callback is defined as:
12: </p><pre class="programlisting">
13: typedef int (*cfg_func_t)(cfg_t *cfg, cfg_opt_t *opt,
14: int argc, const char **argv);
15: </pre><p>
1.1.1.2 ! misho 16: </p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="idm145"></a>8.1. Predefined functions</h3></div></div></div><p>
1.1 misho 17: Currently there is only one pre-defined function:
18: <code class="function">cfg_include()</code>. This function includes
19: another configuration file. Configuration data is immediately
20: read from the included file, and is returned to the position
21: right after the include() statement upon end of file.
22: </p><p>
23: To use this function, include a <code class="function">CFG_FUNC()</code>
24: entry in your options:
25: </p><pre class="programlisting">
26: cfg_opt_t opts[] = {
27: CFG_FUNC("include", cfg_include),
28: CFG_END()
29: };
30: </pre><p>
31: In the configuration file, it is used in the following way:
32: </p><pre class="programlisting">
33: include("included.conf")
1.1.1.2 ! misho 34: </pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s07.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ar01s09.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">7. Value parsing callback </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9. Saving configuration files</td></tr></table></div></body></html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>