Added Christophe Kalt to the `AUTHORS' file.
[collectd.git] / src / collectd.h
1 /**
2  * collectd - src/collectd.h
3  * Copyright (C) 2005  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; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  * Authors:
20  *   Florian octo Forster <octo at verplant.org>
21  **/
22
23 #ifndef COLLECTD_H
24 #define COLLECTD_H
25
26 #if HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29
30 #include <stdio.h>
31 #if HAVE_SYS_TYPES_H
32 # include <sys/types.h>
33 #endif
34 #if HAVE_SYS_STAT_H
35 # include <sys/stat.h>
36 #endif
37 #if STDC_HEADERS
38 # include <stdlib.h>
39 # include <stddef.h>
40 #else
41 # if HAVE_STDLIB_H
42 #  include <stdlib.h>
43 # endif
44 #endif
45 #if HAVE_STRING_H
46 # if !STDC_HEADERS && HAVE_MEMORY_H
47 #  include <memory.h>
48 # endif
49 # include <string.h>
50 #endif
51 #if HAVE_STRINGS_H
52 # include <strings.h>
53 #endif
54 #if HAVE_INTTYPES_H
55 # include <inttypes.h>
56 #endif
57 #if HAVE_STDINT_H
58 # include <stdint.h>
59 #endif
60 #if HAVE_UNISTD_H
61 # include <unistd.h>
62 #endif
63 #if HAVE_SYS_WAIT_H
64 # include <sys/wait.h>
65 #endif
66 #ifndef WEXITSTATUS
67 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
68 #endif
69 #ifndef WIFEXITED
70 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
71 #endif
72 #if HAVE_SIGNAL_H
73 # include <signal.h>
74 #endif
75 #if HAVE_FCNTL_H
76 # include <fcntl.h>
77 #endif
78 #if HAVE_ERRNO_H
79 # include <errno.h>
80 #endif
81 #if HAVE_SYSLOG_H
82 # include <syslog.h>
83 #endif
84 #if HAVE_LIMITS_H
85 # include <limits.h>
86 #endif
87 #if TIME_WITH_SYS_TIME
88 # include <sys/time.h>
89 # include <time.h>
90 #else
91 # if HAVE_SYS_TIME_H
92 #  include <sys/time.h>
93 # else
94 #  include <time.h>
95 # endif
96 #endif
97
98 #if HAVE_ASSERT_H
99 # include <assert.h>
100 #else
101 # define assert(...) /* nop */
102 #endif
103
104 #if HAVE_DIRENT_H
105 # include <dirent.h>
106 # define NAMLEN(dirent) strlen((dirent)->d_name)
107 #else
108 # define dirent direct
109 # define NAMLEN(dirent) (dirent)->d_namlen
110 # if HAVE_SYS_NDIR_H
111 #  include <sys/ndir.h>
112 # endif
113 # if HAVE_SYS_DIR_H
114 #  include <sys/dir.h>
115 # endif
116 # if HAVE_NDIR_H
117 #  include <ndir.h>
118 # endif
119 #endif
120
121 #if HAVE_STDARG_H
122 # include <stdarg.h>
123 #endif
124 #if HAVE_CTYPE_H
125 # include <ctype.h>
126 #endif
127 #if HAVE_SYS_PARAM_H
128 # include <sys/param.h>
129 #endif
130
131 #if HAVE_SYSLOG
132 # define syslog(...) syslog(__VA_ARGS__)
133 # if HAVE_OPENLOG
134 #  define openlog(...) openlog(__VA_ARGS__)
135 # else
136 #  define openlog(...) /**/
137 # endif
138 # if HAVE_CLOSELOG
139 #  define closelog(...) closelog(__VA_ARGS__)
140 # else
141 #  define closelog(...) /**/
142 # endif
143 #else
144 # define syslog(...) /**/
145 # define openlog(...) /**/
146 # define closelog(...) /**/
147 #endif
148
149 #if HAVE_KSTAT_H
150 # include <kstat.h>
151 #endif
152
153 #if HAVE_RRD_H
154 # include <rrd.h>
155 #endif
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 PKGLOCALSTATEDIR
183 #define PKGLOCALSTATEDIR PREFIX "/var/lib/" PACKAGE_NAME
184 #endif
185
186 #ifndef PIDFILE
187 #define PIDFILE PREFIX "/var/run/" PACKAGE_NAME ".pid"
188 #endif
189
190 #ifndef LOGFILE
191 #define LOGFILE PREFIX"/var/log/"PACKAGE_NAME"/"PACKAGE_NAME".log"
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 extern time_t curtime;
204
205 #ifdef HAVE_LIBRRD
206 extern int operating_mode;
207 #endif
208
209 /* int main (int argc, char **argv); */
210
211 #endif /* COLLECTD_H */