Use bool instead of int. Replace TRUE/FALSE with true/false.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28709 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2004-08-08 05:30:36 +00:00
parent 3e1400ac6a
commit 948c96efa1
9 changed files with 102 additions and 124 deletions

View File

@@ -42,13 +42,13 @@ public:
GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
int SetReusable() { return 0; }
bool SetReusable() { return false; }
GSocketError SetNonOriented();
GSocketError Connect(GSocketStream stream);
int Read(char *buffer, int size);
int Write(const char *buffer, int size);
GSocketEventFlags Select(GSocketEventFlags flags);
void SetNonBlocking(int non_block);
void SetNonBlocking(bool non_block);
void SetTimeout(unsigned long millisec);
GSocketError WXDLLIMPEXP_NET GetError();
void SetCallback(GSocketEventFlags flags,
@@ -83,17 +83,17 @@ public:
GAddress *m_peer;
GSocketError m_error;
int m_non_blocking;
int m_server;
int m_stream;
int m_oriented;
bool m_non_blocking;
bool m_server;
bool m_stream;
bool m_oriented;
unsigned long m_timeout;
/* Callbacks */
GSocketEventFlags m_detected;
GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
char *m_data[GSOCK_MAX_EVENT];
int m_takesEvents ;
bool m_takesEvents ;
};

View File

