1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 (* Network messages
*)
21 structure Msg
:> MSG
= struct
23 open OpenSSL MsgTypes Slave
32 | _
=> raise OpenSSL
.OpenSSL
"Bad action number to deserialize"
36 MsgOk
=> OpenSSL
.writeInt (bio
, 1)
37 | MsgError s
=> (OpenSSL
.writeInt (bio
, 2);
38 OpenSSL
.writeString (bio
, s
))
39 | MsgConfig s
=> (OpenSSL
.writeInt (bio
, 3);
40 OpenSSL
.writeString (bio
, s
))
41 | MsgFile
{action
, domain
, dir
, file
} =>
42 (OpenSSL
.writeInt (bio
, 4);
43 OpenSSL
.writeInt (bio
, a2i action
);
44 OpenSSL
.writeString (bio
, domain
);
45 OpenSSL
.writeString (bio
, dir
);
46 OpenSSL
.writeString (bio
, file
))
47 | MsgDoFiles
=> OpenSSL
.writeInt (bio
, 5)
51 NONE
=> raise OpenSSL
.OpenSSL
"Bad Msg format"
55 case OpenSSL
.readInt bio
of
60 |
2 => Option
.map
MsgError (OpenSSL
.readString bio
)
61 |
3 => Option
.map
MsgConfig (OpenSSL
.readString bio
)
62 |
4 => (case (OpenSSL
.readInt bio
,
63 OpenSSL
.readString bio
,
64 OpenSSL
.readString bio
,
65 OpenSSL
.readString bio
) of
66 (SOME action
, SOME domain
, SOME dir
, SOME file
) =>
67 SOME (MsgFile
{action
= i2a action
,
72 |
5 => SOME MsgDoFiles