1 librrd(3) rrdtool librrd(3)
6 librrd - RRD library functions
9 l\bli\bib\bbr\brr\brd\bd contains most of the functionality in R\bRR\bRD\bDT\bTo\boo\bol\bl. The command line
10 utilities and language bindings are often just wrappers around the code
16 incomplete as long as this warning persists. For more information
20 r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_c\bcb\bb_\b_r\br(\b(c\bch\bha\bar\br *\b*f\bfi\bil\ble\ben\bna\bam\bme\be,\b, i\bin\bnt\bt o\bop\bpt\bt_\b_h\bhe\bea\bad\bde\ber\br,\b, r\brr\brd\bd_\b_o\bou\but\btp\bpu\but\bt_\b_c\bca\bal\bll\blb\bba\bac\bck\bk_\b_t\bt c\bcb\bb,\b,
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 r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_c\bcb\bb_\b_r\br 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.
29 The arguments for r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_c\bcb\bb_\b_r\br are the same as for r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_o\bop\bpt\bt_\b_r\br
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.
36 Recent versions of r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_o\bop\bpt\bt_\b_r\br internally use this callback
37 mechanism to write their output to the file provided by the user.
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 }
49 res = rrd_dump_cb_r(filename, opt_header,
50 rrd_dump_opt_cb_fileout, (void *)out_file);
52 where the last parameter specifies the file handle
53 r\brr\brd\bd_\b_d\bdu\bum\bmp\bp_\b_o\bop\bpt\bt_\b_c\bcb\bb_\b_f\bfi\bil\ble\beo\bou\but\bt 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
62 that the random number generator is seeded exactly once per
63 process.
65 r\brr\brd\bd_\b_a\bad\bdd\bd_\b_p\bpt\btr\br(\b(v\bvo\boi\bid\bd *\b**\b**\b*d\bde\bes\bst\bt,\b, s\bsi\biz\bze\be_\b_t\bt *\b*d\bde\bes\bst\bt_\b_s\bsi\biz\bze\be,\b, v\bvo\boi\bid\bd *\b*s\bsr\brc\bc)\b)
66 Dynamically resize the array pointed to by "dest". "dest_size" is
67 a pointer to the current size of "dest". Upon successful
69 pointer is stored at the end of the new "dest". Returns 1 on
70 success, 0 on failure.
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();
78 r\brr\brd\bd_\b_a\bad\bdd\bd_\b_s\bst\btr\brd\bdu\bup\bp(\b(c\bch\bha\bar\br *\b**\b**\b*d\bde\bes\bst\bt,\b, s\bsi\biz\bze\be_\b_t\bt *\b*d\bde\bes\bst\bt_\b_s\bsi\biz\bze\be,\b, c\bch\bha\bar\br *\b*s\bsr\brc\bc)\b)
79 Like "rrd_add_ptr", except adds a "strdup" of the source string.
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();
87 r\brr\brd\bd_\b_f\bfr\bre\bee\be_\b_p\bpt\btr\brs\bs(\b(v\bvo\boi\bid\bd *\b**\b**\b*s\bsr\brc\bc,\b, s\bsi\biz\bze\be_\b_t\bt *\b*c\bcn\bnt\bt)\b)
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.
92 /* created as above */
93 rrd_free_ptrs(&arr, &arr_size);
94 /* here, arr == NULL && arr_size == 0 */
96 r\brr\brd\bd_\b_m\bmk\bkd\bdi\bir\br_\b_p\bp(\b(c\bco\bon\bns\bst\bt c\bch\bha\bar\br *\b*p\bpa\bat\bth\bhn\bna\bam\bme\be,\b, m\bmo\bod\bde\be_\b_t\bt m\bmo\bod\bde\be)\b)
97 Create the directory named "pathname" including all of its parent
98 directories (similar to "mkdir -p" on the command line - see
100 permissions to use. It is modified by the process's "umask". See
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
106 errors:
109 "pathname" is "NULL" or the empty string.
112 Insufficient memory was available.
114 a\ban\bny\by e\ber\brr\bro\bor\br r\bre\bet\btu\bur\brn\bne\bed\bd b\bby\by _\bs\bs_\bt\bt_\ba\ba_\bt\bt(\b(2\b2)\b)
117 already exists and is a directory.
121 1.3.999 2009-09-30 librrd(3)