Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1693 serge 1
/*
2
 * Copyright (c) 1990 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 *	@(#)stdio.h	5.3 (Berkeley) 3/15/86
18
 */
19
 
20
/*
21
 * NB: to fit things in six character monocase externals, the
22
 * stdio code uses the prefix `__s' for stdio objects, typically
23
 * followed by a three-character attempt at a mnemonic.
24
 */
25
 
26
#ifndef _STDIO_H_
27
#define	_STDIO_H_
28
 
29
#include "_ansi.h"
30
 
31
#define	_FSTDIO			/* ``function stdio'' */
32
 
33
#define __need_size_t
34
#include 
35
 
36
#define __need___va_list
37
#include 
38
 
39
/*
40
 *  defines __FILE, _fpos_t.
41
 * They must be defined there because struct _reent needs them (and we don't
42
 * want reent.h to include this file.
43
 */
44
 
45
#include 
46
#include 
47
 
48
_BEGIN_STD_C
49
 
50
typedef __FILE FILE;
51
 
52
#ifdef __CYGWIN__
53
typedef _fpos64_t fpos_t;
54
#else
55
typedef _fpos_t fpos_t;
56
#ifdef __LARGE64_FILES
57
typedef _fpos64_t fpos64_t;
58
#endif
59
#endif /* !__CYGWIN__ */
60
 
61
#include 
62
 
63
#define	__SLBF	0x0001		/* line buffered */
64
#define	__SNBF	0x0002		/* unbuffered */
65
#define	__SRD	0x0004		/* OK to read */
66
#define	__SWR	0x0008		/* OK to write */
67
	/* RD and WR are never simultaneously asserted */
68
#define	__SRW	0x0010		/* open for reading & writing */
69
#define	__SEOF	0x0020		/* found EOF */
70
#define	__SERR	0x0040		/* found error */
71
#define	__SMBF	0x0080		/* _buf is from malloc */
72
#define	__SAPP	0x0100		/* fdopen()ed in append mode - so must  write to end */
73
#define	__SSTR	0x0200		/* this is an sprintf/snprintf string */
74
#define	__SOPT	0x0400		/* do fseek() optimisation */
75
#define	__SNPT	0x0800		/* do not do fseek() optimisation */
76
#define	__SOFF	0x1000		/* set iff _offset is in fact correct */
77
#define	__SORD	0x2000		/* true => stream orientation (byte/wide) decided */
78
#if defined(__CYGWIN__)
79
#  define __SCLE  0x4000        /* convert line endings CR/LF <-> NL */
80
#endif
81
#define	__SL64	0x8000		/* is 64-bit offset large file */
82
 
83
/* _flags2 flags */
84
#define	__SWID	0x2000		/* true => stream orientation wide, false => byte, only valid if __SORD in _flags is true */
85
 
86
/*
87
 * The following three definitions are for ANSI C, which took them
88
 * from System V, which stupidly took internal interface macros and
89
 * made them official arguments to setvbuf(), without renaming them.
90
 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
91
 *
92
 * Although these happen to match their counterparts above, the
93
 * implementation does not rely on that (so these could be renumbered).
94
 */
95
#define	_IOFBF	0		/* setvbuf should set fully buffered */
96
#define	_IOLBF	1		/* setvbuf should set line buffered */
97
#define	_IONBF	2		/* setvbuf should set unbuffered */
98
 
99
#ifndef NULL
100
#define	NULL	0
101
#endif
102
 
103
#define	EOF	(-1)
104
 
105
#ifdef __BUFSIZ__
106
#define	BUFSIZ		__BUFSIZ__
107
#else
108
#define	BUFSIZ		1024
109
#endif
110
 
111
#ifdef __FOPEN_MAX__
112
#define FOPEN_MAX	__FOPEN_MAX__
113
#else
114
#define	FOPEN_MAX	20
115
#endif
116
 
117
#ifdef __FILENAME_MAX__
118
#define FILENAME_MAX    __FILENAME_MAX__
119
#else
120
#define	FILENAME_MAX	1024
121
#endif
122
 
