1 /*****************************************************************************
2 * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010
3 *****************************************************************************
4 * rrdlib.h Public header file for librrd
5 *****************************************************************************
8 * Revision 1.9 2005/02/13 16:13:33 oetiker
9 * let rrd_graph return the actual value range it picked ...
10 * -- Henrik Stoerner <henrik@hswn.dk>
12 * Revision 1.8 2004/05/26 22:11:12 oetiker
13 * reduce compiler warnings. Many small fixes. -- Mike Slifcak <slif@bellsouth.net>
15 * Revision 1.7 2003/11/12 22:14:26 oetiker
16 * allow to pass an open filehandle into rrd_graph as an extra argument
18 * Revision 1.6 2003/11/11 19:46:21 oetiker
19 * replaced time_value with rrd_time_value as MacOS X introduced a struct of that name in their standard headers
21 * Revision 1.5 2003/04/25 18:35:08 jake
22 * Alternate update interface, updatev. Returns info about CDPs written to disk as result of update. Output format is similar to rrd_info, a hash of key-values.
24 * Revision 1.4 2003/04/01 22:52:23 jake
25 * Fix Win32 build. VC++ 6.0 and 7.0 now use the thread-safe code.
27 * Revision 1.3 2003/02/13 07:05:27 oetiker
28 * Find attached the patch I promised to send to you. Please note that there
29 * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c
30 * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This
31 * library is identical to librrd, but it contains support code for per-thread
32 * global variables currently used for error information only. This is similar
33 * to how errno per-thread variables are implemented. librrd_th must be linked
34 * alongside of libpthred
36 * There is also a new file "THREADS", holding some documentation.
38 * -- Peter Stamfest <peter@stamfest.at>
40 * Revision 1.2 2002/05/07 21:58:32 oetiker
41 * new command rrdtool xport integrated
42 * -- Wolfgang Schrimm <Wolfgang.Schrimm@urz.uni-heidelberg.de>
44 * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker
47 *****************************************************************************/
55 #include <sys/types.h> /* for off_t */
58 #include <unistd.h> /* for off_t */
61 #ifndef PERLPATCHLEVEL
64 #define strtoll _strtoi64
66 typedef size_t ssize_t;
71 #include <stdio.h> /* for FILE */
74 /* Formerly rrd_nan_inf.h */
76 # define DNAN rrd_set_to_DNAN()
80 # define DINF rrd_set_to_DINF()
82 double rrd_set_to_DNAN(
84 double rrd_set_to_DINF(
86 /* end of rrd_nan_inf.h */
88 /* Transplanted from rrd_format.h */
89 typedef double rrd_value_t; /* the data storage type is
91 /* END rrd_format.h */
93 /* information about an rrd file */
94 typedef struct rrd_file_t {
95 size_t header_len; /* length of the header of this rrd file */
96 size_t file_len; /* total size of the rrd file */
97 size_t pos; /* current pos in file */
101 /* information used for the conventional file access methods */
102 typedef struct rrd_simple_file_t {
103 int fd; /* file descriptor of this rrd file */
105 char *file_start; /* start address of an open rrd file */
111 /* rrd info interface */
112 typedef struct rrd_blob_t {
113 unsigned long size; /* size of the blob */
114 unsigned char *ptr; /* pointer */
117 typedef enum rrd_info_type { RD_I_VAL = 0,
124 typedef union rrd_infoval {
132 typedef struct rrd_info_t {
134 rrd_info_type_t type;
136 struct rrd_info_t *next;
139 typedef size_t (* rrd_output_callback_t)(
144 /* main function blocks */
148 rrd_info_t *rrd_info(
151 rrd_info_t *rrd_info_push(
163 rrd_info_t *rrd_update_v(
175 rrd_info_t *rrd_graph_v(
200 int rrd_lastupdate(int argc, char **argv);
207 char *rrd_strversion(
221 int rrd_flushcached (int argc, char **argv);
226 /* thread-safe (hopefully) */
228 const char *filename,
229 unsigned long pdp_step,
231 /* int no_overwrite, */
235 const char *filename,
236 unsigned long pdp_step,
241 rrd_info_t *rrd_info_r(
243 /* NOTE: rrd_update_r and rrd_update_v_r are only thread-safe if no at-style
244 time specifications get used!!! */
247 const char *filename,
248 const char *_template,
252 const char *filename,
253 const char *_template,
256 rrd_info_t * pcdp_summary);
258 const char *filename,
263 unsigned long *ds_cnt,
267 const char *filename,
269 time_t rrd_last_r (const char *filename);
270 int rrd_lastupdate_r (const char *filename,
271 time_t *ret_last_update,
272 unsigned long *ret_ds_count,
273 char ***ret_ds_names,
274 char ***ret_last_ds);
276 const char *filename,
280 const char *filename,
282 rrd_output_callback_t cb,
285 /* Transplanted from rrd_parsetime.h */
288 RELATIVE_TO_START_TIME,
289 RELATIVE_TO_END_TIME,
295 typedef struct rrd_time_value {
303 rrd_time_value_t * ptv);
304 /* END rrd_parsetime.h */
306 typedef struct rrd_context {
307 char lib_errstr[256];
308 char rrd_error[4096];
311 /* returns the current per-thread rrd_context */
312 rrd_context_t *rrd_get_context(void);
315 /* this was added by the win32 porters Christof.Wegmann@exitgames.com */
316 rrd_context_t *rrd_force_new_context(void);
319 int rrd_proc_start_end(
325 /* HELPER FUNCTIONS */
329 void rrd_clear_error(
336 /* rrd_strerror is thread safe, but still it uses a global buffer
337 (but one per thread), thus subsequent calls within a single
338 thread overwrite the same buffer */
339 const char *rrd_strerror(
342 /** MULTITHREADED HELPER FUNCTIONS */
343 rrd_context_t *rrd_new_context(
345 void rrd_free_context(
346 rrd_context_t * buf);
348 /* void rrd_set_error_r (rrd_context_t *, char *, ...); */
349 /* void rrd_clear_error_r(rrd_context_t *); */
350 /* int rrd_test_error_r (rrd_context_t *); */
351 /* char *rrd_get_error_r (rrd_context_t *); */
353 /** UTILITY FUNCTIONS */
355 long rrd_random(void);
357 int rrd_add_ptr_chunk(void ***dest, size_t *dest_size, void *src,
358 size_t *alloc, size_t chunk);
359 int rrd_add_ptr(void ***dest, size_t *dest_size, void *src);
360 int rrd_add_strdup(char ***dest, size_t *dest_size, char *src);
361 int rrd_add_strdup_chunk(char ***dest, size_t *dest_size, char *src,
362 size_t *alloc, size_t chunk);
363 void rrd_free_ptrs(void ***src, size_t *cnt);
365 int rrd_mkdir_p(const char *pathname, mode_t mode);
368 * The following functions are _internal_ functions needed to read the raw RRD
369 * files. Since they are _internal_ they may change with the file format and
370 * will be replaced with a more general interface in RRDTool 1.4. Don't use
371 * these functions unless you have good reasons to do so. If you do use these
372 * functions you will have to adapt your code for RRDTool 1.4!
374 * To enable the deprecated functions define `RRD_EXPORT_DEPRECATED' before
375 * including <rrd_test.h>. You have been warned! If you come back to the
376 * RRDTool mailing list and whine about your broken application, you will get
377 * hit with something smelly!
379 #if defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED)
381 # if defined(_RRD_TOOL_H)
382 # include "rrd_format.h"
384 # include <rrd_format.h>
387 #if defined(__GNUC__) && defined (RRD_EXPORT_DEPRECATED)
388 # define RRD_DEPRECATED __attribute__((deprecated))
390 # define RRD_DEPRECATED /**/
399 rrd_file_t *rrd_open(
400 const char *const file_name,
406 rrd_file_t *rrd_file,
410 rrd_file_t *rrd_file)
413 rrd_file_t *rrd_file,
418 rrd_file_t *rrd_file,
423 rrd_file_t *rrd_file)
426 rrd_file_t *rrd_file,
431 rrd_file_t *rrd_file)
437 rrd_file_t *rrd_file,
439 unsigned long rra_row,
442 unsigned long rrd_select_initial_row(
443 rrd_file_t *rrd_file,
448 #endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
450 #endif /* _RRDLIB_H */