On behalf of Scott Mansfield, the 3/4 Net* classes headers are there.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin
2002-11-01 02:49:38 +00:00
parent 2b1e7eaca7
commit 2ae4404ac1
3 changed files with 228 additions and 258 deletions
+5 -8
View File
@@ -2,9 +2,6 @@
* NetAddress.h -- Interface definition for the BNetAddress class. * NetAddress.h -- Interface definition for the BNetAddress class.
* *
* Written by S.T. Mansfield ([email protected]) * Written by S.T. Mansfield ([email protected])
*
* Remarks:
* Mr. Phipps, put that fish away, dude.
*=--------------------------------------------------------------------------=* *=--------------------------------------------------------------------------=*
* Copyright (c) 2002, The OpenBeOS project. * Copyright (c) 2002, The OpenBeOS project.
* *
@@ -31,10 +28,10 @@
#ifndef _NETADDRESS_H #ifndef _NETADDRESS_H
#define _NETADDRESS_H #define _NETADDRESS_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Archivable.h> #include <Archivable.h>
#include <Errors.h> #include <socket.h>
#include <Application.h>
#include <Message.h>
/* /*
* Empty forward declaration to satisfy the GetImpl method. * Empty forward declaration to satisfy the GetImpl method.
@@ -50,7 +47,7 @@ public:
virtual status_t Archive( BMessage* into, bool deep = true ) const; virtual status_t Archive( BMessage* into, bool deep = true ) const;
static BArchivable* Instantiate( BMessage* archive ); static BArchivable* Instantiate( BMessage* archive );
BNetAddress( const char* hostname = NULL, unsigned short port = 0 ); BNetAddress( const char* hostname = 0, unsigned short port = 0 );
BNetAddress( const struct sockaddr_in& sa ); BNetAddress( const struct sockaddr_in& sa );
BNetAddress( in_addr addr, int port = 0 ); BNetAddress( in_addr addr, int port = 0 );
BNetAddress( uint32 addr, int port = 0 ); BNetAddress( uint32 addr, int port = 0 );
@@ -59,7 +56,7 @@ public:
BNetAddress& operator=( const BNetAddress& ); BNetAddress& operator=( const BNetAddress& );
status_t InitCheck( void ) const; status_t InitCheck( void );
status_t SetTo( const char* hostname, const char* protocol, const char* service ); status_t SetTo( const char* hostname, const char* protocol, const char* service );
status_t SetTo( const char* hostname = NULL, unsigned short port = 0 ); status_t SetTo( const char* hostname = NULL, unsigned short port = 0 );
+87 -114
View File
@@ -1,24 +1,29 @@
//------------------------------------------------------------------------------ /*=--------------------------------------------------------------------------=*
// Copyright (c) 2001-2002, OpenBeOS * NetBuffer.h -- Interface definition for the BNetBuffer class.
// *
// Permission is hereby granted, free of charge, to any person obtaining a * Written by S.T. Mansfield ([email protected])
// copy of this software and associated documentation files (the "Software"), *=--------------------------------------------------------------------------=*
// to deal in the Software without restriction, including without limitation * Copyright (c) 2002, The OpenBeOS project.
// the rights to use, copy, modify, merge, publish, distribute, sublicense, *
// and/or sell copies of the Software, and to permit persons to whom the * Permission is hereby granted, free of charge, to any person obtaining a
// Software is furnished to do so, subject to the following conditions: * copy of this software and associated documentation files (the "Software"),
// * to deal in the Software without restriction, including without limitation
// The above copyright notice and this permission notice shall be included in * the rights to use, copy, modify, merge, publish, distribute, sublicense,
// all copies or substantial portions of the Software. * and/or sell copies of the Software, and to permit persons to whom the
// * Software is furnished to do so, subject to the following conditions:
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * The above copyright notice and this permission notice shall be included in
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * all copies or substantial portions of the Software.
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// DEALINGS IN THE SOFTWARE. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//------------------------------------------------------------------------------ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*=--------------------------------------------------------------------------=*
*/
#ifndef _NETBUFFER_H #ifndef _NETBUFFER_H
#define _NETBUFFER_H #define _NETBUFFER_H
@@ -26,123 +31,91 @@
#include <BeBuild.h> #include <BeBuild.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <Archivable.h> #include <Archivable.h>
#include <sys/socket.h> #include <socket.h>
/* /*
* BNetBuffer * Empty forward declaration to satisfy the GetImpl method.
*
* BNetBuffer is a dynamic buffer useful for storing data to be sent
* across the network. Data is inserted into and removed from
* the object using one of the many insert and remove member functions.
* Access to the raw stored data is possible. The BNetEndpoint class has a
* send and recv function for use with BNetBuffer. Network byte order conversion
* is done automatically for all appropriate integral types in the insert and remove
* functions for that type.
*
*/ */
class NLPacket; class NLPacket;
class BNetBuffer : public BArchivable class BNetBuffer : public BArchivable
{ {
public: public:
BNetBuffer( size_t size = 0 );
virtual ~BNetBuffer( void );
BNetBuffer(size_t size = 0); status_t InitCheck( void );
virtual ~BNetBuffer();
/* BNetBuffer( BMessage* Archive );
* It is important to call InitCheck() after creating an instance of this class. virtual status_t Archive( BMessage* into, bool deep = true ) const;
*/ static BArchivable* Instantiate( BMessage* archive );
status_t InitCheck(); BNetBuffer( const BNetBuffer& );
BNetBuffer& operator=( const BNetBuffer& );
BNetBuffer(BMessage *archive); // Mutators.
virtual status_t Archive(BMessage *into, bool deep = true) const; status_t AppendInt8( int8 );
static BArchivable *Instantiate(BMessage *archive); status_t AppendUint8( uint8 );
status_t AppendInt16( int16 );
status_t AppendUint16( uint16 );
status_t AppendInt32( int32 );
status_t AppendUint32( uint32 );
status_t AppendFloat( float );
status_t AppendDouble( double );
status_t AppendString( const char* );
status_t AppendData( const void*, size_t );
status_t AppendMessage( const BMessage& );
status_t AppendInt64( int64 );
status_t AppendUint64( uint64 );
BNetBuffer(const BNetBuffer &); status_t RemoveInt8( int8& );
BNetBuffer &operator=(const BNetBuffer &); status_t RemoveUint8( uint8& );
status_t RemoveInt16( int16& );
status_t RemoveUint16( uint16& );
status_t RemoveInt32( int32& );
status_t RemoveUint32( uint32& );
status_t RemoveFloat( float& );
status_t RemoveDouble( double& );
status_t RemoveString( char*, size_t );
status_t RemoveData( void*, size_t );
status_t RemoveMessage( BMessage& );
status_t RemoveInt64( int64& );
status_t RemoveUint64( uint64& );
// Accessors.
unsigned char* Data( void ) const;
size_t Size( void ) const;
size_t BytesRemaining( void ) const;
/* inline NLPacket *GetImpl( void ) const;
* Data insertion member functions. Data is inserted at the end of the internal
* dynamic buffer. For the short, int, and long versions (and unsigned of
* each as well) byte order conversion is performed.
*
* The terminating null of all strings are inserted as
* well.
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
status_t AppendInt8(int8);
status_t AppendUint8(uint8);
status_t AppendInt16(int16);
status_t AppendUint16(uint16);
status_t AppendInt32(int32);
status_t AppendUint32(uint32);
status_t AppendFloat(float);
status_t AppendDouble(double);
status_t AppendString(const char *);
status_t AppendData(const void *, size_t);
status_t AppendMessage(const BMessage &);
status_t AppendInt64(int64);
status_t AppendUint64(uint64);
/*
* Data extraction member functions. Data is extracted from the start of the
* internal dynamic buffer. For the short, int, and long versions (and
* unsigned of each as well) byte order conversion is performed.
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
status_t RemoveInt8(int8 &);
status_t RemoveUint8(uint8 &);
status_t RemoveInt16(int16 &);
status_t RemoveUint16(uint16 &);
status_t RemoveInt32(int32 &);
status_t RemoveUint32(uint32 &);
status_t RemoveFloat(float &);
status_t RemoveDouble(double &);
status_t RemoveString(char *, size_t);
status_t RemoveData(void *, size_t);
status_t RemoveMessage(BMessage &);
status_t RemoveInt64(int64 &);
status_t RemoveUint64(uint64 &);
/*
* GetData() returns a pointer to the internal data buffer. This is useful
* when wanting to pass the data to a function expecting a pointer to data.
* GetSize() returns the size of the BNetPacket's data, in bytes.
* GetBytesRemaining() returns the bytes remaining in the BNetPacket available
* to be extracted via BNetPacket::Remove*().
*/
unsigned char *Data() const;
size_t Size() const;
size_t BytesRemaining() const;
inline NLPacket *GetImpl() const;
protected: protected:
status_t m_init; // Attributes.
status_t fInitialized;
unsigned char* fData;
int32 fDataSize;
int32 fStackSize;
int32 fCapacity;
private: private:
virtual void _ReservedBNetBufferFBCCruft1(); // Private class helpers.
virtual void _ReservedBNetBufferFBCCruft2(); status_t clone( const BNetBuffer& );
virtual void _ReservedBNetBufferFBCCruft3(); status_t dpop( int32, int32, void* );
virtual void _ReservedBNetBufferFBCCruft4(); status_t dpush( int32, int32, const void* );
virtual void _ReservedBNetBufferFBCCruft5(); status_t resize( int32 NewSize, bool RegenStack = false );
virtual void _ReservedBNetBufferFBCCruft6();
int32 __ReservedBNetBufferFBCCruftData[9];
// Not used, here to maintain R5 binary compatiblilty.
int32 fPrivateData[5];
}; };
inline NLPacket *BNetBuffer::GetImpl() const // WARNING: This method, as it stands, breaks R5 compatibility *STM*.
inline NLPacket* BNetBuffer::GetImpl( void ) const
{ {
return NULL; // No Nettle backward compatibility return NULL; // Cheeky, yes; but no Nettle stuff is allowed...
} }
#endif // _NETBUFFER_H #endif // <-- #ifndef _NETBUFFER_H
/*=------------------------------------------------------------------- End -=*/
+36 -36
View File
@@ -1,24 +1,29 @@
//------------------------------------------------------------------------------ /*=--------------------------------------------------------------------------=*
// Copyright (c) 2001-2002, OpenBeOS * NetDebug.h -- Interface definition for the BNetDebug class.
// *
// Permission is hereby granted, free of charge, to any person obtaining a * Written by S.T. Mansfield ([email protected])
// copy of this software and associated documentation files (the "Software"), *=--------------------------------------------------------------------------=*
// to deal in the Software without restriction, including without limitation * Copyright (c) 2002, The OpenBeOS project.
// the rights to use, copy, modify, merge, publish, distribute, sublicense, *
// and/or sell copies of the Software, and to permit persons to whom the * Permission is hereby granted, free of charge, to any person obtaining a
// Software is furnished to do so, subject to the following conditions: * copy of this software and associated documentation files (the "Software"),
// * to deal in the Software without restriction, including without limitation
// The above copyright notice and this permission notice shall be included in * the rights to use, copy, modify, merge, publish, distribute, sublicense,
// all copies or substantial portions of the Software. * and/or sell copies of the Software, and to permit persons to whom the
// * Software is furnished to do so, subject to the following conditions:
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * The above copyright notice and this permission notice shall be included in
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * all copies or substantial portions of the Software.
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// DEALINGS IN THE SOFTWARE. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//------------------------------------------------------------------------------ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*=--------------------------------------------------------------------------=*
*/
#ifndef _NETDEBUG_H #ifndef _NETDEBUG_H
#define _NETDEBUG_H #define _NETDEBUG_H
@@ -34,25 +39,20 @@
class BNetDebug class BNetDebug
{ {
public: public:
/* // turn debugging message output on or off
* turn debugging message output on or off
*/
static void Enable(bool); static void Enable(bool);
/* // test debugging message output state
* test debugging message output state
*/
static bool IsEnabled(); static bool IsEnabled();
/* // print a debugging message
* print a debugging message static void Print( const char* msg );
*/
static void Print(const char *msg);
/* // dump raw data in a nice hd-like format
* dump raw data in a nice hd-like format static void Dump( const char* data, size_t size, const char* title );
*/
static void Dump(const char *data, size_t size, const char *title);
}; };
#endif // _NETDEBUG_H #endif // <-- #ifndef _NETDEBUG_H
/*=------------------------------------------------------------------- End -=*/