diff --git a/src/core/charutil.cpp b/src/core/charutil.cpp index 78cab49..1bfea90 100644 --- a/src/core/charutil.cpp +++ b/src/core/charutil.cpp @@ -90,7 +90,7 @@ bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur, } else { -#ifndef __AROS__ +#if !IS_AROS mblen (NULL, 0); int len = mblen(&*cur, MB_CUR_MAX); if (len < 0) //invalid multibyte sequence, but let's not blow up. diff --git a/src/core/codeconvert.cpp b/src/core/codeconvert.cpp index 1ffd4c5..07d40f2 100755 --- a/src/core/codeconvert.cpp +++ b/src/core/codeconvert.cpp @@ -61,7 +61,7 @@ #define TSS_USE_UCS2_CCONV16 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_16_BITS) #define TSS_USE_UCS2_CCONV32 (!(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 && WCHAR_IS_32_BITS) -#ifdef __minix__ +#if ICONV_CONST_SOURCE # define ICONV_SOURCE_TYPE const char #else # define ICONV_SOURCE_TYPE char diff --git a/src/core/file.h b/src/core/file.h index 1889c9f..a98f099 100644 --- a/src/core/file.h +++ b/src/core/file.h @@ -47,7 +47,7 @@ #include "fileerror.h" #endif -#ifdef __MINT__ // for off_t +#if IS_MINT // for off_t #include #endif @@ -143,7 +143,7 @@ public: }; -#ifdef __AROS__ +#if IS_AROS class cArosPath { public: diff --git a/src/core/file_unix.cpp b/src/core/file_unix.cpp index 4c22b45..6a9225d 100644 --- a/src/core/file_unix.cpp +++ b/src/core/file_unix.cpp @@ -34,7 +34,7 @@ /* On GNU/Hurd, need to define _GNU_SOURCE in order to use O_NOATIME which technically is still a nonstandard extension to open() */ -#ifdef __gnu_hurd__ +#if IS_HURD # define _GNU_SOURCE #endif @@ -53,7 +53,7 @@ #include #include -#ifdef __hpux__ +#if IS_HPUX # include #endif @@ -104,7 +104,7 @@ cFile_i::~cFile_i() fclose( mpCurrStream ); mpCurrStream = NULL; -#ifdef __AROS__ +#if IS_AROS if( mFlags & cFile::OPEN_LOCKED_TEMP ) { // unlink this file @@ -219,7 +219,7 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) ); } -#ifndef __AROS__ +#if !IS_AROS if( flags & OPEN_LOCKED_TEMP ) { // unlink this file @@ -246,13 +246,11 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) fcntl(fh, F_NOCACHE, 1); #endif -#ifdef __sun +#if IS_SOLARIS if ((flags & OPEN_DIRECT) && (flags & OPEN_SCANNING)) directio(fh, DIRECTIO_ON); -#endif - -#ifdef __hpux__ - + +#elif IS_HPUX if (flags & OPEN_SCANNING) { if (flags & OPEN_DIRECT) @@ -460,7 +458,7 @@ void cFile::Truncate( File_t offset ) // throw(eFile) } -#ifdef __AROS__ +#if IS_AROS TSTRING cArosPath::AsPosix( const TSTRING& in ) { if (in[0] == '/') diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index c0158e4..09a2653 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -74,7 +74,7 @@ #include "config.h" #include #include -#ifndef _SORTIX_SOURCE +#if !IS_SORTIX # include #endif #include @@ -871,7 +871,7 @@ FILE *fp[]; return(mfpclose(indx, fp)); } -#ifdef __AROS__ +#if IS_AROS #define fork() vfork() #endif diff --git a/src/core/msystem.h b/src/core/msystem.h index 09aee38..9f0a13e 100644 --- a/src/core/msystem.h +++ b/src/core/msystem.h @@ -54,6 +54,9 @@ /* * forward declarations */ + +#include "platform.h" + #ifdef __STDC__ void le_clobber(void); int le_set(const char*); @@ -114,7 +117,7 @@ int echild(); # define GID_RESET -2 /* reset EGID to RGID */ #endif #ifndef DEF_PATH -# ifdef __FreeBSD_cc_version +# if IS_FREEBSD # define DEF_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" /* default search path */ # else # define DEF_PATH "PATH=/bin:/usr/bin:/usr/ucb" /* default search path */ diff --git a/src/core/platform.h b/src/core/platform.h index 61284a0..29d229c 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -64,7 +64,6 @@ #define OS_DARWIN 0x0304 #define OS_DRAGONFLYBSD 0x0305 #define OS_MIDNIGHTBSD 0x0306 -#define OS_HARDENEDBSD 0x0307 #define OS_SOLARIS 0x0400 #define OS_AIX 0x0401 @@ -137,14 +136,28 @@ #define OS OS_FREEBSD #define IS_FREEBSD 1 -// add NetBSD, OpenBSD, other BSDs - +#elif defined(__NetBSD__) + #define OS OS_NETBSD + #define IS_NETBSD 1 + +#elif defined(__OpenBSD__) + #define OS OS_OPENBSD + #define IS_OPENBSD 1 + #elif defined(_OSX) #define OS OS_DARWIN #define IS_DARWIN 1 - -#elif defined(_SOLARIS) +#elif defined(__DragonFly__) + #define OS OS_DRAGONFLYBSD + #define IS_DRAGONFLYBSD 1 + +#elif defined(__MidnightBSD__) + #define OS OS_MIDNIGHTBSD + #define IS_MIDNIGHTBSD 1 + + +#elif defined(_SOLARIS) || defined(__sun) #define OS OS_SOLARIS #define IS_SOLARIS 1 @@ -164,13 +177,19 @@ #define OS OS_OSF1 #define IS_OSF1 1 - -// need Minix, Haiku - + +#elif defined(__minix__) + #define OS OS_MINIX + #define IS_MINIX 1 + #elif defined(__gnu_hurd__) #define OS OS_HURD #define IS_HURD 1 - + +#elif defined(__HAIKU__) + #define OS OS_HAIKU + #define IS_HAIKU 1 + #elif defined(__SYLLABLE__) #define OS OS_SYLLABLE #define IS_SYLLABLE 1 @@ -274,6 +293,16 @@ #define SUPPORTS_MEMBER_TEMPLATES ( ! IS_SUNPRO ) #define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST ( ! IS_SUNPRO ) +#define SUPPORTS_ST_BLOCKS (!IS_DOS_DJGPP) +#define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP) +#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP) +#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS) +#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX) +#define USES_MBLEN (!IS_ANDROID && !IS_AROS) +#define ICONV_CONST_SOURCE (IS_MINIX) + + + //============================================================================= // Miscellaneous // diff --git a/src/core/stringutil.cpp b/src/core/stringutil.cpp index 3663d03..bb3fecc 100644 --- a/src/core/stringutil.cpp +++ b/src/core/stringutil.cpp @@ -137,7 +137,7 @@ inline bool tss_find_in_hash( const wc16_string& lhs, TSTRING& rhs ) std::string::const_iterator cStringUtil::Convert( std::string& nbs, const wc16_string& dbs ) { -#ifdef __AROS__ +#if IS_AROS nbs.resize(dbs.length()); for (int x=0; x &v, bool bFullPaths) const throw(eFSServices) { #else @@ -326,7 +326,7 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) { } -#ifndef __AROS__ +#if !IS_AROS void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices) { #else @@ -369,7 +369,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const th stat.size = statbuf.st_size; stat.uid = statbuf.st_uid; stat.blksize = statbuf.st_blksize; -#ifndef __DJGPP__ +#if SUPPORTS_ST_BLOCKS stat.blocks = statbuf.st_blocks; #else stat.blocks = 0; @@ -409,7 +409,7 @@ void cUnixFSServices::GetMachineNameFullyQualified( TSTRING& strName ) const char buf[256]; if (gethostname(buf, 256) != 0) { -#if defined(SOLARIS_NO_GETHOSTBYNAME) || defined(_SORTIX_SOURCE) || defined(__DJGPP__) +#if defined(SOLARIS_NO_GETHOSTBYNAME) || !SUPPORTS_NETWORKING strName = buf; return; #else @@ -464,7 +464,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress ) bool fGotAddress = false; cDebug d( _T("cUnixFSServices::GetIPAddress") ); -#if !defined(_SORTIX_SOURCE) && !defined(__DJGPP__) +#if SUPPORTS_NETWORKING struct utsname utsnameBuf; if( EFAULT != uname( &utsnameBuf) ) { diff --git a/src/cryptlib/misc.h b/src/cryptlib/misc.h index 95a4711..664d993 100644 --- a/src/cryptlib/misc.h +++ b/src/cryptlib/misc.h @@ -9,7 +9,7 @@ #include #endif -#if defined(__MINT__) || defined(__MSDOS__) // has memory.h, but memset defined in string.h anyway. +#if IS_MINT || IS_DOS_DJGPP // has memory.h, but memset defined in string.h anyway. #include #endif diff --git a/src/fs/fsparserutil.cpp b/src/fs/fsparserutil.cpp index e4f6979..5ca28ea 100644 --- a/src/fs/fsparserutil.cpp +++ b/src/fs/fsparserutil.cpp @@ -137,7 +137,7 @@ void cFSParserUtil::InterpretFCOName( const std::list& l, cFCOName& nam for( std::list::const_iterator i = l.begin(); i != l.end(); i++ ) strT += *i; -#ifdef __AROS__ +#if IS_AROS strT = cArosPath::AsPosix(strT); #endif diff --git a/src/siggen/siggenstrings.cpp b/src/siggen/siggenstrings.cpp index d627a24..fb8a8c2 100644 --- a/src/siggen/siggenstrings.cpp +++ b/src/siggen/siggenstrings.cpp @@ -42,7 +42,7 @@ #include "stdsiggen.h" #include "siggenstrings.h" -#ifdef __AROS__ +#if IS_AROS # define VERSION_PREFIX "$VER: " #else # define VERSION_PREFIX "@(#)" diff --git a/src/tripwire/smtpmailmessage.cpp b/src/tripwire/smtpmailmessage.cpp index a16a20b..472b098 100644 --- a/src/tripwire/smtpmailmessage.cpp +++ b/src/tripwire/smtpmailmessage.cpp @@ -56,7 +56,7 @@ #include #include -#ifdef _SORTIX_SOURCE +#if !IS_SORTIX # include #endif @@ -72,7 +72,7 @@ #define INVALID_SOCKET -1 -#ifdef __AROS__ +#if IS_AROS #ifndef HAVE_GETHOSTNAME #define HAVE_GETHOSTNAME 1 #endif @@ -177,7 +177,7 @@ long cSMTPMailMessage::GetServerAddress() } else { -#if defined(_SORTIX_SOURCE) || !defined(HAVE_SYS_SOCKET_H) +#if IS_SORTIX || !defined(HAVE_SYS_SOCKET_H) return INADDR_NONE; #else // do a DNS lookup of the hostname and get the long diff --git a/src/tripwire/syslog_trip.cpp b/src/tripwire/syslog_trip.cpp index c178e6b..66da277 100644 --- a/src/tripwire/syslog_trip.cpp +++ b/src/tripwire/syslog_trip.cpp @@ -49,7 +49,7 @@ #include "tw/twerrors.h" #include "tw/twstrings.h" -#ifdef __AROS__ +#if IS_AROS #include #define openlog(a,b,c) #define closelog() @@ -60,8 +60,9 @@ /////////////////////////////////////////////////////////////////////////////// void cSyslog::Log(const TCHAR* programName, cSyslog::LogType logType, const TCHAR* message) { -#if HAVE_SYSLOG_H && !defined(SKYOS) // Handle an oddball OS that has syslog.h but doesn't implement the calls. - +// SkyOS has syslog.h but doesn't actually implement the calls. +#if SUPPORTS_SYSLOG + (void)logType; // logType is not used for Unix syslog ASSERT(sizeof(TCHAR) == sizeof(char)); diff --git a/src/tripwire/tripwirestrings.cpp b/src/tripwire/tripwirestrings.cpp index 12cffdf..b254d18 100644 --- a/src/tripwire/tripwirestrings.cpp +++ b/src/tripwire/tripwirestrings.cpp @@ -34,7 +34,7 @@ #include "stdtripwire.h" #include "tripwirestrings.h" -#ifdef __AROS__ +#if IS_AROS # define VERSION_PREFIX "$VER: " #else # define VERSION_PREFIX "@(#)" diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index 21f4162..fa02298 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -296,7 +296,7 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory); if (temp_directory.length() == 0) { -#ifdef __AROS__ +#if IS_AROS temp_directory = "T:"; #else temp_directory = "/tmp/"; @@ -311,7 +311,7 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) // make sure it exists... // -#ifdef __AROS__ +#if IS_AROS temp_directory = cArosPath::AsNative(temp_directory); #endif diff --git a/src/tw/twinit.cpp b/src/tw/twinit.cpp index f21f9b1..f3a057e 100644 --- a/src/tw/twinit.cpp +++ b/src/tw/twinit.cpp @@ -79,7 +79,7 @@ #include "core/tw_signal.h" // to ignore SIGPIPE #endif -#ifdef __AROS__ +#if IS_AROS #include #include #include @@ -246,7 +246,7 @@ void cTWInit::Init( const TSTRING& strArgv0 ) // END:RAD // ------------------------------------------------------------ -#ifdef __AROS__ +#if IS_AROS aros_socketbase_init(); #endif // @@ -284,7 +284,7 @@ void cTWInit::Init( const TSTRING& strArgv0 ) mpData->et.SetChild( &mpData->er ); errorQueue.SetChild( &mpData->et ); -#if IS_UNIX && !defined(__DJGPP__) +#if SUPPORTS_POSIX_SIGNALS // ignore SIGPIPE tw_sigign(SIGPIPE); //TODO: somebody add comment here! @@ -316,7 +316,7 @@ void cTWInit::Init( const TSTRING& strArgv0 ) } -#ifdef __AROS__ +#if IS_AROS struct Library* SocketBase=0; bool aros_socketbase_init() diff --git a/src/tw/twutil.cpp b/src/tw/twutil.cpp index a9bb8e7..c6979ba 100644 --- a/src/tw/twutil.cpp +++ b/src/tw/twutil.cpp @@ -1141,7 +1141,7 @@ void cTWUtil::GetString(wc16_string& ret) #endif // tcsetattr doesn't seem to work on AROS, so tweak ANSI terminal settings to hide passphrases. -#ifdef __AROS__ +#if IS_AROS printf("\e[8m"); // set the 'concealed' flag fflush(stdout); #endif @@ -1154,7 +1154,7 @@ void cTWUtil::GetString(wc16_string& ret) TCOUT.flush(); len = read( 0, buf, MAX_STRING ); -#ifdef __AROS__ +#if IS_AROS printf("\e[0m"); // reset back to normal text fflush(stdout); #endif diff --git a/src/twadmin/twadmincl.cpp b/src/twadmin/twadmincl.cpp index 0dc5012..19dc79a 100644 --- a/src/twadmin/twadmincl.cpp +++ b/src/twadmin/twadmincl.cpp @@ -63,7 +63,7 @@ #include "core/displayencoder.h" //Provide a swab() impl. from glibc, for platforms that don't have one -#if defined(__SYLLABLE__) || defined(__ANDROID_API__) || defined(_SORTIX_SOURCE) +#if NEEDS_SWAB_IMPL void swab (const void *bfrom, void *bto, ssize_t n) { const char *from = (const char *) bfrom; diff --git a/src/twadmin/twadminstrings.cpp b/src/twadmin/twadminstrings.cpp index c23a688..d32e94b 100644 --- a/src/twadmin/twadminstrings.cpp +++ b/src/twadmin/twadminstrings.cpp @@ -39,7 +39,7 @@ #include "twadmin.h" #include "twadminstrings.h" -#ifdef __AROS__ +#if IS_AROS # define VERSION_PREFIX "$VER: " #else # define VERSION_PREFIX "@(#)" diff --git a/src/twparser/policyparser.cpp b/src/twparser/policyparser.cpp index c9ba3a7..bdedd97 100644 --- a/src/twparser/policyparser.cpp +++ b/src/twparser/policyparser.cpp @@ -209,7 +209,7 @@ std::string convert_to_encoded_hex( char ch ) std::string util_ConvertMB( const std::string& sIn ) { -#if defined(__ANDROID_API__) || defined(__AROS__) +#if !USES_MBLEN return sIn; #else cDebug d( "cPolicyParser::util_ConvertMB" ); diff --git a/src/twprint/twprintstrings.cpp b/src/twprint/twprintstrings.cpp index a49caac..1930851 100644 --- a/src/twprint/twprintstrings.cpp +++ b/src/twprint/twprintstrings.cpp @@ -39,7 +39,7 @@ #include "twprint.h" #include "twprintstrings.h" -#ifdef __AROS__ +#if IS_AROS # define VERSION_PREFIX "$VER: " #else # define VERSION_PREFIX "@(#)"