Updated wxDataStream (added ByteOrder)

Removed sckint.cpp from Makefile.am and filelist.txt (Could someone rebuild Makefile for MSW)
Some update to the documentation. I'm documenting GSocket.
Added gsockno.c in stubs


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
1999-07-24 09:05:25 +00:00
parent 7e256c24fb
commit 5a96d2f45f
13 changed files with 165 additions and 225 deletions

View File

@@ -29,7 +29,7 @@
// ---------------------------------------------------------------------------
wxDataInputStream::wxDataInputStream(wxInputStream& s)
: m_input(&s)
: m_input(&s), m_be_order(FALSE)
{
}
@@ -39,31 +39,33 @@ wxDataInputStream::~wxDataInputStream()
wxUint32 wxDataInputStream::Read32()
{
char buf[4];
wxUint32 i32;
m_input->Read(buf, 4);
m_input->Read(&i32, 4);
return (wxUint32)buf[0] |
((wxUint32)buf[1] << 8) |
((wxUint32)buf[2] << 16) |
((wxUint32)buf[3] << 24);
if (m_be_order)
return wxUINT32_SWAP_ON_LE(i32);
else
return wxUINT32_SWAP_ON_BE(i32);
}
wxUint16 wxDataInputStream::Read16()
{
char buf[2];
wxUint16 i16;
m_input->Read(buf, 2);
m_input->Read(&i16, 2);
return (wxUint16)buf[0] |
((wxUint16)buf[1] << 8);
if (m_be_order)
return wxUINT16_SWAP_ON_LE(i16);
else
return wxUINT16_SWAP_ON_BE(i16);
}
wxUint8 wxDataInputStream::Read8()
{
wxUint8 buf;
m_input->Read((char *)&buf, 1);
m_input->Read(&buf, 1);
return (wxUint8)buf;
}
@@ -169,22 +171,25 @@ wxDataOutputStream::~wxDataOutputStream()
void wxDataOutputStream::Write32(wxUint32 i)
{
char buf[4];
wxUint32 i32;
buf[0] = i & 0xff;
buf[1] = (i >> 8) & 0xff;
buf[2] = (i >> 16) & 0xff;
buf[3] = (i >> 24) & 0xff;
m_output->Write(buf, 4);
if (m_be_order)
i32 = wxUINT32_SWAP_ON_LE(i);
else
i32 = wxUINT32_SWAP_ON_BE(i);
m_output->Write(&i32, 4);
}
void wxDataOutputStream::Write16(wxUint16 i)
{
char buf[2];
wxUint16 i16;
buf[0] = i & 0xff;
buf[1] = (i >> 8) & 0xff;
m_output->Write(buf, 2);
if (m_be_order)
i16 = wxUINT16_SWAP_ON_LE(i);
else
i16 = wxUINT16_SWAP_ON_BE(i);
m_output->Write(&i16, 2);
}
void wxDataOutputStream::Write8(wxUint8 i)

View File

@@ -106,13 +106,12 @@ bool wxIPV4address::Hostname(const wxString& name)
bool wxIPV4address::Hostname(unsigned long addr)
{
/* Need API */
return TRUE;
return (GAddress_INET_SetHostAddress(m_address, addr) == GSOCK_NOERROR);
}
bool wxIPV4address::Service(const wxString& name)
{
return (GAddress_INET_SetPortName(m_address, name.fn_str()) == GSOCK_NOERROR);
return (GAddress_INET_SetPortName(m_address, name.fn_str(), "tcp") == GSOCK_NOERROR);
}
bool wxIPV4address::Service(unsigned short port)
@@ -139,7 +138,7 @@ unsigned short wxIPV4address::Service()
return GAddress_INET_GetPort(m_address);
}
#ifdef IPV6_ENABLE
#if 0
// ---------------------------------------------------------------------------
// wxIPV6address
// ---------------------------------------------------------------------------

View File

@@ -1,4 +1,4 @@
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Name: txtstrm.cpp
// Purpose: Text stream classes
// Author: Guilhem Lavaux

View File

