[Plib-cvs] plib/src/net netBuffer.h,1.7,1.8 netChannel.cxx,1.7,1.8 netChannel.h,1.8,1.9 netMessage.c
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-03-21 17:51:24
|
Update of /cvsroot/plib/plib/src/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/plib/src/net Modified Files: netBuffer.h netChannel.cxx netChannel.h netMessage.cxx netMessage.h netMonitor.h netSocket.cxx netSocket.h Log Message: Cleaned up some name-space pollution, added readme's for examples. Index: netBuffer.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netBuffer.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- netBuffer.h 2 Sep 2002 06:05:44 -0000 1.7 +++ netBuffer.h 21 Mar 2004 17:41:07 -0000 1.8 @@ -87,7 +87,7 @@ //eg. char name [ NET_MAX_NAME+1 ] ; -inline char* netCopyName ( char* dst, cchar* src ) +inline char* netCopyName ( char* dst, const char* src ) { if ( src != NULL ) { Index: netChannel.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/net/netChannel.cxx,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- netChannel.cxx 2 Sep 2002 06:05:44 -0000 1.7 +++ netChannel.cxx 21 Mar 2004 17:41:07 -0000 1.8 @@ -95,7 +95,7 @@ } int -netChannel::connect ( cchar* host, int port ) +netChannel::connect ( const char* host, int port ) { int result = netSocket::connect ( host, port ) ; if (result == 0) { @@ -201,7 +201,7 @@ } bool -netChannel::poll (u32 timeout) +netChannel::poll (unsigned int timeout) { if (!channels) return false ; @@ -271,7 +271,7 @@ } void -netChannel::loop (u32 timeout) +netChannel::loop (unsigned int timeout) { while ( poll (timeout) ) ; } Index: netChannel.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netChannel.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- netChannel.h 2 Sep 2002 06:05:44 -0000 1.8 +++ netChannel.h 21 Mar 2004 17:41:07 -0000 1.9 @@ -58,7 +58,7 @@ bool closed, connected, accepting, write_blocked, should_delete ; netChannel* next_channel ; - friend bool netPoll (u32 timeout); + friend bool netPoll (unsigned int timeout); public: @@ -77,7 +77,7 @@ bool open ( void ) ; void close ( void ) ; int listen ( int backlog ) ; - int connect ( cchar* host, int port ) ; + int connect ( const char* host, int port ) ; int send ( const void * buf, int size, int flags = 0 ) ; int recv ( void * buf, int size, int flags = 0 ) ; @@ -109,8 +109,8 @@ ulSetError(UL_WARNING,"Network: %d: errno: %s(%d)",getHandle(),strerror(errno),errno); } - static bool poll (u32 timeout = 0 ) ; - static void loop (u32 timeout = 0 ) ; + static bool poll (unsigned int timeout = 0 ) ; + static void loop (unsigned int timeout = 0 ) ; }; #endif // NET_CHANNEL_H Index: netMessage.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/net/netMessage.cxx,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- netMessage.cxx 2 Sep 2002 06:05:44 -0000 1.6 +++ netMessage.cxx 21 Mar 2004 17:41:07 -0000 1.7 @@ -30,7 +30,7 @@ int n = in_buffer.getLength () ; while ( n >= 2 ) { - u16 msg_len = *( (u16*)in_buffer.getData() ) ; + unsigned short msg_len = *( (unsigned short*)in_buffer.getData() ) ; if ( n >= msg_len ) { //we have a complete message; handle it Index: netMessage.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netMessage.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- netMessage.h 11 Nov 2003 22:54:48 -0000 1.10 +++ netMessage.h 21 Mar 2004 17:41:07 -0000 1.11 @@ -54,36 +54,43 @@ class netGuid //Globally Unique IDentifier { public: - u8 data [ 16 ] ; + unsigned char data [ 16 ] ; netGuid () {} - netGuid ( u32 l, u16 w1, u16 w2, - u8 b1, u8 b2, u8 b3, u8 b4, u8 b5, u8 b6, u8 b7, u8 b8 ) + netGuid ( unsigned int l, [...167 lines suppressed...] } - f32 getf () const + float getf () const { - u32 temp ; + unsigned int temp ; geta ( &temp, sizeof(temp) ) ; temp = ntohl ( temp ) ; - return *((f32*)&temp) ; + return *((float*)&temp) ; } - void putf ( f32 f ) + void putf ( float f ) { - u32 temp = *((u32*)&f) ; + unsigned int temp = *((unsigned int*)&f) ; temp = htonl ( temp ) ; puta ( &temp, sizeof(temp) ) ; } Index: netMonitor.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netMonitor.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- netMonitor.h 2 Sep 2002 06:05:44 -0000 1.9 +++ netMonitor.h 21 Mar 2004 17:41:07 -0000 1.10 @@ -50,7 +50,7 @@ char* name ; char* password ; char* prompt ; - void (*cmdfunc)(cchar*) ; + void (*cmdfunc)(const char*) ; class netMonitorChannel* active ; friend class netMonitorChannel ; @@ -60,7 +60,7 @@ public: - netMonitorServer( cchar* _name, int port ) + netMonitorServer( const char* _name, int port ) { name = ulStrDup(_name); password = ulStrDup("") ; @@ -82,20 +82,20 @@ delete[] prompt ; } - cchar* getPassword () const { return password; } - void setPassword ( cchar* string ) + const char* getPassword () const { return password; } + void setPassword ( const char* string ) { delete[] password ; password = ulStrDup ( string?string:"" ) ; } - void setPrompt ( cchar* string ) + void setPrompt ( const char* string ) { delete[] prompt ; prompt = ulStrDup ( string?string:"" ) ; } - void setCommandFunc ( void (*func)(cchar*) ) + void setCommandFunc ( void (*func)(const char*) ) { cmdfunc = func ; } Index: netSocket.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/net/netSocket.cxx,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- netSocket.cxx 21 Mar 2004 17:13:00 -0000 1.26 +++ netSocket.cxx 21 Mar 2004 17:41:07 -0000 1.27 @@ -56,13 +56,13 @@ #define INADDR_NONE ((unsigned long)-1) #endif -netAddress::netAddress ( cchar* host, int port ) +netAddress::netAddress ( const char* host, int port ) { set ( host, port ) ; } -void netAddress::set ( cchar* host, int port ) +void netAddress::set ( const char* host, int port ) { memset(this, 0, sizeof(netAddress)); @@ -116,10 +116,10 @@ This is always a string of the form 'dd.dd.dd.dd' (with variable size numbers). */ -cchar* netAddress::getHost () const +const char* netAddress::getHost () const { #if 0 - cchar* buf = inet_ntoa ( sin_addr ) ; + const char* buf = inet_ntoa ( sin_addr ) ; #else static char buf [32]; long x = ntohl(sin_addr); @@ -136,7 +136,7 @@ return ntohs(sin_port); } -cchar* netAddress::getLocalHost () +const char* netAddress::getLocalHost () { //gethostbyname(gethostname()) @@ -147,7 +147,7 @@ if (hp && *hp->h_addr_list) { in_addr addr = *((in_addr*)*hp->h_addr_list); - cchar* host = inet_ntoa(addr); + const char* host = inet_ntoa(addr); if ( host ) return host ; } @@ -226,7 +226,7 @@ } int -netSocket::bind ( cchar* host, int port ) +netSocket::bind ( const char* host, int port ) { assert ( handle != -1 ) ; netAddress addr ( host, port ) ; @@ -249,7 +249,7 @@ } int -netSocket::connect ( cchar* host, int port ) +netSocket::connect ( const char* host, int port ) { assert ( handle != -1 ) ; netAddress addr ( host, port ) ; @@ -263,14 +263,14 @@ netSocket::send (const void * buffer, int size, int flags) { assert ( handle != -1 ) ; - return ::send (handle, (cchar*)buffer, size, flags); + return ::send (handle, (const char*)buffer, size, flags); } int netSocket::sendto ( const void * buffer, int size, int flags, const netAddress* to ) { assert ( handle != -1 ) ; - return ::sendto(handle,(cchar*)buffer,size,flags,(const sockaddr*)to,sizeof(netAddress)); + return ::sendto(handle,(const char*)buffer,size,flags,(const sockaddr*)to,sizeof(netAddress)); } int @@ -443,7 +443,7 @@ return(0); } -cchar* netFormat ( cchar* format, ... ) +const char* netFormat ( const char* format, ... ) { static char buffer[ 256 ]; va_list argptr; Index: netSocket.h =================================================================== RCS file: /cvsroot/plib/plib/src/net/netSocket.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- netSocket.h 21 Mar 2004 17:13:00 -0000 1.17 +++ netSocket.h 21 Mar 2004 17:41:07 -0000 1.18 @@ -44,45 +44,25 @@ #include "ul.h" #include <errno.h> - -/* - * Define Basic types - */ - -typedef float f32; -typedef double f64; - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; - -typedef const char cchar; -typedef const void cvoid; - - /* * Socket address, internet style. */ class netAddress { - s16 sin_family; - u16 sin_port; - u32 sin_addr; - char sin_zero[8]; + short sin_family ; + unsigned short sin_port ; + unsigned int sin_addr ; + char sin_zero [ 8 ] ; public: netAddress () {} - netAddress ( cchar* host, int port ) ; + netAddress ( const char* host, int port ) ; - void set ( cchar* host, int port ) ; - cchar* getHost () const ; + void set ( const char* host, int port ) ; + const char* getHost () const ; int getPort() const ; - static cchar* getLocalHost () ; + static const char* getLocalHost () ; bool getBroadcast () const ; }; @@ -105,10 +85,10 @@ bool open ( bool stream=true ) ; void close ( void ) ; - int bind ( cchar* host, int port ) ; + int bind ( const char* host, int port ) ; int listen ( int backlog ) ; int accept ( netAddress* addr ) ; - int connect ( cchar* host, int port ) ; + int connect ( const char* host, int port ) ; int send ( const void * buffer, int size, int flags = 0 ) ; int sendto ( const void * buffer, int size, int flags, const netAddress* to ) ; int recv ( void * buffer, int size, int flags = 0 ) ; @@ -127,7 +107,7 @@ int netInit () ; -cchar* netFormat ( cchar* fmt, ... ) ; +const char* netFormat ( const char* fmt, ... ) ; #endif // NET_SOCKET_H |