src/collectd.h: Include `math.h' and try to force it to define `NAN'.
[collectd.git] / src / collectd.h
1 /**
2  * collectd - src/collectd.h
3  * Copyright (C) 2005,2006  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <octo at verplant.org>
20  **/
21
22 #ifndef COLLECTD_H
23 #define COLLECTD_H
24
25 #if HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28
29 #include <stdio.h>
30 #if HAVE_SYS_TYPES_H
31 # include <sys/types.h>
32 #endif
33 #if HAVE_SYS_STAT_H
34 # include <sys/stat.h>
35 #endif
36 #if STDC_HEADERS
37 # include <stdlib.h>
38 # include <stddef.h>
39 #else
40 # if HAVE_STDLIB_H
41 #  include <stdlib.h>
42 # endif
43 #endif
44 #if HAVE_STRING_H
45 # if !STDC_HEADERS && HAVE_MEMORY_H
46 #  include <memory.h>
47 # endif
48 # include <string.h>
49 #endif
50 #if HAVE_STRINGS_H
51 # include <strings.h>
52 #endif
53 #if HAVE_INTTYPES_H
54 # include <inttypes.h>
55 #endif
56 #if HAVE_STDINT_H
57 # include <stdint.h>
58 #endif
59 #if HAVE_UNISTD_H
60 # include <unistd.h>
61 #endif
62 #if HAVE_SYS_WAIT_H
63 # include <sys/wait.h>
64 #endif
65 #ifndef WEXITSTATUS
66 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
67 #endif
68 #ifndef WIFEXITED
69 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
70 #endif
71 #if HAVE_SIGNAL_H
72 # include <signal.h>
73 #endif
74 #if HAVE_FCNTL_H
75 # include <fcntl.h>
76 #endif
77 #if HAVE_ERRNO_H
78 # include <errno.h>
79 #endif
80 #if HAVE_SYSLOG_H
81 # include <syslog.h>
82 #endif
83 #if HAVE_LIMITS_H
84 # include <limits.h>
85 #endif
86 #if TIME_WITH_SYS_TIME
87 # include <sys/time.h>
88 # include <time.h>
89 #else
90 # if HAVE_SYS_TIME_H
91 #  include <sys/time.h>
92 # else
93 #  include <time.h>
94 # endif
95 #endif
96
97 #if HAVE_ASSERT_H
98 # include <assert.h>
99 #else
100 # define assert(...) /* nop */
101 #endif
102
103 /*
104  * This weird macro cascade forces the glibc to define `NAN'. I don't know
105  * another way to solve this, so more intelligent solutions are welcome. -octo
106  */
107 #ifndef __USE_ISOC99
108 # define DISABLE__USE_ISOC99 1
109 # define __USE_ISOC99 1
110 #endif
111 #include <math.h>
112 #ifdef DISABLE__USE_ISOC99
113 # undef DISABLE__USE_ISOC99
114 # undef __USE_ISOC99
115 #endif
116
117 #if HAVE_DIRENT_H
118 # include <dirent.h>
119 # define NAMLEN(dirent) strlen((dirent)->d_name)
120 #else
121 # define dirent direct
122 # define NAMLEN(dirent) (dirent)->d_namlen
123 # if HAVE_SYS_NDIR_H
124 #  include <sys/ndir.h>
125 # endif
126 # if HAVE_SYS_DIR_H
127 #  include <sys/dir.h>
128 # endif
129 # if HAVE_NDIR_H
130 #  include <ndir.h>
131 # endif
132 #endif
133
134 #if HAVE_STDARG_H
135 # include <stdarg.h>
136 #endif
137 #if HAVE_CTYPE_H
138 # include <ctype.h>
139 #endif
140 #if HAVE_SYS_PARAM_H
141 # include <sys/param.h>
142 #endif
143
144 #if !HAVE_SYSLOG
145 # define syslog(...) /**/
146 # define openlog(...) /**/
147 # define closelog(...) /**/
148 #endif
149
150 #if HAVE_KSTAT_H
151 # include <kstat.h>
152 #endif
153
154 #if HAVE_RRD_H
155 # include <rrd.h>
156 #endif
157 #if HAVE_PTH_H
158 # include <pth.h>
159 #endif
160 #if HAVE_STATGRAB_H
161 # include <statgrab.h>
162 #endif
163 #if HAVE_SENSORS_SENSORS_H
164 # include <sensors/sensors.h>
165 #endif
166
167 #ifndef PACKAGE_NAME
168 #define PACKAGE_NAME "collectd"
169 #endif
170
171 #ifndef PREFIX
172 #define PREFIX "/opt/" PACKAGE_NAME
173 #endif
174
175 #ifndef SYSCONFDIR
176 #define SYSCONFDIR PREFIX "/etc"
177 #endif
178
179 #ifndef CONFIGFILE
180 #define CONFIGFILE SYSCONFDIR"/collectd.conf"
181 #endif
182
183 #ifndef PKGLOCALSTATEDIR
184 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
185 #endif
186
187 #ifndef PIDFILE
188 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
189 #endif
190
191 #ifndef LOGFILE
192 #define LOGFILE PREFIX"/var/log/"PACKAGE_NAME"/"PACKAGE_NAME".log"
193 #endif
194
195 #ifndef PLUGINDIR
196 #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
197 #endif
198
199 #define MODE_SERVER 0x01
200 #define MODE_CLIENT 0x02
201 #define MODE_LOCAL  0x04
202 #define MODE_LOG    0x08
203
204 #ifndef COLLECTD_GRP_NAME
205 # define COLLECTD_GRP_NAME "collectd"
206 #endif
207
208 #ifndef COLLECTD_STEP
209 #  define COLLECTD_STEP "10"
210 #endif
211
212 #ifndef COLLECTD_HEARTBEAT
213 #  define COLLECTD_HEARTBEAT "25"
214 #endif
215
216 #ifndef COLLECTD_ROWS
217 #  define COLLECTD_ROWS "1200"
218 #endif
219
220 #ifndef COLLECTD_XFF
221 #  define COLLECTD_XFF 0.1
222 #endif
223
224 extern time_t curtime;
225
226 #ifdef HAVE_LIBRRD
227 extern int operating_mode;
228 #endif
229
230 /* int main (int argc, char **argv); */
231
232 #endif /* COLLECTD_H */