Skip to content

Commit

Permalink
Cleaned up whitespace for the 2.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 22, 2013
1 parent 4252653 commit 8811612
Show file tree
Hide file tree
Showing 11 changed files with 1,411 additions and 1,411 deletions.
108 changes: 54 additions & 54 deletions SDL_net.h
Expand Up @@ -32,9 +32,9 @@ typedef uint16_t Uint16;
typedef uint32_t Uint32;

typedef struct SDLNet_version {
Uint8 major;
Uint8 minor;
Uint8 patch;
Uint8 major;
Uint8 minor;
Uint8 patch;
} SDLNet_version;

#else /* WITHOUT_SDL */
Expand All @@ -56,18 +56,18 @@ extern "C" {

/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_NET_MAJOR_VERSION 1
#define SDL_NET_MINOR_VERSION 2
#define SDL_NET_PATCHLEVEL 9
#define SDL_NET_MAJOR_VERSION 2
#define SDL_NET_MINOR_VERSION 0
#define SDL_NET_PATCHLEVEL 0

/* This macro can be used to fill a version structure with the compile-time
* version of the SDL_net library.
*/
#define SDL_NET_VERSION(X) \
{ \
(X)->major = SDL_NET_MAJOR_VERSION; \
(X)->minor = SDL_NET_MINOR_VERSION; \
(X)->patch = SDL_NET_PATCHLEVEL; \
#define SDL_NET_VERSION(X) \
{ \
(X)->major = SDL_NET_MAJOR_VERSION; \
(X)->minor = SDL_NET_MINOR_VERSION; \
(X)->patch = SDL_NET_PATCHLEVEL; \
}

/* This function gets the version of the dynamically linked SDL_net library.
Expand All @@ -88,8 +88,8 @@ extern DECLSPEC void SDLCALL SDLNet_Quit(void);
/***********************************************************************/

typedef struct {
Uint32 host; /* 32-bit IPv4 host address */
Uint16 port; /* 16-bit protocol port */
Uint32 host; /* 32-bit IPv4 host address */
Uint16 port; /* 16-bit protocol port */
} IPaddress;

/* Resolve a host name and port to an IP address in network form.
Expand All @@ -99,16 +99,16 @@ typedef struct {
If 'host' is NULL, the resolved host will be set to INADDR_ANY.
*/
#ifndef INADDR_ANY
#define INADDR_ANY 0x00000000
#define INADDR_ANY 0x00000000
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xFFFFFFFF
#define INADDR_NONE 0xFFFFFFFF
#endif
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001
#define INADDR_LOOPBACK 0x7f000001
#endif
#ifndef INADDR_BROADCAST
#define INADDR_BROADCAST 0xFFFFFFFF
#define INADDR_BROADCAST 0xFFFFFFFF
#endif
extern DECLSPEC int SDLCALL SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port);

Expand All @@ -134,7 +134,7 @@ typedef struct _TCPsocket *TCPsocket;
If ip.host is INADDR_NONE or INADDR_ANY, this creates a local server
socket on the given port, otherwise a TCP connection to the remote
host and port is attempted. The address passed in should already be
swapped to network byte order (addresses returned from
swapped to network byte order (addresses returned from
SDLNet_ResolveHost() are already in the correct form).
The newly created socket is returned, or NULL if there was an error.
*/
Expand All @@ -156,7 +156,7 @@ extern DECLSPEC IPaddress * SDLCALL SDLNet_TCP_GetPeerAddress(TCPsocket sock);
closed, or an unknown socket error occurred.
*/
extern DECLSPEC int SDLCALL SDLNet_TCP_Send(TCPsocket sock, const void *data,
int len);
int len);

/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
and store them in the buffer pointed to by 'data'.
Expand All @@ -175,18 +175,18 @@ extern DECLSPEC void SDLCALL SDLNet_TCP_Close(TCPsocket sock);
/***********************************************************************/

/* The maximum channels on a a UDP socket */
#define SDLNET_MAX_UDPCHANNELS 32
#define SDLNET_MAX_UDPCHANNELS 32
/* The maximum addresses bound to a single UDP socket channel */
#define SDLNET_MAX_UDPADDRESSES 4
#define SDLNET_MAX_UDPADDRESSES 4

typedef struct _UDPsocket *UDPsocket;
typedef struct {
int channel; /* The src/dst channel of the packet */
Uint8 *data; /* The packet data */
int len; /* The length of the packet data */
int maxlen; /* The size of the data buffer */
int status; /* packet status after sending */
IPaddress address; /* The source/dest address of an incoming/outgoing packet */
int channel; /* The src/dst channel of the packet */
Uint8 *data; /* The packet data */
int len; /* The length of the packet data */
int maxlen; /* The size of the data buffer */
int status; /* packet status after sending */
IPaddress address; /* The source/dest address of an incoming/outgoing packet */
} UDPpacket;

/* Allocate/resize/free a single UDP packet 'size' bytes long.
Expand Down Expand Up @@ -232,7 +232,7 @@ extern DECLSPEC int SDLCALL SDLNet_UDP_Bind(UDPsocket sock, int channel, const I
/* Unbind all addresses from the given channel */
extern DECLSPEC void SDLCALL SDLNet_UDP_Unbind(UDPsocket sock, int channel);

/* Get the primary IP address of the remote system associated with the
/* Get the primary IP address of the remote system associated with the
socket and channel. If the channel is -1, then the primary IP port
of the UDP socket is returned -- this is only meaningful for sockets
opened with a specific port.
Expand All @@ -243,7 +243,7 @@ extern DECLSPEC IPaddress * SDLCALL SDLNet_UDP_GetPeerAddress(UDPsocket sock, in
/* Send a vector of packets to the the channels specified within the packet.
If the channel specified in the packet is -1, the packet will be sent to
the address in the 'src' member of the packet.
Each packet will be updated with the status of the packet after it has
Each packet will be updated with the status of the packet after it has
been sent, -1 if the packet send failed.
This function returns the number of packets sent.
*/
Expand Down Expand Up @@ -299,7 +299,7 @@ typedef struct _SDLNet_SocketSet *SDLNet_SocketSet;

/* Any network socket can be safely cast to this socket type */
typedef struct _SDLNet_GenericSocket {
int ready;
int ready;
} *SDLNet_GenericSocket;

/* Allocate a socket set for use with SDLNet_CheckSockets()
Expand All @@ -312,30 +312,30 @@ extern DECLSPEC SDLNet_SocketSet SDLCALL SDLNet_AllocSocketSet(int maxsockets);
extern DECLSPEC int SDLCALL SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
static __inline__ int SDLNet_TCP_AddSocket(SDLNet_SocketSet set, TCPsocket sock)
{
return SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock);
return SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock);
}
static __inline__ int SDLNet_UDP_AddSocket(SDLNet_SocketSet set, UDPsocket sock)
{
return SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock);
return SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock);
}


/* Remove a socket from a set of sockets to be checked for available data */
extern DECLSPEC int SDLCALL SDLNet_DelSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
static __inline__ int SDLNet_TCP_DelSocket(SDLNet_SocketSet set, TCPsocket sock)
{
return SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock);
return SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock);
}
static __inline__ int SDLNet_UDP_DelSocket(SDLNet_SocketSet set, UDPsocket sock)
{
return SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock);
return SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock);
}