@@ -23,14 +23,6 @@
#include "wx/msw/wrapwin.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
{
public:
@@ -58,7 +50,7 @@ public:
GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
int SetReusable();
bool SetReusable();
GSocketError Connect(GSocketStream stream);
GSocketError SetNonOriented();
int Read(char *buffer, int size);
@@ -92,11 +84,11 @@ public:
GSocketError m_error;
/* Attributes */
int m_non_blocking;
int m_server;
int m_stream;
int m_establishing;
int m_reusable;
bool m_non_blocking;
bool m_server;
bool m_stream;
bool m_establishing;
bool m_reusable;
struct timeval m_timeout;
/* Callbacks */

View File

@@ -21,14 +21,6 @@
#include "gsocket.h"
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
class GSocketGUIFunctionsTableConcrete: public GSocketGUIFunctionsTable
{
public:
@@ -57,13 +49,13 @@ public:
GAddress *GetPeer();
GSocketError SetServer();
GSocket *WaitConnection();
int SetReusable();
bool SetReusable();
GSocketError Connect(GSocketStream stream);
GSocketError SetNonOriented();
int Read(char *buffer, int size);
int Write(const char *buffer, int size);
GSocketEventFlags Select(GSocketEventFlags flags);
void SetNonBlocking(int non_block);
void SetNonBlocking(bool non_block);
void SetTimeout(unsigned long millisec);
GSocketError WXDLLIMPEXP_NET GetError();
void SetCallback(GSocketEventFlags flags,
@@ -95,11 +87,11 @@ public:
GAddress *m_peer;
GSocketError m_error;
int m_non_blocking;
int m_server;
int m_stream;
int m_establishing;
int m_reusable;
bool m_non_blocking;
bool m_server;
bool m_stream;
bool m_establishing;
bool m_reusable;
unsigned long m_timeout;
/* Callbacks */

View File

@@ -23,12 +23,6 @@
#ifdef __DARWIN__
#include <CoreServices/CoreServices.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#else
#include <MacHeaders.c>
#define OTUNIXERRORS 1
@@ -209,11 +203,11 @@ void GSocket_SetGUIFunctions(GSocketGUIFunctionsTable *table)
int GSocket_Init()
{
return TRUE;
return 1;
}
int GSocket_Verify_Inited() ;
int GSocket_Verify_Inited()
bool GSocket_Verify_Inited() ;
bool GSocket_Verify_Inited()
{
OSStatus err ;
#if TARGET_CARBON
@@ -222,7 +216,7 @@ int GSocket_Verify_Inited()
OTClientContextPtr clientcontext;
if ( gInetSvcRef )
return TRUE ;
return true ;
InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext);
gOTInited = 1 ;
@@ -230,7 +224,7 @@ int GSocket_Verify_Inited()
NULL, &err, clientcontext);
#else
if ( gInetSvcRef )
return TRUE ;
return true ;
InitOpenTransport() ;
gOTInited = 1 ;
@@ -239,10 +233,10 @@ int GSocket_Verify_Inited()
if ( gInetSvcRef == NULL || err != kOTNoError )
{
OTAssert("Could not open Inet Services", err == noErr);
return FALSE ;
return false ;
}
gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ;
return TRUE ;
return true ;
}
void GSocket_Cleanup()
@@ -267,7 +261,7 @@ GSocket::GSocket()
{
int i;
m_ok = (GSocket_Verify_Inited() != FALSE);
m_ok = GSocket_Verify_Inited();
m_endpoint = NULL ;
for (i=0;i<GSOCK_MAX_EVENT;i++)
@@ -278,12 +272,12 @@ GSocket::GSocket()
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
m_server = FALSE;
m_stream = TRUE;
m_non_blocking = FALSE;
m_server = false;
m_stream = true;
m_non_blocking = false;
m_timeout = 1*1000;
/* 10 sec * 1000 millisec */
m_takesEvents = TRUE ;
m_takesEvents = true ;
m_mac_events = wxMacGetNotifierTable() ;
}
@@ -493,9 +487,9 @@ GSocketError GSocket::SetServer()
}
/* Initialize all fields */
m_stream = TRUE;
m_server = TRUE;
m_oriented = TRUE;
m_stream = true;
m_server = true;
m_oriented = true;
// TODO
#if 0
@@ -592,9 +586,9 @@ GSocket *GSocket::WaitConnection()
}
/* Initialize all fields */
connection->m_server = FALSE;
connection->m_stream = TRUE;
connection->m_oriented = TRUE;
connection->m_server = false;
connection->m_stream = true;
connection->m_oriented = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
@@ -652,9 +646,9 @@ GSocketError GSocket::SetNonOriented()
}
/* Initialize all fields */
m_stream = FALSE;
m_server = FALSE;
m_oriented = FALSE;
m_stream = false;
m_server = false;
m_oriented = false;
/* Create the socket */
@@ -745,8 +739,8 @@ GSocketError GSocket::Connect(GSocketStream stream)
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
m_oriented = TRUE;
m_server = FALSE;
m_oriented = true;
m_server = false;
/* Create the socket */
#if TARGET_CARBON
@@ -957,7 +951,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
*/
void GSocket::SetNonBlocking(int non_block)
void GSocket::SetNonBlocking(bool non_block)
{
assert(this);
@@ -1267,7 +1261,7 @@ GSocketError _GAddress_translate_from(GAddress *address,
GSocketError _GAddress_translate_to(GAddress *address,
InetAddress *addr)
{
if ( GSocket_Verify_Inited() == FALSE )
if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
memset(addr, 0 , sizeof(struct InetAddress));
OTInitInetAddress( addr , address->m_port , address->m_host ) ;
@@ -1293,7 +1287,7 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
InetHostInfo hinfo ;
OSStatus ret ;
if ( GSocket_Verify_Inited() == FALSE )
if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
assert(address != NULL);
@@ -1387,7 +1381,7 @@ GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port)
GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t sbuf)
{
InetDomainName name ;
if ( GSocket_Verify_Inited() == FALSE )
if ( !GSocket_Verify_Inited() )
return GSOCK_IOERR ;
assert(address != NULL);
@@ -1421,7 +1415,7 @@ void GSocket::Enable_Events()
{
OTResult state ;
m_takesEvents = TRUE ;
m_takesEvents = true ;
state = OTGetEndpointState(m_endpoint);
{
@@ -1445,7 +1439,7 @@ void GSocket::Enable_Events()
void GSocket::Disable_Events()
{
m_takesEvents = FALSE ;
m_takesEvents = false ;
}
/* _GSocket_Input_Timeout:
@@ -1457,10 +1451,10 @@ GSocketError GSocket::Input_Timeout()
if ( !m_non_blocking )
{
UnsignedWide now , start ;
short formerTakesEvents = m_takesEvents ;
bool formerTakesEvents = m_takesEvents ;
Microseconds(&start);
now = start ;
m_takesEvents = FALSE ;
m_takesEvents = false ;
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
{
@@ -1492,10 +1486,10 @@ GSocketError GSocket::Output_Timeout()
if ( !m_non_blocking )
{
UnsignedWide now , start ;
short formerTakesEvents = m_takesEvents ;
bool formerTakesEvents = m_takesEvents ;
Microseconds(&start);
now = start ;
m_takesEvents = FALSE ;
m_takesEvents = false ;
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
{

View File

@@ -55,7 +55,7 @@ bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket *socket)
m_id[0] = -1;
m_id[1] = -1;
return TRUE;
return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)

View File

@@ -171,13 +171,13 @@ GSocket::GSocket()
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
m_server = FALSE;
m_stream = TRUE;
m_server = false;
m_stream = true;
m_non_blocking = false;
m_timeout.tv_sec = 10 * 60; /* 10 minutes */
m_timeout.tv_usec = 0;
m_establishing = FALSE;
m_reusable = FALSE;
m_establishing = false;
m_reusable = false;
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
@@ -382,8 +382,8 @@ GSocketError GSocket::SetServer()
}
/* Initialize all fields */
m_server = TRUE;
m_stream = TRUE;
m_server = true;
m_stream = true;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_STREAM, 0);
@@ -485,8 +485,8 @@ GSocket *GSocket::WaitConnection()
}
/* Initialize all fields */
connection->m_server = FALSE;
connection->m_stream = TRUE;
connection->m_server = false;
connection->m_stream = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
@@ -519,14 +519,14 @@ GSocket *GSocket::WaitConnection()
* Returns TRUE if the flag was set correctly, FALSE if an error occured
* (ie, if the parameter was NULL)
*/
int GSocket::SetReusable()
bool GSocket::SetReusable()
{
/* socket must not be null, and must not be in use/already bound */
if (this && m_fd == INVALID_SOCKET) {
m_reusable = TRUE;
return TRUE;
m_reusable = true;
return true;
}
return FALSE;
return false;
}
/* Client specific parts */
@@ -578,8 +578,8 @@ GSocketError GSocket::Connect(GSocketStream stream)
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
m_server = FALSE;
m_establishing = FALSE;
m_server = false;
m_establishing = false;
/* Create the socket */
m_fd = socket(m_peer->m_realfamily,
@@ -627,7 +627,7 @@ GSocketError GSocket::Connect(GSocketStream stream)
*/
if ((err == WSAEWOULDBLOCK) && (m_non_blocking))
{
m_establishing = TRUE;
m_establishing = true;
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
@@ -675,8 +675,8 @@ GSocketError GSocket::SetNonOriented()
}
/* Initialize all fields */
m_stream = FALSE;
m_server = FALSE;
m_stream = false;
m_server = false;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
@@ -821,7 +821,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
m_establishing = FALSE;
m_establishing = false;
return (GSOCK_LOST_FLAG & flags);
}
@@ -853,7 +853,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
else
{
m_detected = GSOCK_LOST_FLAG;
m_establishing = FALSE;
m_establishing = false;
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
@@ -869,7 +869,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
int error;
SOCKLEN_T len = sizeof(error);
m_establishing = FALSE;
m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*)&error, &len);
@@ -895,7 +895,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
/* Check for exceptions and errors (is this useful in Unices?) */
if (FD_ISSET(m_fd, &exceptfds))
{
m_establishing = FALSE;
m_establishing = false;
m_detected = GSOCK_LOST_FLAG;
/* LOST event: Abort any further processing */

View File

@@ -54,7 +54,7 @@ bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket *socket)
m_id[0] = -1;
m_id[1] = -1;
return TRUE;
return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)