123
#ifdef __L_tmpnam__
124
#define L_tmpnam	__L_tmpnam__
125
#else
126
#define	L_tmpnam	FILENAME_MAX
127
#endif
128
 
129
#ifndef __STRICT_ANSI__
130
#define P_tmpdir        "/tmp"
131
#endif
132
 
133
#ifndef SEEK_SET
134
#define	SEEK_SET	0	/* set file offset to offset */
135
#endif
136
#ifndef SEEK_CUR
137
#define	SEEK_CUR	1	/* set file offset to current plus offset */
138
#endif
139
#ifndef SEEK_END
140
#define	SEEK_END	2	/* set file offset to EOF plus offset */
141
#endif
142
 
143
#define	TMP_MAX		26
144
 
145
#ifndef _REENT_ONLY
146
#define	stdin	(_REENT->_stdin)
147
#define	stdout	(_REENT->_stdout)
148
#define	stderr	(_REENT->_stderr)
149
#else /* _REENT_ONLY */
150
#define	stdin	(_impure_ptr->_stdin)
151
#define	stdout	(_impure_ptr->_stdout)
152
#define	stderr	(_impure_ptr->_stderr)
153
#endif /* _REENT_ONLY */
154
 
155
#define _stdin_r(x)	((x)->_stdin)
156
#define _stdout_r(x)	((x)->_stdout)
157
#define _stderr_r(x)	((x)->_stderr)
158
 
159
/*
160
 * Functions defined in ANSI C standard.
161
 */
162
 
163
#ifndef __VALIST
164
#ifdef __GNUC__
165
#define __VALIST __gnuc_va_list
166
#else
167
#define __VALIST char*
168
#endif
169
#endif
170
 
