]>
git.ipfire.org Git - thirdparty/rrdtool-1.x.git/blob - src/rrd.h
8439413c43432b6c5c28c0de0afeea280e177c5c
1 #ifndef RRDLIB_H_4FD7D37D56A448C392AF46508C56D3CC
2 #define RRDLIB_H_4FD7D37D56A448C392AF46508C56D3CC
4 /*****************************************************************************
5 * RRDtool 1.7.2 Copyright by Tobi Oetiker, 1997-2019
6 *****************************************************************************
7 * rrdlib.h Public header file for librrd
8 *****************************************************************************
11 * Revision 1.9 2005/02/13 16:13:33 oetiker
12 * let rrd_graph return the actual value range it picked ...
13 * -- Henrik Stoerner <henrik@hswn.dk>
15 * Revision 1.8 2004/05/26 22:11:12 oetiker
16 * reduce compiler warnings. Many small fixes. -- Mike Slifcak <slif@bellsouth.net>
18 * Revision 1.7 2003/11/12 22:14:26 oetiker
19 * allow to pass an open filehandle into rrd_graph as an extra argument
21 * Revision 1.6 2003/11/11 19:46:21 oetiker
22 * replaced time_value with rrd_time_value as MacOS X introduced a struct of that name in their standard headers
24 * Revision 1.5 2003/04/25 18:35:08 jake
25 * 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.
27 * Revision 1.4 2003/04/01 22:52:23 jake
28 * Fix Win32 build. VC++ 6.0 and 7.0 now use the thread-safe code.
30 * Revision 1.3 2003/02/13 07:05:27 oetiker
31 * Find attached the patch I promised to send to you. Please note that there
32 * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c
33 * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This
34 * library is identical to librrd, but it contains support code for per-thread
35 * global variables currently used for error information only. This is similar
36 * to how errno per-thread variables are implemented. librrd_th must be linked
37 * alongside of libpthread
39 * There is also a new file "THREADS", holding some documentation.
41 * -- Peter Stamfest <peter@stamfest.at>
43 * Revision 1.2 2002/05/07 21:58:32 oetiker
44 * new command rrdtool xport integrated
45 * -- Wolfgang Schrimm <Wolfgang.Schrimm@urz.uni-heidelberg.de>
47 * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker
50 *****************************************************************************/
55 #include <sys/types.h> /* for off_t */
58 #include <unistd.h> /* for off_t */
63 typedef SSIZE_T ssize_t
;
64 #ifndef PERLPATCHLEVEL
68 #define strtoll _strtoi64
73 #include <stdio.h> /* for FILE */
76 /* Formerly rrd_nan_inf.h */
78 # define DNAN rrd_set_to_DNAN()
81 /* declare opaque data structure, so we can use its pointers for type safety */
86 # define DINF rrd_set_to_DINF()
88 double rrd_set_to_DNAN (
90 double rrd_set_to_DINF (
92 /* end of rrd_nan_inf.h */
94 /* Transplanted from rrd_format.h */
95 typedef double rrd_value_t
; /* the data storage type is
97 /* END rrd_format.h */
99 /* information about an rrd file */
100 typedef struct rrd_file_t
{
101 size_t header_len
; /* length of the header of this rrd file */
102 size_t file_len
; /* total size of the rrd file */
103 size_t pos
; /* current pos in file */
105 struct rrd_t
* rrd
; /* the corresponding RRD structure, if any */
107 struct rrd_rados_t
* rados
;
111 /* information used for the conventional file access methods */
112 typedef struct rrd_simple_file_t
{
113 int fd
; /* file descriptor of this rrd file */
115 char * file_start
; /* start address of an open rrd file */
121 /* rrd info interface */
122 typedef struct rrd_blob_t
{
123 unsigned long size
; /* size of the blob */
124 unsigned char * ptr
; /* pointer */
127 typedef enum rrd_info_type
{ RD_I_VAL
= 0 ,
134 typedef union rrd_infoval
{
142 typedef struct rrd_info_t
{
144 rrd_info_type_t type
;
146 struct rrd_info_t
* next
;
150 * rrd_output_callback_t
) (
155 /* main function blocks */
159 rrd_info_t
* rrd_info (
162 rrd_info_t
* rrd_info_push (
180 rrd_info_t
* rrd_update_v (
192 rrd_info_t
* rrd_graph_v (
226 char * rrd_strversion (
247 /* thread-safe (hopefully) */
249 const char * filename
,
250 unsigned long pdp_step
,
252 /* int no_overwrite, */
256 const char * filename
,
257 unsigned long pdp_step
,
260 const char ** sources
,
261 const char * _template
,
264 rrd_info_t
* rrd_info_r (
266 /* NOTE: rrd_update_r and rrd_update_v_r are only thread-safe if no at-style
267 time specifications get used!!! */
270 const char * filename
,
271 const char * _template
,
275 const char * filename
,
276 const char * _template
,
279 rrd_info_t
* pcdp_summary
);
282 #define RRD_SKIP_PAST_UPDATES 0x01
285 const char * filename
,
286 const char * _template
,
291 const char * filename
,
292 const char * _template
,
296 rrd_info_t
* pcdp_summary
);
298 const char * filename
,
303 unsigned long * ds_cnt
,
307 const char * filename
,
311 const char * filename
,
315 const char * filename
,
318 const char * filename
);
319 int rrd_lastupdate_r (
320 const char * filename
,
321 time_t * ret_last_update
,
322 unsigned long * ret_ds_count
,
323 char *** ret_ds_names
,
324 char *** ret_last_ds
);
326 const char * filename
,
330 const char * filename
,
332 rrd_output_callback_t cb
,
335 /* Transplanted from rrd_parsetime.h */
338 RELATIVE_TO_START_TIME
,
339 RELATIVE_TO_END_TIME
,
345 typedef struct rrd_time_value
{
353 rrd_time_value_t
* ptv
);
354 /* END rrd_parsetime.h */
356 typedef struct rrd_context
{
357 char lib_errstr
[ 256 ];
358 char rrd_error
[ 4096 ];
361 /* returns the current per-thread rrd_context */
362 rrd_context_t
* rrd_get_context (
366 /* this was added by the win32 porters Christof.Wegmann@exitgames.com */
367 rrd_context_t
* rrd_force_new_context (
371 int rrd_proc_start_end (
377 /* HELPER FUNCTIONS */
381 void rrd_clear_error (
388 /* rrd_strerror is thread safe, but still it uses a global buffer
389 (but one per thread), thus subsequent calls within a single
390 thread overwrite the same buffer */
391 const char * rrd_strerror (
394 /** MULTITHREADED HELPER FUNCTIONS */
395 rrd_context_t
* rrd_new_context (
397 void rrd_free_context (
400 /* void rrd_set_error_r (rrd_context_t *, char *, ...); */
401 /* void rrd_clear_error_r(rrd_context_t *); */
402 /* int rrd_test_error_r (rrd_context_t *); */
403 /* char *rrd_get_error_r (rrd_context_t *); */
405 /** UTILITY FUNCTIONS */
410 int rrd_add_ptr_chunk (
424 int rrd_add_strdup_chunk (
435 const char * pathname
,
438 const char * rrd_scaled_duration (
440 unsigned long divisor
,
441 unsigned long * valuep
);
442 void rrd_thread_init (
446 * The following functions are _internal_ functions needed to read the raw RRD
447 * files. Since they are _internal_ they may change with the file format and
448 * will be replaced with a more general interface in RRDtool 1.7.2 Don't use
449 * these functions unless you have good reasons to do so. If you do use these
450 * functions you will have to adapt your code for RRDtool 1.7.2
452 * To enable the deprecated functions define `RRD_EXPORT_DEPRECATED' before
453 * including <rrd_test.h>. You have been warned! If you come back to the
454 * RRDtool mailing list and whine about your broken application, you will get
455 * hit with something smelly!
457 #if defined(RRD_TOOL_H_3853987DDF7E4709A5B5849E5A6204F4) || defined(RRD_EXPORT_DEPRECATED)
459 # if defined(RRD_TOOL_H_3853987DDF7E4709A5B5849E5A6204F4)
460 # include "rrd_format.h"
462 # include <rrd_format.h>
465 #if defined(__GNUC__) && defined (RRD_EXPORT_DEPRECATED)
466 # define RRD_DEPRECATED __attribute__((deprecated))
468 # define RRD_DEPRECATED /**/
477 rrd_file_t
* rrd_open (
478 const char * const file_name
,
484 rrd_file_t
* rrd_file
,
488 rrd_file_t
* rrd_file
)
491 rrd_file_t
* rrd_file
,
496 rrd_file_t
* rrd_file
,
501 rrd_file_t
* rrd_file
)
504 rrd_file_t
* rrd_file
,
509 rrd_file_t
* rrd_file
)
515 rrd_file_t
* rrd_file
,
517 unsigned long rra_row
,
520 unsigned long rrd_select_initial_row (
521 rrd_file_t
* rrd_file
,
525 #endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
530 #endif /* RRDLIB_H */