netinc.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. ** JNetLib
  3. ** Copyright (C) 2000-2006 Nullsoft, Inc.
  4. ** Author: Justin Frankel
  5. ** File: netinc.h - network includes and portability defines (used internally)
  6. ** License: see jnetlib.h
  7. */
  8. #ifndef NULLSOFT_WAC_NETWORK_NETINC_H
  9. #define NULLSOFT_WAC_NETWORK_NETINC_H
  10. #ifdef _WIN32
  11. //#include <time.h>
  12. #ifndef WIN32_LEAN_AND_MEAN
  13. #define WIN32_LEAN_AND_MEAN
  14. #endif
  15. #include <windows.h>
  16. #include <winsock2.h>
  17. #include <Ws2tcpip.h>
  18. #include <wspiapi.h>
  19. #include "..\replicant\foundation\types.h"
  20. #define strtoull(x,y,z) _strtoui64(x,y,z)
  21. #define strcasecmp(x,y) _stricmp(x,y)
  22. #define strcasecmpn(x,y, count) _strnicmp(x,y,count)
  23. #define strncasecmp(x,y, count) _strnicmp(x,y,count)
  24. #define HTONS(val) ((((unsigned short) (val) & (unsigned short) 0x00ffU) << 8) | (((unsigned short) (val) & (unsigned short) 0xff00U) >> 8))
  25. #define ERRNO (WSAGetLastError())
  26. #define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); }
  27. #define EWOULDBLOCK WSAEWOULDBLOCK
  28. #define EINPROGRESS WSAEWOULDBLOCK
  29. #else
  30. #define EWOULDBLOCK EWOULDBLOCK
  31. #define EINPROGRESS EINPROGRESS
  32. #ifndef THREAD_SAFE
  33. #define THREAD_SAFE
  34. #endif
  35. #ifndef _REENTRANT
  36. #define _REENTRANT
  37. #endif
  38. #include <pthread.h>
  39. #include <sys/types.h>
  40. #include <sys/stat.h>
  41. #include <sys/socket.h>
  42. #include <netinet/in.h>
  43. #include <sys/time.h>
  44. #include <arpa/inet.h>
  45. #include <netdb.h>
  46. #include <stdarg.h>
  47. #include <stdio.h>
  48. #include <fcntl.h>
  49. #include <unistd.h>
  50. #include <signal.h>
  51. #include <stdlib.h>
  52. #include <errno.h>
  53. #include <string.h>
  54. #define ERRNO errno
  55. #define closesocket(s) close(s)
  56. #define SET_SOCK_BLOCK(s,block) { int __flags; if ((__flags = fcntl(s, F_GETFL, 0)) != -1) { if (!block) __flags |= O_NONBLOCK; else __flags &= ~O_NONBLOCK; fcntl(s, F_SETFL, __flags); } }
  57. #define _stricmp(x,y) strcasecmp(x,y)
  58. #define _strnicmp(x,y,z) strncasecmp(x,y,z)
  59. #define wsprintf sprintf
  60. typedef int SOCKET;
  61. #endif // !_WIN32
  62. #ifndef INADDR_NONE
  63. #define INADDR_NONE 0xffffffff
  64. #endif
  65. #ifndef INADDR_ANY
  66. #define INADDR_ANY 0
  67. #endif
  68. #ifndef SHUT_RDWR
  69. #define SHUT_RDWR 2
  70. #endif
  71. #endif //!NULLSOFT_WAC_NETWORK_NETINC_H