3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
12 /* v0.3 (2007/12/23): Adding SSP & FORTIFY_SOURCE <jeffschroeder@computer.org>
13 * v0.2 (2005/12/23): Adding 'u_int16_t' for Solaris.
14 * v0.1 (2005/10/27): first version.
18 * The stack smashing protector defeats some BoF via: gcc -fstack-protector
19 * Reference: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/cpp.pdf
22 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) && (__GNUC_PATCHLEVEL__ >= 2)) || \
23 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || \
26 /* Heuristicly enable the stack protector on sensitive functions */
29 /* FORTIFY_SOURCE is Redhat / Fedora specific */
30 #define FORTIFY_SOURCE
36 #ifndef _LARGEFILE64_SOURCE
37 #define _LARGEFILE64_SOURCE
40 #ifndef _FILE_OFFSET_BITS
41 #define _FILE_OFFSET_BITS 64
46 #include <sys/types.h>
49 #include <sys/param.h>
52 /* Making windows happy */
56 /* HPUX does not have select.h */
58 #include <sys/select.h>
61 #include <sys/utsname.h>
73 /* Making Windows happy */
77 #include <netinet/in.h>
78 #include <arpa/inet.h>
79 #include <sys/socket.h>
95 #ifndef _LARGEFILE64_SOURCE
96 #define _LARGEFILE64_SOURCE
99 #ifndef _FILE_OFFSET_BITS
100 #define _FILE_OFFSET_BITS 64
104 /* Global portability code */
108 typedef uint32_t u_int32_t;
109 typedef uint16_t u_int16_t;
110 typedef uint8_t u_int8_t;
113 #define va_copy __va_copy
122 typedef uint32_t u_int32_t;
123 typedef uint16_t u_int16_t;
124 typedef uint8_t u_int8_t;
126 #define MSG_DONTWAIT 0
132 typedef int sock2len_t;
137 #define CloseSocket(x) close(x)
145 typedef int socklen_t;
146 #define sleep(x) Sleep(x * 1000)
147 #define srandom(x) srand(x)
148 #define random(x) rand(x)
149 #define lstat(x,y) stat(x,y)
150 #define CloseSocket(x) closesocket(x)
152 typedef unsigned short int u_int16_t;
153 typedef unsigned char u_int8_t;
154 /* typedef closesocket close; */
156 #define MSG_DONTWAIT 0
158 #ifndef PROCESSOR_ARCHITECTURE_AMD64
159 #define PROCESSOR_ARCHITECTURE_AMD64 9
165 #define MSG_DONTWAIT MSG_NONBLOCK
174 /*** Global prototypes ***/
175 /*** These functions will exit on error. No need to check return code ***/
177 /* for calloc: x = calloc(4,sizeof(char)) -> os_calloc(4,sizeof(char),x) */
178 #define os_calloc(x,y,z) (z = calloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
180 #define os_strdup(x,y) (y = strdup(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
182 #define os_malloc(x,y) (y = malloc(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
184 #define os_free(x) (x)?free(x):merror("free a null")
186 #define os_realloc(x,y,z) (z = realloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
188 #define os_clearnl(x,p) if((p = strrchr(x, '\n')))*p = '\0';
198 #include "debug_op.h"
200 #include "agent_op.h"
205 #include "privsep_op.h"
206 #include "pthreads_op.h"
207 #include "regex_op.h"
210 #include "dirtree_op.h"
212 #include "store_op.h"
215 #include "validate_op.h"
216 #include "file-queue.h"
217 #include "read-agents.h"
218 #include "report_op.h"
220 #include "os_xml/os_xml.h"
221 #include "os_regex/os_regex.h"
223 #include "error_messages/error_messages.h"
226 #endif /* __SHARED_H */