2 * collectd - src/collectd.h
3 * Copyright (C) 2005,2006 Florian octo Forster
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.
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.
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
19 * Florian octo Forster <octo at verplant.org>
31 # include <sys/types.h>
34 # include <sys/stat.h>
45 # if !STDC_HEADERS && HAVE_MEMORY_H
54 # include <inttypes.h>
66 # include <sys/wait.h>
69 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
72 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
86 #if TIME_WITH_SYS_TIME
87 # include <sys/time.h>
91 # include <sys/time.h>
100 # define assert(...) /* nop */
103 #if NAN_STATIC_DEFAULT
105 /* #endif NAN_STATIC_DEFAULT*/
106 #elif NAN_STATIC_ISOC
107 # ifndef __USE_ISOC99
108 # define DISABLE_ISOC99 1
109 # define __USE_ISOC99 1
110 # endif /* !defined(__USE_ISOC99) */
113 # undef DISABLE_ISOC99
115 # endif /* DISABLE_ISOC99 */
116 /* #endif NAN_STATIC_ISOC */
122 # define NAN (0.0 / 0.0)
124 # define isnan(f) ((f) != (f))
125 # endif /* !defined(isnan) */
126 #endif /* NAN_ZERO_ZERO */
128 /* Try really, really hard to determine endianess. Under NexentaStor 1.0.2 this
129 * information is in <sys/isa_defs.h>, possibly some other Solaris versions do
133 #elif HAVE_SYS_ISA_DEFS_H
134 # include <sys/isa_defs.h>
138 # if defined(_BYTE_ORDER)
139 # define BYTE_ORDER _BYTE_ORDER
140 # elif defined(__BYTE_ORDER)
141 # define BYTE_ORDER __BYTE_ORDER
142 # elif defined(__DARWIN_BYTE_ORDER)
143 # define BYTE_ORDER __DARWIN_BYTE_ORDER
147 # if defined(_BIG_ENDIAN)
148 # define BIG_ENDIAN _BIG_ENDIAN
149 # elif defined(__BIG_ENDIAN)
150 # define BIG_ENDIAN __BIG_ENDIAN
151 # elif defined(__DARWIN_BIG_ENDIAN)
152 # define BIG_ENDIAN __DARWIN_BIG_ENDIAN
155 #ifndef LITTLE_ENDIAN
156 # if defined(_LITTLE_ENDIAN)
157 # define LITTLE_ENDIAN _LITTLE_ENDIAN
158 # elif defined(__LITTLE_ENDIAN)
159 # define LITTLE_ENDIAN __LITTLE_ENDIAN
160 # elif defined(__DARWIN_LITTLE_ENDIAN)
161 # define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
165 # if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
167 # define BIG_ENDIAN 4321
168 # define LITTLE_ENDIAN 1234
169 # define BYTE_ORDER BIG_ENDIAN
170 # elif !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
171 # undef LITTLE_ENDIAN
172 # define BIG_ENDIAN 4321
173 # define LITTLE_ENDIAN 1234
174 # define BYTE_ORDER LITTLE_ENDIAN
177 #if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN)
178 # error "Cannot determine byte order"
183 # define NAMLEN(dirent) strlen((dirent)->d_name)
185 # define dirent direct
186 # define NAMLEN(dirent) (dirent)->d_namlen
188 # include <sys/ndir.h>
191 # include <sys/dir.h>
205 # include <sys/param.h>
212 #if HAVE_SENSORS_SENSORS_H
213 # include <sensors/sensors.h>
217 #define PACKAGE_NAME "collectd"
221 #define PREFIX "/opt/" PACKAGE_NAME
225 #define SYSCONFDIR PREFIX "/etc"
229 #define CONFIGFILE SYSCONFDIR"/collectd.conf"
232 #ifndef LOCALSTATEDIR
233 #define LOCALSTATEDIR PREFIX "/var"
236 #ifndef PKGLOCALSTATEDIR
237 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
241 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
245 #define PLUGINDIR PREFIX "/lib/" PACKAGE_NAME
249 #define PKGDATADIR PREFIX "/share/" PACKAGE_NAME
252 #ifndef COLLECTD_GRP_NAME
253 # define COLLECTD_GRP_NAME "collectd"
256 #define STATIC_ARRAY_LEN(array) (sizeof (array) / sizeof ((array)[0]))
258 /* Remove GNU specific __attribute__ settings when using another compiler */
260 # define __attribute__(x) /**/
263 #if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
267 # pragma GCC poison strcpy strcat strtok
271 * Special hack for the perl plugin: Because the later included perl.h defines
272 * a macro which is never used, but contains `sprintf', we cannot poison that
273 * identifies just yet. The parl plugin will do that itself once perl.h is
276 #ifndef DONT_POISON_SPRINTF_YET
277 # if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__
279 # pragma GCC poison sprintf
283 extern char hostname_g[];
284 extern int interval_g;
286 #endif /* COLLECTD_H */