home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / KA9Q212.ZIP / LZW.H < prev    next >
C/C++ Source or Header  |  1993-07-16  |  2KB  |  61 lines

  1. /****************************************************************************
  2. *    $Id: lzw.h 1.2 93/07/16 11:46:28 ROOT_DOS Exp $
  3. *    13 Jul 93    1.2        GT    Conditional on LZW.                                *
  4. ****************************************************************************/
  5.  
  6. #if    LZW
  7. #ifndef _LZW_H
  8. #define _LZW_H
  9.  
  10. /* a string entry */
  11. struct zentry {
  12.     int16 code;    /* codeword of the prefix string */
  13.     char data;    /* character to add to the prefix string */
  14. };
  15. struct zfast {        /* fast version of string entry */
  16.     int16 owncode;    /* own codeword */
  17.     int16 code;    /* codeword of prefix string */
  18.     char data;    /* character to add to prefix string */
  19. };
  20. #define ZCC        256    /* clear code table codeword */
  21. #define ZFLUSH        257    /* codeword that signals a break in coding */
  22.  
  23. struct lzw {
  24.     int16 codebits;        /* significant bits in each codeword */
  25.     int maxbits;        /* maximum number of bits per codeword */
  26. #define LZWBITS        9    /* initial number of bits in each codeword */
  27.     int32 prefix;        /* last processed codeword */
  28.     char mode;        /* Compact or fast compression mode */
  29. #define LZWCOMPACT    0
  30. #define LZWFAST        1
  31.     union {
  32.         struct zentry **tbl;    /* compact table */
  33. #define LZWBLK        130        /* size of entry arrays to allocate */
  34.         struct mbuf **bpp;    /* mbuf version of table */
  35. #define ZHASH        256    /* hash table size */
  36.         void *p;    /* generic table pointer */
  37.     } tu;            /* table of entries */
  38.     int nextbit;        /* next bit to process in code stream */
  39.     int version;        /* version number of sender */
  40. #define ZVERSION    3    /* version number */
  41.     int32 cnt;        /* count of processed bytes */
  42.     int32 code;        /* temporary storage for coding in progress */
  43.     int32 next;        /* next code to be added to the table */
  44.     int flushbit;        /* next bit of the ZFLUSH codeword to send */
  45.     /* the following is used by the decoder only */
  46.     struct mbuf *buf;    /* decoded buffer */
  47. };
  48. #define NULLLZW (struct lzw *)0
  49.  
  50. #ifdef ANSIPROTO
  51. extern struct usock;        /* To please Turbo C++ */
  52. #endif
  53. void lzwencode __ARGS((int s,char c));
  54. void lzwinit __ARGS((int s,int bits,int mode));
  55. void lzwfree __ARGS((struct usock *up));
  56. void lzwflush __ARGS((struct usock *up));
  57. int lzwdecode __ARGS((struct usock *up));
  58.  
  59. #endif  /* _LZW_H */
  60. #endif    /* LZW */
  61.