API related to data compression (gzip format.)
More...
Go to the source code of this file.
|
| void * | gvm_compress (const void *, unsigned long, unsigned long *) |
| | Compresses data in src buffer. More...
|
| |
| void * | gvm_compress_gzipheader (const void *, unsigned long, unsigned long *) |
| | Compresses data in src buffer, gzip format compatible. More...
|
| |
| void * | gvm_uncompress (const void *, unsigned long, unsigned long *) |
| | Uncompresses data in src buffer. More...
|
| |
API related to data compression (gzip format.)
Definition in file compressutils.h.
◆ gvm_compress()
| void* gvm_compress |
( |
const void * |
src, |
|
|
unsigned long |
srclen, |
|
|
unsigned long * |
dstlen |
|
) |
| |
Compresses data in src buffer.
- Parameters
-
| [in] | src | Buffer of data to compress. |
| [in] | srclen | Length of data to compress. |
| [out] | dstlen | Length of compressed data. |
- Returns
- Pointer to compressed data if success, NULL otherwise.
Definition at line 39 of file compressutils.c.
41 unsigned long buflen = srclen * 2;
43 if (src == NULL || dstlen == NULL)
59 strm.avail_in = srclen;
64 strm.next_in = (
void *) src;
66 if (deflateInit (&strm, Z_DEFAULT_COMPRESSION) != Z_OK)
69 buffer = g_malloc0 (buflen);
70 strm.avail_out = buflen;
71 strm.next_out = buffer;
73 err = deflate (&strm, Z_SYNC_FLUSH);
79 if (strm.avail_out != 0)
81 *dstlen = strm.total_out;
◆ gvm_compress_gzipheader()
| void* gvm_compress_gzipheader |
( |
const void * |
src, |
|
|
unsigned long |
srclen, |
|
|
unsigned long * |
dstlen |
|
) |
| |
Compresses data in src buffer, gzip format compatible.
- Parameters
-
| [in] | src | Buffer of data to compress. |
| [in] | srclen | Length of data to compress. |
| [out] | dstlen | Length of compressed data. |
- Returns
- Pointer to compressed data if success, NULL otherwise.
Definition at line 177 of file compressutils.c.
180 unsigned long buflen = srclen * 2;
181 int windowsBits = 15;
182 int GZIP_ENCODING = 16;
184 if (src == NULL || dstlen == NULL)
197 strm.zalloc = Z_NULL;
199 strm.opaque = Z_NULL;
200 strm.avail_in = srclen;
205 strm.next_in = (
void *) src;
208 if (deflateInit2 (&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
209 windowsBits | GZIP_ENCODING, 8, Z_DEFAULT_STRATEGY)
213 buffer = g_malloc0 (buflen);
214 strm.avail_out = buflen;
215 strm.next_out = buffer;
217 err = deflate (&strm, Z_FINISH);
223 if (strm.avail_out != 0)
225 *dstlen = strm.total_out;
◆ gvm_uncompress()
| void* gvm_uncompress |
( |
const void * |
src, |
|
|
unsigned long |
srclen, |
|
|
unsigned long * |
dstlen |
|
) |
| |
Uncompresses data in src buffer.
- Parameters
-
| [in] | src | Buffer of data to uncompress. |
| [in] | srclen | Length of data to uncompress. |
| [out] | dstlen | Length of uncompressed data. |
- Returns
- Pointer to uncompressed data if success, NULL otherwise.
Definition at line 107 of file compressutils.c.
109 unsigned long buflen = srclen * 2;
111 if (src == NULL || dstlen == NULL)
121 strm.zalloc = Z_NULL;
123 strm.opaque = Z_NULL;
124 strm.avail_in = srclen;
129 strm.next_in = (
void *) src;
136 if (inflateInit2 (&strm, 15 + 32) != Z_OK)
139 buffer = g_malloc0 (buflen);
140 strm.avail_out = buflen;
141 strm.next_out = buffer;
143 err = inflate (&strm, Z_SYNC_FLUSH);
149 if (strm.avail_out != 0)
151 *dstlen = strm.total_out;