/*1* zipio.h - stdio emulation library for reading zip files2*3* Version 1.1.24*/56/*7* Copyright (C) 1995, Edward B. Hamrick8*9* Permission to use, copy, modify, and distribute this software and10* its documentation for any purpose and without fee is hereby granted,11* provided that the above copyright notice appear in all copies and12* that both that copyright notice and this permission notice appear in13* supporting documentation, and that the name of the copyright holders14* not be used in advertising or publicity pertaining to distribution of15* the software without specific, written prior permission. The copyright16* holders makes no representations about the suitability of this software17* for any purpose. It is provided "as is" without express or implied warranty.18*19* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS20* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,21* IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT22* OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF23* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER24* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE25* OF THIS SOFTWARE.26*/2728/*29* Changes from 1.1 to 1.1.1:30* Changed "z*" functions to "Z*" to avoid namespace pollution.31* Added "zungetc" macro.32* John Cowan <[email protected]>33*34* Changes from 1.1.1 to 1.1.2:35* Relicensed under the MIT license, with consent of the copyright holders.36* Claudio Matsuoka (Jan 11 2011)37*/3839/*40* This library of routines has the same calling sequence as41* the stdio.h routines for reading files. If these routines42* detect that they are reading from a zip file, they transparently43* unzip the file and make the application think they're reading44* from the uncompressed file.45*46* Note that this library is designed to work for zip files that47* use the deflate compression method, and to read the first file48* within the zip archive.49*50* There are a number of tunable parameters in the reference51* implementation relating to in-memory decompression and the52* use of temporary files.53*54* Particular care was taken to make the Zgetc() macro work55* as efficiently as possible. When reading an uncompressed56* file with Zgetc(), it has exactly the same performance as57* when using getc(). WHen reading a compressed file with58* Zgetc(), it has the same performance as fread(). The total59* CPU overhead for decompression is about 50 cycles per byte.60*61* The Zungetc() macro is quite limited. It ignores the character62* specified for pushback, and essentially just forces the last63* character read to be re-read. This is essential when parsing64* numbers and such. (1.1.1)65*66* There are a few stdio routines that aren't represented here, but67* they can be layered on top of these routines if needed.68*/6970#ifndef __ZIPIO_H71#define __ZIPIO_H7273#include <stdio.h>7475typedef struct {76int len;77unsigned char *ptr;78} ZFILE;7980#define Zgetc(f) \81((--((f)->len) >= 0) \82? (unsigned char)(*(f)->ptr++) \83: _Zgetc (f))8485#define Zungetc(c,f) \86((f)->ptr--, (f)->len++, (c))8788#ifdef __cplusplus89extern "C" {90#endif9192ZFILE *Zopen(const char *path, const char *mode);93int _Zgetc(ZFILE *stream);94size_t Zread(void *ptr, size_t size, size_t n, ZFILE *stream);95int Zseek(ZFILE *stream, long offset, int whence);96long Ztell(ZFILE *stream);97int Zclose(ZFILE *stream);9899#ifdef __cplusplus100}101#endif102103#endif104105106