socket/xmlBlasterZlib.c File Reference

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <socket/xmlBlasterZlib.h>
#include <socket/xmlBlasterSocket.h>

Include dependency graph for xmlBlasterZlib.c:

Go to the source code of this file.

Functions

static void dumpZlib (char *p, XmlBlasterZlibReadBuffers *zlibReadBufP, XmlBlasterZlibWriteBuffers *zlibWriteBufP)
 Helper for debugging.
int xmlBlaster_initZlibWriter (XmlBlasterZlibWriteBuffers *zlibWriteBufP)
 Call only once for a socket connection stream.
ssize_t xmlBlaster_writenCompressed (XmlBlasterZlibWriteBuffers *zlibWriteBufP, int fd, char *ptr, size_t nbytes)
 Compress given bytes with zlib and write them to the socket.
int xmlBlaster_endZlibWriter (XmlBlasterZlibWriteBuffers *zlibWriteBufP)
 
See also:
xmlBlasterZlib.h

int xmlBlaster_initZlibReader (XmlBlasterZlibReadBuffers *zlibReadBufP)
 Call only once for a socket connection stream.
ssize_t xmlBlaster_readnCompressed (XmlBlasterZlibReadBuffers *zlibReadBufP, int fd, char *ptr, size_t nbytes, XmlBlasterNumReadFunc fpNumRead, void *userP2)
 Read compressed data from the socket and uncompress it.
int xmlBlaster_endZlibReader (XmlBlasterZlibReadBuffers *zlibReadBufP)
 Cleanup after socket is closed.


Function Documentation

static void dumpZlib ( char *  p,
XmlBlasterZlibReadBuffers zlibReadBufP,
XmlBlasterZlibWriteBuffers zlibWriteBufP 
) [static]

Helper for debugging.

Definition at line 48 of file xmlBlasterZlib.c.

References XmlBlasterZlibWriteBuffers::c_stream, XmlBlasterZlibReadBuffers::c_stream, XmlBlasterZlibReadBuffers::compBuffer, XmlBlasterZlibReadBuffers::currCompBufferP, and XmlBlasterZlibReadBuffers::currCompBytes.

Referenced by xmlBlaster_endZlibWriter(), xmlBlaster_readnCompressed(), and xmlBlaster_writenCompressed().

int xmlBlaster_endZlibReader ( XmlBlasterZlibReadBuffers zlibReadBufP  ) 

Cleanup after socket is closed.

Parameters:
zlibReadBufP Struct holding necessary variables to use zlib

Definition at line 281 of file xmlBlasterZlib.c.

References XmlBlasterZlibReadBuffers::c_stream.

Referenced by freeXmlBlasterConnectionUnparsed().

int xmlBlaster_endZlibWriter ( XmlBlasterZlibWriteBuffers zlibWriteBufP  ) 

See also:
xmlBlasterZlib.h

Definition at line 149 of file xmlBlasterZlib.c.

References XmlBlasterZlibWriteBuffers::c_stream, XmlBlasterZlibWriteBuffers::debug, and dumpZlib().

Referenced by freeXmlBlasterConnectionUnparsed().

Here is the call graph for this function:

int xmlBlaster_initZlibReader ( XmlBlasterZlibReadBuffers zlibReadBufP  ) 

Call only once for a socket connection stream.

Returns:
Z_OK==0 or error from inflateInit()

Definition at line 166 of file xmlBlasterZlib.c.

References XmlBlasterZlibReadBuffers::c_stream, XmlBlasterZlibReadBuffers::compBuffer, XmlBlasterZlibReadBuffers::currCompBufferP, XmlBlasterZlibReadBuffers::currCompBytes, and XmlBlasterZlibReadBuffers::debug.

Referenced by initConnection().

int xmlBlaster_initZlibWriter ( XmlBlasterZlibWriteBuffers zlibWriteBufP  ) 

Call only once for a socket connection stream.

Returns:
Z_OK==0 or error from deflateInit()

Definition at line 68 of file xmlBlasterZlib.c.

References XmlBlasterZlibWriteBuffers::c_stream, and XmlBlasterZlibWriteBuffers::debug.

Referenced by initConnection().

ssize_t xmlBlaster_readnCompressed ( XmlBlasterZlibReadBuffers zlibReadBufP,
int  fd,
char *  ptr,
size_t  nbytes,
XmlBlasterNumReadFunc  fpNumRead,
void *  userP2 
)

Read compressed data from the socket and uncompress it.

Parameters:
zlibReadBufP Struct holding necessary variables to use zlib
fd The socket descriptor
ptr The empty buffer which gets filled with raw bytes from socket (out parameter)
nbytes The max. size of 'ptr'
Returns:
number of bytes read, -1 is EOF

Definition at line 193 of file xmlBlasterZlib.c.

References XmlBlasterZlibReadBuffers::c_stream, XmlBlasterZlibReadBuffers::compBuffer, XmlBlasterZlibReadBuffers::currCompBufferP, XmlBlasterZlibReadBuffers::currCompBytes, XmlBlasterZlibReadBuffers::debug, dumpZlib(), and XMLBLASTER_ZLIB_READ_COMPBUFFER_LEN.

Referenced by readnCompressed().

Here is the call graph for this function:

ssize_t xmlBlaster_writenCompressed ( XmlBlasterZlibWriteBuffers zlibWriteBufP,
int  fd,
char *  ptr,
size_tnbytes   
)

Compress given bytes with zlib and write them to the socket.

Parameters:
fd The socket descriptor
ptr The buffer with raw bytes
nbytes The number of bytes in 'ptr'
Returns:
Number of bytes written

Definition at line 92 of file xmlBlasterZlib.c.

References XmlBlasterZlibWriteBuffers::c_stream, XmlBlasterZlibWriteBuffers::compBuffer, XmlBlasterZlibWriteBuffers::debug, dumpZlib(), writen(), and XMLBLASTER_ZLIB_WRITE_COMPBUFFER_LEN.

Referenced by writenCompressed().

Here is the call graph for this function: