This manual page documents the librrd API.
NOTE: This document is a work in progress, and should be considered incomplete as long as this warning persists. For more information about the librrd functions, always consult the source code.
The arguments for rrd_dump_cb_r are the same as for rrd_dump_opt_r except that the output filename parameter is replaced by the user-defined callback function and an additional parameter for the callback function that is passed untouched, i.e. to store information about the callback state needed for the user-defined callback to function properly.
Recent versions of rrd_dump_opt_r internally use this callback mechanism to write their output to the file provided by the user.
size_t rrd_dump_opt_cb_fileout(
const void *data,
size_t len,
void *user)
{
return fwrite(data, 1, len, (FILE *)user);
}
The associated call for rrd_dump_cb_r looks like
res = rrd_dump_cb_r(filename, opt_header,
rrd_dump_opt_cb_fileout, (void *)out_file);
where the last parameter specifies the file handle rrd_dump_opt_cb_fileout should write to. There's no specific condition for the callback to detect when it is called for the first time, nor for the last time. If you require this for initialization and cleanup you should do those tasks before and after calling rrd_dump_cr_r respectively.
type **arr = NULL;
type *elem = "whatever";
size_t arr_size = 0;
if (!rrd_add_ptr(&arr, &arr_size, elem))
handle_failure();
char **arr = NULL;
size_t arr_size = NULL;
char *str = "example text";
if (!rrd_add_strdup(&arr, &arr_size, str))
handle_failure();
/* created as above */
rrd_free_ptrs(&arr, &arr_size);
/* here, arr == NULL && arr_size == 0 */
The function returns 0 on success, a negative value else. In case of an error, "errno" is set accordingly. Aside from the errors documented in mkdir(2), the function may fail with the following errors:
In contrast to mkdir(2), the function does not fail if "pathname" already exists and is a directory.