@@ -320,12 +320,16 @@ wxString wxURL::ConvertToValidURI(const wxString& uri)
for (i=0;i<uri.Len();i++) {
wxChar c = uri.GetChar(i);
if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('.') &&
c != _T('/')) {
hexa_code.Printf(_T("%%%02X"), c);
out_str += hexa_code;
} else
out_str += c;
if (c == _T(' '))
out_str += _T('+');
else {
if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('.') &&
c != _T('/')) {
hexa_code.Printf(_T("%%%02X"), c);
out_str += hexa_code;
} else
out_str += c;
}
}
return out_str;

View File

@@ -3,11 +3,6 @@
// Name: gsockmot.cpp
// Purpose: GSocket: Motif part
// CVSID: $Id$
// Log: $Log$
// Log: Revision 1.1 1999/07/23 17:24:24 GL
// Log: Added GSocket motif (it compiles but I didn't tested it)
// Log: Changed wxSockFlags type (switched to int)
// Log:
// -------------------------------------------------------------------------
#include <stdlib.h>
#include <X11/Intrinsic.h>

View File

@@ -87,7 +87,6 @@ libwx_msw_la_SOURCES = \
resource.cpp \
sckaddr.cpp \
sckfile.cpp \
sckint.cpp \
sckipc.cpp \
sckstrm.cpp \
serbase.cpp \

34
src/stubs/gsockno.c Normal file
View File

@@ -0,0 +1,34 @@
/* -------------------------------------------------------------------------
* Project: GSocket (Generic Socket) for WX
* Name: gsockno.c
* Purpose: GSocket stub GUI file
* CVSID: $Id$
* -------------------------------------------------------------------------
*/
#include <stdlib.h>
#include "gsocket.h"
void _GSocket_GUI_Init(GSocket *socket)
{
}
void _GSocket_GUI_Destroy(GSocket *socket)
{
}
void _GSocket_Install_Fallback(GSocket *socket, GSocketEvent event)
{
}
void _GSocket_Uninstall_Fallback(GSocket *socket, GSocketEvent event)
{
}
unsigned long GSocket_GetEventID(GSocket *socket)
{
return 0;
}
void GSocket_DoEvent(unsigned long evt_id)
{
}

View File

@@ -26,7 +26,7 @@
#include <stdlib.h>
#ifdef sun
#include <sys/filio.h>
#include <sys/filio.h>
#endif
#ifdef sgi
@@ -34,12 +34,22 @@
#endif
#include <signal.h>
#include <features.h>
#include <wx/setup.h>
#include <wx/gsocket.h>
#include "gsockunx.h"
#ifndef SOCKLEN_T
# define SOCKLEN_T int
#ifdef __GLIBC__
# if __GLIBC__ == 2
# define SOCKLEN_T socklen_t
# endif
#else
# define SOCKLEN_T int
#endif
#endif
/* Constructors / Destructors */
@@ -107,7 +117,9 @@ void GSocket_Shutdown(GSocket *socket)
GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
{
if (socket == NULL || (socket->m_fd != -1 && !socket->m_server))
assert(socket != NULL);
if ((socket->m_fd != -1 && !socket->m_server))
return GSOCK_INVSOCK;
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
@@ -123,8 +135,7 @@ GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address)
{
if (socket == NULL)
return GSOCK_INVSOCK;
assert(socket != NULL);
if (address == NULL || address->m_family == GSOCK_NOFAMILY) {
socket->m_error = GSOCK_INVADDR;
@@ -184,7 +195,8 @@ GAddress *GSocket_GetPeer(GSocket *socket)
GSocket_SetServer() setup the socket as a server. It uses the "Local" field
of GSocket. "Local" must be set by GSocket_SetLocal() before
GSocket_SetServer() is called. GSOCK_INVSOCK if socket has been initialized.
In the other cases, it returns GSOCK_INVADDR.
In case, you haven't yet defined the local address, it returns GSOCK_INVADDR.
In the other cases it returns GSOCK_IOERR.
*/
GSocketError GSocket_SetServer(GSocket *sck)
{
@@ -795,7 +807,8 @@ GSocketError GAddress_INET_SetHostAddress(GAddress *address,
return GSOCK_NOERROR;
}
GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port)
GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
const char *protocol)
{
struct servent *se;
struct sockaddr_in *addr;
@@ -809,7 +822,7 @@ GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port)
}
/* TODO: TCP or UDP */
se = getservbyname(port, "tcp");
se = getservbyname(port, protocol);
if (!se) {
if (isdigit(port[0])) {
int port_int;