prepare for the release of rrdtool-1.4.2
[rrdtool.git] / src / rrd_tool.h
1 /*****************************************************************************
2  * RRDtool 1.4.2  Copyright by Tobi Oetiker, 1997-2009
3  *****************************************************************************
4  * rrd_tool.h   Common Header File
5  *****************************************************************************/
6 #ifdef  __cplusplus
7 extern    "C" {
8 #endif
9
10 #ifndef _RRD_TOOL_H
11 #define _RRD_TOOL_H
12
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
18
19 #include "rrd.h"
20
21 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
22
23 /* Win32 only includes */
24
25 #include <float.h>      /* for _isnan  */
26 #include <io.h>         /* for chdir   */
27
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);
41
42 #else
43
44 /* unix-only includes */
45 #if !defined isnan && !defined HAVE_ISNAN
46     int       isnan(
47     double value);
48 #endif
49
50 #endif
51
52 /* local include files -- need to be after the system ones */
53 #ifdef HAVE_GETOPT_LONG
54 #define _GNU_SOURCE
55 #include <getopt.h>
56 #else
57 #include "rrd_getopt.h"
58 #endif
59
60 #include "rrd_format.h"
61
62 #ifndef max
63 #define max(a,b) ((a) > (b) ? (a) : (b))
64 #endif
65
66 #ifndef min
67 #define min(a,b) ((a) < (b) ? (a) : (b))
68 #endif
69
70 #define DIM(x) (sizeof(x)/sizeof(x[0]))
71
72     char     *sprintf_alloc(
73     char *,
74     ...);
75
76 /* HELPER FUNCTIONS */
77
78     int       PngSize(
79     FILE *,
80     long *,
81     long *);
82
83     int       rrd_create_fn(
84     const char *file_name,
85     rrd_t *rrd);
86     int rrd_fetch_fn (const char *filename,
87             enum cf_en cf_idx,
88             time_t *start,
89             time_t *end,
90             unsigned long *step,
91             unsigned long *ds_cnt,
92             char ***ds_namv,
93             rrd_value_t **data);
94
95
96 #ifdef HAVE_LIBDBI
97 int rrd_fetch_fn_libdbi(const char *filename, enum cf_en cf_idx,
98                         time_t *start,time_t *end,
99                         unsigned long *step,
100                         unsigned long *ds_cnt,
101                         char        ***ds_namv,
102                         rrd_value_t **data);
103 #endif
104
105 #define RRD_READONLY    (1<<0)
106 #define RRD_READWRITE   (1<<1)
107 #define RRD_CREAT       (1<<2)
108 #define RRD_READAHEAD   (1<<3)
109 #define RRD_COPY        (1<<4)
110
111     enum cf_en cf_conv(
112     const char *string);
113     enum dst_en dst_conv(
114     char *string);
115     long      ds_match(
116     rrd_t *rrd,
117     char *ds_nam);
118     off_t rrd_get_header_size(
119     rrd_t *rrd);
120     double    rrd_diff(
121     char *a,
122     char *b);
123
124 #endif /* _RRD_TOOL_H */
125
126 #ifdef  __cplusplus
127 }
128 #endif