5ba481bd1d7c6ea2508382192eb6b0a173c53ad7
1 /*****************************************************************************
2 * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
11 #ifndef _RRD_TOOL_H
12 #define _RRD_TOOL_H
14 #ifdef WIN32
15 #include "../confignt/config.h"
16 #else
17 #ifdef HAVE_CONFIG_H
18 #include <config.h>
19 #endif
20 #endif
22 #ifdef MUST_DISABLE_SIGFPE
23 #include <signal.h>
24 #endif
26 #ifdef MUST_DISABLE_FPMASK
27 #include <floatingpoint.h>
28 #endif
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <errno.h>
33 #include <string.h>
34 #include <time.h>
35 #include <ctype.h>
37 #if HAVE_SYS_PARAM_H
38 # include <sys/param.h>
39 #endif
41 #ifndef MAXPATH
42 # define MAXPATH 1024
43 #endif
45 #if HAVE_MATH_H
46 # include <math.h>
47 #endif
48 #if HAVE_UNISTD_H
49 # include <unistd.h>
50 #endif
51 #if HAVE_SYS_TIME_H
52 # include <sys/time.h>
53 #endif
54 #if HAVE_SYS_TIMES_H
55 # include <sys/times.h>
56 #endif
57 #if HAVE_SYS_RESOURCE_H
58 # include <sys/resource.h>
59 #if (defined(__svr4__) && defined(__sun__))
60 /* Solaris headers (pre 2.6) don't have a getrusage prototype.
61 Use this instead. */
62 extern int getrusage(int, struct rusage *);
63 #endif /* __svr4__ && __sun__ */
64 #endif
66 #include "rrd.h"
68 #ifndef WIN32
70 /* unix-only includes */
71 #ifndef isnan
72 int isnan(double value);
73 #endif
75 #else
77 /* Win32 only includes */
79 #include <float.h> /* for _isnan */
80 #define isnan _isnan
81 #define finite _finite
82 #define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
83 #endif
85 /* local include files -- need to be after the system ones */
86 #include "getopt.h"
87 #include "rrd_format.h"
89 #ifndef max
90 #define max(a,b) ((a) > (b) ? (a) : (b))
91 #endif
93 #ifndef min
94 #define min(a,b) ((a) < (b) ? (a) : (b))
95 #endif
97 #define DIM(x) (sizeof(x)/sizeof(x[0]))
99 /* rrd info interface */
100 enum info_type { RD_I_VAL=0,
101 RD_I_CNT,
102 RD_I_STR };
104 typedef union infoval {
105 unsigned long u_cnt;
106 rrd_value_t u_val;
107 char *u_str;
108 } infoval;
110 typedef struct info_t {
111 char *key;
112 enum info_type type;
113 union infoval value;
114 struct info_t *next;
115 } info_t;
118 info_t *rrd_info(int, char **);
120 /* HELPER FUNCTIONS */
122 int PngSize(FILE *, long *, long *);
124 int rrd_create_fn(char *file_name, rrd_t *rrd);
125 int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
126 time_t *start,time_t *end,
127 unsigned long *step,
128 unsigned long *ds_cnt,
129 char ***ds_namv,
130 rrd_value_t **data);
132 void rrd_free(rrd_t *rrd);
133 void rrd_init(rrd_t *rrd);
135 int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
136 int readfile(char *file, char **buffer, int skipfirst);
138 #define RRD_READONLY 0
139 #define RRD_READWRITE 1
141 enum cf_en cf_conv(char *string);
142 enum dst_en dst_conv(char *string);
143 long ds_match(rrd_t *rrd,char *ds_nam);
144 double rrd_diff(char *a, char *b);
146 #endif
148 #ifdef __cplusplus
149 }
150 #endif