/* This function checks to see if data is available for reading on the
given set of sockets. If 'timeout' is 0, it performs a quick poll,
otherwise the function returns when either data is available for
reading, or the timeout in milliseconds has elapsed, which ever occurs
first. This function returns the number of sockets ready for reading,
first. This function returns the number of sockets ready for reading,
or -1 if there was an error with the select() system call.
*/
extern DECLSPEC int SDLCALL SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout);
Expand All @@ -347,7 +347,7 @@ extern DECLSPEC int SDLCALL SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 tim
#define SDLNet_SocketReady(sock) _SDLNet_SocketReady((SDLNet_GenericSocket)(sock))
static __inline__ int _SDLNet_SocketReady(SDLNet_GenericSocket sock)
{
return (sock != NULL) && (sock->ready);
return (sock != NULL) && (sock->ready);
}

/* Free a set of sockets allocated by SDL_NetAllocSocketSet() */
Expand All @@ -366,10 +366,10 @@ extern DECLSPEC const char * SDLCALL SDLNet_GetError(void);

/* Warning, some systems have data access alignment restrictions */
#if defined(sparc) || defined(mips) || defined(__arm__)
#define SDL_DATA_ALIGNED 1
#define SDL_DATA_ALIGNED 1
#endif
#ifndef SDL_DATA_ALIGNED
#define SDL_DATA_ALIGNED 0
#define SDL_DATA_ALIGNED 0
#endif