View File

@@ -240,13 +240,13 @@ GSocket::GSocket()
m_local = NULL;
m_peer = NULL;
m_error = GSOCK_NOERROR;
m_server = FALSE;
m_stream = TRUE;
m_server = false;
m_stream = true;
m_gui_dependent = NULL;
m_non_blocking = FALSE;
m_non_blocking = false;
m_timeout = 10*60*1000;
/* 10 minutes * 60 sec * 1000 millisec */
m_establishing = FALSE;
m_establishing = false;
assert(gs_gui_functions);
/* Per-socket GUI-specific initialization */
@@ -456,8 +456,8 @@ GSocketError GSocket::SetServer()
}
/* Initialize all fields */
m_stream = TRUE;
m_server = TRUE;
m_stream = true;
m_server = true;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_STREAM, 0);
@@ -561,8 +561,8 @@ GSocket *GSocket::WaitConnection()
}
/* Initialize all fields */
connection->m_server = FALSE;
connection->m_stream = TRUE;
connection->m_server = false;
connection->m_stream = true;
/* Setup the peer address field */
connection->m_peer = GAddress_new();
@@ -590,14 +590,14 @@ GSocket *GSocket::WaitConnection()
return connection;
}
int GSocket::SetReusable()
bool GSocket::SetReusable()
{
/* socket must not be null, and must not be in use/already bound */
if (this && m_fd == INVALID_SOCKET) {
m_reusable = TRUE;
return TRUE;
m_reusable = true;
return true;
}
return FALSE;
return false;
}
/* Client specific parts */
@@ -649,8 +649,8 @@ GSocketError GSocket::Connect(GSocketStream stream)
/* Streamed or dgram socket? */
m_stream = (stream == GSOCK_STREAMED);
m_server = FALSE;
m_establishing = FALSE;
m_server = false;
m_establishing = false;
/* Create the socket */
m_fd = socket(m_peer->m_realfamily,
@@ -708,7 +708,7 @@ GSocketError GSocket::Connect(GSocketStream stream)
*/
if ((err == EINPROGRESS) && (m_non_blocking))
{
m_establishing = TRUE;
m_establishing = true;
m_error = GSOCK_WOULDBLOCK;
return GSOCK_WOULDBLOCK;
}
@@ -756,8 +756,8 @@ GSocketError GSocket::SetNonOriented()
}
/* Initialize all fields */
m_stream = FALSE;
m_server = FALSE;
m_stream = false;
m_server = false;
/* Create the socket */
m_fd = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
@@ -931,7 +931,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
m_establishing = FALSE;
m_establishing = false;
return (GSOCK_LOST_FLAG & flags);
}
@@ -962,7 +962,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
else
{
m_detected = GSOCK_LOST_FLAG;
m_establishing = FALSE;
m_establishing = false;
/* LOST event: Abort any further processing */
return (GSOCK_LOST_FLAG & flags);
@@ -978,7 +978,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
int error;
SOCKLEN_T len = sizeof(error);
m_establishing = FALSE;
m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);
@@ -1004,7 +1004,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
/* Check for exceptions and errors (is this useful in Unices?) */
if (FD_ISSET(m_fd, &exceptfds))
{
m_establishing = FALSE;
m_establishing = false;
m_detected = GSOCK_LOST_FLAG;
/* LOST event: Abort any further processing */
@@ -1029,7 +1029,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
* Sets the socket to non-blocking mode. All IO calls will return
* immediately.
*/
void GSocket::SetNonBlocking(int non_block)
void GSocket::SetNonBlocking(bool non_block)
{
assert(this);
@@ -1356,7 +1356,7 @@ void GSocket::Detected_Read()
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
m_establishing = FALSE;
m_establishing = false;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
@@ -1388,7 +1388,7 @@ void GSocket::Detected_Write()
*/
if ((m_detected & GSOCK_LOST_FLAG) != 0)
{
m_establishing = FALSE;
m_establishing = false;
CALL_CALLBACK(this, GSOCK_LOST);
Shutdown();
@@ -1400,7 +1400,7 @@ void GSocket::Detected_Write()
int error;
SOCKLEN_T len = sizeof(error);
m_establishing = FALSE;
m_establishing = false;
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (void*)&error, &len);

View File

@@ -64,7 +64,7 @@ bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket *socket)
m_id[0] = -1;
m_id[1] = -1;
return TRUE;
return true;
}
void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket *socket)