Main Page   Compound List   File List   Compound Members   File Members  

lib/stream.c File Reference

Stream implementation. More...

#include "gobj/stream.h"
#include "gobj/id.h"
#include "gobj/iface.h"
#include "gobj/errors.h"
#include "gobj/utils.h"

Compounds

struct  Gj_Stream_struct

Defines

#define GJ_FLOATBUFLEN   30
 String buffer for floating pointer numbers length.


Functions

Gj_StreamGj_stream_new (Gj_Ctx* ctx, Gj_Id* iface, char* addr)
 Create a new stream. More...

Gj_StreamGj_stream_newFromIncomingConn (Gj_Ctx* ctx, Gj_IfaceIncomingConn* conn)
 Create a new stream from a Gj_IfaceIncomingConn. More...

int Gj_stream_delete (Gj_Ctx* ctx, Gj_Stream* ptr)
 Destroy a stream. More...

char* Gj_stream_getAddr (Gj_Ctx* ctx, Gj_Stream* stream)
 Get the address of a stream. More...

int Gj_stream_open (Gj_Ctx* ctx, Gj_Stream* stream)
 Open the stream. More...

int Gj_stream_close (Gj_Ctx* ctx, Gj_Stream* stream)
 Close the stream. More...

int Gj_stream_flush (Gj_Ctx* ctx, Gj_Stream* stream)
 Flush the stream. More...

int gj_stream_read2write (Gj_Ctx* ctx, Gj_Stream* stream)
 Switch from read to write mode. More...

int gj_stream_write2read (Gj_Ctx* ctx, Gj_Stream* stream)
 Switch from write to read mode. More...

int gj_stream_write (Gj_Ctx* ctx, Gj_Stream* stream, void* ptr, int size)
 Write size bytes from the given memory location to the lower layers. More...

int gj_stream_writeLow (Gj_Ctx* ctx, Gj_Stream* stream, void* ptr, int size)
 Write size bytes from the given memory location to the lower layers. More...

int gj_stream_read (Gj_Ctx* ctx, Gj_Stream* stream, void* ptr, int size)
 Read size bytes from the lower layers and write them to the given memory location. More...

int gj_stream_readLow (Gj_Ctx* ctx, Gj_Stream* stream, void* ptr, int size)
 Read size bytes from the lower layers and write them to the given memory location. More...

int Gj_stream_writeI32 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si32 value)
 Write a 32-bit integer value to the stream. More...

int Gj_stream_writeI16 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si16 value)
 Write a 16-bit integer value to the stream. More...

int Gj_stream_writeI8 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si8 value)
 Write a 8-bit integer value to the stream. More...

int Gj_stream_writeF64 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_F64 value)
 Write a 64-bit float value to the stream. More...

int Gj_stream_writeF32 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_F32 value)
 Write a 32-bit float value to the stream. More...

int Gj_stream_writeStr (Gj_Ctx* ctx, Gj_Stream* stream, char* string)
 Write a string to the stream. More...

int Gj_stream_readI32 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si32* value)
 Read a 32-bit integer value from the stream. More...

int Gj_stream_readI16 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si16* value)
 Read a 16-bit integer value from the stream. More...

int Gj_stream_readI8 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_Si8* value)
 Read a 8-bit integer value from the stream. More...

int Gj_stream_readF64 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_F64* value)
 Read a 64-bit float value from the stream. More...

int Gj_stream_readF32 (Gj_Ctx* ctx, Gj_Stream* stream, Gj_F32* value)
 Read a 32-bit float value from the stream. More...

int Gj_stream_readStr (Gj_Ctx* ctx, Gj_Stream* stream, char** string)
 Read a string from the stream. More...


Detailed Description

Stream implementation.


Function Documentation

Gj_Stream * Gj_stream_new ( Gj_Ctx * ctx,
Gj_Id * iface,
char * addr )
 

Create a new stream.

Parameters:
ctx   The context.
iface   The iface id.
addr   The destination address (is NOT being DUPLICATED and not deleted on destruction, too).

Returns:
The pointer to the new stream on success, 0 otherwise.