/* Write a 16/32-bit value to network packet buffer */
Expand All @@ -384,52 +384,52 @@ extern DECLSPEC const char * SDLCALL SDLNet_GetError(void);

static __inline__ void _SDLNet_Write16(Uint16 value, void *areap)
{
*(Uint16 *)areap = SDL_SwapBE16(value);
*(Uint16 *)areap = SDL_SwapBE16(value);
}

static __inline__ void _SDLNet_Write32(Uint32 value, void *areap)
{
*(Uint32 *)areap = SDL_SwapBE32(value);
*(Uint32 *)areap = SDL_SwapBE32(value);
}

static __inline__ Uint16 _SDLNet_Read16(void *areap)
{
return SDL_SwapBE16(*(Uint16 *)areap);
return SDL_SwapBE16(*(Uint16 *)areap);
}

static __inline__ Uint32 _SDLNet_Read32(void *areap)
{
return SDL_SwapBE32(*(Uint32 *)areap);
return SDL_SwapBE32(*(Uint32 *)areap);
}

#else /* !defined(WITHOUT_SDL) && !SDL_DATA_ALIGNED */

static __inline__ void _SDLNet_Write16(Uint16 value, void *areap)
{
Uint8 *area = (Uint8*)areap;
area[0] = (value >> 8) & 0xFF;
area[1] = value & 0xFF;
Uint8 *area = (Uint8*)areap;
area[0] = (value >> 8) & 0xFF;
area[1] = value & 0xFF;
}

static __inline__ void _SDLNet_Write32(Uint32 value, void *areap)
{
Uint8 *area = (Uint8*)areap;
area[0] = (value >> 24) & 0xFF;
area[1] = (value >> 16) & 0xFF;
area[2] = (value >> 8) & 0xFF;
area[3] = value & 0xFF;
Uint8 *area = (Uint8*)areap;
area[0] = (value >> 24) & 0xFF;
area[1] = (value >> 16) & 0xFF;
area[2] = (value >> 8) & 0xFF;
area[3] = value & 0xFF;
}

static __inline__ Uint16 _SDLNet_Read16(void *areap)
{
Uint8 *area = (Uint8*)areap;
return ((Uint16)area[0]) << 8 | ((Uint16)area[1]);
Uint8 *area = (Uint8*)areap;
return ((Uint16)area[0]) << 8 | ((Uint16)area[1]);
}

static __inline__ Uint32 _SDLNet_Read32(void *areap)
{
Uint8 *area = (Uint8*)areap;
return ((Uint32)area[0]) << 24 | ((Uint32)area[1]) << 16 | ((Uint32)area[2]) << 8 | ((Uint32)area[3]);
Uint8 *area = (Uint8*)areap;
return ((Uint32)area[0]) << 24 | ((Uint32)area[1]) << 16 | ((Uint32)area[2]) << 8 | ((Uint32)area[3]);
}

#endif /* !defined(WITHOUT_SDL) && !SDL_DATA_ALIGNED */
Expand Down

0 comments on commit 8811612

Please sign in to comment.