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