Debian Codegraph @

gcc/m2/pge-boot/GFIO.h

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