unix.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. @file unix.h
  3. @brief ENet Unix header
  4. */
  5. #ifndef __ENET_UNIX_H__
  6. #define __ENET_UNIX_H__
  7. #include <stdlib.h>
  8. #include <sys/time.h>
  9. #include <sys/types.h>
  10. #include <netinet/in.h>
  11. #include <unistd.h>
  12. typedef int ENetSocket;
  13. enum
  14. {
  15. ENET_SOCKET_NULL = -1
  16. };
  17. #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */
  18. #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */
  19. #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
  20. #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
  21. typedef struct
  22. {
  23. void * data;
  24. size_t dataLength;
  25. } ENetBuffer;
  26. #define ENET_CALLBACK
  27. #define ENET_API extern
  28. typedef fd_set ENetSocketSet;
  29. #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
  30. #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
  31. #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset))
  32. #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
  33. #endif /* __ENET_UNIX_H__ */