1 /* @(#) $Id: ./src/headers/shared.h, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
13 /* v0.3 (2007/12/23): Adding SSP & FORTIFY_SOURCE <jeffschroeder@computer.org>
14 * v0.2 (2005/12/23): Adding 'u_int16_t' for Solaris.
15 * v0.1 (2005/10/27): first version.
19 * The stack smashing protector defeats some BoF via: gcc -fstack-protector
20 * Reference: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/cpp.pdf
23 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) && (__GNUC_PATCHLEVEL__ >= 2)) || \
24 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || \
27 /* Heuristicly enable the stack protector on sensitive functions */
30 /* FORTIFY_SOURCE is Redhat / Fedora specific */
31 #define FORTIFY_SOURCE
37 #ifndef _LARGEFILE64_SOURCE
38 #define _LARGEFILE64_SOURCE
41 #ifndef _FILE_OFFSET_BITS
42 #define _FILE_OFFSET_BITS 64
47 #include <sys/types.h>
50 #include <sys/param.h>
53 /* Making windows happy */
57 /* HPUX does not have select.h */
59 #include <sys/select.h>
62 #include <sys/utsname.h>
74 /* Making Windows happy */
78 #include <netinet/in.h>
79 #include <arpa/inet.h>
80 #include <sys/socket.h>
98 #ifndef _LARGEFILE64_SOURCE
99 #define _LARGEFILE64_SOURCE
102 #ifndef _FILE_OFFSET_BITS
103 #define _FILE_OFFSET_BITS 64
107 /* Global portability code */
111 typedef uint32_t u_int32_t;
112 typedef uint16_t u_int16_t;
113 typedef uint8_t u_int8_t;
116 #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
135 typedef int sock2len_t;
140 #define CloseSocket(x) close(x)
148 typedef int socklen_t;
149 #define sleep(x) Sleep(x * 1000)
150 #define srandom(x) srand(x)
151 #define random(x) rand(x)
152 #define lstat(x,y) stat(x,y)
153 #define CloseSocket(x) closesocket(x)
155 typedef unsigned short int u_int16_t;
156 typedef unsigned char u_int8_t;
157 /* typedef closesocket close; */
159 #define MSG_DONTWAIT 0
161 #ifndef PROCESSOR_ARCHITECTURE_AMD64
162 #define PROCESSOR_ARCHITECTURE_AMD64 9
168 #define MSG_DONTWAIT MSG_NONBLOCK
177 /*** Global prototypes ***/
178 /*** These functions will exit on error. No need to check return code ***/
180 /* for calloc: x = calloc(4,sizeof(char)) -> os_calloc(4,sizeof(char),x) */
181 #define os_calloc(x,y,z) (z = calloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
183 #define os_strdup(x,y) (y = strdup(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
185 #define os_malloc(x,y) (y = malloc(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
187 #define os_free(x) (x)?free(x):merror("free a null")
189 #define os_realloc(x,y,z) (z = realloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
191 #define os_clearnl(x,p) if((p = strrchr(x, '\n')))*p = '\0';
201 #include "debug_op.h"
203 #include "agent_op.h"
208 #include "privsep_op.h"
209 #include "pthreads_op.h"
210 #include "regex_op.h"
213 #include "dirtree_op.h"
215 #include "store_op.h"
218 #include "validate_op.h"
219 #include "file-queue.h"
220 #include "read-agents.h"
221 #include "report_op.h"
222 #include "string_op.h"
224 #include "os_xml/os_xml.h"
225 #include "os_regex/os_regex.h"
227 #include "error_messages/error_messages.h"
230 #endif /* __SHARED_H */