Commit c827815f authored by Samuel Mimram's avatar Samuel Mimram

Imported Upstream version 1.03

parent bb676eb5
Release 1.03:
- Fixed bug in Zlib.uncompress that could cause it to loop infinitely.
- Documentation comments in .mli files converted to ocamldoc format.
Release 1.02:
- 64-bit incompatibility fixed.
- Better support for large ZIP files (> 2 Gb).
......
......@@ -44,11 +44,11 @@ The directory test/ contains examples of using this library.
LICENSING:
This library is copyright 2001, 2002, 2006 Institut National de Recherche
en Informatique et en Automatique, and distributed under the terms
of the GNU Library General Public License (LGPL) with a special exception
concerning static linking. See the file LICENSE for the exact
licensing terms.
This library is copyright 2001, 2002, 2006, 2007 Institut National de
Recherche en Informatique et en Automatique, and distributed under the
terms of the GNU Library General Public License (LGPL) with a special
exception concerning static linking. See the file LICENSE for the
exact licensing terms.
BUG REPORTS AND USER FEEDBACK:
......
......@@ -11,33 +11,33 @@
(* *)
(***********************************************************************)
(* $Id: gzip.mli,v 1.3 2006/04/04 08:29:07 xleroy Exp $ *)
(* $Id: gzip.mli,v 1.4 2007/01/21 15:12:55 xleroy Exp $ *)
(* Module [Gzip]: reading and writing to/from [gzip] compressed files *)
(** Reading and writing to/from [gzip] compressed files
(* This module provides functions to read and write compressed data
This module provides functions to read and write compressed data
to/from files in [gzip] format. *)
(*** Reading from compressed files *)
(** {6 Reading from compressed files} *)
type in_channel
(* Abstract type representing a channel opened for reading
(** Abstract type representing a channel opened for reading
from a compressed file. *)
val open_in: string -> in_channel
(* Open a compressed file for reading. The argument is the file
(** Open a compressed file for reading. The argument is the file
name. *)
val open_in_chan: Pervasives.in_channel -> in_channel
(* Open a compressed file for reading. The argument is a
(** Open a compressed file for reading. The argument is a
regular file channel already opened on the compressed file. *)
val input_char: in_channel -> char
(* Uncompress one character from the given channel, and return it.
(** Uncompress one character from the given channel, and return it.
Raise [End_of_file] if no more compressed data is available. *)
val input_byte: in_channel -> int
(* Same as [Gzip.input_char], but return the 8-bit integer representing
the character.
(** Same as [Gzip.input_char], but return the 8-bit integer
representing the character.
Raise [End_of_file] if no more compressed data is available. *)
val input: in_channel -> string -> int -> int -> int
(* [input ic buf pos len] uncompresses up to [len] characters
(** [input ic buf pos len] uncompresses up to [len] characters
from the given channel [ic],
storing them in string [buf], starting at character number [pos].
It returns the actual number of characters read, between 0 and
......@@ -53,32 +53,32 @@ val input: in_channel -> string -> int -> int -> int
Exception [Invalid_argument "Gzip.input"] is raised if
[pos] and [len] do not designate a valid substring of [buf]. *)
val really_input: in_channel -> string -> int -> int -> unit
(* [really_input ic buf pos len] uncompresses [len] characters
(** [really_input ic buf pos len] uncompresses [len] characters
from the given channel, storing them in
string [buf], starting at character number [pos].
Raise [End_of_file] if fewer than [len] characters can be read.
Raise [Invalid_argument "Gzip.input"] if
[pos] and [len] do not designate a valid substring of [buf]. *)
val close_in: in_channel -> unit
(* Close the given input channel. If the channel was created with
(** Close the given input channel. If the channel was created with
[Gzip.open_in_chan], the underlying regular file channel
(of type [Pervasives.in_channel]) is also closed.
Do not apply any of the functions above to a closed channel. *)
val dispose: in_channel -> unit
(* Same as [Gzip.close_in], but does not close the underlying
(** Same as [Gzip.close_in], but does not close the underlying
regular file channel (of type [Pervasives.in_channel]);
just dispose of the resources associated with the decompression
channel. This can be useful if e.g. the underlying file channel
is a network socket on which more (uncompressed) data
is expected. *)
(*** Writing to compressed files *)
(** {6 Writing to compressed files} *)
type out_channel
(* Abstract type representing a channel opened for writing
(** Abstract type representing a channel opened for writing
to a compressed file. *)
val open_out: ?level:int -> string -> out_channel
(* Open a compressed file for writing. The argument is the file
(** Open a compressed file for writing. The argument is the file
name. The file is created if it does not exist, or
truncated to zero length if it exists.
The optional [level] argument (an integer between 1 and 9)
......@@ -87,36 +87,36 @@ val open_out: ?level:int -> string -> out_channel
(but slowest) compression. The default level is 6
(medium compression). *)
val open_out_chan: ?level:int -> Pervasives.out_channel -> out_channel
(* Open a compressed file for writing. The argument is a
(** Open a compressed file for writing. The argument is a
regular file channel already opened on the compressed file.
The optional [level] argument sets the compression level
as documented for [Gzip.open_out]. *)
val output_char: out_channel -> char -> unit
(* Output one character to the given compressed channel. *)
(** Output one character to the given compressed channel. *)
val output_byte: out_channel -> int -> unit
(* Same as [Gzip.output_char], but the output character is given
(** Same as [Gzip.output_char], but the output character is given
by its code. The given integer is taken modulo 256. *)
val output: out_channel -> string -> int -> int -> unit
(* [output oc buf pos len] compresses and writes [len] characters
(** [output oc buf pos len] compresses and writes [len] characters
from string [buf], starting at offset [pos], and writes the
compressed data to the channel [oc].
Raise [Invalid_argument "Gzip.output"] if
[pos] and [len] do not designate a valid substring of [buf]. *)
val close_out: out_channel -> unit
(* Close the given output channel. If the channel was created with
(** Close the given output channel. If the channel was created with
[Gzip.open_out_chan], the underlying regular file channel
(of type [Pervasives.out_channel]) is also closed.
Do not apply any of the functions above to a closed channel. *)
val flush: out_channel -> unit
(* Same as [Gzip.close_out], but do not close the underlying
(** Same as [Gzip.close_out], but do not close the underlying
regular file channel (of type [Pervasives.out_channel]);
just flush all pending compressed data and
dispose of the resources associated with the compression
channel. This can be useful if e.g. the underlying file channel
is a network socket on which more data is to be sent. *)
(*** Error reporting *)
(** {6 Error reporting} *)
exception Error of string
(* Exception raised by the functions above to signal errors during
(** Exception raised by the functions above to signal errors during
compression or decompression, or ill-formed input files. *)
This diff is collapsed.
......@@ -63,10 +63,10 @@ let uncompress ?(header = true) refill flush =
let incount = refill inbuf in
if incount = 0 then uncompr_finish true else uncompr 0 incount
end else begin
let (_, used_in, used_out) =
let (finished, used_in, used_out) =
inflate zs inbuf inpos inavail outbuf 0 buffer_size Z_SYNC_FLUSH in
flush outbuf used_out;
uncompr (inpos + used_in) (inavail - used_in)
if not finished then uncompr (inpos + used_in) (inavail - used_in)
end
and uncompr_finish first_finish =
(* Gotcha: if there is no header, inflate requires an extra "dummy" byte
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment