blob: 3d331f43cfd82c9fbee8e8ef002fe187c5fa5609 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
(* Library module defined by the International Standard
Information technology - programming languages
BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
Copyright ISO/IEC (International Organization for Standardization
and International Electrotechnical Commission) 1996-2021.
It may be freely copied for the purpose of implementation (see page
707 of the Information technology - Programming languages Part 1:
Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
DEFINITION MODULE TermFile;
(* Access to the terminal device *)
(* Channels opened by this module are connected to a single
terminal device; typed characters are distributed between
channels according to the sequence of read requests.
*)
IMPORT IOChan, ChanConsts;
TYPE
ChanId = IOChan.ChanId;
FlagSet = ChanConsts.FlagSet;
OpenResults = ChanConsts.OpenResults;
(* Accepted singleton values of FlagSet *)
CONST
read = FlagSet{ChanConsts.readFlag};
(* input operations are requested/available *)
write = FlagSet{ChanConsts.writeFlag};
(* output operations are requested/available *)
text = FlagSet{ChanConsts.textFlag};
(* text operations are requested/available *)
raw = FlagSet{ChanConsts.rawFlag};
(* raw operations are requested/available *)
echo = FlagSet{ChanConsts.echoFlag};
(* echoing by interactive device on reading of
characters from input stream requested/applies
*)
PROCEDURE Open (VAR cid: ChanId; flagset: FlagSet; VAR res: OpenResults);
(* Attempts to obtain and open a channel connected to
the terminal. Without the raw flag, text is implied.
Without the echo flag, line mode is requested,
otherwise single character mode is requested.
If successful, assigns to cid the identity of
the opened channel, and assigns the value opened to res.
If a channel cannot be opened as required, the value of
res indicates the reason, and cid identifies the
invalid channel.
*)
PROCEDURE IsTermFile (cid: ChanId): BOOLEAN;
(* Tests if the channel identified by cid is open to
the terminal. *)
PROCEDURE Close (VAR cid: ChanId);
(* If the channel identified by cid is not open to the terminal,
the exception wrongDevice is raised; otherwise closes the
channel and assigns the value identifying the invalid channel
to cid.
*)
END TermFile.
|