171
FILE *	_EXFUN(tmpfile, (void));
172
char *	_EXFUN(tmpnam, (char *));
173
int	_EXFUN(fclose, (FILE *));
174
int	_EXFUN(fflush, (FILE *));
175
FILE *	_EXFUN(freopen, (const char *, const char *, FILE *));
176
void	_EXFUN(setbuf, (FILE *, char *));
177
int	_EXFUN(setvbuf, (FILE *, char *, int, size_t));
178
int	_EXFUN(fprintf, (FILE *, const char *, ...)
179
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
180
int	_EXFUN(fscanf, (FILE *, const char *, ...)
181
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
182
int	_EXFUN(printf, (const char *, ...)
183
               _ATTRIBUTE ((__format__ (__printf__, 1, 2))));
184
int	_EXFUN(scanf, (const char *, ...)
185
               _ATTRIBUTE ((__format__ (__scanf__, 1, 2))));
186
int	_EXFUN(sscanf, (const char *, const char *, ...)
187
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
188
int	_EXFUN(vfprintf, (FILE *, const char *, __VALIST)
189
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
190
int	_EXFUN(vprintf, (const char *, __VALIST)
191
               _ATTRIBUTE ((__format__ (__printf__, 1, 0))));
192
int	_EXFUN(vsprintf, (char *, const char *, __VALIST)
193
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
194
int	_EXFUN(fgetc, (FILE *));
195
char *  _EXFUN(fgets, (char *, int, FILE *));
196
int	_EXFUN(fputc, (int, FILE *));
197
int	_EXFUN(fputs, (const char *, FILE *));
198
int	_EXFUN(getc, (FILE *));
199
int	_EXFUN(getchar, (void));
200
char *  _EXFUN(gets, (char *));
201
int	_EXFUN(putc, (int, FILE *));
202
int	_EXFUN(putchar, (int));
203
int	_EXFUN(puts, (const char *));
204
int	_EXFUN(ungetc, (int, FILE *));
205
size_t	_EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));
206
size_t	_EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));
207
#ifdef _COMPILING_NEWLIB
208
int	_EXFUN(fgetpos, (FILE *, _fpos_t *));
209
#else
210
int	_EXFUN(fgetpos, (FILE *, fpos_t *));
211
#endif
212
int	_EXFUN(fseek, (FILE *, long, int));
213
#ifdef _COMPILING_NEWLIB
214
int	_EXFUN(fsetpos, (FILE *, const _fpos_t *));
215
#else
216
int	_EXFUN(fsetpos, (FILE *, const fpos_t *));
217
#endif
218
long	_EXFUN(ftell, ( FILE *));
219
void	_EXFUN(rewind, (FILE *));
220
void	_EXFUN(clearerr, (FILE *));
221
int	_EXFUN(feof, (FILE *));
222
int	_EXFUN(ferror, (FILE *));
223
void    _EXFUN(perror, (const char *));
224
#ifndef _REENT_ONLY
225
FILE *	_EXFUN(fopen, (const char *_name, const char *_type));
226
int	_EXFUN(sprintf, (char *, const char *, ...)
227
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
228
int	_EXFUN(remove, (const char *));
229
int	_EXFUN(rename, (const char *, const char *));
230
#endif
231
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
232
#ifdef _COMPILING_NEWLIB
233
int	_EXFUN(fseeko, (FILE *, _off_t, int));
234
_off_t	_EXFUN(ftello, ( FILE *));
235
#else
236
int	_EXFUN(fseeko, (FILE *, off_t, int));
237
off_t	_EXFUN(ftello, ( FILE *));
238
#endif
239
#endif
240
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
241
#ifndef _REENT_ONLY
242
int	_EXFUN(asiprintf, (char **, const char *, ...)
243
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
244
char *	_EXFUN(asniprintf, (char *, size_t *, const char *, ...)
245
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
246
char *	_EXFUN(asnprintf, (char *, size_t *, const char *, ...)
247
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
248
int	_EXFUN(asprintf, (char **, const char *, ...)
249
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
250
#ifndef diprintf
251
int	_EXFUN(diprintf, (int, const char *, ...)
252
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
253
#endif
254
int	_EXFUN(fcloseall, (_VOID));
255
int	_EXFUN(fiprintf, (FILE *, const char *, ...)
256
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
257
int	_EXFUN(fiscanf, (FILE *, const char *, ...)
258
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
259
int	_EXFUN(iprintf, (const char *, ...)
260
               _ATTRIBUTE ((__format__ (__printf__, 1, 2))));
261
int	_EXFUN(iscanf, (const char *, ...)
262
               _ATTRIBUTE ((__format__ (__scanf__, 1, 2))));
263
int	_EXFUN(siprintf, (char *, const char *, ...)
264
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
265
int	_EXFUN(siscanf, (const char *, const char *, ...)
266
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
267
int	_EXFUN(snprintf, (char *, size_t, const char *, ...)
268
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
3959 Serge 269
int _EXFUN(snprintf, (char *, size_t, const char *, ...)
1693 serge 270
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
3959 Serge 271
int _EXFUN(snprintf, (char *, size_t, const char *, ...)
272
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
273
int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
274
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
1693 serge 275
char *	_EXFUN(tempnam, (const char *, const char *));
276
int	_EXFUN(vasiprintf, (char **, const char *, __VALIST)
277
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
278
char *	_EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST)
279
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
280
char *	_EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
281
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
282
int	_EXFUN(vasprintf, (char **, const char *, __VALIST)
283
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
284
int	_EXFUN(vdiprintf, (int, const char *, __VALIST)
285
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
286
int	_EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
287
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
288
int	_EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
289
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
290
int	_EXFUN(vfscanf, (FILE *, const char *, __VALIST)
291
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
292
int	_EXFUN(viprintf, (const char *, __VALIST)
293
               _ATTRIBUTE ((__format__ (__printf__, 1, 0))));
294
int	_EXFUN(viscanf, (const char *, __VALIST)
295
               _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
296
int	_EXFUN(vscanf, (const char *, __VALIST)
297
               _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
298
int	_EXFUN(vsiprintf, (char *, const char *, __VALIST)
299
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
300
int	_EXFUN(vsiscanf, (const char *, const char *, __VALIST)
301
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
302
int	_EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
303
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
304
int	_EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST)
305
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
306
int	_EXFUN(vsscanf, (const char *, const char *, __VALIST)
307
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
308
#endif /* !_REENT_ONLY */
309
#endif /* !__STRICT_ANSI__ */
310
 
311
/*
312
 * Routines in POSIX 1003.1:2001.
313
 */
314
 
315
#ifndef __STRICT_ANSI__
316
#ifndef _REENT_ONLY
317
FILE *	_EXFUN(fdopen, (int, const char *));
318
#endif
319
int	_EXFUN(fileno, (FILE *));
320
int	_EXFUN(getw, (FILE *));
321
int	_EXFUN(pclose, (FILE *));
322
FILE *  _EXFUN(popen, (const char *, const char *));
323
int	_EXFUN(putw, (int, FILE *));
324
void    _EXFUN(setbuffer, (FILE *, char *, int));
325
int	_EXFUN(setlinebuf, (FILE *));
326
int	_EXFUN(getc_unlocked, (FILE *));
327
int	_EXFUN(getchar_unlocked, (void));
328
void	_EXFUN(flockfile, (FILE *));
329
int	_EXFUN(ftrylockfile, (FILE *));
330
void	_EXFUN(funlockfile, (FILE *));
331
int	_EXFUN(putc_unlocked, (int, FILE *));
332
int	_EXFUN(putchar_unlocked, (int));
333
#endif /* ! __STRICT_ANSI__ */
334
 
335
/*
336
 * Routines in POSIX 1003.1:200x.
337
 */
338
 
339
#ifndef __STRICT_ANSI__
340
# ifndef _REENT_ONLY
341
#  ifndef dprintf
342
int	_EXFUN(dprintf, (int, const char *, ...)
343
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
344
#  endif
345
FILE *	_EXFUN(fmemopen, (void *, size_t, const char *));
346
/* getdelim - see __getdelim for now */
347
/* getline - see __getline for now */
348
FILE *	_EXFUN(open_memstream, (char **, size_t *));
349
#if defined (__CYGWIN__)
350
int	_EXFUN(renameat, (int, const char *, int, const char *));
351
#endif
352
int	_EXFUN(vdprintf, (int, const char *, __VALIST)
353
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
354
# endif
355
#endif
356
 
357
/*
358
 * Recursive versions of the above.
359
 */
360
 
361
int	_EXFUN(_asiprintf_r, (struct _reent *, char **, const char *, ...)
362
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
363
char *	_EXFUN(_asniprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
364
               _ATTRIBUTE ((__format__ (__printf__, 4, 5))));
365
char *	_EXFUN(_asnprintf_r, (struct _reent *, char *, size_t *, const char *, ...)
366
               _ATTRIBUTE ((__format__ (__printf__, 4, 5))));
367
int	_EXFUN(_asprintf_r, (struct _reent *, char **, const char *, ...)
368
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
369
int	_EXFUN(_diprintf_r, (struct _reent *, int, const char *, ...)
370
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
371
int	_EXFUN(_dprintf_r, (struct _reent *, int, const char *, ...)
372
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
373
int	_EXFUN(_fclose_r, (struct _reent *, FILE *));
374
int	_EXFUN(_fcloseall_r, (struct _reent *));
375
FILE *	_EXFUN(_fdopen_r, (struct _reent *, int, const char *));
376
int	_EXFUN(_fflush_r, (struct _reent *, FILE *));
377
int	_EXFUN(_fgetc_r, (struct _reent *, FILE *));
378
char *  _EXFUN(_fgets_r, (struct _reent *, char *, int, FILE *));
379
#ifdef _COMPILING_NEWLIB
380
int	_EXFUN(_fgetpos_r, (struct _reent *, FILE *, _fpos_t *));
381
int	_EXFUN(_fsetpos_r, (struct _reent *, FILE *, const _fpos_t *));
382
#else
383
int	_EXFUN(_fgetpos_r, (struct _reent *, FILE *, fpos_t *));
384
int	_EXFUN(_fsetpos_r, (struct _reent *, FILE *, const fpos_t *));
385
#endif
386
int	_EXFUN(_fiprintf_r, (struct _reent *, FILE *, const char *, ...)
387
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
388
int	_EXFUN(_fiscanf_r, (struct _reent *, FILE *, const char *, ...)
389
               _ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
390
FILE *	_EXFUN(_fmemopen_r, (struct _reent *, void *, size_t, const char *));
391
FILE *	_EXFUN(_fopen_r, (struct _reent *, const char *, const char *));
392
FILE *	_EXFUN(_freopen_r, (struct _reent *, const char *, const char *, FILE *));
393
int	_EXFUN(_fprintf_r, (struct _reent *, FILE *, const char *, ...)
394
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
395
int	_EXFUN(_fpurge_r, (struct _reent *, FILE *));
396
int	_EXFUN(_fputc_r, (struct _reent *, int, FILE *));
397
int	_EXFUN(_fputs_r, (struct _reent *, const char *, FILE *));
398
size_t	_EXFUN(_fread_r, (struct _reent *, _PTR, size_t _size, size_t _n, FILE *));
399
int	_EXFUN(_fscanf_r, (struct _reent *, FILE *, const char *, ...)
400
               _ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
401
int	_EXFUN(_fseek_r, (struct _reent *, FILE *, long, int));
402
int	_EXFUN(_fseeko_r,(struct _reent *, FILE *, _off_t, int));
403
long	_EXFUN(_ftell_r, (struct _reent *, FILE *));
404
_off_t	_EXFUN(_ftello_r,(struct _reent *, FILE *));
405
void	_EXFUN(_rewind_r, (struct _reent *, FILE *));
406
size_t	_EXFUN(_fwrite_r, (struct _reent *, const _PTR , size_t _size, size_t _n, FILE *));
407
int	_EXFUN(_getc_r, (struct _reent *, FILE *));
408
int	_EXFUN(_getc_unlocked_r, (struct _reent *, FILE *));
409
int	_EXFUN(_getchar_r, (struct _reent *));
410
int	_EXFUN(_getchar_unlocked_r, (struct _reent *));
411
char *	_EXFUN(_gets_r, (struct _reent *, char *));
412
int	_EXFUN(_iprintf_r, (struct _reent *, const char *, ...)
413
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
414
int	_EXFUN(_iscanf_r, (struct _reent *, const char *, ...)
415
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
416
FILE *	_EXFUN(_open_memstream_r, (struct _reent *, char **, size_t *));
417
void	_EXFUN(_perror_r, (struct _reent *, const char *));
418
int	_EXFUN(_printf_r, (struct _reent *, const char *, ...)
419
               _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
420
int	_EXFUN(_putc_r, (struct _reent *, int, FILE *));
421
int	_EXFUN(_putc_unlocked_r, (struct _reent *, int, FILE *));
422
int	_EXFUN(_putchar_unlocked_r, (struct _reent *, int));
423
int	_EXFUN(_putchar_r, (struct _reent *, int));
424
int	_EXFUN(_puts_r, (struct _reent *, const char *));
425
int	_EXFUN(_remove_r, (struct _reent *, const char *));
426
int	_EXFUN(_rename_r, (struct _reent *,
427
			   const char *_old, const char *_new));
428
int	_EXFUN(_scanf_r, (struct _reent *, const char *, ...)
429
               _ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
430
int	_EXFUN(_siprintf_r, (struct _reent *, char *, const char *, ...)
431
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
432
int	_EXFUN(_siscanf_r, (struct _reent *, const char *, const char *, ...)
433
               _ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
434
int	_EXFUN(_sniprintf_r, (struct _reent *, char *, size_t, const char *, ...)
435
               _ATTRIBUTE ((__format__ (__printf__, 4, 5))));
436
int	_EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...)
437
               _ATTRIBUTE ((__format__ (__printf__, 4, 5))));
438
int	_EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...)
439
               _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
440
int	_EXFUN(_sscanf_r, (struct _reent *, const char *, const char *, ...)
441
               _ATTRIBUTE ((__format__ (__scanf__, 3, 4))));
442
char *	_EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));
443
FILE *	_EXFUN(_tmpfile_r, (struct _reent *));
444
char *	_EXFUN(_tmpnam_r, (struct _reent *, char *));
445
int	_EXFUN(_ungetc_r, (struct _reent *, int, FILE *));
446
int	_EXFUN(_vasiprintf_r, (struct _reent *, char **, const char *, __VALIST)
447
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
448
char *	_EXFUN(_vasniprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST)
449
               _ATTRIBUTE ((__format__ (__printf__, 4, 0))));
450
char *	_EXFUN(_vasnprintf_r, (struct _reent*, char *, size_t *, const char *, __VALIST)
451
               _ATTRIBUTE ((__format__ (__printf__, 4, 0))));
452
int	_EXFUN(_vasprintf_r, (struct _reent *, char **, const char *, __VALIST)
453
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
454
int	_EXFUN(_vdiprintf_r, (struct _reent *, int, const char *, __VALIST)
455
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
456
int	_EXFUN(_vdprintf_r, (struct _reent *, int, const char *, __VALIST)
457
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
458
int	_EXFUN(_vfiprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
459
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
460
int	_EXFUN(_vfiscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
461
               _ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
462
int	_EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST)
463
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
464
int	_EXFUN(_vfscanf_r, (struct _reent *, FILE *, const char *, __VALIST)
465
               _ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
466
int	_EXFUN(_viprintf_r, (struct _reent *, const char *, __VALIST)
467
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
468
int	_EXFUN(_viscanf_r, (struct _reent *, const char *, __VALIST)
469
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
470
int	_EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST)
471
               _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
472
int	_EXFUN(_vscanf_r, (struct _reent *, const char *, __VALIST)
473
               _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
474
int	_EXFUN(_vsiprintf_r, (struct _reent *, char *, const char *, __VALIST)
475
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
476
int	_EXFUN(_vsiscanf_r, (struct _reent *, const char *, const char *, __VALIST)
477
               _ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
478
int	_EXFUN(_vsniprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
479
               _ATTRIBUTE ((__format__ (__printf__, 4, 0))));
480
int	_EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST)
481
               _ATTRIBUTE ((__format__ (__printf__, 4, 0))));
482
int	_EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST)
483
               _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
484
int	_EXFUN(_vsscanf_r, (struct _reent *, const char *, const char *, __VALIST)
485
               _ATTRIBUTE ((__format__ (__scanf__, 3, 0))));
486
 
487
/* Other extensions.  */
488
 
489
int	_EXFUN(fpurge, (FILE *));
490
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
491
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
492
 
493
#ifdef __LARGE64_FILES
494
#if !defined(__CYGWIN__) || defined(_COMPILING_NEWLIB)
495
FILE *	_EXFUN(fdopen64, (int, const char *));
496
FILE *  _EXFUN(fopen64, (const char *, const char *));
497
FILE *  _EXFUN(freopen64, (_CONST char *, _CONST char *, FILE *));
498
_off64_t _EXFUN(ftello64, (FILE *));
499
_off64_t _EXFUN(fseeko64, (FILE *, _off64_t, int));
500
int     _EXFUN(fgetpos64, (FILE *, _fpos64_t *));
501
int     _EXFUN(fsetpos64, (FILE *, const _fpos64_t *));
502
FILE *  _EXFUN(tmpfile64, (void));
503
 
504
FILE *	_EXFUN(_fdopen64_r, (struct _reent *, int, const char *));
505
FILE *  _EXFUN(_fopen64_r, (struct _reent *,const char *, const char *));
506
FILE *  _EXFUN(_freopen64_r, (struct _reent *, _CONST char *, _CONST char *, FILE *));
507
_off64_t _EXFUN(_ftello64_r, (struct _reent *, FILE *));
508
_off64_t _EXFUN(_fseeko64_r, (struct _reent *, FILE *, _off64_t, int));
509
int     _EXFUN(_fgetpos64_r, (struct _reent *, FILE *, _fpos64_t *));
510
int     _EXFUN(_fsetpos64_r, (struct _reent *, FILE *, const _fpos64_t *));
511
FILE *  _EXFUN(_tmpfile64_r, (struct _reent *));
512
#endif /* !__CYGWIN__ */
513
#endif /* __LARGE64_FILES */
514
 
515
/*
516
 * Routines internal to the implementation.
517
 */
518
 
519
int	_EXFUN(__srget_r, (struct _reent *, FILE *));
520
int	_EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
521
 
522
/*
523
 * Stdio function-access interface.
524
 */
525
 
526
#ifndef __STRICT_ANSI__
527
# ifdef __LARGE64_FILES
528
FILE	*_EXFUN(funopen,(const _PTR __cookie,
529
		int (*__readfn)(_PTR __c, char *__buf, int __n),
530
		int (*__writefn)(_PTR __c, const char *__buf, int __n),
531
		_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
532
		int (*__closefn)(_PTR __c)));
533
FILE	*_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
534
		int (*__readfn)(_PTR __c, char *__buf, int __n),
535
		int (*__writefn)(_PTR __c, const char *__buf, int __n),
536
		_fpos64_t (*__seekfn)(_PTR __c, _fpos64_t __off, int __whence),
537
		int (*__closefn)(_PTR __c)));
538
# else
539
FILE	*_EXFUN(funopen,(const _PTR __cookie,
540
		int (*__readfn)(_PTR __cookie, char *__buf, int __n),
541
		int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
542
		fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
543
		int (*__closefn)(_PTR __cookie)));
544
FILE	*_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
545
		int (*__readfn)(_PTR __cookie, char *__buf, int __n),
546
		int (*__writefn)(_PTR __cookie, const char *__buf, int __n),
547
		fpos_t (*__seekfn)(_PTR __cookie, fpos_t __off, int __whence),
548
		int (*__closefn)(_PTR __cookie)));
549
# endif /* !__LARGE64_FILES */
550
 
551
# define	fropen(__cookie, __fn) funopen(__cookie, __fn, (int (*)())0, \
552
					       (fpos_t (*)())0, (int (*)())0)
553
# define	fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
554
					       (fpos_t (*)())0, (int (*)())0)
555
 
556
typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n);
557
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf,
558
					size_t __n);
559
# ifdef __LARGE64_FILES
560
typedef int cookie_seek_function_t(void *__cookie, _off64_t *__off,
561
				   int __whence);
562
# else
563
typedef int cookie_seek_function_t(void *__cookie, off_t *__off, int __whence);
564
# endif /* !__LARGE64_FILES */
565
typedef int cookie_close_function_t(void *__cookie);
566
typedef struct
567
{
568
  /* These four struct member names are dictated by Linux; hopefully,
569
     they don't conflict with any macros.  */
570
  cookie_read_function_t  *read;
571
  cookie_write_function_t *write;
572
  cookie_seek_function_t  *seek;
573
  cookie_close_function_t *close;
574
} cookie_io_functions_t;
575
FILE *_EXFUN(fopencookie,(void *__cookie,
576
		const char *__mode, cookie_io_functions_t __functions));
577
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie,
578
		const char *__mode, cookie_io_functions_t __functions));
579
#endif /* ! __STRICT_ANSI__ */
580
 
581
#ifndef __CUSTOM_FILE_IO__
582
/*
3959 Serge 583
 * The __sfoo macros are here so that we can
1693 serge 584
 * define function versions in the C library.
585
 */
586
#define       __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
587
 
588
#ifdef __SCLE
589
/*  For a platform with CR/LF, additional logic is required by
590
  __sgetc_r which would otherwise simply be a macro; therefore we
591
  use an inlined function.  The function is only meant to be inlined
3959 Serge 592
  in place as used and the function body should never be emitted.
1693 serge 593
 
594
  There are two possible means to this end when compiling with GCC,
595
  one when compiling with a standard C99 compiler, and for other
596
  compilers we're just stuck.  At the moment, this issue only
597
  affects the Cygwin target, so we'll most likely be using GCC. */
598
 
599
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p);
600
 
601
_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p)
602
  {
603
    int __c = __sgetc_raw_r(__ptr, __p);
604
    if ((__p->_flags & __SCLE) && (__c == '\r'))
605
      {
606
      int __c2 = __sgetc_raw_r(__ptr, __p);
607
      if (__c2 == '\n')
608
        __c = __c2;
609
      else
610
        ungetc(__c2, __p);
611
      }
612
    return __c;
613
  }
614
#else
615
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
616
#endif
617
 
618
#ifdef _never /* __GNUC__ */
619
/* If this inline is actually used, then systems using coff debugging
620
   info get hopelessly confused.  21sept93 rich@cygnus.com.  */
621
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
622
	if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
623
		return (*_p->_p++ = _c);
624
	else
625
		return (__swbuf_r(_ptr, _c, _p));
626
}
627
#else
628
/*
629
 * This has been tuned to generate reasonable code on the vax using pcc
630
 */
631
#define       __sputc_raw_r(__ptr, __c, __p) \
632
	(--(__p)->_w < 0 ? \
633
		(__p)->_w >= (__p)->_lbfsize ? \
634
			(*(__p)->_p = (__c)), *(__p)->_p != '\n' ? \
635
				(int)*(__p)->_p++ : \
636
				__swbuf_r(__ptr, '\n', __p) : \
637
			__swbuf_r(__ptr, (int)(__c), __p) : \
638
		(*(__p)->_p = (__c), (int)*(__p)->_p++))
639
#ifdef __SCLE
640
#define __sputc_r(__ptr, __c, __p) \
641
        ((((__p)->_flags & __SCLE) && ((__c) == '\n')) \
642
          ? __sputc_raw_r(__ptr, '\r', (__p)) : 0 , \
643
        __sputc_raw_r((__ptr), (__c), (__p)))
644
#else
645
#define __sputc_r(__ptr, __c, __p) __sputc_raw_r(__ptr, __c, __p)
646
#endif
647
#endif
648
 
649
#define	__sfeof(p)	(((p)->_flags & __SEOF) != 0)
650
#define	__sferror(p)	(((p)->_flags & __SERR) != 0)
651
#define	__sclearerr(p)	((void)((p)->_flags &= ~(__SERR|__SEOF)))
652
#define	__sfileno(p)	((p)->_file)
653
 
654
#ifndef _REENT_SMALL
655
#define	feof(p)		__sfeof(p)
656
#define	ferror(p)	__sferror(p)
657
#define	clearerr(p)	__sclearerr(p)
658
#endif
659
 
660
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
661
#define	fileno(p)	__sfileno(p)
662
#endif
663
 
664
#ifndef __CYGWIN__
665
#ifndef lint
666
#define	getc(fp)	__sgetc_r(_REENT, fp)
667
#define putc(x, fp)	__sputc_r(_REENT, x, fp)
668
#endif /* lint */
669
#endif /* __CYGWIN__ */
670
 
671
#ifndef __STRICT_ANSI__
672
/* fast always-buffered version, true iff error */
673
#define	fast_putc(x,p) (--(p)->_w < 0 ? \
674
	__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
675
 
676
#define	L_cuserid	9		/* posix says it goes in stdio.h :( */
677
#ifdef __CYGWIN__
678
#define L_ctermid       16
679
#endif
680
#endif
681
 
682
#endif /* !__CUSTOM_FILE_IO__ */
683
 
684
#define	getchar()	getc(stdin)
685
#define	putchar(x)	putc(x, stdout)
686
 
687
_END_STD_C
688
 
689
#endif /* _STDIO_H_ */