Welcome to mirror list, hosted at ThFree Co, Russian Federation.

stdio.h « include « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7922a24dd4b08d88cf241dd15f32f5402d0b18fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
/*
 * stdio.h
 *
 * Definitions of types and prototypes of functions for standard input and
 * output.
 *
 * NOTE: The file manipulation functions provided by Microsoft seem to
 * work with either slash (/) or backslash (\) as the path separator.
 *
 * This file is part of the Mingw32 package.
 *
 * Contributors:
 *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
 *
 *  THIS SOFTWARE IS NOT COPYRIGHTED
 *
 *  This source code is offered for use in the public domain. You may
 *  use, modify or distribute it freely.
 *
 *  This code is distributed in the hope that it will be useful but
 *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 *  DISCLAMED. This includes but is not limited to warranties of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * $Revision$
 * $Author$
 * $Date$
 *
 */

#ifndef _STDIO_H_
#define	_STDIO_H_

/* All the headers include this file. */
#include <_mingw.h>

#define __need_size_t
#define __need_NULL
#define __need_wchar_t
#define	__need_wint_t
#ifndef RC_INVOKED
#include <stddef.h>
#endif	/* Not RC_INVOKED */


/* Some flags for the iobuf structure provided by <paag@tid.es> */
#define	_IOREAD	1
#define	_IOWRT	2
#define	_IORW	4

/*
 * The three standard file pointers provided by the run time library.
 * NOTE: These will go to the bit-bucket silently in GUI applications!
 */
#define	STDIN_FILENO	0
#define	STDOUT_FILENO	1
#define	STDERR_FILENO	2

/* Returned by various functions on end of file condition or error. */
#define	EOF	(-1)

/*
 * The maximum length of a file name. You should use GetVolumeInformation
 * instead of this constant. But hey, this works.
 *
 * NOTE: This is used in the structure _finddata_t (see io.h) so changing it
 *       is probably not a good idea.
 */
#define	FILENAME_MAX	(260)

/*
 * The maximum number of files that may be open at once. I have set this to
 * a conservative number. The actual value may be higher.
 */
#define FOPEN_MAX	(20)

/*
 * The maximum size of name (including NUL) that will be put in the user
 * supplied buffer caName for tmpnam.
 * NOTE: This has not been determined by experiment, but based on the
 * maximum file name length above it is probably reasonable. I could be
 * wrong...
 */
#define	L_tmpnam	(260)

/*
 * The three possible buffering mode (nMode) values for setvbuf.
 * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered...
 * maybe I'm testing it wrong?
 */
#define	_IOFBF	0	/* fully buffered */
#define	_IOLBF	1	/* line buffered */
#define	_IONBF	2	/* unbuffered */

/*
 * The buffer size as used by setbuf such that it is equivalent to
 * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
 */
#define	BUFSIZ	512

/* Constants for nOrigin indicating the position relative to which fseek
 * sets the file position. Enclosed in ifdefs because io.h could also
 * define them. (Though not anymore since io.h includes this file now.) */
#ifndef	SEEK_SET
#define SEEK_SET	(0)
#endif

#ifndef	SEEK_CUR
#define	SEEK_CUR	(1)
#endif

#ifndef	SEEK_END
#define SEEK_END	(2)
#endif


#ifndef	RC_INVOKED

/*
 * I used to include stdarg.h at this point, in order to allow for the
 * functions later on in the file which use va_list. That conflicts with
 * using stdio.h and varargs.h in the same file, so I do the typedef myself.
 */
#ifndef _VA_LIST
#define _VA_LIST
typedef	char* va_list;
#endif

/*
 * The structure underlying the FILE type.
 *
 * I still believe that nobody in their right mind should make use of the
 * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
 * <paag@tid.es>.
 */
#ifndef _FILE_DEFINED
#define	_FILE_DEFINED
typedef struct _iobuf
{
	char*	_ptr;
	int	_cnt;
	char*	_base;
	int	_flag;
	int	_file;
	int	_charbuf;
	int	_bufsiz;
	char*	_tmpfname;
} FILE;
#endif	/* Not _FILE_DEFINED */


/*
 * The standard file handles
 */
#ifndef __DECLSPEC_SUPPORTED

extern FILE (*__imp__iob)[];	/* A pointer to an array of FILE */

#define _iob	(*__imp__iob)	/* An array of FILE */

#else /* __DECLSPEC_SUPPORTED */

__MINGW_IMPORT FILE _iob[];	/* An array of FILE imported from DLL. */

#endif /* __DECLSPEC_SUPPORTED */

#define stdin	(&_iob[STDIN_FILENO])
#define stdout	(&_iob[STDOUT_FILENO])
#define stderr	(&_iob[STDERR_FILENO])

