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