Merge branch 'collectd-4.1'
[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_LIMITS_H
81 # include <limits.h>
82 #endif
83 #if TIME_WITH_SYS_TIME
84 # include <sys/time.h>
85 # include <time.h>
86 #else
87 # if HAVE_SYS_TIME_H
88 #  include <sys/time.h>
89 # else
90 #  include <time.h>
91 # endif
92 #endif
93
94 #if HAVE_ASSERT_H
95 # include <assert.h>
96 #else
97 # define assert(...) /* nop */
98 #endif
99
100 #if NAN_STATIC_DEFAULT
101 # include <math.h>
102 /* #endif NAN_STATIC_DEFAULT*/
103 #elif NAN_STATIC_ISOC
104 # ifndef __USE_ISOC99
105 #  define DISABLE_ISOC99 1
106 #  define __USE_ISOC99 1
107 # endif /* !defined(__USE_ISOC99) */
108 # include <math.h>
109 # if DISABLE_ISOC99
110 #  undef DISABLE_ISOC99
111 #  undef __USE_ISOC99
112 # endif /* DISABLE_ISOC99 */
113 /* #endif NAN_STATIC_ISOC */
114 #elif NAN_ZERO_ZERO
115 # include <math.h>
116 # ifdef NAN
117 #  undef NAN
118 # endif
119 # define NAN (0.0 / 0.0)
120 # ifndef isnan
121 #  define isnan(f) ((f) != (f))
122 # endif /* !defined(isnan) */
123 #endif /* NAN_ZERO_ZERO */
124
125 #if HAVE_DIRENT_H
126 # include <dirent.h>
127 # define NAMLEN(dirent) strlen((dirent)->d_name)
128 #else
129 # define dirent direct
130 # define NAMLEN(dirent) (dirent)->d_namlen
131 # if HAVE_SYS_NDIR_H
132 #  include <sys/ndir.h>
133 # endif
134 # if HAVE_SYS_DIR_H
135 #  include <sys/dir.h>
136 # endif
137 # if HAVE_NDIR_H
138 #  include <ndir.h>
139 # endif
140 #endif
141
142 #if HAVE_STDARG_H
143 # include <stdarg.h>
144 #endif
145 #if HAVE_CTYPE_H
146 # include <ctype.h>
147 #endif
148 #if HAVE_SYS_PARAM_H
149 # include <sys/param.h>
150 #endif
151
152 #if HAVE_KSTAT_H
153 # include <kstat.h>
154 #endif
155
156 #if HAVE_PTH_H
157 # include <pth.h>
158 #endif
159 #if HAVE_STATGRAB_H
160 # include <statgrab.h>
161 #endif
162 #if HAVE_SENSORS_SENSORS_H
163 # include <sensors/sensors.h>
164 #endif
165
166 #ifndef PACKAGE_NAME
167 #define PACKAGE_NAME "collectd"
168 #endif
169
170 #ifndef PREFIX
171 #define PREFIX "/opt/" PACKAGE_NAME
172 #endif
173
174 #ifndef SYSCONFDIR
175 #define SYSCONFDIR PREFIX "/etc"
176 #endif
177
178 #ifndef CONFIGFILE
179 #define CONFIGFILE SYSCONFDIR"/collectd.conf"
180 #endif
181
182 #ifndef LOCALSTATEDIR
183 #define LOCALSTATEDIR PREFIX "/var"
184 #endif
185
186 #ifndef PKGLOCALSTATEDIR
187 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
188 #endif
189
190 #ifndef PIDFILE
191 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
192 #endif
193
194 #ifndef PLUGINDIR
195 #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
196 #endif
197
198 #define MODE_SERVER 0x01
199 #define MODE_CLIENT 0x02
200 #define MODE_LOCAL  0x04
201 #define MODE_LOG    0x08
202
203 #ifndef COLLECTD_GRP_NAME
204 # define COLLECTD_GRP_NAME "collectd"
205 #endif
206
207 #define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0]))
208
209 extern char hostname_g[];
210 extern int  interval_g;
211
212 #endif /* COLLECTD_H */