1 /*****************************************************************************
2 * RRDtool 1.2.19 Copyright by Tobi Oetiker, 1997-2007
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
14 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
15 #include "../win32/config.h"
18 #include "../rrd_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__ */
98 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
100 /* Win32 only includes */
102 #include <float.h> /* for _isnan */
103 #include <io.h> /* for chdir */
105 struct tm* localtime_r(const time_t *timep, struct tm* result);
106 char* ctime_r(const time_t *timep, char* result);
107 struct tm* gmtime_r(const time_t *timep, struct tm* result);
108 char *strtok_r(char *str, const char *sep, char **last);
112 /* unix-only includes */
114 int isnan(double value);
119 /* local include files -- need to be after the system ones */
121 #include "rrd_format.h"
124 #define max(a,b) ((a) > (b) ? (a) : (b))
128 #define min(a,b) ((a) < (b) ? (a) : (b))
131 #define DIM(x) (sizeof(x)/sizeof(x[0]))
133 /* rrd info interface */
134 enum info_type { RD_I_VAL=0,
139 typedef union infoval {
146 typedef struct info_t {
153 info_t *rrd_info(int, char **);
154 int rrd_lastupdate(int argc, char **argv, time_t *last_update,
155 unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
156 info_t *rrd_update_v(int, char **);
157 char * sprintf_alloc(char *, ...);
158 info_t *info_push(info_t *, char *, enum info_type, infoval);
160 /* HELPER FUNCTIONS */
162 int PngSize(FILE *, long *, long *);
164 int rrd_create_fn(char *file_name, rrd_t *rrd);
165 int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
166 time_t *start,time_t *end,
168 unsigned long *ds_cnt,
172 void rrd_free(rrd_t *rrd);
173 void rrd_freemem(void *mem);
174 void rrd_init(rrd_t *rrd);
176 int rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
177 int readfile(const char *file, char **buffer, int skipfirst);
179 #define RRD_READONLY 0
180 #define RRD_READWRITE 1
182 enum cf_en cf_conv(char *string);
183 enum dst_en dst_conv(char *string);
184 long ds_match(rrd_t *rrd,char *ds_nam);
185 double rrd_diff(char *a, char *b);
187 /* rrd_strerror is thread safe, but still it uses a global buffer
188 (but one per thread), thus subsequent calls within a single
189 thread overwrite the same buffer */
190 const char *rrd_strerror(int err);