]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/mc-boot/GFIO.h
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / mc-boot / GFIO.h
1 /* do not edit automatically generated by mc from FIO. */
2 /* FIO.def provides a simple buffered file input/output library.
3
4 Copyright (C) 2001-2021 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6
7 This file is part of GNU Modula-2.
8
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
27
28
29 #if !defined (_FIO_H)
30 # define _FIO_H
31
32 #include "config.h"
33 #include "system.h"
34 # ifdef __cplusplus
35 extern "C" {
36 # endif
37 # if !defined (PROC_D)
38 # define PROC_D
39 typedef void (*PROC_t) (void);
40 typedef struct { PROC_t proc; } PROC;
41 # endif
42
43 # include "GSYSTEM.h"
44
45 # if defined (_FIO_C)
46 # define EXTERN
47 # else
48 # define EXTERN extern
49 # endif
50
51 typedef unsigned int FIO_File;
52
53 EXTERN FIO_File FIO_StdIn;
54 EXTERN FIO_File FIO_StdOut;
55 EXTERN FIO_File FIO_StdErr;
56
57 /*
58 IsNoError - returns a TRUE if no error has occured on file, f.
59 */
60
61 EXTERN unsigned int FIO_IsNoError (FIO_File f);
62
63 /*
64 IsActive - returns TRUE if the file, f, is still active.
65 */
66
67 EXTERN unsigned int FIO_IsActive (FIO_File f);
68
69 /*
70 Exists - returns TRUE if a file named, fname exists for reading.
71 */
72
73 EXTERN unsigned int FIO_Exists (const char *fname_, unsigned int _fname_high);
74
75 /*
76 OpenToRead - attempts to open a file, fname, for reading and
77 it returns this file.
78 The success of this operation can be checked by
79 calling IsNoError.
80 */
81
82 EXTERN FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high);
83
84 /*
85 OpenToWrite - attempts to open a file, fname, for write and
86 it returns this file.
87 The success of this operation can be checked by
88 calling IsNoError.
89 */
90
91 EXTERN FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_high);
92
93 /*
94 OpenForRandom - attempts to open a file, fname, for random access
95 read or write and it returns this file.
96 The success of this operation can be checked by
97 calling IsNoError.
98 towrite, determines whether the file should be
99 opened for writing or reading.
100 newfile, determines whether a file should be
101 created if towrite is TRUE or whether the
102 previous file should be left alone,
103 allowing this descriptor to seek
104 and modify an existing file.
105 */
106
107 EXTERN FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_high, unsigned int towrite, unsigned int newfile);
108
109 /*
110 Close - close a file which has been previously opened using:
111 OpenToRead, OpenToWrite, OpenForRandom.
112 It is correct to close a file which has an error status.
113 */
114
115 EXTERN void FIO_Close (FIO_File f);
116 EXTERN unsigned int FIO_exists (void * fname, unsigned int flength);
117 EXTERN FIO_File FIO_openToRead (void * fname, unsigned int flength);
118 EXTERN FIO_File FIO_openToWrite (void * fname, unsigned int flength);
119 EXTERN FIO_File FIO_openForRandom (void * fname, unsigned int flength, unsigned int towrite, unsigned int newfile);
120
121 /*
122 FlushBuffer - flush contents of the FIO file, f, to libc.
123 */
124
125 EXTERN void FIO_FlushBuffer (FIO_File f);
126
127 /*
128 ReadNBytes - reads nBytes of a file into memory area, dest, returning
129 the number of bytes actually read.
130 This function will consume from the buffer and then
131 perform direct libc reads. It is ideal for large reads.
132 */
133
134 EXTERN unsigned int FIO_ReadNBytes (FIO_File f, unsigned int nBytes, void * dest);
135
136 /*
137 ReadAny - reads HIGH(a) bytes into, a. All input
138 is fully buffered, unlike ReadNBytes and thus is more
139 suited to small reads.
140 */
141
142 EXTERN void FIO_ReadAny (FIO_File f, unsigned char *a, unsigned int _a_high);
143
144 /*
145 WriteNBytes - writes nBytes from memory area src to a file
146 returning the number of bytes actually written.
147 This function will flush the buffer and then
148 write the nBytes using a direct write from libc.
149 It is ideal for large writes.
150 */
151
152 EXTERN unsigned int FIO_WriteNBytes (FIO_File f, unsigned int nBytes, void * src);
153
154 /*
155 WriteAny - writes HIGH(a) bytes onto, file, f. All output
156 is fully buffered, unlike WriteNBytes and thus is more
157 suited to small writes.
158 */
159
160 EXTERN void FIO_WriteAny (FIO_File f, unsigned char *a, unsigned int _a_high);
161
162 /*
163 WriteChar - writes a single character to file, f.
164 */
165
166 EXTERN void FIO_WriteChar (FIO_File f, char ch);
167
168 /*
169 EOF - tests to see whether a file, f, has reached end of file.
170 */
171
172 EXTERN unsigned int FIO_EOF (FIO_File f);
173
174 /*
175 EOLN - tests to see whether a file, f, is about to read a newline.
176 It does NOT consume the newline. It reads the next character
177 and then immediately unreads the character.
178 */
179
180 EXTERN unsigned int FIO_EOLN (FIO_File f);
181
182 /*
183 WasEOLN - tests to see whether a file, f, has just read a newline
184 character.
185 */
186
187 EXTERN unsigned int FIO_WasEOLN (FIO_File f);
188
189 /*
190 ReadChar - returns a character read from file, f.
191 Sensible to check with IsNoError or EOF after calling
192 this function.
193 */
194
195 EXTERN char FIO_ReadChar (FIO_File f);
196
197 /*
198 UnReadChar - replaces a character, ch, back into file, f.
199 This character must have been read by ReadChar
200 and it does not allow successive calls. It may
201 only be called if the previous read was successful,
202 end of file or end of line seen.
203 */
204
205 EXTERN void FIO_UnReadChar (FIO_File f, char ch);
206
207 /*
208 WriteLine - writes out a linefeed to file, f.
209 */
210
211 EXTERN void FIO_WriteLine (FIO_File f);
212
213 /*
214 WriteString - writes a string to file, f.
215 */
216
217 EXTERN void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_high);
218
219 /*
220 ReadString - reads a string from file, f, into string, a.
221 It terminates the string if HIGH is reached or
222 if a newline is seen or an error occurs.
223 */
224
225 EXTERN void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high);
226
227 /*
228 WriteCardinal - writes a CARDINAL to file, f.
229 It writes the binary image of the CARDINAL.
230 to file, f.
231 */
232
233 EXTERN void FIO_WriteCardinal (FIO_File f, unsigned int c);
234
235 /*
236 ReadCardinal - reads a CARDINAL from file, f.
237 It reads a bit image of a CARDINAL
238 from file, f.
239 */
240
241 EXTERN unsigned int FIO_ReadCardinal (FIO_File f);
242
243 /*
244 GetUnixFileDescriptor - returns the UNIX file descriptor of a file.
245 Useful when combining FIO.mod with select
246 (in Selective.def - but note the comments in
247 Selective about using read/write primatives)
248 */
249
250 EXTERN int FIO_GetUnixFileDescriptor (FIO_File f);
251
252 /*
253 SetPositionFromBeginning - sets the position from the beginning
254 of the file.
255 */
256
257 EXTERN void FIO_SetPositionFromBeginning (FIO_File f, long int pos);
258
259 /*
260 SetPositionFromEnd - sets the position from the end of the file.
261 */
262
263 EXTERN void FIO_SetPositionFromEnd (FIO_File f, long int pos);
264
265 /*
266 FindPosition - returns the current absolute position in file, f.
267 */
268
269 EXTERN long int FIO_FindPosition (FIO_File f);
270
271 /*
272 GetFileName - assigns, a, with the filename associated with, f.
273 */
274
275 EXTERN void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high);
276
277 /*
278 getFileName - returns the address of the filename associated with, f.
279 */
280
281 EXTERN void * FIO_getFileName (FIO_File f);
282
283 /*
284 getFileNameLength - returns the number of characters associated with
285 filename, f.
286 */
287
288 EXTERN unsigned int FIO_getFileNameLength (FIO_File f);
289
290 /*
291 FlushOutErr - flushes, StdOut, and, StdErr.
292 */
293
294 EXTERN void FIO_FlushOutErr (void);
295 # ifdef __cplusplus
296 }
297 # endif
298
299 # undef EXTERN
300 #endif