#ifdef __cplusplus
extern "C" {
#endif

/*
 * File Operations
 */

FILE*	fopen (const char*, const char*);
FILE*	freopen (const char*, const char*, FILE*);
int	fflush (FILE*);
int	fclose (FILE*);
int	remove (const char*);
int	rename (const char*, const char*);
FILE*	tmpfile (void);
char*	tmpnam (char*);
char*	_tempnam (const char*, const char*);

#ifndef	NO_OLDNAMES
char*	tempnam (const char*, const char*);
#endif

int	setvbuf (FILE*, char*, int, size_t);

void	setbuf (FILE*, char*);

/*
 * Formatted Output
 */

int	fprintf (FILE*, const char*, ...);
int	printf (const char*, ...);
int	sprintf (char*, const char*, ...);
int     _snprintf (char*, size_t, const char*, ...);
int	vfprintf (FILE*, const char*, va_list);
int	vprintf (const char*, va_list);
int	vsprintf (char*, const char*, va_list);
int     _vsnprintf (char*, size_t, const char*, va_list);

/* Wide character versions */
int	fwprintf (FILE*, const wchar_t*, ...);
int	wprintf (const wchar_t*, ...);
int	swprintf (wchar_t*, const wchar_t*, ...);
int	vfwprintf (FILE*, const wchar_t*, va_list);
int	vwprintf (const wchar_t*, va_list);
int	vswprintf (wchar_t*, const wchar_t*, va_list);

/*
 * Formatted Input
 */

int	fscanf (FILE*, const char*, ...);
int	scanf (const char*, ...);
int	sscanf (const char*, const char*, ...);

/* Wide character versions */
int	fwscanf (FILE*, const wchar_t*, ...);
int	wscanf (const wchar_t*, ...);
int	swscanf (wchar_t*, const wchar_t*, ...);

/*
 * Character Input and Output Functions
 */

int	fgetc (FILE*);
char*	fgets (char*, int, FILE*);
int	fputc (int, FILE*);
int	fputs (const char*, FILE*);
int	getc (FILE*);
int	getchar (void);
char*	gets (char*);
int	putc (int, FILE*);
int	putchar (int);
int	puts (const char*);
int	ungetc (int, FILE*);

/* Wide character versions */
wint_t	fgetwc (FILE*);
wint_t	fputwc (wchar_t, FILE*);
wint_t	ungetwc (wchar_t, FILE*);


#ifdef __MSVCRT__ 
wchar_t*	fgetws (wchar_t*, int, FILE*);
int		fputws (const wchar_t*, FILE*);
wint_t		getwc (FILE*);
wint_t		getwchar (void);
wchar_t*	_getws (wchar_t*);
wint_t		putwc (wint_t, FILE*);
int		_putws (const wchar_t*);
wint_t		putwchar (wint_t);
#endif	/* __MSVCRT__ */

/*
 * Direct Input and Output Functions
 */

size_t	fread (void*, size_t, size_t, FILE*);
size_t	fwrite (const void*, size_t, size_t, FILE*);


/*
 * File Positioning Functions
 */

int	fseek	(FILE*, long, int);
long	ftell	(FILE*);
void	rewind	(FILE*);

/*
 * An opaque data type used for storing file positions... The contents of
 * this type are unknown, but we (the compiler) need to know the size
 * because the programmer using fgetpos and fsetpos will be setting aside
 * storage for fpos_t structres. Actually I tested using a byte array and
 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
 * MSVCRT however, and for now `long long' will do.
 */
#ifdef __MSVCRT__
typedef long long fpos_t;
#else
typedef long	fpos_t;
#endif

int	fgetpos	(FILE*, fpos_t*);
int	fsetpos (FILE*, const fpos_t*);

/*
 * Error Functions
 */

void	clearerr (FILE*);
int	feof (FILE*);
int	ferror (FILE*);
void	perror (const char*);


#ifndef __STRICT_ANSI__

/*
 * Pipes
 */
FILE*	_popen (const char*, const char*);
int	_pclose (FILE*);

#ifndef NO_OLDNAMES
FILE*	popen (const char*, const char*);
int	pclose (FILE*);
#endif

/* The wide character version, only available in MSVCRT DLL versions, not
 * CRTDLL. */
#ifdef __MSVCRT__
FILE*	_wpopen (const wchar_t*, const wchar_t*);

#ifndef NO_OLDNAMES
#if 0
FILE*	wpopen (const wchar_t*, const wchar_t*);
#else /* Always true */
/*
 * The above prototypeing is not possible unless the wpopen export is added
 * to moldnames, which can't be done unless we make separate moldnames.def
 * files for every supported runtime. For the time being we use a define
 * instead. Pedro's modified dlltool should take care of this I think.
 */
#define wpopen _wpopen
#endif	/* Always true */

#endif /* not NO_OLDNAMES */
#endif /* MSVCRT runtime */

/*
 * Other Non ANSI functions
 */
int	_fgetchar (void);
int	_fputchar (int);
FILE*	_fdopen (int, const char*);
wint_t	_fgetwchar(void);
wint_t	_fputwchar(wint_t);
int	_fileno (FILE*);
int	_getw (FILE*);
int	_putw (int, FILE*);

#ifndef _NO_OLDNAMES
int	fgetchar (void);
int	fputchar (int);
FILE*	fdopen (int, const char*);
wint_t	fgetwchar(void);
wint_t	fputwchar(wint_t);
int	fileno (FILE*);
int	getw (FILE*);
int	putw (int, FILE*);
#endif	/* Not _NO_OLDNAMES */

#endif	/* Not __STRICT_ANSI__ */

#ifdef __cplusplus
}
#endif

#endif	/* Not RC_INVOKED */

#endif /* _STDIO_H_ */