Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

platform.h

Go to the documentation of this file.
00001 #ifndef ABUSEPLATFORM_H
00002 
00003 #define ABUSEPLATFORM_H
00004 
00005 
00006 
00007 //platform dependent definitions and includes
00008 
00009 
00010 
00011 #ifdef WIN32
00012 
00013 
00014 
00015 #define _WIN32_IE 0x0500 //for compatibility...
00016 
00017 #include <winsock2.h>
00018 
00019 #include <abuse/Win32Initializer.h>
00020 
00021 #define INITNETLIB const Win32Initializer& __initlib__=Win32Initializer::get();
00022 
00023 #define socklen_t int
00024 
00025 #define THREADHANDLE HANDLE
00026 
00027 #define CONDVAR    HANDLE
00028 
00029 #define CONDVARPTR HANDLE
00030 
00031 #define THREADRETVALUE DWORD
00032 
00033 typedef HANDLE WaitableObjectPtr;
00034 
00035 #else
00036 
00037 
00038 
00039 #pragma message("Compiles only on win32")
00040 
00041 #define INITNETLIB
00042 
00043 #include <sys/socket.h>
00044 
00045 #include <netinet/in.h>
00046 
00047 #include <errno.h>
00048 
00049 #include <netdb.h>
00050 
00051 #include <arpa/inet.h>
00052 
00053 #include <unistd.h>
00054 
00055 #include <sys/ioctl.h>
00056 
00057 #include <pthread.h>
00058 
00059 #ifdef _DEBUG //for OutputDebugString
00060 
00061 #include <iostream>
00062 
00063 #endif
00064 
00065 #define _inline inline
00066 
00067 #define INVALID_SOCKET -1
00068 
00069 #define SOCKET_ERROR   -1
00070 
00071 #define closesocket close
00072 
00073 #define ioctlsocket ioctl
00074 
00075 #define _strnicmp strncasecmp
00076 
00077 #define wsprintf sprintf
00078 
00079 #define MAX_COMPUTERNAME_LENGTH 1024
00080 
00081 #define MAX_PATH   1024
00082 
00083 #define THREADHANDLE pthread_t
00084 
00085 #define CONDVAR      pthread_cond_t
00086 
00087 #define CONDVARPTR   pthread_cond_t*
00088 
00089 #define THREADRETVALUE void*
00090 
00091 #define WSAGetLastError GetLastError
00092 
00093 #define ZeroMemory bzero
00094 
00095 typedef int SOCKET;
00096 
00097 typedef pid_t HMODULE;
00098 
00099 typedef unsigned long DWORD;
00100 
00101 typedef unsigned char UCHAR;
00102 
00103 typedef unsigned char BYTE;
00104 
00105 typedef unsigned short int WORD;
00106 
00107 typedef char* LPSTR;
00108 
00109 typedef const char* LPCSTR;
00110 
00111 typedef void* LPVOID;
00112 
00113 typedef pthread_mutex_t CRITICAL_SECTION;
00114 
00115 #ifndef BOOL
00116 
00117 typedef bool BOOL;
00118 
00119 #endif
00120 
00121 #ifndef TRUE
00122 
00123 #define TRUE true
00124 
00125 #endif
00126 
00127 #ifndef FALSE
00128 
00129 #define FALSE false
00130 
00131 #endif
00132 
00133 inline int GetLastError(){return errno;}
00134 
00135 inline void Sleep(int millis)
00136 
00137 {
00138 
00139   timespec towait,result;
00140 
00141   towait.tv_sec=millis/1000;
00142 
00143   towait.tv_nsec=(millis%1000)*1000;
00144 
00145   nanosleep(&towait,&result);
00146 
00147 }
00148 
00149 #ifdef _DEBUG
00150 
00151 inline void OutputDebugString(const char* msg)
00152 
00153 {
00154 
00155   std::cerr<<msg;
00156 
00157 }
00158 
00159 #endif
00160 
00161 /*Sync helper, implemented in Utils.cpp*/
00162 
00163 //Forward decl
00164 
00165 class WaitableObject;
00166 
00167 typedef WaitableObject* WaitableObjectPtr;
00168 
00169 DWORD WaitForMultipleObjects(DWORD howmany,const WaitableObjectPtr* array,BOOL WaitForAll,DWORD dwMillis);
00170 
00171 DWORD WaitForSingleObject(const WaitableObject* object,DWORD dwMills);
00172 
00173 //ret values
00174 
00175 #define WAIT_OBJECT_0  0
00176 
00177 #define WAIT_TIMEOUT   (DWORD)-1
00178 
00179 #endif 
00180 
00181 
00182 
00183 #endif
00184 
00185 
00186 

Generated on Thu Jun 16 00:13:14 2005 for Netlib for Abuse! by  doxygen 1.4.3