131dcbb97e86fd570a8a97647fb96c72fc1d49ef
[rrdtool.git] / src / rrd_tool.h
1 /*****************************************************************************
2  * RRDtool 1.3.1  Copyright by Tobi Oetiker, 1997-2008
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 #ifndef max
61 #define max(a,b) ((a) > (b) ? (a) : (b))
62 #endif
63
64 #ifndef min
65 #define min(a,b) ((a) < (b) ? (a) : (b))
66 #endif
67
68 #define DIM(x) (sizeof(x)/sizeof(x[0]))
69
70     char     *sprintf_alloc(
71     char *,
72     ...);
73
74 /* HELPER FUNCTIONS */
75
76     int       PngSize(
77     FILE *,
78     long *,
79     long *);
80
81     int       rrd_create_fn(
82     const char *file_name,
83     rrd_t *rrd);
84     int       rrd_fetch_fn(
85     const char *filename,
86     enum cf_en cf_idx,
87     time_t *start,
88     time_t *end,
89     unsigned long *step,
90     unsigned long *ds_cnt,
91     char ***ds_namv,
92     rrd_value_t **data);
93
94 #define RRD_READONLY    (1<<0)
95 #define RRD_READWRITE   (1<<1)
96 #define RRD_CREAT       (1<<2)
97 #define RRD_READAHEAD   (1<<3)
98 #define RRD_COPY        (1<<4)
99
100     enum cf_en cf_conv(
101     const char *string);
102     enum dst_en dst_conv(
103     char *string);
104     long      ds_match(
105     rrd_t *rrd,
106     char *ds_nam);
107     double    rrd_diff(
108     char *a,
109     char *b);
110
111 #endif
112
113 #ifdef  __cplusplus
114 }
115 #endif