home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / WIN_NT / NTZIP2 / IMPLODE.H < prev    next >
C/C++ Source or Header  |  1992-03-26  |  5KB  |  209 lines

  1. /*
  2.  
  3.  Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
  4.  Permission is granted to any individual or institution to use, copy, or
  5.  redistribute this software so long as all of the original files are included
  6.  unmodified, that it is not sold for profit, and that this copyright notice
  7.  is retained.
  8.  
  9. */
  10.  
  11. /*
  12.  * implode.h by Richard B. Wales.
  13.  */
  14.  
  15. #include "crypt.h"
  16. #include "tempf.h"
  17. #include <errno.h>
  18.  
  19.  
  20. /***********************************************************************
  21.  *
  22.  * Type definitions.
  23.  */
  24.  
  25.  
  26. typedef long  L_INT;
  27. #ifndef MIPS
  28. typedef int   INT;
  29. #endif
  30. typedef short S_INT;
  31.  
  32. typedef unsigned long  UL_INT;
  33. typedef unsigned int   U_INT;
  34. typedef unsigned short US_INT;
  35.  
  36. typedef unsigned char  U_CHAR;
  37.  
  38. typedef unsigned long  CRC;
  39.  
  40. #define VOID void
  41.  
  42. #define local static            /* More meaningful outside functions */
  43. /* #define local */
  44.  
  45. #define TRUE  1
  46. #define FALSE 0
  47.  
  48. /* Error return codes. */
  49. typedef
  50. enum
  51.     {   IM_OK,                  /* all OK */
  52.         IM_EOF,                 /* end of file on input */
  53.         IM_IOERR,               /* I/O error */
  54.         IM_BADARG,              /* invalid procedure argument */
  55.         IM_NOMEM,               /* out of memory */
  56.         IM_LOGICERR,            /* logic error */
  57.         IM_NOCTBLS              /* no more code tables */
  58.     }
  59.     ImpErr;
  60.  
  61. /* The different possible compression methods. */
  62. typedef
  63. enum
  64.     {   NO_LITERAL_TREE,        /* use only two trees */
  65.         LITERAL_TREE            /* use all three trees */
  66.     }
  67.     Method;
  68.  
  69. /* File data structure. */
  70. typedef
  71. struct  fdata
  72.     {   L_INT    fd_len;        /* # of bytes in file */
  73.         L_INT    fd_clen;       /* compressed length */
  74.         tFILE    *fd_temp;      /* temporary file stream pointer */
  75.         U_INT    fd_bufsize;    /* size of sliding dictionary */
  76.         U_INT    fd_strsize;    /* max string match length */
  77.         U_INT    fd_nbits;      /* # distance bits to write literally */
  78.         Method   fd_method;     /* compression method */
  79.     }
  80.     FDATA;
  81.  
  82. /* Data structure for string matches. */
  83. typedef
  84. struct  match
  85.     {   S_INT       ma_dist;    /* distance back into buffer */
  86.         union {
  87.            US_INT   ma_length;  /* length of matched string */
  88.            U_CHAR   ma_litc[2]; /* literal characters matched */
  89.         } l;
  90.         /* l is ma_litc if ma_dist <= 0. If ma_dist < 0, the length is
  91.          * 2 and the distance is -ma_dist.
  92.          */
  93.     }
  94.     MATCH;
  95.  
  96.  
  97. /***********************************************************************
  98.  *
  99.  * External variable declarations.
  100.  */
  101.  
  102. extern FDATA fd;                /* file data */
  103. #ifndef MSDOS
  104. extern int errno;               /* system error code */
  105. #endif  /* MSDOS */
  106.  
  107. extern MATCH *ma_buf;           /* match info buffer */
  108. #define MA_BUFSIZE 512
  109. /* MA_BUFSIZE must be such that
  110.  *     256*sizeof(TRDATA) <= MA_BUFSIZE*sizeof(MATCH)
  111.  * since the same buffer is used for both purposes at different times.
  112.  */
  113.  
  114. /***********************************************************************
  115.  *
  116.  * External procedure declarations.
  117.  */
  118.  
  119.  
  120. #ifdef  MODERN
  121. #include <string.h>
  122. #else
  123. voidp *malloc();
  124. char  *strcpy();
  125. char  *strcat();
  126. #endif  /* MODERN */
  127.  
  128.  
  129. /***********************************************************************
  130.  *
  131.  * Routines in "im_lmat.c" source file.
  132.  */
  133.  
  134.  
  135. ImpErr  lm_init
  136.         OF ((int pack_level));
  137.  
  138. ImpErr  lm_input
  139.         OF ((U_CHAR *block, U_INT count));
  140.  
  141. ImpErr  lm_windup
  142.         OF ((void));
  143.  
  144.  
  145. /***********************************************************************
  146.  *
  147.  * Routines in "im_ctree.c" source file.
  148.  */
  149.  
  150. ImpErr ct_init
  151.         OF ((void));
  152.  
  153. ImpErr ct_tally
  154.         OF ((MATCH *ma));
  155.  
  156. ImpErr ct_mktrees
  157.         OF ((void));
  158.  
  159. ImpErr ct_wrtrees
  160.         OF ((FILE *outfp));
  161.  
  162. ImpErr ct_wrdata
  163.         OF ((FILE *outfp));
  164.  
  165. ImpErr ct_windup
  166.         OF ((void));
  167.  
  168.  
  169. /***********************************************************************
  170.  *
  171.  * Routines in "im_bits.c" source file.
  172.  */
  173.  
  174. ImpErr bi_init
  175.         OF ((FILE *fp));
  176.  
  177. ImpErr bi_rlout
  178.         OF ((int value, int length));
  179.  
  180. int bi_reverse
  181.         OF ((int value, int length));
  182.  
  183. ImpErr bi_windup
  184.         OF ((void));
  185.  
  186.  
  187. /***********************************************************************
  188.  *
  189.  * Routines in "implode.c" source file.
  190.  */
  191.  
  192. int imp_setup
  193.         OF ((long filesize, int pack_level));
  194.  
  195. int imp_p1
  196.         OF ((char *buf, int count));
  197.  
  198. int imp_size
  199.         OF ((long *size, char *opts));
  200.  
  201. int imp_p2
  202.         OF ((FILE *outfp));
  203.  
  204. int imp_clear
  205.         OF ((void));
  206.  
  207.  
  208. /**********************************************************************/
  209.