home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / FREEZE-2.ZIP / bitio.h < prev    next >
C/C++ Source or Header  |  1992-07-18  |  940b  |  26 lines

  1. /* Some definitions for faster bit-level I/O */
  2.  
  3. extern ul_t getbuf;    /* Bit I/O buffers */
  4. extern us_t putbuf;
  5. extern uc_t bitlen;            /* Number of bits actually in `???buf' */
  6.  
  7. extern uc_t crpt_flag;   /* 1 == EOF was read when melting */
  8. extern uc_t __;          /* temporary variable for GetBit/Byte */
  9.  
  10. extern void EncodeEnd(), Putcode(), crpt_message();
  11.  
  12. #define bits(x) ((int)sizeof(x)*8)
  13. #define BYSH  (bits(getbuf)-8)
  14. #define BISH  (bits(getbuf)-1)
  15.  
  16. #define GetByte()       (bitlen >= 8 ? (__ = getbuf >> BYSH, bitlen -= 8,\
  17.             getbuf <<= 8, __) : (getbuf |= (ul_t) \
  18.             (getchar() & 0xFF) << (BYSH - bitlen), __ = getbuf\
  19.             >> BYSH, getbuf <<= 8, __))
  20.  
  21. #define GetBit()        (bitlen ? (__ = getbuf >> BISH, bitlen--, \
  22.             getbuf <<= 1, __) : (getbuf = __ = getchar(), \
  23.             getbuf <<= BYSH + 1, bitlen = 7, __ >> 7))
  24.  
  25. #define InitIO()        { crpt_flag = bitlen = 0; putbuf = 0; getbuf = 0; }
  26.