platform.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include "stdio.h"
  3. #include "stdlib.h"
  4. #include "string.h"
  5. #ifdef _WIN32
  6. #include <winsock2.h>
  7. #include <Ws2tcpip.h>
  8. #include <io.h>
  9. #else
  10. #include <string>
  11. #include "unistd.h"
  12. #include "stdint.h"
  13. #include "limits.h"
  14. #include "fcntl.h"
  15. #include "dlfcn.h"
  16. #include "sys/types.h"
  17. #include "sys/socket.h"
  18. #include "sys/ioctl.h"
  19. #include "arpa/inet.h"
  20. #include "netinet/in.h"
  21. #include "netinet/tcp.h"
  22. typedef intptr_t LPARAM;
  23. typedef int BOOL, INT, LONG;
  24. typedef char CHAR;
  25. typedef const char *LPCSTR;
  26. typedef unsigned char BYTE, *PBYTE, UCHAR;
  27. typedef short SHORT;
  28. typedef unsigned short USHORT, WORD;
  29. typedef unsigned int UINT, DWORD, ULONG, UINT_PTR, DWORD_PTR, WPARAM;
  30. typedef void *LPVOID, *HWND, *HANDLE, *HINSTANCE;
  31. typedef int __int32, SOCKET;
  32. typedef long long LONGLONG;
  33. typedef unsigned long long ULONGLONG, UINT64, DWORDLONG;
  34. #define TRUE 1
  35. #define FALSE 0
  36. #define MAX_PATH PATH_MAX
  37. #define __stdcall
  38. #define WM_USER 0x0400
  39. #define _countof(v) (sizeof(v) / sizeof(v[0]))
  40. #define TEXT(s) s
  41. #define _T(s) s
  42. //#define min(a, b) (((a) < (b)) ? (a) : (b))
  43. //#define max(a, b) (((a) > (b)) ? (a) : (b))
  44. #define _snprintf snprintf
  45. #define _vsnprintf vsnprintf
  46. #define stricmp strcasecmp
  47. #define INVALID_SOCKET (SOCKET)(~0)
  48. #define SOCKET_ERROR (-1)
  49. typedef sockaddr_in SOCKADDR_IN;
  50. #define closesocket close
  51. #define WSAGetLastError() errno
  52. #define WSAEWOULDBLOCK EAGAIN
  53. #define WSAEINVAL EAGAIN
  54. #define WSAEISCONN EISCONN
  55. #define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD_PTR)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD_PTR)(b)) & 0xff))) << 8))
  56. #define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16))
  57. #define MAKEWPARAM(l, h) ((WPARAM)(DWORD)MAKELONG(l, h))
  58. #define MAKELPARAM(l, h) ((LPARAM)(DWORD)MAKELONG(l, h))
  59. #define MAKELRESULT(l, h) ((LRESULT)(DWORD)MAKELONG(l, h))
  60. #define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff))
  61. #define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff))
  62. #define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
  63. #define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff))
  64. #endif