PageRenderTime 33ms CodeModel.GetById 27ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/middleware/enet/unix.h

https://bitbucket.org/vivkin/gam3b00bs/
C++ Header | 45 lines | 29 code | 12 blank | 4 comment | 0 complexity | a8d6ed987e52f267f561612b368b1200 MD5 | raw file
 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 <netinet/in.h>
12#include <unistd.h>
13
14typedef int ENetSocket;
15
16enum
17{
18    ENET_SOCKET_NULL = -1
19};
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
24#define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */
25#define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */
26
27typedef struct
28{
29    void * data;
30    size_t dataLength;
31} ENetBuffer;
32
33#define ENET_CALLBACK
34
35#define ENET_API extern
36
37typedef fd_set ENetSocketSet;
38
39#define ENET_SOCKETSET_EMPTY(sockset)          FD_ZERO (& (sockset))
40#define ENET_SOCKETSET_ADD(sockset, socket)    FD_SET (socket, & (sockset))
41#define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset))
42#define ENET_SOCKETSET_CHECK(sockset, socket)  FD_ISSET (socket, & (sockset))
43    
44#endif /* __ENET_UNIX_H__ */
45