portability fixes

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@59 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-05-09 20:51:34 +00:00
parent 06eb8cc3a4
commit 3591d7dc01
25 changed files with 217 additions and 190 deletions

View file

@ -167,8 +167,10 @@ LINK = CXX
# common flags
warningFlags = '-W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter '
warningFlagsCXX = '-Wno-non-virtual-dtor -Wreorder ' # -Wold-style-cast
CCFLAGS = '' + warningFlags
CXXFLAGS = '-pipe -DQ_NO_STLPORT ' + warningFlags + warningFlagsCXX
# POSIX macro: platform supports posix IEEE Std 1003.1:2001
# XWINDOWS macro: platform supports X-Windows API
CCFLAGS = '-DPOSIX -DXWINDOWS ' + warningFlags
CXXFLAGS = '-pipe -DPOSIX -DXWINDOWS ' + warningFlags + warningFlagsCXX
CPPPATH = []
if (BUILD == 'debug'):
CXXFLAGS += '-g -D_DEBUG '

View file

@ -190,7 +190,7 @@ extern char* PLUGIN_NAME;
return buffer;
}*/
#if defined (__linux__) || defined (__APPLE__)
#if defined (POSIX)
// the bCreateConsole parameter is ignored on linux ..
bool Q_Exec( const char *pCmd, bool bCreateConsole )
{

View file

@ -30,10 +30,12 @@ extern GtkWidget *g_pEditModeAddRadioButton;
char* Q_realpath(const char *path, char *resolved_path, size_t size)
{
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
return realpath(path, resolved_path);
#elif defined(WIN32)
return _fullpath(resolved_path, path, size);
#else
return _fullpath(resolved_path, path, size);
#error "unsupported platform"
#endif
}

View file

@ -82,7 +82,7 @@ const char* ExtractFilename( const char* path )
}
int Q_stricmp (const char *s1, const char *s2) {
return stricmp( s1, s2 );
return string_equal_nocase( s1, s2 );
}
/*

View file

@ -298,7 +298,7 @@ GSList *AddToWadList(GSList *wadlist, const char *shadername, const char *wad)
for (GSList *l = wadlist; l != NULL ; l = l->next)
{
if (!stricmp((char *)l->data,wadname))
if (string_equal_nocase((char *)l->data,wadname))
{
free( wadname );
return wadlist;
@ -334,7 +334,7 @@ void UpdateWadKeyPair( void )
Sys_Printf("Searching for in-use wad files...\n");
for(pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next)
{
if (stricmp(pEpair->key,"wad") == 0)
if (string_equal_nocase(pEpair->key,"wad"))
{
strcpy(wads,pEpair->value);
ConvertDOSToUnixName(wads,wads);
@ -415,7 +415,7 @@ void UpdateWadKeyPair( void )
wads[0] = 0;
while (wadlist)
{
if (stricmp((char *)wadlist->data,"common-hydra.wad") == 0)
if (string_equal_nocase((char *)wadlist->data,"common-hydra.wad"))
{
Sys_Printf("Skipping radiant-supplied wad file %s\n",(char *)wadlist->data);
}

View file

@ -32,15 +32,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "os/path.h"
#include "container/array.h"
#ifdef WIN32
#include <windows.h>
#endif
#if defined (__linux__) || defined (__APPLE__)
#include <unistd.h>
#endif
#if defined (POSIX)
#include <unistd.h>
#if defined (__linux__) || defined (__APPLE__)
bool Q_Exec(const char *cmd, char *cmdline, const char *, bool)
{
char fullcmd[2048];
@ -82,9 +78,11 @@ bool Q_Exec(const char *cmd, char *cmdline, const char *, bool)
}
return true;
}
#endif
#ifdef WIN32
#elif defined(WIN32)
#include <windows.h>
// NOTE TTimo windows is VERY nitpicky about the syntax in CreateProcess
bool Q_Exec(const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole)
{
@ -126,5 +124,6 @@ bool Q_Exec(const char *cmd, char *cmdline, const char *execdir, bool bCreateCon
return true;
return false;
}
#endif

View file

@ -28,7 +28,69 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/// \file
/// \brief Platform-independent GTK clipboard support.
/// \todo Using GDK_SELECTION_CLIPBOARD fails on win32, so we use the win32 API directly for now.
#if defined (__linux__) || defined (__APPLE__)
#if defined(WIN32)
const char* c_clipboard_format = "RadiantClippings";
#include <windows.h>
void clipboard_copy(ClipboardCopyFunc copy)
{
BufferOutputStream ostream;
copy(ostream);
bool bClipped = false;
UINT nClipboard = ::RegisterClipboardFormat(c_clipboard_format);
if (nClipboard > 0)
{
if (::OpenClipboard(0))
{
EmptyClipboard();
std::size_t length = ostream.size();
HANDLE h = ::GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE, length + sizeof(std::size_t));
if (h != 0)
{
char *buffer = reinterpret_cast<char*>(::GlobalLock(h));
*reinterpret_cast<std::size_t*>(buffer) = length;
buffer += sizeof(std::size_t);
memcpy(buffer, ostream.data(), length);
::GlobalUnlock(h);
::SetClipboardData(nClipboard, h);
::CloseClipboard();
bClipped = true;
}
}
}
if (!bClipped)
{
globalOutputStream() << "Unable to register Windows clipboard formats, copy/paste between editors will not be possible\n";
}
}
void clipboard_paste(ClipboardPasteFunc paste)
{
UINT nClipboard = ::RegisterClipboardFormat(c_clipboard_format);
if (nClipboard > 0 && ::OpenClipboard(0))
{
if(IsClipboardFormatAvailable(nClipboard))
{
HANDLE h = ::GetClipboardData(nClipboard);
if(h)
{
const char *buffer = reinterpret_cast<const char*>(::GlobalLock(h));
std::size_t length = *reinterpret_cast<const std::size_t*>(buffer);
buffer += sizeof(std::size_t);
BufferInputStream istream(buffer, length);
paste(istream);
::GlobalUnlock(h);
}
}
::CloseClipboard();
}
}
#else
#include <gtk/gtkclipboard.h>
@ -96,67 +158,5 @@ void clipboard_paste(ClipboardPasteFunc paste)
gtk_clipboard_request_contents (clipboard, gdk_atom_intern(clipboard_targets[0].target, FALSE), clipboard_received, &g_clipboardPasteFunc);
}
#elif defined(WIN32)
const char* c_clipboard_format = "RadiantClippings";
#include <windows.h>
void clipboard_copy(ClipboardCopyFunc copy)
{
BufferOutputStream ostream;
copy(ostream);
bool bClipped = false;
UINT nClipboard = ::RegisterClipboardFormat(c_clipboard_format);
if (nClipboard > 0)
{
if (::OpenClipboard(0))
{
EmptyClipboard();
std::size_t length = ostream.size();
HANDLE h = ::GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE | GMEM_DDESHARE, length + sizeof(std::size_t));
if (h != 0)
{
char *buffer = reinterpret_cast<char*>(::GlobalLock(h));
*reinterpret_cast<std::size_t*>(buffer) = length;
buffer += sizeof(std::size_t);
memcpy(buffer, ostream.data(), length);
::GlobalUnlock(h);
::SetClipboardData(nClipboard, h);
::CloseClipboard();
bClipped = true;
}
}
}
if (!bClipped)
{
globalOutputStream() << "Unable to register Windows clipboard formats, copy/paste between editors will not be possible\n";
}
}
void clipboard_paste(ClipboardPasteFunc paste)
{
UINT nClipboard = ::RegisterClipboardFormat(c_clipboard_format);
if (nClipboard > 0 && ::OpenClipboard(0))
{
if(IsClipboardFormatAvailable(nClipboard))
{
HANDLE h = ::GetClipboardData(nClipboard);
if(h)
{
const char *buffer = reinterpret_cast<const char*>(::GlobalLock(h));
std::size_t length = *reinterpret_cast<const std::size_t*>(buffer);
buffer += sizeof(std::size_t);
BufferInputStream istream(buffer, length);
paste(istream);
::GlobalUnlock(h);
}
}
::CloseClipboard();
}
}
#endif

View file

@ -40,7 +40,7 @@ extern "C"
#endif
// LZ: linux stuff
#if defined (__linux__) || defined (__APPLE__)
#if !defined (WIN32)
#include <stdio.h>
#include <stdlib.h>

View file

@ -83,10 +83,9 @@ void Net_SetAddressPort(address_t *address, int port)
int Net_AddressCompare(address_t *addr1, address_t *addr2)
{
#ifdef WIN32
return stricmp(addr1->ip, addr2->ip);
#endif
#ifdef __linux__
return strcasecmp(addr1->ip, addr2->ip);
return _stricmp(addr1->ip, addr2->ip);
#else
return strcasecmp(addr1->ip, addr2->ip);
#endif
} //end of the function Net_AddressCompare
//===========================================================================

View file

@ -93,7 +93,7 @@ inline bool path_is_absolute(const char* path)
#if defined(WIN32)
return path[0] == '/'
|| (path[0] != '\0' && path[1] == ':'); // local drive
#elif defined(__linux__) || defined(__APPLE__)
#elif defined(POSIX)
return path[0] == '/';
#endif
}

View file

@ -20,7 +20,7 @@ extern "C"
#endif
// LZ: linux stuff
#if defined (__linux__) || defined (__APPLE__)
#if !defined (WIN32)
#include <stdio.h>
#include <stdlib.h>

View file

@ -67,7 +67,7 @@ inline char* Q_StrDup(const char* pStr)
return strcpy(new char[strlen(pStr)+1], pStr);
}
#if defined (__linux__) || defined (__APPLE__)
#if !defined(WIN32)
#define strcmpi strcasecmp
#define stricmp strcasecmp
#define strnicmp strncasecmp

View file

@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <stdio.h>
#include <stdlib.h>
#if defined(__linux__) || defined(__APPLE__)
#if !defined(WIN32)
// Necessary for proper boolean type declaration
#include "qertypes.h"

View file

@ -548,6 +548,12 @@ copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)install&quot
<File
RelativePath=".\shaders.h">
</File>
<File
RelativePath=".\sockets.cpp">
</File>
<File
RelativePath=".\sockets.h">
</File>
<File
RelativePath=".\stacktrace.cpp">
</File>

View file

@ -72,7 +72,7 @@ const char* environment_get_app_path()
}
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
#include <stdlib.h>
#include <pwd.h>
@ -83,7 +83,7 @@ const char* environment_get_app_path()
const char* LINK_NAME =
#if defined (__linux__)
"/proc/self/exe"
#else
#else // FreeBSD and OSX
"/proc/curproc/file"
#endif
;
@ -147,9 +147,7 @@ void environment_init(int argc, char* argv[])
}
}
#endif
#ifdef WIN32
#elif defined(WIN32)
#include <windows.h>
#include <shfolder.h>
@ -197,4 +195,6 @@ void environment_init(int argc, char* argv[])
}
}
#else
#error "unsupported platform"
#endif

View file

@ -32,9 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef WIN32
#define UNICODE
#include <windows.h>
#endif
#if defined (__linux__) || defined (__APPLE__)
#else
#include <errno.h>
#include <unistd.h>
#endif
@ -66,15 +64,6 @@ void Error (const char *error, ...)
strcat( text, "\n" );
#if defined (__linux__) || defined (__APPLE__)
if (errno != 0)
{
strcat( text, "errno: " );
strcat( text, strerror (errno));
strcat( text, "\n");
}
#endif
#ifdef WIN32
if (GetLastError() != 0)
{
@ -110,8 +99,16 @@ void Error (const char *error, ...)
strcat( text, "\n");
LocalFree( lpMsgBuf );
}
#else
if (errno != 0)
{
strcat( text, "errno: " );
strcat( text, strerror (errno));
strcat( text, "\n");
}
#endif
#if 0
// we need to have a current context to call glError()
if (g_glwindow_globals.d_glBase != 0)

View file

@ -186,7 +186,7 @@ void VFS_Destroy()
void HomePaths_Realise()
{
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
const char* prefix = g_pGameDescription->getKeyValue("prefix");
if(!string_empty(prefix))
{
@ -510,10 +510,10 @@ public:
const char* const c_library_extension =
#if defined(WIN32)
"dll"
#elif defined(__linux__)
"so"
#elif defined (__APPLE__)
"dylib"
#elif defined(__linux__) || defined (__FreeBSD__)
"so"
#endif
;
@ -3499,7 +3499,7 @@ void MainFrame_Construct()
const char* ENGINEPATH_ATTRIBUTE =
#if defined(WIN32)
"enginepath_win32"
#elif defined(__linux__)
#elif defined(__linux__) || defined (__FreeBSD__)
"enginepath_linux"
#elif defined(__APPLE__)
"enginepath_macos"

View file

@ -78,7 +78,7 @@ void QE_InitVFS()
const char* gamename = gamename_get();
const char* basegame = basegame_get();
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
#endif
const char* globalRoot = EnginePath_get();
@ -86,7 +86,7 @@ void QE_InitVFS()
// if we have a mod dir
if(!string_equal(gamename, basegame))
{
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
// ~/.<gameprefix>/<fs_game>
{
StringOutputStream userGamePath(256);
@ -103,7 +103,7 @@ void QE_InitVFS()
}
}
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
// ~/.<gameprefix>/<fs_main>
{
StringOutputStream userBasePath(256);
@ -172,7 +172,7 @@ bool ConfirmModified(const char* title)
const char* const EXECUTABLE_TYPE =
#if defined(__linux__)
#if defined(__linux__) || defined (__FreeBSD__)
"x86"
#elif defined(__APPLE__)
"ppc"
@ -317,20 +317,21 @@ void RunBSP(const char* name)
strcat(junkpath, "junk.txt");
char batpath[PATH_MAX];
#if defined (__linux__) || defined (__APPLE__)
#if defined(POSIX)
strcpy(batpath, SettingsPath_get());
strcat(batpath, "qe3bsp.sh");
#endif
#ifdef WIN32
#elif defined(WIN32)
strcpy(batpath, SettingsPath_get());
strcat(batpath, "qe3bsp.bat");
#else
#error "unsupported platform"
#endif
bool written = false;
{
TextFileOutputStream batchFile(batpath);
if(!batchFile.failed())
{
#if defined (__linux__) || defined (__APPLE__)
#if defined (POSIX)
batchFile << "#!/bin/sh \n\n";
#endif
BatchCommandListener listener(batchFile, junkpath);
@ -340,7 +341,7 @@ void RunBSP(const char* name)
}
if(written)
{
#if defined (__linux__) || defined (__APPLE__)
#if defined (POSIX)
chmod (batpath, 0744);
#endif
globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";

View file

@ -75,7 +75,7 @@ int ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int, COLORREF *);
BOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);
BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT);
#elif defined (__linux__) || defined (__APPLE__)
#elif defined (XWINDOWS)
#include <GL/glx.h>
#include <dlfcn.h>
@ -101,6 +101,8 @@ void (*qglXUseXFont)( Font font, int first, int count, int list );
void* (*qglXGetProcAddressARB) (const GLubyte *procName);
typedef void* (*glXGetProcAddressARBProc) (const GLubyte *procName);
#else
#error "unsupported platform"
#endif
@ -108,7 +110,7 @@ void QGL_Shutdown(OpenGLBinding& table)
{
globalOutputStream() << "Shutting down OpenGL module...";
#ifdef WIN32
#if defined(WIN32)
qwglCopyContext = 0;
qwglCreateContext = 0;
qwglCreateLayerContext = 0;
@ -131,9 +133,7 @@ void QGL_Shutdown(OpenGLBinding& table)
qwglGetPixelFormat = 0;
qwglSetPixelFormat = 0;
qwglSwapBuffers = 0;
#endif
#if defined (__linux__) || defined (__APPLE__)
#elif defined(XWINDOWS)
qglXChooseVisual = 0;
qglXCreateContext = 0;
qglXDestroyContext = 0;
@ -152,6 +152,8 @@ void QGL_Shutdown(OpenGLBinding& table)
qglXWaitX = 0;
qglXUseXFont = 0;
qglXGetProcAddressARB = 0;
#else
#error "unsupported platform"
#endif
globalOutputStream() << "Done.\n";
@ -236,7 +238,7 @@ typedef int (QGL_DLLEXPORT *QGLFunctionPointer)();
QGLFunctionPointer QGL_getExtensionFunc(const char* symbol)
{
#if defined (__linux__) || defined (__APPLE__)
#if defined(XWINDOWS)
//ASSERT_NOTNULL(qglXGetProcAddressARB);
if (qglXGetProcAddressARB == 0)
{
@ -246,9 +248,11 @@ QGLFunctionPointer QGL_getExtensionFunc(const char* symbol)
{
return (QGLFunctionPointer)qglXGetProcAddressARB(reinterpret_cast<const GLubyte*>(symbol));
}
#else
#elif defined(WIN32)
ASSERT_NOTNULL(qwglGetProcAddress);
return qwglGetProcAddress(symbol);
#else
#error "unsupported platform"
#endif
}
@ -610,7 +614,7 @@ int QGL_Init(OpenGLBinding& table)
{
QGL_clear(table);
#ifdef WIN32
#if defined(WIN32)
qwglCopyContext = wglCopyContext;
qwglCreateContext = wglCreateContext;
qwglCreateLayerContext = wglCreateLayerContext;
@ -633,9 +637,7 @@ int QGL_Init(OpenGLBinding& table)
qwglGetPixelFormat = GetPixelFormat;
qwglSetPixelFormat = SetPixelFormat;
qwglSwapBuffers = SwapBuffers;
#endif
#if defined (__linux__) || defined (__APPLE__)
#elif defined(XWINDOWS)
qglXChooseVisual = glXChooseVisual;
qglXCreateContext = glXCreateContext;
qglXDestroyContext = glXDestroyContext;
@ -654,12 +656,12 @@ int QGL_Init(OpenGLBinding& table)
qglXWaitX = glXWaitX;
qglXUseXFont = glXUseXFont;
// qglXGetProcAddressARB = glXGetProcAddressARB; // Utah-GLX fix
qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym(NULL, "glXGetProcAddressARB");
#endif
#if defined (__linux__) || defined (__APPLE__)
qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym(NULL, "glXGetProcAddressARB");
if ((qglXQueryExtension == 0) || (qglXQueryExtension(GDK_DISPLAY(),0,0) != True))
return 0;
#else
#error "unsupported platform"
#endif
return 1;

View file

@ -160,7 +160,7 @@ public:
}
};
#elif defined(__linux__) || defined (__APPLE__)
#elif defined(POSIX)
#include <dlfcn.h>
@ -198,6 +198,8 @@ public:
}
};
#else
#error "unsupported platform"
#endif
class DynamicLibraryModule

47
radiant/sockets.cpp Normal file
View file

@ -0,0 +1,47 @@
#include "sockets.h"
#if defined(WIN32)
#include <winsock2.h>
#elif defined (POSIX)
#include <sys/time.h>
#define SOCKET_ERROR -1
#else
#error "unsupported platform"
#endif
#ifdef __APPLE__
#include <unistd.h>
#endif
int Net_Wait(socket_t *sock, long sec, long usec)
{
// used for select()
#ifdef WIN32
TIMEVAL tout = { sec, usec };
#endif
#if defined (POSIX)
timeval tout;
tout.tv_sec = sec;
tout.tv_usec = usec;
#endif
// select() will identify if the socket needs an update
// if the socket is identified that means there's either a message or the connection has been closed/reset/terminated
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(((unsigned int)sock->socket), &readfds);
// from select man page:
// n is the highest-numbered descriptor in any of the three sets, plus 1
// (no use on windows)
switch( select( sock->socket + 1, &readfds, NULL, NULL, &tout ) )
{
case SOCKET_ERROR:
return -1;
case 0:
return 0;
default:
return 1;
}
}

14
radiant/sockets.h Normal file
View file

@ -0,0 +1,14 @@
#if !defined(INCLUDED_SOCKETS_H)
#define INCLUDED_SOCKETS_H
#include "l_net/l_net.h"
// waits for a socket to become ready
// returns
// -1: error
// 0: timeout
// 1: ready
int Net_Wait(socket_t *sock, long sec, long usec);
#endif

View file

@ -67,7 +67,7 @@ MillisecondTime MillisecondTime::current()
#elif defined(__linux__) || defined (__APPLE__)
#elif defined(POSIX)
#include <time.h>
#include "sys/time.h"

View file

@ -33,7 +33,7 @@ bool open_url(const char* url)
}
#endif
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <stdlib.h>
bool open_url(const char* url)
{

View file

@ -50,21 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "points.h"
#include "feedback.h"
#include "mainframe.h"
#ifdef WIN32
//#include <winsock2.h>
#endif
#if defined (__linux__) || defined (__APPLE__)
#include <sys/time.h>
#define SOCKET_ERROR -1
#endif
#ifdef __APPLE__
#include <unistd.h>
#endif
#include "sockets.h"
void message_flush(message_info_t* self)
{
@ -93,7 +79,6 @@ void message_print(message_info_t* self, const char* characters, std::size_t len
}
#include "l_net/l_net.h"
#include <glib/gtimer.h>
#include <glib/garray.h>
#include "xmlstuff.h"
@ -614,14 +599,14 @@ void CWatchBSP::DoEBeginStep()
#if defined(WIN32)
#define ENGINE_ATTRIBUTE "engine_win32"
#define MP_ENGINE_ATTRIBUTE "mp_engine_win32"
#elif defined(__linux__)
#elif defined(__linux__) || defined (__FreeBSD__)
#define ENGINE_ATTRIBUTE "engine_linux"
#define MP_ENGINE_ATTRIBUTE "mp_engine_linux"
#elif defined(__APPLE__)
#define ENGINE_ATTRIBUTE "engine_macos"
#define MP_ENGINE_ATTRIBUTE "mp_engine_macos"
#else
#error "unknown platform"
#error "unsupported platform"
#endif
class RunEngineConfiguration
@ -678,22 +663,8 @@ inline void GlobalGameDescription_string_write_mapparameter(StringOutputStream&
}
#ifdef WIN32
#include <windows.h>
#endif
void CWatchBSP::RoutineProcessing()
{
// used for select()
#ifdef WIN32
TIMEVAL tout = { 0, 0 };
#endif
#if defined (__linux__) || defined (__APPLE__)
timeval tout;
tout.tv_sec = 0;
tout.tv_usec = 0;
#endif
switch (m_eState)
{
case EBeginStep:
@ -732,6 +703,7 @@ void CWatchBSP::RoutineProcessing()
}
break;
case EWatching:
{
#ifdef _DEBUG
// some debug checks
if (!m_pInSocket)
@ -740,33 +712,16 @@ void CWatchBSP::RoutineProcessing()
return;
}
#endif
// select() will identify if the socket needs an update
// if the socket is identified that means there's either a message or the connection has been closed/reset/terminated
fd_set readfds;
int ret;
FD_ZERO(&readfds);
FD_SET(((unsigned int)m_pInSocket->socket), &readfds);
// from select man page:
// n is the highest-numbered descriptor in any of the three sets, plus 1
// (no use on windows)
ret = select( m_pInSocket->socket + 1, &readfds, NULL, NULL, &tout );
if (ret == SOCKET_ERROR)
int ret = Net_Wait(m_pInSocket, 0, 0);
if (ret == -1)
{
globalOutputStream() << "WARNING: SOCKET_ERROR in CWatchBSP::RoutineProcessing\n";
globalOutputStream() << "Terminating the connection.\n";
EndMonitoringLoop();
return;
}
#ifdef _DEBUG
if (ret == -1)
{
// we are non-blocking?? we should never get timeout errors
globalOutputStream() << "WARNING: unexpected timeout expired in CWatchBSP::Processing\n";
globalOutputStream() << "Terminating the connection.\n";
EndMonitoringLoop();
return;
}
#endif
if (ret == 1)
{
// the socket has been identified, there's something (message or disconnection)
@ -872,6 +827,7 @@ void CWatchBSP::RoutineProcessing()
}
}
}
}
break;
default:
break;