LibreOffice Module hwpfilter (master) 1
Macros | Functions
hgzip.cxx File Reference
#include "precompile.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "hgzip.h"
#include "hstream.hxx"
Include dependency graph for hgzip.cxx:

Go to the source code of this file.

Macros

#define Z_BUFSIZE   (1024 * 4)
 
#define ALLOC(size)   malloc(size)
 
#define TRYFREE(p)   {if (p) free(p);}
 

Functions

static int get_byte (gz_stream *s)
 
static int destroy (gz_stream *s)
 
static uLong getLong (gz_stream *s)
 
gz_streamgz_open (HStream &_stream)
 Opens a gzipped stream for reading. More...
 
size_t gz_read (gz_stream *file, voidp buf, unsigned len)
 Reads the given number of uncompressed bytes from the compressed stream. More...
 
int gz_flush (gz_stream *file, int flush)
 Flushes all pending output into the compressed file gz_flush should be called only when strictly necessary because it can degrade compression. More...
 
int gz_close (gz_stream *file)
 Flushes all pending output if necessary, closes the compressed stream and deallocates all the (de)compression state. More...
 

Macro Definition Documentation

◆ ALLOC

#define ALLOC (   size)    malloc(size)

Definition at line 31 of file hgzip.cxx.

◆ TRYFREE

#define TRYFREE (   p)    {if (p) free(p);}

Definition at line 32 of file hgzip.cxx.

◆ Z_BUFSIZE

#define Z_BUFSIZE   (1024 * 4)

Definition at line 29 of file hgzip.cxx.

Function Documentation

◆ destroy()

static int destroy ( gz_stream s)
static

Definition at line 123 of file hgzip.cxx.

References err, gz_stream::inbuf, gz_stream::msg, gz_stream::stream, TRYFREE, and gz_stream::z_err.

Referenced by gz_close(), and gz_open().

◆ get_byte()

static int get_byte ( gz_stream s)
static

◆ getLong()

static uLong getLong ( gz_stream s)
static

Definition at line 259 of file hgzip.cxx.

References get_byte(), x, gz_stream::z_eof, and gz_stream::z_err.

Referenced by gz_read().

◆ gz_close()

int gz_close ( gz_stream file)

Flushes all pending output if necessary, closes the compressed stream and deallocates all the (de)compression state.

Definition at line 278 of file hgzip.cxx.

References gz_stream::crc, destroy(), err, gz_flush(), gz_stream::mode, and gz_stream::stream.

Referenced by HStreamIODev::setCompressed(), and HStreamIODev::~HStreamIODev().

◆ gz_flush()

int gz_flush ( gz_stream file,
int  flush 
)

Flushes all pending output into the compressed file gz_flush should be called only when strictly necessary because it can degrade compression.

Parameters
flushIs as in the deflate() function

Definition at line 215 of file hgzip.cxx.

References gz_stream::mode, gz_stream::stream, Z_BUFSIZE, and gz_stream::z_err.

Referenced by HStreamIODev::flush(), gz_close(), and HStreamIODev::setCompressed().

◆ gz_open()

gz_stream * gz_open ( HStream _stream)

Opens a gzipped stream for reading.

gz_open returns NULL if the stream could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR).

Parameters
_streamReference of stream object having binary data.

Definition at line 47 of file hgzip.cxx.

References gz_stream::_inputstream, ALLOC, Byte, gz_stream::crc, destroy(), err, gz_stream::inbuf, gz_stream::mode, gz_stream::msg, gz_stream::stream, Z_BUFSIZE, gz_stream::z_eof, and gz_stream::z_err.

Referenced by HStreamIODev::setCompressed().

◆ gz_read()

size_t gz_read ( gz_stream file,
voidp  buf,
unsigned  len 
)

Reads the given number of uncompressed bytes from the compressed stream.

Parameters
fileGzipped stream
bufBuffer to have the data to be read
lenLength of data to be read
Returns
The number of bytes actually read

Definition at line 151 of file hgzip.cxx.

References gz_stream::_inputstream, gz_stream::crc, getLong(), gz_stream::inbuf, HStream::readBytes(), start, gz_stream::stream, Z_BUFSIZE, gz_stream::z_eof, and gz_stream::z_err.