From Norman Vine (with small tweaks by Robert Osfield), build fixes for Cygwin

This commit is contained in:
Robert Osfield
2004-08-04 08:27:43 +00:00
parent 041b664660
commit 7eb3f2646e
33 changed files with 137 additions and 111 deletions

View File

@@ -2,7 +2,7 @@
#include <fcntl.h>
#include <sys/types.h>
#if !defined (WIN32)
#if !defined (WIN32) || defined(__CYGWIN__)
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/socket.h>
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <net/soioctl.h>
#elif defined(__CYGWIN__)
// nothing needed
#include <unistd.h>
#elif defined(__sun)
#include <unistd.h>
#include <sys/sockio.h>
@@ -56,7 +56,7 @@ Broadcaster::Broadcaster( void )
Broadcaster::~Broadcaster( void )
{
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
closesocket( _so);
#else
close( _so );
@@ -65,7 +65,7 @@ Broadcaster::~Broadcaster( void )
bool Broadcaster::init( void )
{
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
WORD version = MAKEWORD(1,1);
WSADATA wsaData;
// First, we start up Winsock
@@ -83,13 +83,13 @@ bool Broadcaster::init( void )
perror( "Socket" );
return false;
}
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
const BOOL on = TRUE;
#else
int on = 1;
#endif
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
setsockopt( _so, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(int));
#else
setsockopt( _so, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
@@ -99,16 +99,16 @@ bool Broadcaster::init( void )
saddr.sin_port = htons( _port );
if( _address == 0 )
{
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
setsockopt( _so, SOL_SOCKET, SO_BROADCAST, (const char *) &on, sizeof(int));
#else
setsockopt( _so, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
#endif
#if !defined (WIN32)
#if !defined (WIN32) || defined(__CYGWIN__)
struct ifreq ifr;
#endif
#if defined (__linux)
#if defined (__linux) || defined(__CYGWIN__)
strcpy( ifr.ifr_name, "eth0" );
#elif defined(__sun)
strcpy( ifr.ifr_name, "hme0" );
@@ -174,7 +174,7 @@ void Broadcaster::sync( void )
return;
}
#if defined (WIN32)
#if defined (WIN32) && !defined(__CYGWIN__)
unsigned int size = sizeof( SOCKADDR_IN );
sendto( _so, (const char *)_buffer, _buffer_size, 0, (struct sockaddr *)&saddr, size );
int err = WSAGetLastError ();