X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=doc%2Flibrrd.pod;h=0d05f6eeaa0f8c50b5a6e363299d34828b1a50af;hp=4daa93cf73c74bc5533564b60ca8073175e2c1aa;hb=9e2eb0abd095264f584490ede57ae5afe8beb748;hpb=8753076ac00af4a10484417a91d1c07baa872fbe diff --git a/doc/librrd.pod b/doc/librrd.pod index 4daa93c..0d05f6e 100644 --- a/doc/librrd.pod +++ b/doc/librrd.pod @@ -16,9 +16,52 @@ 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 CORE FUNCTIONS + +=over 4 + +=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 + =head1 UTILITY FUNCTIONS -=over +=over 4 =item B @@ -38,6 +81,16 @@ end of the new C. Returns 1 on success, 0 on failure. if (!rrd_add_ptr(&arr, &arr_size, elem)) handle_failure(); +=item B + +Like C, except the destination is allocated in chunks of +C. C points to the number of entries allocated, whereas +C points to the number of valid pointers. If more pointers are +needed, C pointers are allocated and C is increased +accordingly. C must be E= C. + +This method improves performance on hosts with expensive C. + =item B Like C, except adds a C of the source string. @@ -48,6 +101,14 @@ Like C, except adds a C of the source string. if (!rrd_add_strdup(&arr, &arr_size, str)) handle_failure(); +=item B + +Like C, except the destination is allocated in chunks of +C. C points to the number of entries allocated, whereas +C points to the number of valid pointers. If more pointers are +needed, C pointers are allocated and C is increased +accordingly. C must be E= C. + =item B Free an array of pointers allocated by C or @@ -86,41 +147,8 @@ Insufficient memory was available. In contrast to L, the function does B fail if C already exists and is a directory. -=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); +=back -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. +=head1 AUTHOR -=back +RRD Contributors