1 /*****************************************************************************
2 * RRDtool 1.3.0 Copyright by Tobi Oetiker, 1997-2008
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 */
56 #include <unistd.h> /* for off_t */
58 #include <stdio.h> /* for FILE */
61 /* Formerly rrd_nan_inf.h */
63 # define DNAN rrd_set_to_DNAN()
67 # define DINF rrd_set_to_DINF()
69 double rrd_set_to_DNAN(
71 double rrd_set_to_DINF(
73 /* end of rrd_nan_inf.h */
75 /* Transplanted from rrd_format.h */
76 typedef double rrd_value_t; /* the data storage type is
78 /* END rrd_format.h */
80 /* information about an rrd file */
81 typedef struct rrd_file_t {
82 int fd; /* file descriptor if this rrd file */
83 char *file_start; /* start address of an open rrd file */
84 off_t header_len; /* length of the header of this rrd file */
85 off_t file_len; /* total size of the rrd file */
86 off_t pos; /* current pos in file */
89 /* rrd info interface */
90 typedef struct rrd_blob_t {
91 unsigned long size; /* size of the blob */
92 unsigned char *ptr; /* pointer */
95 typedef enum rrd_info_type { RD_I_VAL = 0,
102 typedef union rrd_infoval {
110 typedef struct rrd_info_t {
112 rrd_info_type_t type;
114 struct rrd_info_t *next;
118 /* main function blocks */
122 rrd_info_t *rrd_info(
125 rrd_info_t *rrd_info_push(
137 rrd_info_t *rrd_update_v(
149 rrd_info_t *rrd_graph_v(
174 int rrd_lastupdate(int argc, char **argv);
181 char *rrd_strversion(
199 /* thread-safe (hopefully) */
201 const char *filename,
202 unsigned long pdp_step,
206 /* NOTE: rrd_update_r are only thread-safe if no at-style time
207 specifications get used!!! */
210 const char *filename,
211 const char *_template,
215 const char *filename,
220 unsigned long *ds_cnt,
224 const char *filename,
226 time_t rrd_last_r (const char *filename);
227 int rrd_lastupdate_r (const char *filename,
228 time_t *ret_last_update,
229 unsigned long *ret_ds_count,
230 char ***ret_ds_names,
231 char ***ret_last_ds);
233 const char *filename,
236 /* Transplanted from rrd_parsetime.h */
239 RELATIVE_TO_START_TIME,
245 typedef struct rrd_time_value {
253 rrd_time_value_t * ptv);
254 /* END rrd_parsetime.h */
256 typedef struct rrd_context {
257 char lib_errstr[256];
258 char rrd_error[4096];
261 /* returns the current per-thread rrd_context */
262 rrd_context_t *rrd_get_context(
266 int rrd_proc_start_end(
272 /* HELPER FUNCTIONS */
276 void rrd_clear_error(
283 /* rrd_strerror is thread safe, but still it uses a global buffer
284 (but one per thread), thus subsequent calls within a single
285 thread overwrite the same buffer */
286 const char *rrd_strerror(
289 /** MULTITHREADED HELPER FUNCTIONS */
290 rrd_context_t *rrd_new_context(
292 void rrd_free_context(
293 rrd_context_t * buf);
295 /* void rrd_set_error_r (rrd_context_t *, char *, ...); */
296 /* void rrd_clear_error_r(rrd_context_t *); */
297 /* int rrd_test_error_r (rrd_context_t *); */
298 /* char *rrd_get_error_r (rrd_context_t *); */
301 * The following functions are _internal_ functions needed to read the raw RRD
302 * files. Since they are _internal_ they may change with the file format and
303 * will be replaced with a more general interface in RRDTool 1.4. Don't use
304 * these functions unless you have good reasons to do so. If you do use these
305 * functions you will have to adapt your code for RRDTool 1.4!
307 * To enable the deprecated functions define `RRD_EXPORT_DEPRECATED' before
308 * including <rrd_test.h>. You have been warned! If you come back to the
309 * RRDTool mailing list and whine about your broken application, you will get
310 * hit with something smelly!
312 #if defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED)
314 # if defined(_RRD_TOOL_H)
315 # include "rrd_format.h"
317 # include <rrd_format.h>
320 #if defined(__GNUC__) && defined (RRD_EXPORT_DEPRECATED)
321 # define RRD_DEPRECATED __attribute__((deprecated))
323 # define RRD_DEPRECATED /**/
326 void rrd_free (rrd_t *rrd)
328 void rrd_init (rrd_t *rrd)
331 rrd_file_t *rrd_open (const char *const file_name, rrd_t *rrd,
335 void rrd_dontneed (rrd_file_t *rrd_file, rrd_t *rrd)
337 int rrd_close (rrd_file_t *rrd_file)
339 ssize_t rrd_read (rrd_file_t *rrd_file, void *buf, size_t count)
341 ssize_t rrd_write (rrd_file_t *rrd_file,
342 const void *buf, size_t count)
344 void rrd_flush (rrd_file_t *rrd_file)
346 off_t rrd_seek (rrd_file_t *rrd_file, off_t off, int whence)
348 off_t rrd_tell (rrd_file_t *rrd_file)
350 int rrd_lock (rrd_file_t *file)
352 #endif /* defined(_RRD_TOOL_H) || defined(RRD_EXPORT_DEPRECATED) */
354 #endif /* _RRDLIB_H */