Code

471e6f3d664ed8fb2effa5c707a10b66ee313fba
[pkg-rrdtool.git] / doc / librrd.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>librrd</title>
5 <link rev="made" href="mailto:root@localhost" />
6 </head>
8 <body style="background-color: white">
10 <p><a name="__index__"></a></p>
11 <!-- INDEX BEGIN -->
12 <!--
14 <ul>
16         <li><a href="#name">NAME</a></li>
17         <li><a href="#description">DESCRIPTION</a></li>
18         <li><a href="#utility_functions">UTILITY FUNCTIONS</a></li>
19 </ul>
20 -->
21 <!-- INDEX END -->
23 <p>
24 </p>
25 <hr />
26 <h1><a name="name">NAME</a></h1>
27 <p>librrd - RRD library functions</p>
28 <p>
29 </p>
30 <hr />
31 <h1><a name="description">DESCRIPTION</a></h1>
32 <p><strong>librrd</strong> contains most of the functionality in <strong>RRDTool</strong>.  The command
33 line utilities and language bindings are often just wrappers around the
34 code contained in <strong>librrd</strong>.</p>
35 <p>This manual page documents the <strong>librrd</strong> API.</p>
36 <p><strong>NOTE:</strong> This document is a work in progress, and should be considered
37 incomplete as long as this warning persists.  For more information about
38 the <strong>librrd</strong> functions, always consult the source code.</p>
39 <p>
40 </p>
41 <hr />
42 <h1><a name="utility_functions">UTILITY FUNCTIONS</a></h1>
43 <dl>
44 <dt><strong><a name="item_rrd_random"><strong>rrd_random()</strong></a></strong><br />
45 </dt>
46 <dd>
47 Generates random numbers just like random().  This further ensures that
48 the random number generator is seeded exactly once per process.
49 </dd>
50 <p></p>
51 <dt><strong><a name="item_rrd_add_ptr"><strong>rrd_add_ptr(void ***dest, size_t *dest_size, void *src)</strong></a></strong><br />
52 </dt>
53 <dd>
54 Dynamically resize the array pointed to by <code>dest</code>.  <code>dest_size</code> is a
55 pointer to the current size of <code>dest</code>.  Upon successful realloc(), the
56 <code>dest_size</code> is incremented by 1 and the <code>src</code> pointer is stored at the
57 end of the new <code>dest</code>.  Returns 1 on success, 0 on failure.
58 </dd>
59 <dd>
60 <pre>
61     type **arr = NULL;
62     type *elem = &quot;whatever&quot;;
63     size_t arr_size = 0;
64     if (!rrd_add_ptr(&amp;arr, &amp;arr_size, elem))
65         handle_failure();</pre>
66 </dd>
67 <p></p>
68 <dt><strong><a name="item_rrd_add_strdup"><strong>rrd_add_strdup(char ***dest, size_t *dest_size, char *src)</strong></a></strong><br />
69 </dt>
70 <dd>
71 Like <a href="#item_rrd_add_ptr"><code>rrd_add_ptr</code></a>, except adds a <code>strdup</code> of the source string.
72 </dd>
73 <dd>
74 <pre>
75     char **arr = NULL;
76     size_t arr_size = NULL;
77     char *str  = &quot;example text&quot;;
78     if (!rrd_add_strdup(&amp;arr, &amp;arr_size, str))
79         handle_failure();</pre>
80 </dd>
81 <p></p>
82 <dt><strong><a name="item_rrd_free_ptrs"><strong>rrd_free_ptrs(void ***src, size_t *cnt)</strong></a></strong><br />
83 </dt>
84 <dd>
85 Free an array of pointers allocated by <a href="#item_rrd_add_ptr"><code>rrd_add_ptr</code></a> or
86 <a href="#item_rrd_add_strdup"><code>rrd_add_strdup</code></a>.  Also frees the array pointer itself.  On return, the
87 source pointer will be NULL and the count will be zero.
88 </dd>
89 <dd>
90 <pre>
91     /* created as above */
92     rrd_free_ptrs(&amp;arr, &amp;arr_size);
93     /* here, arr == NULL &amp;&amp; arr_size == 0 */</pre>
94 </dd>
95 <p></p></dl>
97 </body>
99 </html>