~ubuntu-branches/ubuntu/saucy/rrdtool/saucy-proposed

« back to all changes in this revision

Viewing changes to doc/librrd.html

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2010-07-22 08:07:01 UTC
  • mfrom: (1.2.8 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100722080701-k46mgdfz6euxwqsm
Tags: 1.4.3-1ubuntu1
* Merge from debian unstable, Remaining changes:
  - debian/control: Don't build against ruby1.9 as we don't want
    it in main.
* require libdbi >= 0.8.3 to prevent aborts when using dbi datasources

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" ?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml">
 
4
<head>
 
5
<title>librrd</title>
 
6
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
 
7
<link rev="made" href="mailto:root@localhost" />
 
8
</head>
 
9
 
 
10
<body style="background-color: white">
 
11
 
 
12
 
 
13
<!-- INDEX BEGIN -->
 
14
<div name="index">
 
15
<p><a name="__index__"></a></p>
 
16
<!--
 
17
 
 
18
<ul>
 
19
 
 
20
        <li><a href="#name">NAME</a></li>
 
21
        <li><a href="#description">DESCRIPTION</a></li>
 
22
        <li><a href="#core_functions">CORE FUNCTIONS</a></li>
 
23
        <li><a href="#utility_functions">UTILITY FUNCTIONS</a></li>
 
24
        <li><a href="#author">AUTHOR</a></li>
 
25
</ul>
 
26
 
 
27
-->
 
28
 
 
29
 
 
30
</div>
 
31
<!-- INDEX END -->
 
32
 
 
33
<p>
 
34
</p>
 
35
<hr />
 
36
<h1><a name="name">NAME</a></h1>
 
37
<p>librrd - RRD library functions</p>
 
38
<p>
 
39
</p>
 
40
<hr />
 
41
<h1><a name="description">DESCRIPTION</a></h1>
 
42
<p><strong>librrd</strong> contains most of the functionality in <strong>RRDTool</strong>.  The command
 
43
line utilities and language bindings are often just wrappers around the
 
44
code contained in <strong>librrd</strong>.</p>
 
45
<p>This manual page documents the <strong>librrd</strong> API.</p>
 
46
<p><strong>NOTE:</strong> This document is a work in progress, and should be considered
 
47
incomplete as long as this warning persists.  For more information about
 
48
the <strong>librrd</strong> functions, always consult the source code.</p>
 
49
<p>
 
50
</p>
 
51
<hr />
 
52
<h1><a name="core_functions">CORE FUNCTIONS</a></h1>
 
53
<dl>
 
54
<dt><strong><a name="rrd_dump_cb_r" class="item"><strong>rrd_dump_cb_r(char *filename, int opt_header, rrd_output_callback_t cb, void *user)</strong></a></strong></dt>
 
55
 
 
56
<dd>
 
57
<p>In some situations it is necessary to get the output of <code>rrd_dump</code> without
 
58
writing it to a file or the standard output. In such cases an application
 
59
can ask <strong>rrd_dump_cb_r</strong> to call an user-defined function each time there
 
60
is output to be stored somewhere. This can be used, to e.g. directly feed
 
61
an XML parser with the dumped output or transfer the resulting string
 
62
in memory.</p>
 
63
<p>The arguments for <strong>rrd_dump_cb_r</strong> are the same as for <strong>rrd_dump_opt_r</strong>
 
64
except that the output filename parameter is replaced by the user-defined
 
65
callback function and an additional parameter for the callback function
 
66
that is passed untouched, i.e. to store information about the callback state
 
67
needed for the user-defined callback to function properly.</p>
 
68
<p>Recent versions of <strong>rrd_dump_opt_r</strong> internally use this callback mechanism
 
69
to write their output to the file provided by the user.</p>
 
70
<pre>
 
71
    size_t rrd_dump_opt_cb_fileout(
 
72
        const void *data,
 
73
        size_t len,
 
74
        void *user)
 
75
    {
 
76
        return fwrite(data, 1, len, (FILE *)user);
 
77
    }</pre>
 
78
<p>The associated call for <strong>rrd_dump_cb_r</strong> looks like</p>
 
79
<pre>
 
80
    res = rrd_dump_cb_r(filename, opt_header,
 
81
        rrd_dump_opt_cb_fileout, (void *)out_file);</pre>
 
82
<p>where the last parameter specifies the file handle <strong>rrd_dump_opt_cb_fileout</strong>
 
83
should write to. There's no specific condition for the callback to detect
 
84
when it is called for the first time, nor for the last time. If you require
 
85
this for initialization and cleanup you should do those tasks before and
 
86
after calling <strong>rrd_dump_cr_r</strong> respectively.</p>
 
87
</dd>
 
88
</dl>
 
89
<p>
 
90
</p>
 
91
<hr />
 
92
<h1><a name="utility_functions">UTILITY FUNCTIONS</a></h1>
 
93
<dl>
 
94
<dt><strong><a name="rrd_random" class="item"><strong>rrd_random()</strong></a></strong></dt>
 
95
 
 
96
<dd>
 
97
<p>Generates random numbers just like <code>random()</code>.  This further ensures that
 
98
the random number generator is seeded exactly once per process.</p>
 
99
</dd>
 
100
<dt><strong><a name="rrd_add_ptr" class="item"><strong>rrd_add_ptr(void ***dest, size_t *dest_size, void *src)</strong></a></strong></dt>
 
101
 
 
102
<dd>
 
103
<p>Dynamically resize the array pointed to by <code>dest</code>.  <code>dest_size</code> is a
 
104
pointer to the current size of <code>dest</code>.  Upon successful <code>realloc()</code>, the
 
105
<code>dest_size</code> is incremented by 1 and the <code>src</code> pointer is stored at the
 
106
end of the new <code>dest</code>.  Returns 1 on success, 0 on failure.</p>
 
107
<pre>
 
108
    type **arr = NULL;
 
109
    type *elem = &quot;whatever&quot;;
 
110
    size_t arr_size = 0;
 
111
    if (!rrd_add_ptr(&amp;arr, &amp;arr_size, elem))
 
112
        handle_failure();</pre>
 
113
</dd>
 
114
<dt><strong><a name="rrd_add_strdup" class="item"><strong>rrd_add_strdup(char ***dest, size_t *dest_size, char *src)</strong></a></strong></dt>
 
115
 
 
116
<dd>
 
117
<p>Like <a href="#rrd_add_ptr"><code>rrd_add_ptr</code></a>, except adds a <code>strdup</code> of the source string.</p>
 
118
<pre>
 
119
    char **arr = NULL;
 
120
    size_t arr_size = NULL;
 
121
    char *str  = &quot;example text&quot;;
 
122
    if (!rrd_add_strdup(&amp;arr, &amp;arr_size, str))
 
123
        handle_failure();</pre>
 
124
</dd>
 
125
<dt><strong><a name="rrd_free_ptrs" class="item"><strong>rrd_free_ptrs(void ***src, size_t *cnt)</strong></a></strong></dt>
 
126
 
 
127
<dd>
 
128
<p>Free an array of pointers allocated by <a href="#rrd_add_ptr"><code>rrd_add_ptr</code></a> or
 
129
<a href="#rrd_add_strdup"><code>rrd_add_strdup</code></a>.  Also frees the array pointer itself.  On return, the
 
130
source pointer will be NULL and the count will be zero.</p>
 
131
<pre>
 
132
    /* created as above */
 
133
    rrd_free_ptrs(&amp;arr, &amp;arr_size);
 
134
    /* here, arr == NULL &amp;&amp; arr_size == 0 */</pre>
 
135
</dd>
 
136
<dt><strong><a name="rrd_mkdir_p" class="item"><strong>rrd_mkdir_p(const char *pathname, mode_t mode)</strong></a></strong></dt>
 
137
 
 
138
<dd>
 
139
<p>Create the directory named <code>pathname</code> including all of its parent
 
140
directories (similar to <code>mkdir -p</code> on the command line - see <em>mkdir(1)</em> for
 
141
more information). The argument <code>mode</code> specifies the permissions to use. It
 
142
is modified by the process's <code>umask</code>. See <em>mkdir(2)</em> for more details.</p>
 
143
<p>The function returns 0 on success, a negative value else. In case of an error,
 
144
<code>errno</code> is set accordingly. Aside from the errors documented in <em>mkdir(2)</em>,
 
145
the function may fail with the following errors:</p>
 
146
<dl>
 
147
<dt><strong><a name="einval" class="item"><strong>EINVAL</strong></a></strong></dt>
 
148
 
 
149
<dd>
 
150
<p><code>pathname</code> is <code>NULL</code> or the empty string.</p>
 
151
</dd>
 
152
<dt><strong><a name="enomem" class="item"><strong>ENOMEM</strong></a></strong></dt>
 
153
 
 
154
<dd>
 
155
<p>Insufficient memory was available.</p>
 
156
</dd>
 
157
<dt><strong><a name="stat" class="item"><strong>any error returned by <a href="#stat">stat(2)</a></strong></a></strong></dt>
 
158
 
 
159
</dl>
 
160
<p>In contrast to <em>mkdir(2)</em>, the function does <strong>not</strong> fail if <code>pathname</code>
 
161
already exists and is a directory.</p>
 
162
</dd>
 
163
</dl>
 
164
<p>
 
165
</p>
 
166
<hr />
 
167
<h1><a name="author">AUTHOR</a></h1>
 
168
<p>RRD Contributors &lt;<a href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a>&gt;</p>
 
169
 
 
170
</body>
 
171
 
 
172
</html>