ZLIB

Section: (3)
Updated:
Index Return to Main Contents
 

NAME

zlib - stream interface to compress, read only  

SYNOPSIS

#include <zlib.h>

ZFILE *zfopen (fileptr, how)
char *fileptr;
char *how;

ZFILE *zfilter (f)
FILE *f;

int zfgetc (z)
ZFILE *z;

int zfeof (z)
ZFILE *z;

void zfclose (z)
ZFILE *z;

char *zfgets (line, len, zfp)
char *line;
int len;
ZFILE *zfp;

 

DESCRIPTION

This implementation supplies 'z' versions of fopen, fputc, feof and fclose to be used as direct substitutes for the originals; it would be cleaner and more transparent if the decompress filter were hidden under the real stdio procedures. An extra call zfilter() is supplied to convert an already-opened stream into a z-stream: see the example at the end of this file. Note that on the Atari, depending on the shell, stdin may have been opened as an ASCII stream and hence these routines are useless. A pre-existion stream MUST have been opened as a binary file.

If a file opened by zfopen() was not compressed, the files contents are still recovered correctly at the low expense of an extra procedure call per byte. This makes the routines more generally usable - they can be left in production programs which can be speeded up in the field by compressing selected input files (see NOTES); also, files can be compressed or not selectively depending on whether the compression makes them smaller or not - code accessing the files does not need to know.  

NOTES

Reading from a compressed file off floppy disk is faster than reading from an uncompressed file. This probably isn't true of hard disks though.

The original decompress has been restructured so that data can be fetched on demand a byte at a time. This lets it be used as a filter for programs which read large data files - you do not need the disk space to decompress the input files first.

Incidentally, programs reading data off floppies will be speeded up because decompression is always faster than the equivalent amount of disk I/O.  

BUGS

Opening a file "r" will not do CR/LF processing on computers with this file structure. Actually, I force all fopens in the code to ba fopenb (Alcyon flavor) so this is not really a problem.  

SEE ALSO

intro(3S), fopen(3S)  

AUTHOR

Graham Toal, 3rd September 1988.
My changes released to public domain.
Updated Nov 90.

Modified for Atari ST (Alcyon) by Bill Rosenkranz


 

Index

NAME
SYNOPSIS
DESCRIPTION
NOTES
BUGS
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 08:40:45 GMT, February 26, 2025