unix.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #define ENET_SOCKET_NULL -1
  18. #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */
  19. #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */
  20. #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
  21. #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
  22. typedef struct
  23. {
  24. void * data;
  25. size_t dataLength;
  26. } ENetBuffer;
  27. #define ENET_CALLBACK
  28. #define ENET_API extern
  29. typedef fd_set ENetSocketSet;
  30. #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset))
  31. #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset))
  32. #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset))
  33. #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset))
  34. #endif /* __ENET_UNIX_H__ */