]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/SeqFile.def
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / SeqFile.def
1 (* Library module defined by the International Standard
2 Information technology - programming languages
3 BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
4
5 Copyright ISO/IEC (International Organization for Standardization
6 and International Electrotechnical Commission) 1996-2021.
7
8 It may be freely copied for the purpose of implementation (see page
9 707 of the Information technology - Programming languages Part 1:
10 Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
11
12 DEFINITION MODULE SeqFile;
13
14 (* Rewindable sequential files *)
15
16 IMPORT IOChan, ChanConsts;
17
18 TYPE
19 ChanId = IOChan.ChanId;
20 FlagSet = ChanConsts.FlagSet;
21 OpenResults = ChanConsts.OpenResults;
22
23 (* Accepted singleton values of FlagSet *)
24
25 CONST
26 (* input operations are requested/available *)
27 read = FlagSet{ChanConsts.readFlag};
28
29 (* output operations are requested/available *)
30 write = FlagSet{ChanConsts.writeFlag};
31
32 (* a file may/must/did exist before the channel is opened *)
33 old = FlagSet{ChanConsts.oldFlag};
34
35 (* text operations are requested/available *)
36 text = FlagSet{ChanConsts.textFlag};
37
38 (* raw operations are requested/available *)
39 raw = FlagSet{ChanConsts.rawFlag};
40
41 PROCEDURE OpenWrite (VAR cid: ChanId; name: ARRAY OF CHAR;
42 flags: FlagSet; VAR res: OpenResults);
43 (*
44 Attempts to obtain and open a channel connected to a stored
45 rewindable file of the given name.
46 The write flag is implied; without the raw flag, text is
47 implied. If successful, assigns to cid the identity of
48 the opened channel, assigns the value opened to res, and
49 selects output mode, with the write position at the start
50 of the file (i.e. the file is of zero length).
51 If a channel cannot be opened as required, the value of
52 res indicates the reason, and cid identifies the invalid
53 channel.
54 *)
55
56 PROCEDURE OpenAppend (VAR cid: ChanId; name: ARRAY OF CHAR;
57 flags: FlagSet; VAR res: OpenResults);
58 (*
59 Attempts to obtain and open a channel connected to a stored
60 rewindable file of the given name. The write and old flags
61 are implied; without the raw flag, text is implied. If
62 successful, assigns to cid the identity of the opened channel,
63 assigns the value opened to res, and selects output mode,
64 with the write position corresponding to the length of the
65 file. If a channel cannot be opened as required, the value
66 of res indicates the reason, and cid identifies the invalid
67 channel.
68 *)
69
70 PROCEDURE OpenRead (VAR cid: ChanId; name: ARRAY OF CHAR;
71 flags: FlagSet; VAR res: OpenResults);
72 (* Attempts to obtain and open a channel connected to a stored
73 rewindable file of the given name.
74 The read and old flags are implied; without the raw flag,
75 text is implied. If successful, assigns to cid the
76 identity of the opened channel, assigns the value opened to
77 res, and selects input mode, with the read position
78 corresponding to the start of the file.
79 If a channel cannot be opened as required, the value of
80 res indicates the reason, and cid identifies the invalid
81 channel.
82 *)
83
84 PROCEDURE IsSeqFile (cid: ChanId): BOOLEAN;
85 (* Tests if the channel identified by cid is open to a
86 rewindable sequential file. *)
87
88 PROCEDURE Reread (cid: ChanId);
89 (* If the channel identified by cid is not open to a rewindable
90 sequential file, the exception wrongDevice is raised;
91 otherwise attempts to set the read position to the
92 start of the file, and to select input mode.
93 If the operation cannot be performed (perhaps because of
94 insufficient permissions) neither input mode nor output
95 mode is selected.
96 *)
97
98 PROCEDURE Rewrite (cid: ChanId);
99 (* If the channel identified by cid is not open to a
100 rewindable sequential file, the exception wrongDevice is
101 raised; otherwise, attempts to truncate the file to zero
102 length, and to select output mode. If the operation
103 cannot be performed (perhaps because of insufficient
104 permissions) neither input mode nor output mode is selected.
105 *)
106
107 PROCEDURE Close (VAR cid: ChanId);
108 (* If the channel identified by cid is not open to a rewindable
109 sequential file, the exception wrongDevice is raised;
110 otherwise closes the channel, and assigns the value
111 identifying the invalid channel to cid.
112 *)
113
114 END SeqFile.
115