Gj_Stream * Gj_stream_newFromIncomingConn ( Gj_Ctx * ctx,
Gj_IfaceIncomingConn * conn )
 

Create a new stream from a Gj_IfaceIncomingConn.

The port of the connection must not be closed anymore - this is done by the stream. The clientaddr has still to be freed on destruction of the connection.

Parameters:
ctx   The context (of the connection).
conn   The incoming connection (including the context of the listening function).

Returns:
The pointer to the new stream on success, 0 otherwise.

int Gj_stream_delete ( Gj_Ctx * ctx,
Gj_Stream * ptr )
 

Destroy a stream.

The address is not deleted.

Parameters:
ctx   The context.
stream   The stream.

Returns:
0 on success, -1 otherwise.

char * Gj_stream_getAddr ( Gj_Ctx * ctx,
Gj_Stream * stream )
 

Get the address of a stream.

Parameters:
ctx   The context.
stream   The stream.

Returns:
The address (not duplicated).

int Gj_stream_open ( Gj_Ctx * ctx,
Gj_Stream * stream )
 

Open the stream.

Returns:
0 on success, -1 otherwise .

int Gj_stream_close ( Gj_Ctx * ctx,
Gj_Stream * stream )
 

Close the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_flush ( Gj_Ctx * ctx,
Gj_Stream * stream )
 

Flush the stream.

Returns:
0 on success, -1 otherwise.

int gj_stream_read2write ( Gj_Ctx * ctx,
Gj_Stream * stream ) [inline]
 

Switch from read to write mode.

Returns:
0 on success, -1 otherwise.

For internal use only.

int gj_stream_write2read ( Gj_Ctx * ctx,
Gj_Stream * stream ) [inline]
 

Switch from write to read mode.

Returns:
0 on success, -1 otherwise.

For internal use only.

int gj_stream_write ( Gj_Ctx * ctx,
Gj_Stream * stream,
void * ptr,
int size ) [inline]
 

Write size bytes from the given memory location to the lower layers.

Returns:
0 on success, -1 otherwise.

For internal use only.

int gj_stream_writeLow ( Gj_Ctx * ctx,
Gj_Stream * stream,
void * ptr,
int size )
 

Write size bytes from the given memory location to the lower layers.

Returns:
0 on success, -1 otherwise.

For internal use only.

int gj_stream_read ( Gj_Ctx * ctx,
Gj_Stream * stream,
void * ptr,
int size ) [inline]
 

Read size bytes from the lower layers and write them to the given memory location.

Returns:
0 on success, -1 otherwise.

For internal use only.

int gj_stream_readLow ( Gj_Ctx * ctx,
Gj_Stream * stream,
void * ptr,
int size )
 

Read size bytes from the lower layers and write them to the given memory location.

Returns:
0 on success, -1 otherwise.

For internal use only.

int Gj_stream_writeI32 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si32 value )
 

Write a 32-bit integer value to the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_writeI16 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si16 value )
 

Write a 16-bit integer value to the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_writeI8 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si8 value )
 

Write a 8-bit integer value to the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_writeF64 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_F64 value )
 

Write a 64-bit float value to the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_writeF32 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_F32 value )
 

Write a 32-bit float value to the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_writeStr ( Gj_Ctx * ctx,
Gj_Stream * stream,
char * string )
 

Write a string to the stream.

Accepts

string == 0 
.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readI32 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si32 * value )
 

Read a 32-bit integer value from the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readI16 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si16 * value )
 

Read a 16-bit integer value from the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readI8 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_Si8 * value )
 

Read a 8-bit integer value from the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readF64 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_F64 * value )
 

Read a 64-bit float value from the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readF32 ( Gj_Ctx * ctx,
Gj_Stream * stream,
Gj_F32 * value )
 

Read a 32-bit float value from the stream.

Returns:
0 on success, -1 otherwise.

int Gj_stream_readStr ( Gj_Ctx * ctx,
Gj_Stream * stream,
char ** string )
 

Read a string from the stream.

The string is allocated via Gj_alloc.

Returns:
0 on success, -1 otherwise.


Generated at Fri Aug 17 18:28:59 2001 for Gobj by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000