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 47 of file compressutils.c.
49 unsigned long buflen = srclen * 2;
51 if (src == NULL || dstlen == NULL)
67 strm.avail_in = srclen;
72 strm.next_in = (
void *) src;
74 if (deflateInit (&strm, Z_DEFAULT_COMPRESSION) != Z_OK)
77 buffer = g_malloc0 (buflen);
78 strm.avail_out = buflen;
79 strm.next_out = buffer;
81 err = deflate (&strm, Z_SYNC_FLUSH);
87 if (strm.avail_out != 0)
89 *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 185 of file compressutils.c.
188 unsigned long buflen = srclen * 2;
189 int windowsBits = 15;
190 int GZIP_ENCODING = 16;
192 if (src == NULL || dstlen == NULL)
205 strm.zalloc = Z_NULL;
207 strm.opaque = Z_NULL;
208 strm.avail_in = srclen;
213 strm.next_in = (
void *) src;
216 if (deflateInit2 (&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
217 windowsBits | GZIP_ENCODING, 8, Z_DEFAULT_STRATEGY)
221 buffer = g_malloc0 (buflen);
222 strm.avail_out = buflen;
223 strm.next_out = buffer;
225 err = deflate (&strm, Z_FINISH);
231 if (strm.avail_out != 0)
233 *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 115 of file compressutils.c.
117 unsigned long buflen = srclen * 2;
119 if (src == NULL || dstlen == NULL)
129 strm.zalloc = Z_NULL;
131 strm.opaque = Z_NULL;
132 strm.avail_in = srclen;
137 strm.next_in = (
void *) src;
144 if (inflateInit2 (&strm, 15 + 32) != Z_OK)
147 buffer = g_malloc0 (buflen);
148 strm.avail_out = buflen;
149 strm.next_out = buffer;
151 err = inflate (&strm, Z_SYNC_FLUSH);
157 if (strm.avail_out != 0)
159 *dstlen = strm.total_out;