4 * Definitions of types and prototypes of functions for standard input and
7 * NOTE: The file manipulation functions provided by Microsoft seem to
8 * work with either slash (/) or backslash (\) as the path separator.
10 * This file is part of the Mingw32 package.
13 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
15 * THIS SOFTWARE IS NOT COPYRIGHTED
17 * This source code is offered for use in the public domain. You may
18 * use, modify or distribute it freely.
20 * This code is distributed in the hope that it will be useful but
21 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
22 * DISCLAMED. This includes but is not limited to warranties of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 * $Date: 1999/03/19 05:55:06 $
30 /* Appropriated for Reactos Crtdll by Ariadne */
31 /* implemented clearerr feof ferror perror as macros */
41 #define __need_wchar_t
45 /* Some flags for the iobuf structure provided by djgpp stdio.h */
46 #define _IOREAD 000010
48 #define _IOMYBUF 000040
51 #define _IOSTRG 000400
53 #define _IOAPPEND 002000
54 #define _IORMONCL 004000 /* remove on close, for temp files */
55 /* if _flag & _IORMONCL, ._name_to_remove needs freeing */
56 #define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */
60 * I used to include stdarg.h at this point, in order to allow for the
61 * functions later on in the file which use va_list. That conflicts with
62 * using stdio.h and varargs.h in the same file, so I do the typedef myself.
66 typedef char* va_list;
70 * FILE should be used as a pointer to an opaque data type. Do not rely on
71 * anything else, especially the size or contents of this structure!
82 char *_name_to_remove
;
89 * The three standard file pointers provided by the run time library.
90 * NOTE: These will go to the bit-bucket silently in GUI applications!
92 extern FILE (*__imp__iob
)[]; /* A pointer to an array of FILE */
93 #define _iob (*__imp__iob) /* An array of FILE */
94 #define stdin (&_iob[0])
95 #define stdout (&_iob[1])
96 #define stderr (&_iob[2])
97 #define stdaux (&_iob[3])
98 #define stdprn (&_iob[4])
100 /* Returned by various functions on end of file condition or error. */
105 * The maximum length of a file name. You should use GetVolumeInformation
106 * instead of this constant. But hey, this works.
108 * NOTE: This is used in the structure _finddata_t (see dir.h) so changing it
109 * is probably not a good idea.
111 #define FILENAME_MAX (260)
114 * The maximum number of files that may be open at once. I have set this to
115 * a conservative number. The actual value may be higher.
117 #define FOPEN_MAX (20)
124 FILE* fopen (const char* szFileName
, const char* szMode
);
125 FILE* freopen (const char* szNewFileName
, const char* szNewMode
,
126 FILE* fileChangeAssociation
);
127 int fflush (FILE* fileFlush
);
128 int fclose (FILE* fileClose
);
129 int remove (const char* szFileName
);
130 int rename (const char* szOldFileName
, const char* szNewFileName
);
131 FILE* tmpfile (void);
135 * The maximum size of name (including NUL) that will be put in the user
136 * supplied buffer caName.
137 * NOTE: This has not been determined by experiment, but based on the
138 * maximum file name length above it is probably reasonable. I could be
141 #define L_tmpnam (260)
143 char* tmpnam (char caName
[]);
144 char* _tempnam (const char *szDir
, const char *szPfx
);
147 #define tempnam _tempnam
148 #endif /* Not _NO_OLDNAMES */
151 * The three possible buffering mode (nMode) values for setvbuf.
152 * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
153 * maybe I'm testing it wrong?
155 #define _IOFBF 0 /* fully buffered */
156 #define _IOLBF 1 /* line buffered */
157 #define _IONBF 2 /* unbuffered */
159 int setvbuf (FILE* fileSetBuffer
, char* caBuffer
, int nMode
,
164 * The buffer size as used by setbuf such that it is equivalent to
165 * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
169 void setbuf (FILE* fileSetBuffer
, char* caBuffer
);
175 int _pclose (FILE* pipeClose
);
176 FILE* _popen (const char* szPipeName
, const char* szMode
);
179 #define pclose _pclose
181 /* Wide character version */
182 FILE* _wpopen (const wchar_t* szPipeName
, const wchar_t* szMode
);
188 int fprintf (FILE* filePrintTo
, const char* szFormat
, ...);
189 int printf (const char* szFormat
, ...);
190 int sprintf (char* caBuffer
, const char* szFormat
, ...);
191 int vfprintf (FILE* filePrintTo
, const char* szFormat
, va_list varg
);
192 int vprintf (const char* szFormat
, va_list varg
);
193 int vsprintf (char* caBuffer
, const char* szFormat
, va_list varg
);
195 /* Wide character versions */
196 int fwprintf (FILE* filePrintTo
, const wchar_t* wsFormat
, ...);
197 int wprintf (const wchar_t* wsFormat
, ...);
198 int swprintf (wchar_t* wcaBuffer
, const wchar_t* wsFormat
, ...);
199 int vfwprintf (FILE* filePrintTo
, const wchar_t* wsFormat
, va_list varg
);
200 int vwprintf (const wchar_t* wsFormat
, va_list varg
);
201 int vswprintf (wchar_t* wcaBuffer
, const wchar_t* wsFormat
, va_list varg
);
207 int fscanf (FILE* fileReadFrom
, const char* szFormat
, ...);
208 int scanf (const char* szFormat
, ...);
209 int sscanf (const char* szReadFrom
, const char* szFormat
, ...);
211 /* Wide character versions */
212 int fwscanf (FILE* fileReadFrom
, const wchar_t* wsFormat
, ...);
213 int wscanf (const wchar_t* wsFormat
, ...);
214 int swscanf (const wchar_t* wsReadFrom
, const wchar_t* wsFormat
, ...);
217 * Character Input and Output Functions
220 int fgetc (FILE* fileRead
);
221 char* fgets (char* caBuffer
, int nBufferSize
, FILE* fileRead
);
222 int fputc (int c
, FILE* fileWrite
);
223 int fputs (const char* szOutput
, FILE* fileWrite
);
224 int getc (FILE* fileRead
);
226 char* gets (char* caBuffer
); /* Unsafe: how does gets know how long the
228 int putc (int c
, FILE* fileWrite
);
230 int puts (const char* szOutput
);
231 int ungetc (int c
, FILE* fileWasRead
);
233 /* Wide character versions */
234 int fgetwc (FILE* fileRead
);
235 int fputwc (wchar_t wc
, FILE* fileWrite
);
236 int ungetwc (wchar_t wc
, FILE* fileWasRead
);
239 * Not exported by CRTDLL.DLL included for reference purposes.
242 wchar_t* fgetws (wchar_t* wcaBuffer
, int nBufferSize
, FILE* fileRead
);
243 int fputws (const wchar_t* wsOutput
, FILE* fileWrite
);
244 int getwc (FILE* fileRead
);
246 wchar_t* getws (wchar_t* wcaBuffer
);
247 int putwc (wchar_t wc
, FILE* fileWrite
);
248 int putws (const wchar_t* wsOutput
);
251 /* NOTE: putchar has no wide char equivalent even in tchar.h */
255 * Direct Input and Output Functions
258 size_t fread (void* pBuffer
, size_t sizeObject
, size_t sizeObjCount
,
260 size_t fwrite (const void* pObjArray
, size_t sizeObject
, size_t sizeObjCount
,
265 * File Positioning Functions
268 /* Constants for nOrigin indicating the position relative to which fseek
269 * sets the file position. Enclosed in ifdefs because io.h could also
270 * define them. (Though not anymore since io.h includes this file now.) */
283 int fseek (FILE* fileSetPosition
, long lnOffset
, int nOrigin
);
284 long ftell (FILE* fileGetPosition
);
285 void rewind (FILE* fileRewind
);
288 * An opaque data type used for storing file positions... The contents of
289 * this type are unknown, but we (the compiler) need to know the size
290 * because the programmer using fgetpos and fsetpos will be setting aside
291 * storage for fpos_t structres. Actually I tested using a byte array and
292 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
293 * Perhaps an unsigned long? TODO?
297 int fgetpos (FILE* fileGetPosition
, fpos_t* pfpos
);
298 int fsetpos (FILE* fileSetPosition
, const fpos_t* pfpos
);
305 void clearerr (FILE* fileClearErrors
);
306 int feof (FILE* fileIsAtEnd
);
307 int ferror (FILE* fileIsError
);
308 void perror (const char* szErrorMessage
);
312 #define clearerr(f) (((f)->_flag) &= ~(_IOERR|_IOEOF))
313 #define feof(f) (((f)->_flag&_IOEOF)!=0)
314 #define ferror(f) (((f)->_flag&_IOERR)!=0)
315 #define perror(s) (fprintf(stderr, "%s: %s\n", (s), _strerror(NULL)))
320 #ifndef __STRICT_ANSI__
321 int _fgetchar (void);
322 int _fputchar (int c
);
323 FILE* _fdopen (int nHandle
, char* szMode
);
326 #define fgetchar _fgetchar
327 #define fputchar _fputchar
328 #define fdopen _fdopen
329 #endif /* Not _NO_OLDNAMES */
331 #endif /* Not __STRICT_ANSI__ */
337 #endif /* _STDIO_H_ */