compressutils.c File Reference

Functions related to data compression (gzip format.) More...

`#include "compressutils.h"`
`#include <glib.h>`
`#include <zlib.h>`

Go to the source code of this file.

## Macros

#define | ZLIB_CONST
| For z_const to be defined as const.
#define | _GNU_SOURCE
#define | G_LOG_DOMAIN "libgvm util"
| GLib logging domain.

## Functions

void * | gvm_compress (const void *src, unsigned long srclen, unsigned long *dstlen)
| Compresses data in src buffer.
void * | gvm_uncompress (const void *src, unsigned long srclen, unsigned long *dstlen)
| Uncompresses data in src buffer.
void * | gvm_compress_gzipheader (const void *src, unsigned long srclen, unsigned long *dstlen)
| Compresses data in src buffer, gzip format compatible.
static ssize_t | gz_file_read (void *cookie, char *buffer, size_t buffer_size)
| Read decompressed data from a gzip file.
static int | gz_file_close (void *cookie)
| Close a gzip file.
FILE * | gvm_gzip_open_file_reader (const char *path)
| Opens a gzip file as a FILE* stream for reading and decompression.
FILE * | gvm_gzip_open_file_reader_fd (int fd)
| Opens a gzip file as a FILE* stream for reading and decompression.

## Detailed Description

Functions related to data compression (gzip format.)

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

## G_LOG_DOMAIN

#define G_LOG_DOMAIN "libgvm util"

GLib logging domain.

## ZLIB_CONST

#define ZLIB_CONST

For z_const to be defined as const.

## Function Documentation

## 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.

## 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.

## gvm_gzip_open_file_reader()

FILE * gvm_gzip_open_file_reader | ( | const char * | path | ) |

Opens a gzip file as a FILE* stream for reading and decompression.

Parameters

  [in] | path | Path to the gzip file to open.

Returns
  The FILE* on success, NULL otherwise.

## gvm_gzip_open_file_reader_fd()

FILE * gvm_gzip_open_file_reader_fd | ( | int | fd | ) |

Opens a gzip file as a FILE* stream for reading and decompression.

Parameters

  [in] | fd | File descriptor of the gzip file to open.

Returns
  The FILE* on success, NULL otherwise.

## 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.

## gz_file_close()

static int gz_file_close | ( | void * | cookie | ) |

static

Close a gzip file.

Parameters

  [in] | cookie | The gzFile to close.

Returns
  0 on success, other values on error (see gzclose() from zlib).

## gz_file_read()

static ssize_t gz_file_read | ( | void * | cookie,
|  | char * | buffer,
|  | size_t | buffer_size
| ) |  |

static

Read decompressed data from a gzip file.

Parameters

  [in] | cookie | The gzFile to read from.
  [in] | buffer | The buffer to output decompressed data to.
  [in] | buffer_size | The size of the buffer.

Returns
  The number of bytes read into the buffer.