1
(**************************************************************************)
2
(* Copyright © 2009-2010 Stéphane Glondu <steph@glondu.net> *)
3
(* © 2010 Mehdi Dogguy <mehdi@dogguy.org> *)
5
(* This program is free software: you can redistribute it and/or modify *)
6
(* it under the terms of the GNU Affero General Public License as *)
7
(* published by the Free Software Foundation, either version 3 of the *)
8
(* License, or (at your option) any later version, with the additional *)
9
(* exemption that compiling, linking, and/or using OpenSSL is allowed. *)
11
(* This program is distributed in the hope that it will be useful, but *)
12
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
13
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)
14
(* Affero General Public License for more details. *)
16
(* You should have received a copy of the GNU Affero General Public *)
17
(* License along with this program. If not, see *)
18
(* <http://www.gnu.org/licenses/>. *)
19
(**************************************************************************)
25
module type MARSHALLABLE = sig
27
val magic_number : string
30
module Make (I : MARSHALLABLE) = struct
33
with_in_file filename begin
35
let n = String.length I.magic_number in
36
let buf = String.create n in
37
really_input ic buf 0 n;
38
if buf = I.magic_number then begin
39
(input_value ic : I.t)
41
raise (Bad_marshalled_data filename)
45
let dump filename (data : I.t) =
46
with_out_file filename begin
48
output_string ic I.magic_number;