]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-pim/InOut.def
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-pim / InOut.def
1 (* InOut.def provides a compatible PIM [234] InOut module.
2
3 Copyright (C) 2004-2023 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE InOut ;
28
29 IMPORT ASCII ;
30 FROM DynamicStrings IMPORT String ;
31 EXPORT QUALIFIED EOL, Done, termCH, OpenInput, OpenOutput,
32 CloseInput, CloseOutput,
33 Read, ReadString, ReadInt, ReadCard,
34 Write, WriteLn, WriteString, WriteInt, WriteCard,
35 WriteOct, WriteHex,
36 ReadS, WriteS ;
37
38 CONST
39 EOL = ASCII.EOL ;
40
41 VAR
42 Done : BOOLEAN ;
43 termCH: CHAR ;
44
45
46 (*
47 OpenInput - reads a string from stdin as the filename for reading.
48 If the filename ends with `.' then it appends the defext
49 extension. The global variable Done is set if all
50 was successful.
51 *)
52
53 PROCEDURE OpenInput (defext: ARRAY OF CHAR) ;
54
55
56 (*
57 CloseInput - closes an opened input file and returns input back to
58 StdIn.
59 *)
60
61 PROCEDURE CloseInput ;
62
63
64 (*
65 OpenOutput - reads a string from stdin as the filename for writing.
66 If the filename ends with `.' then it appends the defext
67 extension. The global variable Done is set if all
68 was successful.
69 *)
70
71 PROCEDURE OpenOutput (defext: ARRAY OF CHAR) ;
72
73
74 (*
75 CloseOutput - closes an opened output file and returns output back to
76 StdOut.
77 *)
78
79 PROCEDURE CloseOutput ;
80
81
82 (*
83 Read - reads a single character from the current input file.
84 Done is set to FALSE if end of file is reached or an
85 error occurs.
86 *)
87
88 PROCEDURE Read (VAR ch: CHAR) ;
89
90
91 (*
92 ReadString - reads a sequence of characters. Leading white space
93 is ignored and the string is terminated with a character
94 <= ' '
95 *)
96
97 PROCEDURE ReadString (VAR s: ARRAY OF CHAR) ;
98
99
100 (*
101 WriteString - writes a string to the output file.
102 *)
103
104 PROCEDURE WriteString (s: ARRAY OF CHAR) ;
105
106
107 (*
108 Write - writes out a single character, ch, to the current output file.
109 *)
110
111 PROCEDURE Write (ch: CHAR) ;
112
113
114 (*
115 WriteLn - writes a newline to the output file.
116 *)
117
118 PROCEDURE WriteLn ;
119
120
121 (*
122 ReadInt - reads a string and converts it into an INTEGER, x.
123 Done is set if an INTEGER is read.
124 *)
125
126 PROCEDURE ReadInt (VAR x: INTEGER) ;
127
128
129 (*
130 ReadInt - reads a string and converts it into an INTEGER, x.
131 Done is set if an INTEGER is read.
132 *)
133
134 PROCEDURE ReadCard (VAR x: CARDINAL) ;
135
136
137 (*
138 WriteCard - writes the CARDINAL, x, to the output file. It ensures
139 that the number occupies, n, characters. Leading spaces
140 are added if required.
141 *)
142
143 PROCEDURE WriteCard (x, n: CARDINAL) ;
144
145
146 (*
147 WriteInt - writes the INTEGER, x, to the output file. It ensures
148 that the number occupies, n, characters. Leading spaces
149 are added if required.
150 *)
151
152 PROCEDURE WriteInt (x: INTEGER; n: CARDINAL) ;
153
154
155 (*
156 WriteOct - writes the CARDINAL, x, to the output file in octal.
157 It ensures that the number occupies, n, characters.
158 Leading spaces are added if required.
159 *)
160
161 PROCEDURE WriteOct (x, n: CARDINAL) ;
162
163
164 (*
165 WriteHex - writes the CARDINAL, x, to the output file in hexadecimal.
166 It ensures that the number occupies, n, characters.
167 Leading spaces are added if required.
168 *)
169
170 PROCEDURE WriteHex (x, n: CARDINAL) ;
171
172
173 (*
174 ReadS - returns a string which has is a sequence of characters.
175 Leading white space is ignored and string is terminated
176 with a character <= ' '.
177 *)
178
179 PROCEDURE ReadS () : String ;
180
181
182 (*
183 WriteS - writes a String to the output device.
184 It returns the string, s.
185 *)
186
187 PROCEDURE WriteS (s: String) : String ;
188
189
190 END InOut.