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 * DISCLAIMED. This includes but is not limited to warranties of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 * $Date: 2005/04/17 13:14:29 $
34 /* All the headers include this file. */
39 #define __need_wchar_t
43 #endif /* Not RC_INVOKED */
46 /* Flags for the iobuf structure */
49 #define _IORW 0x0080 /* opened as "r+w" */
53 * The three standard file pointers provided by the run time library.
54 * NOTE: These will go to the bit-bucket silently in GUI applications!
56 #define STDIN_FILENO 0
57 #define STDOUT_FILENO 1
58 #define STDERR_FILENO 2
60 /* Returned by various functions on end of file condition or error. */
64 * The maximum length of a file name. You should use GetVolumeInformation
65 * instead of this constant. But hey, this works.
67 * NOTE: This is used in the structure _finddata_t (see io.h) so changing it
68 * is probably not a good idea.
70 #define FILENAME_MAX (260)
73 * The maximum number of files that may be open at once. I have set this to
74 * a conservative number. The actual value may be higher.
76 #define FOPEN_MAX (20)
78 /* After creating this many names, tmpnam and tmpfile return NULL */
81 * Tmpnam, tmpfile and, sometimes, _tempnam try to create
82 * temp files in the root directory of the current drive
83 * (not in pwd, as suggested by some older MS doc's).
84 * Redefining these macros does not effect the CRT functions.
86 #define _P_tmpdir "\\"
87 #define _wP_tmpdir L"\\"
90 * The maximum size of name (including NUL) that will be put in the user
91 * supplied buffer caName for tmpnam.
92 * Inferred from the size of the static buffer returned by tmpnam
93 * when passed a NULL argument. May actually be smaller.
102 * The buffer size as used by setbuf such that it is equivalent to
103 * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
107 /* Constants for nOrigin indicating the position relative to which fseek
108 * sets the file position. Enclosed in ifdefs because io.h could also
109 * define them. (Though not anymore since io.h includes this file now.) */
126 * I used to include stdarg.h at this point, in order to allow for the
127 * functions later on in the file which use va_list. That conflicts with
128 * using stdio.h and varargs.h in the same file, so I do the typedef myself.
132 #if defined __GNUC__ && __GNUC__ >= 3
133 typedef __builtin_va_list
va_list;
135 typedef char* va_list;
139 * The structure underlying the FILE type.
141 * I still believe that nobody in their right mind should make use of the
142 * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
145 #ifndef _FILE_DEFINED
146 #define _FILE_DEFINED
147 typedef struct _iobuf
158 #endif /* Not _FILE_DEFINED */
162 * The standard file handles
164 #ifndef __DECLSPEC_SUPPORTED
166 extern FILE (*__imp__iob
)[]; /* A pointer to an array of FILE */
168 #define _iob (*__imp__iob) /* An array of FILE */
170 #else /* __DECLSPEC_SUPPORTED */
172 __MINGW_IMPORT
FILE _iob
[]; /* An array of FILE imported from DLL. */
174 #endif /* __DECLSPEC_SUPPORTED */
176 #define stdin (&_iob[STDIN_FILENO])
177 #define stdout (&_iob[STDOUT_FILENO])
178 #define stderr (&_iob[STDERR_FILENO])
187 FILE* fopen (const char*, const char*);
188 FILE* freopen (const char*, const char*, FILE*);
191 /* MS puts remove & rename (but not wide versions) in io.h also */
192 int remove (const char*);
193 int rename (const char*, const char*);
194 FILE* tmpfile (void);
195 char* tmpnam (char*);
196 char* _tempnam (const char*, const char*);
199 char* tempnam (const char*, const char*);
202 int setvbuf (FILE*, char*, int, size_t);
204 void setbuf (FILE*, char*);
210 int fprintf (FILE*, const char*, ...);
211 int printf (const char*, ...);
212 int sprintf (char*, const char*, ...);
213 int _snprintf (char*, size_t, const char*, ...);
214 int vfprintf (FILE*, const char*, va_list);
215 int vprintf (const char*, va_list);
216 int vsprintf (char*, const char*, va_list);
217 int _vsnprintf (char*, size_t, const char*, va_list);
219 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
220 int snprintf(char* s
, size_t n
, const char* format
, ...);
221 extern inline int vsnprintf (char* s
, size_t n
, const char* format
,
223 { return _vsnprintf ( s
, n
, format
, arg
); }
230 int fscanf (FILE*, const char*, ...);
231 int scanf (const char*, ...);
232 int sscanf (const char*, const char*, ...);
234 * Character Input and Output Functions
238 char* fgets (char*, int, FILE*);
239 int fputc (int, FILE*);
240 int fputs (const char*, FILE*);
244 int putc (int, FILE*);
246 int puts (const char*);
247 int ungetc (int, FILE*);
250 * Direct Input and Output Functions
253 size_t fread (void*, size_t, size_t, FILE*);
254 size_t fwrite (const void*, size_t, size_t, FILE*);
257 * File Positioning Functions
260 int fseek (FILE*, long, int);
264 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
266 * Workaround for limitations on win9x where a file contents are
267 * not zero'd out if you seek past the end and then write.
270 int __mingw_fseek (FILE *, long, int);
271 int __mingw_fwrite (const void*, size_t, size_t, FILE*);
272 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
273 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
274 #endif /* __USE_MINGW_FSEEK */
278 * An opaque data type used for storing file positions... The contents of
279 * this type are unknown, but we (the compiler) need to know the size
280 * because the programmer using fgetpos and fsetpos will be setting aside
281 * storage for fpos_t structres. Actually I tested using a byte array and
282 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
283 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
284 * MSVCRT however, and for now `long long' will do.
287 typedef long long fpos_t;
292 int fgetpos (FILE*, fpos_t*);
293 int fsetpos (FILE*, const fpos_t*);
299 void clearerr (FILE*);
302 void perror (const char*);
305 #ifndef __STRICT_ANSI__
309 FILE* _popen (const char*, const char*);
313 FILE* popen (const char*, const char*);
318 * Other Non ANSI functions
320 int _flushall (void);
321 int _fgetchar (void);
323 FILE* _fdopen (int, const char*);
329 FILE* fdopen (int, const char*);
331 #endif /* Not _NO_OLDNAMES */
333 #endif /* Not __STRICT_ANSI__ */
337 #ifndef _WSTDIO_DEFINED
338 /* also in wchar.h - keep in sync */
339 int fwprintf (FILE*, const wchar_t*, ...);
340 int wprintf (const wchar_t*, ...);
341 int swprintf (wchar_t*, const wchar_t*, ...);
342 int _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
343 int vfwprintf (FILE*, const wchar_t*, va_list);
344 int vwprintf (const wchar_t*, va_list);
345 int vswprintf (wchar_t*, const wchar_t*, va_list);
346 int _vsnwprintf (wchar_t*, size_t, const wchar_t*, va_list);
347 int fwscanf (FILE*, const wchar_t*, ...);
348 int wscanf (const wchar_t*, ...);
349 int swscanf (const wchar_t*, const wchar_t*, ...);
350 wint_t fgetwc (FILE*);
351 wint_t fputwc (wchar_t, FILE*);
352 wint_t ungetwc (wchar_t, FILE*);
354 wchar_t* fgetws (wchar_t*, int, FILE*);
355 int fputws (const wchar_t*, FILE*);
356 wint_t getwc (FILE*);
357 wint_t getwchar (void);
358 wchar_t* _getws (wchar_t*);
359 wint_t putwc (wint_t, FILE*);
360 int _putws (const wchar_t*);
361 wint_t putwchar (wint_t);
362 FILE* _wfopen (const wchar_t*, const wchar_t*);
363 FILE* _wfreopen (const wchar_t*, const wchar_t*, FILE*);
364 FILE* _wfsopen (const wchar_t*, const wchar_t*, int);
365 wchar_t* _wtmpnam (wchar_t*);
366 wchar_t* _wtempnam (const wchar_t*, const wchar_t*);
367 int _wrename (const wchar_t*, const wchar_t*);
368 int _wremove (const wchar_t*);
369 void _wperror (const wchar_t*);
370 FILE* _wpopen (const wchar_t*, const wchar_t*);
371 #endif /* __MSVCRT__ */
373 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
374 int snwprintf(wchar_t* s
, size_t n
, const wchar_t* format
, ...);
375 extern inline int vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
,
377 { return _vsnwprintf ( s
, n
, format
, arg
); }
380 #define _WSTDIO_DEFINED
381 #endif /* _WSTDIO_DEFINED */
383 #ifndef __STRICT_ANSI__
386 FILE* wpopen (const wchar_t*, const wchar_t*);
387 #endif /* not NO_OLDNAMES */
388 #endif /* MSVCRT runtime */
391 * Other Non ANSI wide functions
393 wint_t _fgetwchar (void);
394 wint_t _fputwchar (wint_t);
396 int _putw (int, FILE*);
399 wint_t fgetwchar (void);
400 wint_t fputwchar (wint_t);
402 int putw (int, FILE*);
403 #endif /* Not _NO_OLDNAMES */
405 #endif /* __STRICT_ANSI */
411 #endif /* Not RC_INVOKED */
413 #endif /* _STDIO_H_ */