From: Nicolas Cannasse <warplayer@fr...>  20050519 07:35:08

Hi list, I just added to the IO module a "bits" API that enable you to read/write bitbybit binary files. This complete well the already defined APIs for reading and writing integers in low and bigendian mode. It's quite short but difficult to write correctly (a lot of bit shifting , especially concering the 31 bits limit of ocaml). type bc_in type bc_out exception Bits_error val input_bits : input > bc_in (** Read bits from an input *) val output_bits : 'a output > bc_out (** Write bits to an output *) val read_bits : bc_in > int > int (** Read up to 31 bits, raise Bits_error if n < 0 or n > 31 *) val write_bits : bc_out > nbits:int > int > unit (** Write up to 31 bits represented as a value, raise Bits_error if nbits < 0 or nbits > 31 or the value representation excess nbits. *) val flush_bits : bc_out > unit (** Flush remaining unwritten bits, adding up to 7 bits which values 0. *) val drop_bits : bc_in > unit (** Drop up to 7 buffered bits and restart to next input character. *) I also added the following that can be useful some time when you don't want to carry the polymorphic value of an IO.output for example : external cast_output : 'a output > unit output = "%identity" (** You can safely transform any output to an unit output in a safe way by using this function. *) I also have a complete, small, and easy Png library, that can be used together with Unzip module to read Png using only ExtLib. If there is some interest it could be added to ExtLib. Nicolas 