OCAML_TEST_INC = -I $(shell ocamlfind query oUnit)
OCAML_TEST_LIB = $(shell ocamlfind query oUnit)/oUnit.cmxa
-STDEXT_OBJS = filenameext stringext arrayext hashtblext listext pervasiveext threadext ring qring fring opt unixext range bigbuffer vIO trie
+STDEXT_OBJS = filenameext stringext arrayext hashtblext listext pervasiveext threadext ring qring fring opt bigbuffer unixext range vIO trie
INTF = $(foreach obj, $(STDEXT_OBJS),$(obj).cmi)
LIBS = stdext.cma stdext.cmxa
let length bigbuf = bigbuf.index
+let get bigbuf n =
+ let array_offset = Int64.to_int (Int64.div n (Int64.of_int cell_size)) in
+ let cell_offset = Int64.to_int (Int64.rem n (Int64.of_int cell_size)) in
+ match bigbuf.cells.(array_offset) with
+ | None -> "".[0]
+ | Some buf -> buf.[cell_offset]
+
let rec append_substring bigbuf s offset len =
let array_offset = Int64.to_int (Int64.div bigbuf.index (Int64.of_int cell_size)) in
let cell_offset = Int64.to_int (Int64.rem bigbuf.index (Int64.of_int cell_size)) in
type t
val make : unit -> t
val length : t -> int64
+val get : t -> int64 -> char
val append_substring : t -> string -> int -> int -> unit
val to_fct : t -> (string -> unit) -> unit
val to_string : t -> string
really_read fd buf 0 length;
buf
+let really_read_bigbuffer fd bigbuf n =
+ let chunk = 4096 in
+ let s = String.make chunk '\000' in
+ let written = ref 0L in
+ while !written < n do
+ let remaining = Int64.sub n !written in
+ let to_write = min remaining (Int64.of_int chunk) in
+ really_read fd s 0 (Int64.to_int to_write);
+ Bigbuffer.append_substring bigbuf s 0 (Int64.to_int to_write);
+ written := Int64.add !written to_write;
+ done
+
let really_write fd string off n =
let written = ref 0 in
while !written < n
val proxy : Unix.file_descr -> Unix.file_descr -> unit
val really_read : Unix.file_descr -> string -> int -> int -> unit
val really_read_string : Unix.file_descr -> int -> string
+val really_read_bigbuffer : Unix.file_descr -> Bigbuffer.t -> int64 -> unit
val really_write : Unix.file_descr -> string -> int -> int -> unit
val really_write_string : Unix.file_descr -> string -> unit
exception Timeout
let i = Xmlm.input_of_string s in
parse i
+let parse_bigbuffer b =
+ let n = ref Int64.zero in
+ let aux () =
+ try
+ let c = Bigbuffer.get b !n in
+ n := Int64.add !n Int64.one;
+ int_of_char c
+ with _ -> raise End_of_file in
+ let i = Xmlm.input_of_fun aux in
+ parse i
+
(* common output function *)
let substitute list s =
s
val parse_file : string -> xml
val parse_in : in_channel -> xml
val parse_string : string -> xml
+val parse_bigbuffer : Bigbuffer.t -> xml
(** output functions *)
val to_fct : xml -> (string -> unit) -> unit