5182898ef7f3ee4c443a6c0c0a8b21b41d36ecd2
1 /*****************************************************************************
2 * RRDtool 1.3rc4 Copyright by Tobi Oetiker, 1997-2008
3 *****************************************************************************
4 * rrd_tool.h Common Header File
5 *****************************************************************************/
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #ifndef _RRD_TOOL_H
11 #define _RRD_TOOL_H
13 #ifdef HAVE_CONFIG_H
14 #include "../rrd_config.h"
15 #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
16 #include "../win32/config.h"
17 #endif
19 #include "rrd.h"
21 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
23 /* Win32 only includes */
25 #include <float.h> /* for _isnan */
26 #include <io.h> /* for chdir */
28 struct tm *localtime_r(
29 const time_t *timep,
30 struct tm *result);
31 char *ctime_r(
32 const time_t *timep,
33 char *result);
34 struct tm *gmtime_r(
35 const time_t *timep,
36 struct tm *result);
37 char *strtok_r(
38 char *str,
39 const char *sep,
40 char **last);
42 #else
44 /* unix-only includes */
45 #if !defined isnan && !defined HAVE_ISNAN
46 int isnan(
47 double value);
48 #endif
50 #endif
52 /* local include files -- need to be after the system ones */
53 #include "rrd_getopt.h"
54 #include "rrd_format.h"
56 #ifndef max
57 #define max(a,b) ((a) > (b) ? (a) : (b))
58 #endif
60 #ifndef min
61 #define min(a,b) ((a) < (b) ? (a) : (b))
62 #endif
64 #define DIM(x) (sizeof(x)/sizeof(x[0]))
66 info_t *rrd_info(
67 int,
68 char **);
69 int rrd_lastupdate(
70 int argc,
71 char **argv,
72 time_t *last_update,
73 unsigned long *ds_cnt,
74 char ***ds_namv,
75 char ***last_ds);
76 info_t *rrd_update_v(
77 int,
78 char **);
79 char *sprintf_alloc(
80 char *,
81 ...);
82 info_t *info_push(
83 info_t *,
84 char *,
85 enum info_type,
86 infoval);
87 void info_print(
88 info_t *data);
89 void info_free(
90 info_t *);
92 /* HELPER FUNCTIONS */
94 int PngSize(
95 FILE *,
96 long *,
97 long *);
99 int rrd_create_fn(
100 const char *file_name,
101 rrd_t *rrd);
102 int rrd_fetch_fn(
103 const char *filename,
104 enum cf_en cf_idx,
105 time_t *start,
106 time_t *end,
107 unsigned long *step,
108 unsigned long *ds_cnt,
109 char ***ds_namv,
110 rrd_value_t **data);
112 void rrd_free(
113 rrd_t *rrd);
114 void rrd_freemem(
115 void *mem);
116 void rrd_init(
117 rrd_t *rrd);
119 rrd_file_t *rrd_open(
120 const char *const file_name,
121 rrd_t *rrd,
122 unsigned rdwr);
123 void rrd_dontneed(
124 rrd_file_t *rrd_file,
125 rrd_t *rrd);
126 int rrd_close(
127 rrd_file_t *rrd_file);
128 ssize_t rrd_read(
129 rrd_file_t *rrd_file,
130 void *buf,
131 size_t count);
132 ssize_t rrd_write(
133 rrd_file_t *rrd_file,
134 const void *buf,
135 size_t count);
136 void rrd_flush(
137 rrd_file_t *rrd_file);
138 off_t rrd_seek(
139 rrd_file_t *rrd_file,
140 off_t off,
141 int whence);
142 off_t rrd_tell(
143 rrd_file_t *rrd_file);
144 int readfile(
145 const char *file,
146 char **buffer,
147 int skipfirst);
149 #define RRD_READONLY (1<<0)
150 #define RRD_READWRITE (1<<1)
151 #define RRD_CREAT (1<<2)
152 #define RRD_READAHEAD (1<<3)
153 #define RRD_COPY (1<<4)
155 enum cf_en cf_conv(
156 const char *string);
157 enum dst_en dst_conv(
158 char *string);
159 long ds_match(
160 rrd_t *rrd,
161 char *ds_nam);
162 double rrd_diff(
163 char *a,
164 char *b);
166 /* rrd_strerror is thread safe, but still it uses a global buffer
167 (but one per thread), thus subsequent calls within a single
168 thread overwrite the same buffer */
169 const char *rrd_strerror(
170 int err);
172 #endif
174 #ifdef __cplusplus
175 }
176 #endif