1 /*****************************************************************************
2 * RRDtool 1.2.19 Copyright by Tobi Oetiker, 1997-2007
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
15 #include "../rrd_config.h"
16 #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
17 #include "../win32/config.h"
20 #ifdef MUST_DISABLE_SIGFPE
24 #ifdef MUST_DISABLE_FPMASK
25 #include <floatingpoint.h>
36 # include <sys/param.h>
46 /* Sorry: don't know autoconf as well how to check the exist of
47 dirent.h ans sys/stat.h
52 # define NAMLEN(dirent) strlen((dirent)->d_name)
54 # define dirent direct
55 # define NAMLEN(dirent) (dirent)->d_namlen
57 # include <sys/ndir.h>
68 # include <sys/types.h>
72 # include <sys/stat.h>
80 # include <sys/time.h>
83 # include <sys/times.h>
85 #if HAVE_SYS_RESOURCE_H
86 # include <sys/resource.h>
87 #if (defined(__svr4__) && defined(__sun__))
88 /* Solaris headers (pre 2.6) don't have a getrusage prototype.
90 extern int getrusage(int, struct rusage *);
91 #endif /* __svr4__ && __sun__ */
96 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
98 /* Win32 only includes */
100 #include <float.h> /* for _isnan */
101 #include <io.h> /* for chdir */
103 struct tm* localtime_r(const time_t *timep, struct tm* result);
104 char* ctime_r(const time_t *timep, char* result);
105 struct tm* gmtime_r(const time_t *timep, struct tm* result);
106 char *strtok_r(char *str, const char *sep, char **last);
110 /* unix-only includes */
112 int isnan(double value);
117 /* local include files -- need to be after the system ones */
118 #include "rrd_getopt.h"
119 #include "rrd_format.h"
122 #define max(a,b) ((a) > (b) ? (a) : (b))
126 #define min(a,b) ((a) < (b) ? (a) : (b))
129 #define DIM(x) (sizeof(x)/sizeof(x[0]))
131 /* rrd info interface */
132 enum info_type { RD_I_VAL=0,
137 typedef union infoval {
144 typedef struct info_t {
151 info_t *rrd_info(int, char **);
152 int rrd_lastupdate(int argc, char **argv, time_t *last_update,
153 unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
154 info_t *rrd_update_v(int, char **);
155 char * sprintf_alloc(char *, ...);
156 info_t *info_push(info_t *, char *, enum info_type, infoval);
158 /* HELPER FUNCTIONS */
160 int PngSize(FILE *, long *, long *);
162 int rrd_create_fn(char *file_name, rrd_t *rrd);
163 int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
164 time_t *start,time_t *end,
166 unsigned long *ds_cnt,
170 void rrd_free(rrd_t *rrd);
171 void rrd_freemem(void *mem);
172 void rrd_init(rrd_t *rrd);
174 int rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
175 int readfile(const char *file, char **buffer, int skipfirst);
177 #define RRD_READONLY 0
178 #define RRD_READWRITE 1
180 enum cf_en cf_conv(char *string);
181 enum dst_en dst_conv(char *string);
182 long ds_match(rrd_t *rrd,char *ds_nam);
183 double rrd_diff(char *a, char *b);
185 /* rrd_strerror is thread safe, but still it uses a global buffer
186 (but one per thread), thus subsequent calls within a single
187 thread overwrite the same buffer */
188 const char *rrd_strerror(int err);