1 /*****************************************************************************
2 * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
14 #include "../rrd_config.h"
15 #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
16 #include "../win32/config.h"
21 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
23 /* Win32 only includes */
25 #include <float.h> /* for _isnan */
26 #include <io.h> /* for chdir */
28 struct tm* localtime_r(const time_t *timep, struct tm* result);
29 char* ctime_r(const time_t *timep, char* result);
30 struct tm* gmtime_r(const time_t *timep, struct tm* result);
31 char *strtok_r(char *str, const char *sep, char **last);
35 /* unix-only includes */
36 #if !defined isnan && !defined HAVE_ISNAN
37 int isnan(double value);
42 /* local include files -- need to be after the system ones */
43 #include "rrd_getopt.h"
44 #include "rrd_format.h"
47 #define max(a,b) ((a) > (b) ? (a) : (b))
51 #define min(a,b) ((a) < (b) ? (a) : (b))
54 #define DIM(x) (sizeof(x)/sizeof(x[0]))
56 /* rrd info interface */
57 enum info_type { RD_I_VAL=0,
62 typedef union infoval {
69 typedef struct info_t {
76 info_t *rrd_info(int, char **);
77 int rrd_lastupdate(int argc, char **argv, time_t *last_update,
78 unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
79 info_t *rrd_update_v(int, char **);
80 char * sprintf_alloc(char *, ...);
81 info_t *info_push(info_t *, char *, enum info_type, infoval);
83 /* HELPER FUNCTIONS */
85 int PngSize(FILE *, long *, long *);
87 int rrd_create_fn(const char *file_name, rrd_t *rrd);
88 int rrd_fetch_fn(const char *filename, enum cf_en cf_idx,
89 time_t *start,time_t *end,
91 unsigned long *ds_cnt,
95 void rrd_free(rrd_t *rrd);
96 void rrd_freemem(void *mem);
97 void rrd_init(rrd_t *rrd);
99 rrd_file_t* rrd_open(const char * const file_name, rrd_t *rrd, unsigned rdwr);
100 int rrd_close(rrd_file_t* rrd_file);
101 ssize_t rrd_read(rrd_file_t* rrd_file, void*buf, size_t count);
102 ssize_t rrd_write(rrd_file_t* rrd_file, const void*buf, size_t count);
103 void rrd_flush(rrd_file_t* rrd_file);
104 off_t rrd_seek(rrd_file_t* rrd_file, off_t off, int whence);
105 off_t rrd_tell(rrd_file_t* rrd_file);
106 int readfile(const char *file, char **buffer, int skipfirst);
108 #define RRD_READONLY 0
109 #define RRD_READWRITE 1
112 enum cf_en cf_conv(const char *string);
113 enum dst_en dst_conv(char *string);
114 long ds_match(rrd_t *rrd,char *ds_nam);
115 double rrd_diff(char *a, char *b);
117 /* rrd_strerror is thread safe, but still it uses a global buffer
118 (but one per thread), thus subsequent calls within a single
119 thread overwrite the same buffer */
120 const char *rrd_strerror(int err);