1 /*****************************************************************************
2 * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
15 #include "../confignt/config.h"
22 #ifdef MUST_DISABLE_SIGFPE
26 #ifdef MUST_DISABLE_FPMASK
27 #include <floatingpoint.h>
38 # include <sys/param.h>
48 /* Sorry: don't know autoconf as well how to check the exist of
49 dirent.h ans sys/stat.h
54 # define NAMLEN(dirent) strlen((dirent)->d_name)
56 # define dirent direct
57 # define NAMLEN(dirent) (dirent)->d_namlen
59 # include <sys/ndir.h>
70 # include <sys/types.h>
74 # include <sys/stat.h>
82 # include <sys/time.h>
85 # include <sys/times.h>
87 #if HAVE_SYS_RESOURCE_H
88 # include <sys/resource.h>
89 #if (defined(__svr4__) && defined(__sun__))
90 /* Solaris headers (pre 2.6) don't have a getrusage prototype.
92 extern int getrusage(int, struct rusage *);
93 #endif /* __svr4__ && __sun__ */
100 /* unix-only includes */
102 int isnan(double value);
107 /* Win32 only includes */
109 #include <float.h> /* for _isnan */
111 #define finite _finite
112 #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
115 /* local include files -- need to be after the system ones */
117 #include "rrd_format.h"
120 #define max(a,b) ((a) > (b) ? (a) : (b))
124 #define min(a,b) ((a) < (b) ? (a) : (b))
127 #define DIM(x) (sizeof(x)/sizeof(x[0]))
129 /* rrd info interface */
130 enum info_type { RD_I_VAL=0,
134 typedef union infoval {
140 typedef struct info_t {
148 info_t *rrd_info(int, char **);
150 /* HELPER FUNCTIONS */
152 int PngSize(FILE *, long *, long *);
154 int rrd_create_fn(char *file_name, rrd_t *rrd);
155 int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
156 time_t *start,time_t *end,
158 unsigned long *ds_cnt,
162 void rrd_free(rrd_t *rrd);
163 void rrd_freemem(void *mem);
164 void rrd_init(rrd_t *rrd);
166 int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
167 int rrd_open_r(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
168 int readfile(char *file, char **buffer, int skipfirst);
169 int readfile_r(char *file, char **buffer, int skipfirst);
171 #define RRD_READONLY 0
172 #define RRD_READWRITE 1
174 enum cf_en cf_conv(char *string);
175 enum dst_en dst_conv(char *string);
176 long ds_match(rrd_t *rrd,char *ds_nam);
177 double rrd_diff(char *a, char *b);
179 /* rrd_strerror is thread safe, but still it uses a global buffer
180 (but one per thread), thus subsequent calls within a single
181 thread overwrite the same buffer */
182 const char *rrd_strerror(int err);
184 /* just a defensive work-around... */
185 #define strerror(x) rrd_strerror(x)