Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

zlib_util.c File Reference


Detailed Description

Zlib wrapper functions.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "zlib_util.h"
#include "misc.h"
#include "walloc.h"
#include "override.h"

Defines

#define OUT_GROW   1024 /**< To grow output buffer if it's to short */
 To grow output buffer if it's to short.


Functions

 RCSID ("$Id:zlib_util.c, v 1.13 2005/09/10 10:10:36 daichik Exp $")
gchar * zlib_strerror (gint errnum)
 Maps the given error code to an error message.

zlib_deflater_tzlib_deflater_alloc (gconstpointer data, gint len, gpointer dest, gint destlen, gint level)
 Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

zlib_deflater_tzlib_deflater_make (gconstpointer data, gint len, gint level)
 Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

zlib_deflater_tzlib_deflater_make_into (gconstpointer data, gint len, gpointer dest, gint destlen, gint level)
 Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

gint zlib_deflate_step (zlib_deflater_t *zd, gint amount, gboolean may_close)
 Incrementally deflate more data.

gint zlib_deflate (zlib_deflater_t *zd, gint amount)
 Incrementally deflate more data, the `amount' specified.

gboolean zlib_deflate_data (zlib_deflater_t *zd, gconstpointer data, gint len)
 Deflate the data supplied, but do not close the stream when all the data have been compressed.

gboolean zlib_deflate_close (zlib_deflater_t *zd)
 Marks the end of the data: flush the stream and close.

void zlib_deflater_free (zlib_deflater_t *zd, gboolean output)
 Dispose of the incremental deflater.

gpointer zlib_uncompress (gconstpointer data, gint len, gulong uncompressed_len)
 Inflate data, whose final uncompressed size is known.

gboolean zlib_is_valid_header (gconstpointer data, gint len)
 Check whether first bytes of data make up a valid zlib marker.


Define Documentation

#define OUT_GROW   1024 /**< To grow output buffer if it's to short */
 

To grow output buffer if it's to short.


Function Documentation

RCSID "$Id:zlib_util.  c,
v 1.13 2005/09/10 10:10:36 daichik Exp $" 
 

gint zlib_deflate zlib_deflater_t zd,
gint  amount
 

Incrementally deflate more data, the `amount' specified.

When all the data have been compressed, the stream is closed.

Returns:
-1 on error, 1 if work remains, 0 when done.

gboolean zlib_deflate_close zlib_deflater_t zd  ) 
 

Marks the end of the data: flush the stream and close.

Returns:
TRUE if OK, FALSE on error.

gboolean zlib_deflate_data zlib_deflater_t zd,
gconstpointer  data,
gint  len
 

Deflate the data supplied, but do not close the stream when all the data have been compressed.

Needs to call zlib_deflate_close() for that.

Returns:
TRUE if OK, FALSE on error.

gint zlib_deflate_step zlib_deflater_t zd,
gint  amount,
gboolean  may_close
[static]
 

Incrementally deflate more data.

Parameters:
zd the deflator object
amount amount of data to deflate
may_close whether to allow closing when all data was consumed
Returns:
-1 on error, 1 if work remains, 0 when done.

zlib_deflater_t* zlib_deflater_alloc gconstpointer  data,
gint  len,
gpointer  dest,
gint  destlen,
gint  level
[static]
 

Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

Parameters:
data data to compress; if NULL, will be incrementally given
len length of data to compress (if data not NULL) or estimation
dest where compressed data should go, or NULL if allocated
destlen length of supplied output buffer, if dest != NULL
level compression level, between 0 and 9.
Returns:
new deflater, or NULL if error.

void zlib_deflater_free zlib_deflater_t zd,
gboolean  output
 

Dispose of the incremental deflater.

If `output' is true, also free the output buffer.

zlib_deflater_t* zlib_deflater_make gconstpointer  data,
gint  len,
gint  level
 

Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

Data will be compressed into a dynamically allocated buffer, resized as needed.

If `data' is NULL, data to compress will have to be fed to the deflater via zlib_deflate_data() calls. Otherwise, calls to zlib_deflate() will incrementally compress the initial buffer.

Returns:
new deflater, or NULL if error.

zlib_deflater_t* zlib_deflater_make_into gconstpointer  data,
gint  len,
gpointer  dest,
gint  destlen,
gint  level
 

Creates an incremental zlib deflater for `len' bytes starting at `data', with specified compression `level'.

Data will be compressed into the supplied buffer starting at `dest'.

If `data' is NULL, data to compress will have to be fed to the deflater via zlib_deflate_data() calls. Otherwise, calls to zlib_deflate() will incrementally compress the initial buffer.

Returns:
new deflater, or NULL if error.

gboolean zlib_is_valid_header gconstpointer  data,
gint  len
 

Check whether first bytes of data make up a valid zlib marker.

gchar* zlib_strerror gint  errnum  ) 
 

Maps the given error code to an error message.

Returns:
human-readable error string corresponding to error code `errnum'.

gpointer zlib_uncompress gconstpointer  data,
gint  len,
gulong  uncompressed_len
 

Inflate data, whose final uncompressed size is known.

Returns:
allocated uncompressed data if OK, NULL on error.


Generated on Sun Feb 12 10:50:10 2006 for Gtk-Gnutella by doxygen 1.3.6