1 /*****************************************************************************
2 * RRDtool 1.2.23 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>
35 # include <sys/param.h>
45 /* Sorry: don't know autoconf as well how to check the exist of
46 dirent.h ans sys/stat.h
51 # define NAMLEN(dirent) strlen((dirent)->d_name)
53 # define dirent direct
54 # define NAMLEN(dirent) (dirent)->d_namlen
56 # include <sys/ndir.h>
67 # include <sys/types.h>
71 # include <sys/stat.h>
78 #if TIME_WITH_SYS_TIME
79 # include <sys/time.h>
83 # include <sys/time.h>
90 # include <sys/times.h>
94 #if HAVE_SYS_RESOURCE_H
95 # include <sys/resource.h>
96 #if (defined(__svr4__) && defined(__sun__))
97 /* Solaris headers (pre 2.6) don't have a getrusage prototype.
99 extern int getrusage(int, struct rusage *);
100 #endif /* __svr4__ && __sun__ */
105 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
107 /* Win32 only includes */
109 #include <float.h> /* for _isnan */
110 #include <io.h> /* for chdir */
112 struct tm* localtime_r(const time_t *timep, struct tm* result);
113 char* ctime_r(const time_t *timep, char* result);
114 struct tm* gmtime_r(const time_t *timep, struct tm* result);
115 char *strtok_r(char *str, const char *sep, char **last);
119 /* unix-only includes */
120 #if !defined isnan && !defined HAVE_ISNAN
121 int isnan(double value);
126 /* local include files -- need to be after the system ones */
127 #include "rrd_getopt.h"
128 #include "rrd_format.h"
131 #define max(a,b) ((a) > (b) ? (a) : (b))
135 #define min(a,b) ((a) < (b) ? (a) : (b))
138 #define DIM(x) (sizeof(x)/sizeof(x[0]))
140 /* rrd info interface */
141 enum info_type { RD_I_VAL=0,
146 typedef union infoval {
153 typedef struct info_t {
160 info_t *rrd_info(int, char **);
161 int rrd_lastupdate(int argc, char **argv, time_t *last_update,
162 unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
163 info_t *rrd_update_v(int, char **);
164 char * sprintf_alloc(char *, ...);
165 info_t *info_push(info_t *, char *, enum info_type, infoval);
167 /* HELPER FUNCTIONS */
169 int PngSize(FILE *, long *, long *);
171 int rrd_create_fn(const char *file_name, rrd_t *rrd);
172 int rrd_fetch_fn(const char *filename, enum cf_en cf_idx,
173 time_t *start,time_t *end,
175 unsigned long *ds_cnt,
179 void rrd_free(rrd_t *rrd);
180 void rrd_freemem(void *mem);
181 void rrd_init(rrd_t *rrd);
183 int rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
184 int readfile(const char *file, char **buffer, int skipfirst);
186 #define RRD_READONLY 0
187 #define RRD_READWRITE 1
189 enum cf_en cf_conv(const char *string);
190 enum dst_en dst_conv(char *string);
191 long ds_match(rrd_t *rrd,char *ds_nam);
192 double rrd_diff(char *a, char *b);
194 /* rrd_strerror is thread safe, but still it uses a global buffer
195 (but one per thread), thus subsequent calls within a single
196 thread overwrite the same buffer */
197 const char *rrd_strerror(int err);