whack.h 966 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. typedef struct Whack Whack;
  2. typedef struct Unwhack Unwhack;
  3. enum
  4. {
  5. WhackStats = 8,
  6. WhackErrLen = 64, /* max length of error message from thwack or unthwack */
  7. WhackMaxOff = 16*1024, /* max allowed offset */
  8. HashLog = 14,
  9. HashSize = 1<<HashLog,
  10. HashMask = HashSize - 1,
  11. MinMatch = 3, /* shortest match possible */
  12. MinDecode = 8, /* minimum bits to decode a match or lit; >= 8 */
  13. MaxSeqMask = 8, /* number of bits in coding block mask */
  14. MaxSeqStart = 256 /* max offset of initial coding block */
  15. };
  16. struct Whack
  17. {
  18. ushort begin; /* time of first byte in hash */
  19. ushort hash[HashSize];
  20. ushort next[WhackMaxOff];
  21. uchar *data;
  22. };
  23. struct Unwhack
  24. {
  25. char err[WhackErrLen];
  26. };
  27. void whackinit(Whack*, int level);
  28. void unwhackinit(Unwhack*);
  29. int whack(Whack*, uchar *dst, uchar *src, int nsrc, ulong stats[WhackStats]);
  30. int unwhack(Unwhack*, uchar *dst, int ndst, uchar *src, int nsrc);
  31. int whackblock(uchar *dst, uchar *src, int ssize);