X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=blobdiff_plain;f=src%2Fheaders%2Fshared.h;h=40e4d38854a1ba864b5547d46290e697be0c1c41;hb=HEAD;hp=d3e019bcb20cb05118b154b5f6208617330ab6c6;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/headers/shared.h b/src/headers/shared.h old mode 100755 new mode 100644 index d3e019b..40e4d38 --- a/src/headers/shared.h +++ b/src/headers/shared.h @@ -1,38 +1,31 @@ -/* @(#) $Id: shared.h,v 1.47 2009/09/17 18:47:23 dcid Exp $ */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ -/* v0.3 (2007/12/23): Adding SSP & FORTIFY_SOURCE - * v0.2 (2005/12/23): Adding 'u_int16_t' for Solaris. - * v0.1 (2005/10/27): first version. - */ - /* * The stack smashing protector defeats some BoF via: gcc -fstack-protector * Reference: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/cpp.pdf */ - + #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) && (__GNUC_PATCHLEVEL__ >= 2)) || \ ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || \ (__GNUC__ >= 5)) -/* Heuristicly enable the stack protector on sensitive functions */ +/* Heuristically enable the stack protector on sensitive functions */ #define __SSP__ 1 -/* FORTIFY_SOURCE is Redhat / Fedora specific */ +/* FORTIFY_SOURCE is RedHat / Fedora specific */ #define FORTIFY_SOURCE #endif #ifndef __SHARED_H - #define __SHARED_H + #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif @@ -41,15 +34,16 @@ #define _FILE_OFFSET_BITS 64 #endif - /* Global headers */ #include #include #include #include +#ifdef __OpenBSD__ +#include +#endif -/* Making windows happy */ #ifndef WIN32 #include @@ -59,7 +53,8 @@ #endif #include -#endif +#endif /* WIN32 */ + #include #include #include @@ -70,18 +65,29 @@ #include #include -/* Making Windows happy */ -#ifndef WIN32 +/* The mingw32 builder used by travis.ci can't find glob.h + * Yet glob must work on actual win32. + */ +#ifndef __MINGW32__ #include +#endif + +#ifndef WIN32 #include #include #include #include #include #else +/* WINVER needs to be 0x0501 or higher to pull in IPv6 functions */ +#ifndef WINVER +#define WINVER 0x0501 +#endif +#include #include -#include #include +#include +#include #endif #include @@ -100,7 +106,6 @@ #define _FILE_OFFSET_BITS 64 #endif - /* Global portability code */ #ifdef SOLARIS @@ -115,8 +120,6 @@ typedef uint8_t u_int8_t; #endif /* SOLARIS */ - -/* For HP-UX */ #if defined HPUX #include typedef uint32_t u_int32_t; @@ -126,13 +129,14 @@ typedef uint8_t u_int8_t; #define MSG_DONTWAIT 0 #endif - -/* For Darwin */ #ifdef Darwin typedef int sock2len_t; #endif -/* For Windows (so high maintenance :)) */ +#ifndef WIN32 +#define CloseSocket(x) close(x) +#endif + #ifdef WIN32 typedef int uid_t; typedef int gid_t; @@ -141,57 +145,52 @@ typedef int socklen_t; #define srandom(x) srand(x) #define random(x) rand(x) #define lstat(x,y) stat(x,y) +#define CloseSocket(x) closesocket(x) void WinSetError(); typedef unsigned short int u_int16_t; typedef unsigned char u_int8_t; -/* typedef closesocket close; */ #define MSG_DONTWAIT 0 #ifndef PROCESSOR_ARCHITECTURE_AMD64 - #define PROCESSOR_ARCHITECTURE_AMD64 9 -#endif +#define PROCESSOR_ARCHITECTURE_AMD64 9 #endif +#endif /* WIN32 */ -/* For AIX */ #ifdef AIX #define MSG_DONTWAIT MSG_NONBLOCK #endif - - /* Local name */ -char *__local_name; - +extern const char *__local_name; /*** Global prototypes ***/ /*** These functions will exit on error. No need to check return code ***/ /* for calloc: x = calloc(4,sizeof(char)) -> os_calloc(4,sizeof(char),x) */ -#define os_calloc(x,y,z) (z = calloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0) +#define os_calloc(x,y,z) ((z = (__typeof__(z)) calloc(x,y)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno)) -#define os_strdup(x,y) (y = strdup(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0) +#define os_strdup(x,y) ((y = strdup(x)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno)) -#define os_malloc(x,y) (y = malloc(x))?(void)1:ErrorExit(MEM_ERROR, ARGV0) +#define os_malloc(x,y) ((y = (__typeof__(y)) malloc(x)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno)) #define os_free(x) (x)?free(x):merror("free a null") -#define os_realloc(x,y,z) (z = realloc(x,y))?(void)1:ErrorExit(MEM_ERROR, ARGV0) +#define os_realloc(x,y,z) ((z = (__typeof__(z))realloc(x,y)))?(void)1:ErrorExit(MEM_ERROR, __local_name, errno, strerror(errno)) #define os_clearnl(x,p) if((p = strrchr(x, '\n')))*p = '\0'; #ifdef CLIENT - #define isAgent 1 +#define isAgent 1 #else - #define isAgent 0 +#define isAgent 0 #endif - - #include "debug_op.h" #include "wait_op.h" #include "agent_op.h" #include "file_op.h" +#include "fs_op.h" #include "mem_op.h" #include "math_op.h" #include "mq_op.h" @@ -209,13 +208,14 @@ char *__local_name; #include "file-queue.h" #include "read-agents.h" #include "report_op.h" +#include "string_op.h" +#include "randombytes.h" #include "os_xml/os_xml.h" #include "os_regex/os_regex.h" #include "error_messages/error_messages.h" - +#include "custom_output_search.h" #endif /* __SHARED_H */ - -/* EOF */ +