/*! \file sysconfig.h The intent of this header file is to put operating system or compiler specific configuration information in one place. It also holds common includes for convenience. \author Jon A. Lambert \date 05/02/2003 \version 0.30 \remarks Global headers like this tend to get a little out of control and populated with a lot of crap. However... I'll be careful. */ #ifndef SYSCONFIG_H #define SYSCONFIG_H /* \def __BORLANDC__ Manifest constant present in all Borland compilers that contains the compiler version number. */ /* \def __CYGWIN__ Manifest constant present in cygwin compilers. */ /* \def _MSC_VER Manifest constant present in all Microsoft Visual C compilers that contains the compiler version number. */ /*! \def WIN32 Pre-processor directive the we will or may use to indicate that Paradigm compilation will be done for Windows operating systems. This is auto-detected from fairly common __WIN32__ or _WIN32 manifest constant. */ /*! \def UNIX Pre-processor directive the we will or may use to indicate that Paradigm compilation will be done for Unix operating systems. This is the default if Windows is not detected. */ #if ( defined (__WIN32__) || defined (_WIN32) ) && !defined (WIN32) #define WIN32 1 #elif defined(__CYGWIN__) #define UNIX 1 #endif #if !defined(UNIX) && !defined(WIN32) && !defined(__cplusplus) #error Unsupported compiler and/or operating system. #error Please update sysconfig.h with your compiler or OS information. #endif /*! \def WIN32_LEAN_AND_MEAN Pre-processor directive used to limit inclusion of unneccesary windows header files. Defined in windows header files. */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN 1 #endif // BC++ uses _MT which is a manifest constant picked by compiler options. // VC++ 6.0 compiler options by default are multi-threaded #ifdef UNIX #define _MULTI_THREADED #endif // Disable some noise and blather from VC++ compiler #ifdef _MSC_VER #pragma warning(disable:4786) // names over 255 characters in templates #pragma warning(disable:4068) // unknown pragma warnings #pragma warning(disable:4101) // unreferenced variables #endif // C++ STL headers used #include <iostream> #include <fstream> #include <list> #include <queue> #include <string> #include <exception> // C++ wrappers for C stdlib functions #include <cstdio> #include <ctime> #if defined(WIN32) && defined(__BORLANDC__) #include <cprocess> #endif /*! The std namespace is that used by the C++ STL. For laziness and convenience we'll use its namespace. */ using namespace std; #if defined(WIN32) #include <winsock2.h> #else #include <netinet/in.h> #include <sys/socket.h> #include <sys/ioctl.h> #endif // For threading - Borland has a cprocess header - see above #if defined(WIN32) && defined(_MSC_VER) #include <process.h> #endif // Additional headers required for Unix. #if defined(UNIX) #include <pthread.h> // pthreads library #include <unistd.h> #include <stdarg.h> // for variable arguments - used by Log #endif #pragma hdrstop /* This is a feeble attempt to minimize the changes to this code for Cygwin/Unix by making use of macros that disguise, hide, morph and otherwise obfuscate the code. With the side effect of confusing programmers looking at it. So I lied above when I said I'd be careful. */ #if defined(WIN32) // Thread stuff typedef unsigned long THREADHANDLE_T; #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \ T_HANDLE = _beginthread((FUNCTION), (STACKSIZE), (ARGS)); #elif defined(UNIX) // Network stuff typedef int SOCKET; #define INVALID_SOCKET -1 // Better look for side-effects with this! - 0 on Windows #define SOCKET_ERROR -1 #define WSAEWOULDBLOCK EWOULDBLOCK // Used in Server and Socket #define SD_SEND SHUT_WR // Used in Server::Disconnect #define closesocket(X) close(X) #define WSAGetLastError(X) errno #define ioctlsocket(X,Y,Z) ioctl(X,Y,Z) // Synchronization stuff #define InitializeCriticalSection(X) *(X) = PTHREAD_MUTEX_INITIALIZER; #define DeleteCriticalSection(X) #define CRITICAL_SECTION pthread_mutex_t #define EnterCriticalSection(X) pthread_mutex_lock(X); #define LeaveCriticalSection(X) pthread_mutex_unlock(X); // Thread stuff typedef pthread_t THREADHANDLE_T; #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \ pthread_create(&(T_HANDLE), NULL, (FUNCTION), (ARGS)); #define WaitForSingleObject(T_HANDLE, WAIT) \ pthread_join(*(T_HANDLE), NULL) #endif #endif // SYSCONFIG_H