error.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include "defaults.h"
  3. #if defined(_win_)
  4. #include <winerror.h>
  5. #include <errno.h>
  6. #undef E_FAIL
  7. #undef ERROR_TIMEOUT
  8. #if defined(_MSC_VER)
  9. #undef EADDRINUSE
  10. #undef EADDRNOTAVAIL
  11. #undef EAFNOSUPPORT
  12. #undef EALREADY
  13. #undef ECANCELED
  14. #undef ECONNABORTED
  15. #undef ECONNREFUSED
  16. #undef ECONNRESET
  17. #undef EDESTADDRREQ
  18. #undef EHOSTUNREACH
  19. #undef EINPROGRESS
  20. #undef EISCONN
  21. #undef ELOOP
  22. #undef EMSGSIZE
  23. #undef ENETDOWN
  24. #undef ENETRESET
  25. #undef ENETUNREACH
  26. #undef ENOBUFS
  27. #undef ENOPROTOOPT
  28. #undef ENOTCONN
  29. #undef ENOTSOCK
  30. #undef EOPNOTSUPP
  31. #undef EPROTONOSUPPORT
  32. #undef EPROTOTYPE
  33. #undef ETIMEDOUT
  34. #undef EWOULDBLOCK
  35. #undef ENAMETOOLONG
  36. #undef ENOTEMPTY
  37. #define EWOULDBLOCK WSAEWOULDBLOCK
  38. #define EINPROGRESS WSAEINPROGRESS
  39. #define EALREADY WSAEALREADY
  40. #define ENOTSOCK WSAENOTSOCK
  41. #define EDESTADDRREQ WSAEDESTADDRREQ
  42. #define EMSGSIZE WSAEMSGSIZE
  43. #define EPROTOTYPE WSAEPROTOTYPE
  44. #define ENOPROTOOPT WSAENOPROTOOPT
  45. #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
  46. #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
  47. #define EOPNOTSUPP WSAEOPNOTSUPP
  48. #define EPFNOSUPPORT WSAEPFNOSUPPORT
  49. #define EAFNOSUPPORT WSAEAFNOSUPPORT
  50. #define EADDRINUSE WSAEADDRINUSE
  51. #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
  52. #define ENETDOWN WSAENETDOWN
  53. #define ENETUNREACH WSAENETUNREACH
  54. #define ENETRESET WSAENETRESET
  55. #define ECONNABORTED WSAECONNABORTED
  56. #define ECONNRESET WSAECONNRESET
  57. #define ENOBUFS WSAENOBUFS
  58. #define EISCONN WSAEISCONN
  59. #define ENOTCONN WSAENOTCONN
  60. #define ESHUTDOWN WSAESHUTDOWN
  61. #define ETOOMANYREFS WSAETOOMANYREFS
  62. #define ETIMEDOUT WSAETIMEDOUT
  63. #define ECONNREFUSED WSAECONNREFUSED
  64. #define ELOOP WSAELOOP
  65. #define ENAMETOOLONG WSAENAMETOOLONG
  66. #define EHOSTDOWN WSAEHOSTDOWN
  67. #define EHOSTUNREACH WSAEHOSTUNREACH
  68. #define ENOTEMPTY WSAENOTEMPTY
  69. #define EPROCLIM WSAEPROCLIM
  70. #define EUSERS WSAEUSERS
  71. #define ESTALE WSAESTALE
  72. #define EREMOTE WSAEREMOTE
  73. #define ECANCELED WSAECANCELLED
  74. #endif
  75. #define EDQUOT WSAEDQUOT
  76. #endif
  77. void ClearLastSystemError();
  78. int LastSystemError();
  79. void LastSystemErrorText(char* str, size_t size, int code);
  80. const char* LastSystemErrorText(int code);
  81. inline const char* LastSystemErrorText() {
  82. return LastSystemErrorText(LastSystemError());
  83. }
  84. inline void LastSystemErrorText(char* str, size_t size) {
  85. LastSystemErrorText(str, size, LastSystemError());
  86. }