ZLIB
Loading...
Searching...
No Matches
gzguts.h File Reference

zlib internal header definitions for gz* operations More...

#include <stdio.h>
#include <zlib/zlib.h>
#include <fcntl.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  gz_state
 internal gzip file state data structure More...
 

Macros

#define ZLIB_INTERNAL
 
#define _POSIX_SOURCE
 
#define local   static
 
#define zstrerror()   strerror(errno)
 
#define DEF_MEM_LEVEL   8
 
#define GZBUFSIZE   8192
 
#define GZ_NONE   0
 
#define GZ_READ   7247
 
#define GZ_WRITE   31153
 
#define GZ_APPEND   1 /* mode set to GZ_WRITE after the file is opened */
 
#define LOOK   0 /* look for a gzip header */
 
#define COPY   1 /* copy input directly */
 
#define GZIP   2 /* decompress a gzip stream */
 
#define GT_OFF(x)   (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
 

Typedefs

typedef gz_state FAR * gz_statep
 

Functions

voidp malloc (uInt size)
 
void free (voidpf ptr)
 
ZEXTERN gzFile ZEXPORT gzopen64 (const char *, const char *)
 
ZEXTERN z_off64_t ZEXPORT gzseek64 (gzFile, z_off64_t, int)
 Set the starting position to offset relative to whence for the next gzread or gzwrite on file.
 
ZEXTERN z_off64_t ZEXPORT gztell64 (gzFile)
 Return the starting position for the next gzread or gzwrite on file.
 
ZEXTERN z_off64_t ZEXPORT gzoffset64 (gzFile)
 Return the current compressed (actual) read or write offset of file.
 
void ZLIB_INTERNAL gz_error (gz_statep, int, const char *)
 Create an error message in allocated memory and set state->err and state->msg accordingly.
 
unsigned ZLIB_INTERNAL gz_intmax (void)
 

Detailed Description

zlib internal header definitions for gz* operations

Copyright (C) 2004-2019 Mark Adler For conditions of distribution and use, see copyright notice in zlib.h

Function Documentation

◆ gz_error()

void ZLIB_INTERNAL gz_error ( gz_statep  state,
int  err,
const char *  msg 
)

Create an error message in allocated memory and set state->err and state->msg accordingly.

Free any previous error message already there. Do not try to free or allocate space if the error is Z_MEM_ERROR (out of memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory.

◆ gzoffset64()

ZEXTERN z_off64_t ZEXPORT gzoffset64 ( gzFile  file)

Return the current compressed (actual) read or write offset of file.

This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset does not include as yet unused buffered input. This information can be used for a progress indicator. On error, gzoffset64() returns -1.

◆ gzseek64()

ZEXTERN z_off64_t ZEXPORT gzseek64 ( gzFile  file,
z_off64_t  offset,
int  whence 
)

Set the starting position to offset relative to whence for the next gzread or gzwrite on file.

The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported.

If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek64 then compresses a sequence of zeroes up to the new starting position.

Returns
the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position.

◆ gztell64()

ZEXTERN z_off64_t ZEXPORT gztell64 ( gzFile  file)

Return the starting position for the next gzread or gzwrite on file.

This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or reading a gzip stream from the middle of a file using gzdopen().

gztell64(file) is equivalent to gzseek64(file, 0L, SEEK_CUR)