sunterlib/s48/binary-parse
Martin Gasbichler 9339ae863e Export make-bit-reader 2003-10-14 18:35:48 +00:00
..
AUTHORS final newlines 2003-04-22 18:10:34 +00:00
BLURB final newlines 2003-04-22 18:10:34 +00:00
README Added reference to the origin of the code 2003-04-14 06:45:20 +00:00
binary-parse.scm Added reference to the origin of the code 2003-04-14 06:45:20 +00:00
interfaces.scm Export make-bit-reader 2003-10-14 18:35:48 +00:00
packages.scm Added Oleg's binary-parsing 2003-04-14 06:38:47 +00:00

README

[This file and the accompanying source code were derived from
 Oleg's code for Gambit available from

     http://okmij.org/ftp/Scheme/index.html#binio

]

(make-bit-reader byte-reader) -> bit-reader

Given a BYTE-READER (a thunk), construct and return a function

      (bit-reader N) -> integer

that reads N bits from a byte-stream represented by the BYTE-READER.

The BYTE-READER is a function that takes no arguments and returns
the current byte as an exact integer [0-255]. The byte reader
should return #f on EOF.
The bit reader returns N bits as an exact unsigned integer, 
0 -... (no limit). N must be a positive integer, otherwise the bit reader
returns #f. There is no upper limit on N -- other than the size of the
input stream itself and the amount of (virtual) memory an OS is willing
to give to your process. If you want to read 1M of _bits_, go ahead.

It is assumed that the bit order is the most-significant bit first.