netinc.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 _NETINC_H_
  9. #define _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 "../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 JNL_EWOULDBLOCK WSAEWOULDBLOCK
  28. #define JNL_EINPROGRESS WSAEWOULDBLOCK
  29. #else
  30. #define JNL_EWOULDBLOCK EWOULDBLOCK
  31. #define JNL_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 //_NETINC_H_