1librrd(3)                           rrdtool                          librrd(3)
2
3
4

NAME

6       librrd - RRD library functions
7

DESCRIPTION

9       librrd contains most of the functionality in RRDTool.  The command line
10       utilities and language bindings are often just wrappers around the code
11       contained in librrd.
12
13       This manual page documents the librrd API.
14
15       NOTE: This document is a work in progress, and should be considered
16       incomplete as long as this warning persists.  For more information
17       about the librrd functions, always consult the source code.
18

CORE FUNCTIONS

20       rrd_dump_cb_r(char *filename, int opt_header, rrd_output_callback_t cb,
21       void *user)
22           In some situations it is necessary to get the output of "rrd_dump"
23           without writing it to a file or the standard output. In such cases
24           an application can ask rrd_dump_cb_r to call an user-defined
25           function each time there is output to be stored somewhere. This can
26           be used, to e.g. directly feed an XML parser with the dumped output
27           or transfer the resulting string in memory.
28
29           The arguments for rrd_dump_cb_r are the same as for rrd_dump_opt_r
30           except that the output filename parameter is replaced by the user-
31           defined callback function and an additional parameter for the
32           callback function that is passed untouched, i.e. to store
33           information about the callback state needed for the user-defined
34           callback to function properly.
35
36           Recent versions of rrd_dump_opt_r internally use this callback
37           mechanism to write their output to the file provided by the user.
38
39               size_t rrd_dump_opt_cb_fileout(
40                   const void *data,
41                   size_t len,
42                   void *user)
43               {
44                   return fwrite(data, 1, len, (FILE *)user);
45               }
46
47           The associated call for rrd_dump_cb_r looks like
48
49               res = rrd_dump_cb_r(filename, opt_header,
50                   rrd_dump_opt_cb_fileout, (void *)out_file);
51
52           where the last parameter specifies the file handle
53           rrd_dump_opt_cb_fileout should write to. There's no specific
54           condition for the callback to detect when it is called for the
55           first time, nor for the last time. If you require this for
56           initialization and cleanup you should do those tasks before and
57           after calling rrd_dump_cr_r respectively.
58

UTILITY FUNCTIONS

60       rrd_random()
61           Generates random numbers just like random().  This further ensures
62           that the random number generator is seeded exactly once per
63           process.
64
65       rrd_add_ptr(void ***dest, size_t *dest_size, void *src)
66           Dynamically resize the array pointed to by "dest".  "dest_size" is
67           a pointer to the current size of "dest".  Upon successful
68           realloc(), the "dest_size" is incremented by 1 and the "src"
69           pointer is stored at the end of the new "dest".  Returns 1 on
70           success, 0 on failure.
71
72               type **arr = NULL;
73               type *elem = "whatever";
74               size_t arr_size = 0;
75               if (!rrd_add_ptr(&arr, &arr_size, elem))
76                   handle_failure();
77
78       rrd_add_strdup(char ***dest, size_t *dest_size, char *src)
79           Like "rrd_add_ptr", except adds a "strdup" of the source string.
80
81               char **arr = NULL;
82               size_t arr_size = NULL;
83               char *str  = "example text";
84               if (!rrd_add_strdup(&arr, &arr_size, str))
85                   handle_failure();
86
87       rrd_free_ptrs(void ***src, size_t *cnt)
88           Free an array of pointers allocated by "rrd_add_ptr" or
89           "rrd_add_strdup".  Also frees the array pointer itself.  On return,
90           the source pointer will be NULL and the count will be zero.
91
92               /* created as above */
93               rrd_free_ptrs(&arr, &arr_size);
94               /* here, arr == NULL && arr_size == 0 */
95
96       rrd_mkdir_p(const char *pathname, mode_t mode)
97           Create the directory named "pathname" including all of its parent
98           directories (similar to "mkdir -p" on the command line - see
99           mkdir(1) for more information). The argument "mode" specifies the
100           permissions to use. It is modified by the process's "umask". See
101           mkdir(2) for more details.
102
103           The function returns 0 on success, a negative value else. In case
104           of an error, "errno" is set accordingly. Aside from the errors
105           documented in mkdir(2), the function may fail with the following
106           errors:
107
108           EINVAL
109               "pathname" is "NULL" or the empty string.
110
111           ENOMEM
112               Insufficient memory was available.
113
114           any error returned by stat(2)
115
116           In contrast to mkdir(2), the function does not fail if "pathname"
117           already exists and is a directory.
118

AUTHOR

120       RRD Contributors <rrd-developers@lists.oetiker.ch>
121
122
123
1241.4.4                             2009-11-15                         librrd(3)
Impressum