1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
11 * The stack smashing protector defeats some BoF via: gcc -fstack-protector
12 * Reference: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/cpp.pdf
15 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) && (__GNUC_PATCHLEVEL__ >= 2)) || \
16 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || \
19 /* Heuristically enable the stack protector on sensitive functions */
22 /* FORTIFY_SOURCE is RedHat / Fedora specific */
23 #define FORTIFY_SOURCE
29 #ifndef _LARGEFILE64_SOURCE
30 #define _LARGEFILE64_SOURCE
33 #ifndef _FILE_OFFSET_BITS
34 #define _FILE_OFFSET_BITS 64
38 #include <sys/types.h>
41 #include <sys/param.h>
44 #include <sys/mount.h>
50 /* HPUX does not have select.h */
52 #include <sys/select.h>
55 #include <sys/utsname.h>
68 /* The mingw32 builder used by travis.ci can't find glob.h
69 * Yet glob must work on actual win32.
77 #include <netinet/in.h>
78 #include <arpa/inet.h>
79 #include <sys/socket.h>
82 /* WINVER needs to be 0x0501 or higher to pull in IPv6 functions */
101 #ifndef _LARGEFILE64_SOURCE
102 #define _LARGEFILE64_SOURCE
105 #ifndef _FILE_OFFSET_BITS
106 #define _FILE_OFFSET_BITS 64
109 /* Global portability code */
113 typedef uint32_t u_int32_t;
114 typedef uint16_t u_int16_t;
115 typedef uint8_t u_int8_t;
118 #define va_copy __va_copy
125 typedef uint32_t u_int32_t;
126 typedef uint16_t u_int16_t;
127 typedef uint8_t u_int8_t;
129 #define MSG_DONTWAIT 0
133 typedef int sock2len_t;
137 #define CloseSocket(x) close(x)
143 typedef int socklen_t;
144 #define sleep(x) Sleep(x * 1000)
145 #define srandom(x) srand(x)
146 #define random(x) rand(x)
147 #define lstat(x,y) stat(x,y)
148 #define CloseSocket(x) closesocket(x)
150 typedef unsigned short int u_int16_t;
151 typedef unsigned char u_int8_t;
153 #define MSG_DONTWAIT 0
155 #ifndef PROCESSOR_ARCHITECTURE_AMD64
156 #define PROCESSOR_ARCHITECTURE_AMD64 9
161 #define MSG_DONTWAIT MSG_NONBLOCK
165 extern const char *__local_name;
167 /*** Global prototypes ***/
168 /*** These functions will exit on error. No need to check return code ***/
170 /* for calloc: x = calloc(4,sizeof(char)) -> os_calloc(4,sizeof(char),x) */
171 #define os_calloc(x,y,z) ((z = (__typeof__(z)) calloc(x,y)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno))
173 #define os_strdup(x,y) ((y = strdup(x)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno))
175 #define os_malloc(x,y) ((y = (__typeof__(y)) malloc(x)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno))
177 #define os_free(x) (x)?free(x):merror("free a null")
179 #define os_realloc(x,y,z) ((z = (__typeof__(z))realloc(x,y)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno))
181 #define os_clearnl(x,p) if((p = strrchr(x, '\n')))*p = '\0';
189 #include "debug_op.h"
191 #include "agent_op.h"
197 #include "privsep_op.h"
198 #include "pthreads_op.h"
199 #include "regex_op.h"
202 #include "dirtree_op.h"
204 #include "store_op.h"
207 #include "validate_op.h"
208 #include "file-queue.h"
209 #include "read-agents.h"
210 #include "report_op.h"
211 #include "string_op.h"
212 #include "randombytes.h"
214 #include "os_xml/os_xml.h"
215 #include "os_regex/os_regex.h"
217 #include "error_messages/error_messages.h"
218 #include "custom_output_search.h"
220 #endif /* __SHARED_H */