1 /* 2 ** Zabbix 3 ** Copyright (C) 2001-2021 Zabbix SIA 4 ** 5 ** This program is free software; you can redistribute it and/or modify 6 ** it under the terms of the GNU General Public License as published by 7 ** the Free Software Foundation; either version 2 of the License, or 8 ** (at your option) any later version. 9 ** 10 ** This program is distributed in the hope that it will be useful, 11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 ** GNU General Public License for more details. 14 ** 15 ** You should have received a copy of the GNU General Public License 16 ** along with this program; if not, write to the Free Software 17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 **/ 19 20 #ifndef ZABBIX_SYSINC_H 21 #define ZABBIX_SYSINC_H 22 23 #include "config.h" 24 25 #ifdef HAVE_STDIO_H 26 # include <stdio.h> 27 #endif 28 29 #ifdef HAVE_STDLIB_H 30 # include <stdlib.h> 31 #endif 32 33 #ifdef HAVE_ASSERT_H 34 # include <assert.h> 35 #endif 36 37 #ifdef HAVE_ERRNO_H 38 # include <errno.h> 39 #endif 40 41 #ifdef HAVE_WINSOCK2_H 42 # include <winsock2.h> 43 #endif 44 45 #ifdef HAVE_WS2TCPIP_H 46 # include <ws2tcpip.h> 47 #endif 48 49 #ifdef HAVE_WSPIAPI_H 50 # include "Wspiapi.h" 51 #endif 52 53 #ifdef HAVE_IPHLPAPI_H 54 # include <Iphlpapi.h> 55 #endif 56 57 #ifdef HAVE_NETIOAPI_H 58 # include <Netioapi.h> 59 #endif 60 61 #ifdef HAVE_WINDOWS_H 62 /* to speed build process and reduce size of the Win32 header files */ 63 # define WIN32_LEAN_AND_MEAN 1 64 # include <windows.h> 65 #endif 66 67 #ifdef HAVE_PROCESS_H 68 # include <process.h> 69 #endif 70 71 #ifdef HAVE_CONIO_H 72 # include <conio.h> 73 #endif 74 75 #ifdef HAVE_PDH_H 76 # include <pdh.h> 77 # ifndef PDH_MAX_COUNTER_NAME 78 # define PDH_MAX_COUNTER_NAME 1024 /* maximum counter name length */ 79 # endif 80 # ifndef PDH_MAX_COUNTER_PATH 81 # define PDH_MAX_COUNTER_PATH 2048 /* maximum full counter path length */ 82 # endif 83 #endif 84 85 #ifdef HAVE_PDHMSG_H 86 # include <pdhmsg.h> 87 #endif 88 89 #ifdef HAVE_PSAPI_H 90 # include <psapi.h> 91 #endif 92 93 #ifdef HAVE_STDARG_H 94 # include <stdarg.h> 95 #endif 96 97 #ifdef HAVE_CTYPE_H 98 # include <ctype.h> 99 #endif 100 101 #ifdef HAVE_GRP_H 102 # include <grp.h> 103 #endif 104 105 #ifdef HAVE_SYS_TYPES_H 106 # include <sys/types.h> 107 #endif 108 109 #ifdef HAVE_SYS_SYSTEMCFG_H 110 # include <sys/systemcfg.h> 111 #endif 112 113 #ifdef HAVE_INTTYPES_H 114 # include <inttypes.h> 115 #endif 116 117 #ifdef HAVE_STRING_H 118 # include <string.h> 119 #endif 120 121 #ifdef HAVE_STRINGS_H 122 # include <strings.h> 123 #endif 124 125 #ifdef HAVE_SYS_TIME_H 126 # include <sys/time.h> 127 #endif 128 129 #ifdef HAVE_SYS_TIMES_H 130 # include <sys/times.h> 131 #endif 132 133 #ifdef HAVE_LINUX_KERNEL_H 134 # include <linux/kernel.h> 135 #endif 136 137 #ifdef HAVE_ARPA_NAMESER_H 138 # ifdef MAC_OS_X 139 # define BIND_8_COMPAT 1 140 # endif 141 # include <arpa/nameser.h> 142 #endif 143 144 #ifdef HAVE_DIRENT_H 145 # include <dirent.h> 146 #endif 147 148 #ifdef HAVE_SYS_DKSTAT_H 149 # include <sys/dkstat.h> 150 #endif 151 152 #ifdef HAVE_DEVSTAT_H 153 # include <devstat.h> 154 #endif 155 156 #ifdef HAVE_FCNTL_H 157 # include <fcntl.h> 158 #endif 159 160 #ifdef HAVE_KNLIST_H 161 # include <knlist.h> 162 #endif 163 164 #ifdef HAVE_KSTAT_H 165 # include <kstat.h> 166 #endif 167 168 #ifdef HAVE_WINLDAP_H 169 # undef SEC_I_INCOMPLETE_CREDENTIALS 170 # undef SEC_E_INCOMPLETE_CREDENTIALS 171 # undef SEC_I_RENEGOTIATE 172 # include <Winldap.h> 173 #endif 174 175 #ifdef HAVE_WINBER_H 176 # include <Winber.h> 177 #endif 178 179 #ifdef HAVE_MACH_HOST_INFO_H 180 # include <mach/host_info.h> 181 #endif 182 183 #ifdef HAVE_MACH_MACH_HOST_H 184 # include <mach/mach_host.h> 185 #endif 186 187 #ifdef HAVE_MTENT_H 188 # include <mtent.h> 189 #endif 190 191 #ifdef HAVE_NETDB_H 192 # include <netdb.h> 193 #endif 194 195 #ifdef HAVE_SYS_WAIT_H 196 # include <sys/wait.h> 197 #endif 198 199 #ifdef HAVE_NETINET_IN_H 200 # include <netinet/in.h> 201 #endif 202 203 #ifdef HAVE_PWD_H 204 # include <pwd.h> 205 #endif 206 207 #ifdef HAVE_SIGNAL_H 208 # include <signal.h> 209 #endif 210 211 #ifdef HAVE_STDINT_H 212 # include <stdint.h> 213 #endif 214 215 #ifdef HAVE_SYS_LOADAVG_H 216 # include <sys/loadavg.h> 217 #endif 218 219 #ifdef HAVE_SYS_PARAM_H 220 # include <sys/param.h> 221 #endif 222 223 #ifdef HAVE_SYS_PROC_H 224 # include <sys/proc.h> 225 #endif 226 227 #ifdef HAVE_SYS_PSTAT_H 228 # include <sys/pstat.h> 229 #endif 230 231 #ifdef HAVE_PTHREAD_H 232 # include <pthread.h> 233 #endif 234 235 #ifdef HAVE_SYS_DK_H 236 # include <sys/dk.h> 237 #endif 238 239 #ifdef HAVE_RESOLV_H 240 # include <resolv.h> 241 #endif 242 243 #ifdef HAVE_SYS_DISK_H 244 # include <sys/disk.h> 245 #endif 246 247 #ifdef HAVE_SYS_SOCKET_H 248 # include <sys/socket.h> 249 #endif 250 251 #ifdef HAVE_SYS_STAT_H 252 # include <sys/stat.h> 253 #endif 254 255 #ifdef HAVE_SYS_STATVFS_H 256 # include <sys/statvfs.h> 257 #endif 258 259 #ifdef HAVE_SYS_SWAP_H 260 # include <sys/swap.h> 261 #endif 262 263 #ifdef HAVE_SYS_SYSCALL_H 264 # include <sys/syscall.h> 265 #endif 266 267 #ifdef HAVE_SYS_SYSCTL_H 268 # include <sys/sysctl.h> 269 #endif 270 271 #ifdef HAVE_SYS_SYSINFO_H 272 # include <sys/sysinfo.h> 273 #endif 274 275 #ifdef HAVE_SYS_SYSMACROS_H 276 # include <sys/sysmacros.h> 277 #endif 278 279 #ifdef HAVE_SYS_VAR_H 280 # include <sys/var.h> 281 #endif 282 283 #ifdef HAVE_SYS_VFS_H 284 # include <sys/vfs.h> 285 #endif 286 287 #ifdef HAVE_SYS_VMMETER_H 288 # include <sys/vmmeter.h> 289 #endif 290 291 #ifdef HAVE_LIBPERFSTAT 292 # ifdef HAVE_SYS_PROTOSW_H 293 # include <sys/protosw.h> /* workaround for /usr/include/netinet/in6_var.h bug, see ZBX-6565 */ 294 # endif 295 # include <libperfstat.h> 296 #endif 297 298 #ifdef HAVE_SYS_RESOURCE_H 299 # include <sys/resource.h> 300 #endif 301 302 #ifdef HAVE_NLIST_H 303 # include <nlist.h> 304 #endif 305 306 #ifdef HAVE_NET_IF_H 307 # include <net/if.h> 308 #endif 309 310 #ifdef HAVE_NET_IF_MIB_H 311 # include <net/if_mib.h> 312 #endif 313 314 #ifdef HAVE_SYS_USER_H 315 # include <sys/user.h> 316 #endif 317 318 #ifdef HAVE_KVM_H 319 # include <kvm.h> 320 #endif 321 322 #ifdef HAVE_SYSLOG_H 323 # include <syslog.h> 324 #endif 325 326 #ifdef HAVE_TIME_H 327 # include <time.h> 328 #endif 329 330 #ifdef HAVE_UNISTD_H 331 # include <unistd.h> 332 #endif 333 334 #ifdef HAVE_SYS_IPC_H 335 # include <sys/ipc.h> 336 #endif 337 338 #ifdef HAVE_SYS_SEM_H 339 # include <sys/sem.h> 340 #endif 341 342 #ifdef HAVE_SYS_SHM_H 343 # include <sys/shm.h> 344 #endif 345 346 #ifdef HAVE_SYS_FILE_H 347 # include <sys/file.h> 348 #endif 349 350 #ifdef HAVE_MATH_H 351 # include <math.h> 352 #endif 353 354 #ifdef HAVE_PCRE_H 355 # include <pcre.h> 356 #endif 357 358 #ifdef HAVE_VM_VM_PARAM_H 359 # include <vm/vm_param.h> 360 #endif 361 362 #ifdef HAVE_ARPA_INET_H 363 # include <arpa/inet.h> 364 #endif 365 366 #ifdef HAVE_SYS_MOUNT_H 367 # include <sys/mount.h> 368 #endif 369 370 #ifdef HAVE_SYS_TIMEB_H 371 # include <sys/timeb.h> 372 #endif 373 374 #ifdef HAVE_SYS_UN_H 375 # include <sys/un.h> 376 #endif 377 378 #ifdef HAVE_PROCINFO_H 379 # undef T_NULL /* to solve definition conflict */ 380 # include <procinfo.h> 381 #endif 382 383 #ifdef HAVE_LIBCURL 384 # include <curl/curl.h> 385 # if !defined(HAVE_FUNCTION_CURL_EASY_ESCAPE) 386 # define curl_easy_escape(handle, string, length) curl_escape(string, length) 387 # endif 388 # if 0x071004 >= LIBCURL_VERSION_NUM /* version 7.16.4 */ 389 # define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD 390 # endif 391 # if 0x071400 <= LIBCURL_VERSION_NUM /* version 7.20.0 */ 392 # define HAVE_SMTP_AUTHENTICATION 1 393 # endif 394 # define ZBX_CURLOPT_MAXREDIRS 10L 395 #endif 396 397 /* Required for advanced sigaction */ 398 #ifdef HAVE_SYS_UCONTEXT_H 399 # include <sys/ucontext.h> 400 #endif 401 402 #ifdef HAVE_IO_H 403 # include <io.h> 404 #endif 405 406 #ifdef HAVE_SYS_MNTTAB_H 407 # include <sys/mnttab.h> 408 #endif 409 410 #ifdef HAVE_MNTENT_H 411 # include <mntent.h> 412 #endif 413 414 #ifdef HAVE_DLFCN_H 415 # include <dlfcn.h> 416 #endif 417 418 #ifdef HAVE_ZONE_H 419 # include <zone.h> 420 # include <utmpx.h> 421 #endif 422 423 #ifdef HAVE_STDDEF_H 424 # include <stddef.h> 425 #endif 426 427 #ifdef HAVE_LIMITS_H 428 # include <limits.h> 429 #endif 430 431 #ifdef HAVE_FLOAT_H 432 # include <float.h> 433 #endif 434 435 #endif 436