unix.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 <sys/socket.h>
  11. #include <netinet/in.h>
  12. #include <unistd.h>
  13. #ifdef MSG_MAXIOVLEN
  14. #define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN
  15. #endif
  16. typedef int ENetSocket;
  17. enum
  18. {
  19. ENET_SOCKET_NULL = -1
  20. };
  21. #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */
  22. #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */
  23. #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
  24. #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
  25. typedef struct
  26. {
  27. void * data;
  28. size_t dataLength;
  29. } ENetBuffer;
  30. #define ENET_CALLBACK
  31. #define ENET_API extern
  32. typedef fd_set ENetSocketSet;
  33. #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
  34. #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
  35. #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset))
  36. #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
  37. #endif /* __ENET_UNIX_H__ */