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