1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 2000 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 (* Handling of sections in bytecode executable files *)
17
18 (** Recording sections written to a bytecode executable file *)
19
20 val init_record: out_channel -> unit
21 (* Start recording sections from the current position in out_channel *)
22
23 val record: out_channel -> string -> unit
24 (* Record the current position in the out_channel as the end of
25 the section with the given name *)
26
27 val write_toc_and_trailer: out_channel -> unit
28 (* Write the table of contents and the standard trailer for bytecode
29 executable files *)
30
31 (** Reading sections from a bytecode executable file *)
32
33 val read_toc: in_channel -> unit
34 (* Read the table of sections from a bytecode executable *)
35
36 exception Bad_magic_number
37 (* Raised by [read_toc] if magic number doesn't match *)
38
39 val toc: unit -> (string * int) list
40 (* Return the current table of contents as a list of
41 (section name, section length) pairs. *)
42
43 val seek_section: in_channel -> string -> int
44 (* Position the input channel at the beginning of the section named "name",
45 and return the length of that section. Raise Not_found if no
46 such section exists. *)
47
48 val read_section_string: in_channel -> string -> string
49 (* Return the contents of a section, as a string *)
50
51 val read_section_struct: in_channel -> string -> 'a
52 (* Return the contents of a section, as marshalled data *)
53
54 val pos_first_section: in_channel -> int
55 (* Return the position of the beginning of the first section *)
56
57 val reset: unit -> unit
58