home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / LZW.H < prev    next >
C/C++ Source or Header  |  1990-11-08  |  2KB  |  54 lines

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