1 /* @(#) $Id: shared.h,v 1.47 2009/09/17 18:47:23 dcid Exp $ */
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 3) 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;
135 /* For Windows (so high maintenance :)) */
139 typedef int socklen_t;
140 #define sleep(x) Sleep(x * 1000)
141 #define srandom(x) srand(x)
142 #define random(x) rand(x)
143 #define lstat(x,y) stat(x,y)
145 typedef unsigned short int u_int16_t;
146 typedef unsigned char u_int8_t;
147 /* typedef closesocket close; */
149 #define MSG_DONTWAIT 0
151 #ifndef PROCESSOR_ARCHITECTURE_AMD64
152 #define PROCESSOR_ARCHITECTURE_AMD64 9
158 #define MSG_DONTWAIT MSG_NONBLOCK
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 = calloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
173 #define os_strdup(x,y) (y = strdup(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
175 #define os_malloc(x,y) (y = malloc(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
177 #define os_free(x) (x)?free(x):merror("free a null")
179 #define os_realloc(x,y,z) (z = realloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0)
181 #define os_clearnl(x,p) if((p = strrchr(x, '\n')))*p = '\0';
191 #include "debug_op.h"
193 #include "agent_op.h"
198 #include "privsep_op.h"
199 #include "pthreads_op.h"
200 #include "regex_op.h"
203 #include "dirtree_op.h"
205 #include "store_op.h"
208 #include "validate_op.h"
209 #include "file-queue.h"
210 #include "read-agents.h"
211 #include "report_op.h"
213 #include "os_xml/os_xml.h"
214 #include "os_regex/os_regex.h"
216 #include "error_messages/error_messages.h"
219 #endif /* __SHARED_H */