=pod =head1 NAME librrd - RRD library functions =head1 DESCRIPTION B contains most of the functionality in B. The command line utilities and language bindings are often just wrappers around the code contained in B. This manual page documents the B API. B This document is a work in progress, and should be considered incomplete as long as this warning persists. For more information about the B functions, always consult the source code. =head1 UTILITY FUNCTIONS =over =item B Generates random numbers just like random(). This further ensures that the random number generator is seeded exactly once per process. =item B Dynamically resize the array pointed to by C. C is a pointer to the current size of C. Upon successful realloc(), the C is incremented by 1 and the C pointer is stored at the end of the new C. Returns 1 on success, 0 on failure. type **arr = NULL; type *elem = "whatever"; size_t arr_size = 0; if (!rrd_add_ptr(&arr, &arr_size, elem)) handle_failure(); =item B Like C, except adds a C of the source string. char **arr = NULL; size_t arr_size = NULL; char *str = "example text"; if (!rrd_add_strdup(&arr, &arr_size, str)) handle_failure(); =item B Free an array of pointers allocated by C or C. Also frees the array pointer itself. On return, the source pointer will be NULL and the count will be zero. /* created as above */ rrd_free_ptrs(&arr, &arr_size); /* here, arr == NULL && arr_size == 0 */ =item B In some situations it is necessary to get the output of C without writing it to a file or the standard output. In such cases an application can ask B to call an user-defined function each time there is output to be stored somewhere. This can be used, to e.g. directly feed an XML parser with the dumped output or transfer the resulting string in memory. The arguments for B are the same as for B 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 B 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 B 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 B 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 B respectively. =back