home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / LZW.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  2KB  |  65 lines

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