home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / sharew / packer / zlib / zdef.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-17  |  3.9 KB  |  118 lines

  1. #undef DEBUG    /*1*/
  2. #undef MONITOR_CRLF
  3.  
  4. /*
  5.  *    zdef.h
  6.  */
  7.  
  8. /*
  9.  *    These wondrous debugging macros helped me find the nasty bug which
  10.  *    only manifested itself on msdos -- stackp has to be a long on msdos
  11.  *    because the array it is indexing is 'huge' ...
  12.  */
  13. #ifdef DEBUG
  14. int    debug = 1;
  15. # define TRACT(lev, stmnt)    if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt);
  16. # define TRACE(lev, stmnt)    if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt); stmnt
  17. # define TRACA(lev, stmnt)    stmnt; if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt);
  18. # define TRACL(lev, var)    if (lev <= debug) fprintf(stderr, "%d: %s <- %ld\n", __LINE__, #var, var);
  19. #else
  20. # define TRACT(lev, stmnt)
  21. # define TRACE(lev, stmnt) stmnt
  22. # define TRACA(lev, stmnt) stmnt
  23. # define TRACL(lev, var)
  24. #endif
  25.  
  26.  
  27. /* 
  28.  *
  29.  * Originally:
  30.  *
  31.  * compress.c - File compression ala IEEE Computer, June 1984.
  32.  *
  33.  * Authors:    Spencer W. Thomas       (decvax!harpo!utah-cs!utah-gr!thomas)
  34.  *             Jim McKie               (decvax!mcvax!jim)
  35.  *             Steve Davies            (decvax!vax135!petsd!peora!srd)
  36.  *             Ken Turkowski           (decvax!decwrl!turtlevax!ken)
  37.  *             James A. Woods          (decvax!ihnp4!ames!jaw)
  38.  *             Joe Orost               (decvax!vax135!petsd!joe)
  39.  *
  40.  * $Header: zlib.c,v 4.1 90/11/12 14:52:24 gtoal Release $
  41.  *
  42.  * Graham Toal, 3rd September 1988.  My changes released to public domain.
  43.  *                                   Updated Nov 90.
  44.  *
  45.  * The original decompress has been restructured so that data can be
  46.  * fetched on demand a byte at a time.  This lets it be used as a filter
  47.  * for programs which read large data files - you do not need the disk
  48.  * space to decompress the input files first.
  49.  *
  50.  * (Incidentally, programs reading data off floppies will be speeded up
  51.  *  because decompression is always faster than the equivalent amount
  52.  *  of disk I/O).
  53.  *
  54.  * This implementation supplies 'z' versions of fopen, fputc, feof and fclose
  55.  * to be used as direct substitutes for the originals; it would be cleaner
  56.  * and more transparent if the decompress filter were hidden under the
  57.  * real stdio procedures.  An extra call zfilter() is supplied to convert
  58.  * an already-opened stream into a z-stream: see the example at the end
  59.  * of this file.
  60.  *
  61.  * If a file opened by zfopen() was not compressed, the files contents are
  62.  * still recovered correctly at the low expense of an extra procedure call
  63.  * per byte.  This makes the routines more generally usable - they can be
  64.  * left in production programs which can be speeded up in the field by
  65.  * compressing selected input files(*); also, files can be compressed or
  66.  * not selectively depending on whether the compression makes them
  67.  * smaller or not - code accessing the files does not need to know.
  68.  *
  69.  * [(*) reading from a compressed file off floppy disk is faster than
  70.  * reading from an uncompressed file. This probably isn't true of
  71.  * hard disks though.]
  72.  *
  73.  * BUGS: Opening a file "r" will not do CR/LF processing on computers with
  74.  *       this file structure.
  75.  */
  76.  
  77.  
  78. #include <stdio.h>
  79. #include <string.h>
  80. #ifdef __STDC__
  81. # include <stdlib.h>
  82. #else
  83. # define size_t        int
  84. #endif
  85. #include <ctype.h>
  86.  
  87. #ifdef MSDOS
  88. # include <malloc.h>
  89. #else
  90. extern char    *malloc ();
  91. #endif
  92.  
  93. #ifndef min
  94. # define min(a,b)    ((a>b) ? b : a)
  95. # endif
  96. #define HSIZE        69001L        /* 95% occupancy */
  97.  
  98. /*
  99.  *    the next two codes should not be changed lightly, as they must not
  100.  *    lie within the contiguous general code space.
  101.  */
  102. #define FIRST        257L        /* first free entry */
  103. #define CLEAR        256L        /* table clear output code */
  104.  
  105. #define BIT_MASK        0x1f
  106. #define BLOCK_MASK      0x80
  107. #define INIT_BITS       9        /* initial number of bits/code */
  108.  
  109. #define CHECK_GAP    10000L        /* ratio check interval */
  110.  
  111. #include "zlib.h"
  112.  
  113. #define NOT_COMPRESSED    1
  114. #define ALLOCATED    2
  115.  
  116.  
  117. /* end of zdef.h */
  118.