00001
00014 #ifndef SYSCONFIG_H
00015 #define SYSCONFIG_H
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00044 #if ( defined (__WIN32__) || defined (_WIN32) ) && !defined (WIN32)
00045 #define WIN32 1
00046 #elif defined(__CYGWIN__)
00047 #define UNIX 1
00048 #endif
00049
00050 #if !defined(UNIX) && !defined(WIN32) && !defined(__cplusplus)
00051 #error Unsupported compiler and/or operating system.
00052 #error Please update sysconfig.h with your compiler or OS information.
00053 #endif
00054
00059 #ifdef WIN32
00060 #define WIN32_LEAN_AND_MEAN 1
00061 #endif
00062
00063
00064
00065 #ifdef UNIX
00066 #define _MULTI_THREADED
00067 #endif
00068
00069
00070 #ifdef _MSC_VER
00071 #pragma warning(disable:4786) // names over 255 characters in templates
00072 #pragma warning(disable:4068) // unknown pragma warnings
00073 #pragma warning(disable:4101) // unreferenced variables
00074 #endif
00075
00076
00077 #include <iostream>
00078 #include <fstream>
00079 #include <list>
00080 #include <queue>
00081 #include <string>
00082 #include <exception>
00083
00084 #include <cstdio>
00085 #include <ctime>
00086 #if defined(WIN32) && defined(__BORLANDC__)
00087 #include <cprocess>
00088 #endif
00089
00094 using namespace std;
00095
00096 #if defined(WIN32)
00097 #include <winsock2.h>
00098 #else
00099 #include <netinet/in.h>
00100 #include <sys/socket.h>
00101 #include <sys/ioctl.h>
00102 #endif
00103
00104
00105 #if defined(WIN32) && defined(_MSC_VER)
00106 #include <process.h>
00107 #endif
00108
00109
00110 #if defined(UNIX)
00111 #include <pthread.h>
00112 #include <unistd.h>
00113 #include <stdarg.h>
00114 #endif
00115 #pragma hdrstop
00116
00117
00118
00119
00120
00121
00122
00123 #if defined(WIN32)
00124
00125 typedef unsigned long THREADHANDLE_T;
00126 #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \
00127 T_HANDLE = _beginthread((FUNCTION), (STACKSIZE), (ARGS));
00128 #elif defined(UNIX)
00129
00130 typedef int SOCKET;
00131 #define INVALID_SOCKET -1 // Better look for side-effects with this! - 0 on Windows
00132 #define SOCKET_ERROR -1
00133 #define WSAEWOULDBLOCK EWOULDBLOCK // Used in Server and Socket
00134 #define SD_SEND SHUT_WR // Used in Server::Disconnect
00135 #define closesocket(X) close(X)
00136 #define WSAGetLastError(X) errno
00137 #define ioctlsocket(X,Y,Z) ioctl(X,Y,Z)
00138
00139 #define InitializeCriticalSection(X) *(X) = PTHREAD_MUTEX_INITIALIZER;
00140 #define DeleteCriticalSection(X)
00141 #define CRITICAL_SECTION pthread_mutex_t
00142 #define EnterCriticalSection(X) pthread_mutex_lock(X);
00143 #define LeaveCriticalSection(X) pthread_mutex_unlock(X);
00144
00145
00146 typedef pthread_t THREADHANDLE_T;
00147 #define StartThread(T_HANDLE, FUNCTION, STACKSIZE, ARGS) \
00148 pthread_create(&(T_HANDLE), NULL, (FUNCTION), (ARGS));
00149 #define WaitForSingleObject(T_HANDLE, WAIT) \
00150 pthread_join(*(T_HANDLE), NULL)
00151 #endif
00152
00153 #endif // SYSCONFIG_H