| 1 | /* stdio.h,v 1.13 2004/09/14 22:27:36 bird Exp */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * FreeBSD 5.1
|
|---|
| 4 | * @changed bird: EMX isms + LIBC implementation specifics.
|
|---|
| 5 | * @changed bird: Made quite a few @todos on function which aren't implemented.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*-
|
|---|
| 9 | * Copyright (c) 1990, 1993
|
|---|
| 10 | * The Regents of the University of California. All rights reserved.
|
|---|
| 11 | *
|
|---|
| 12 | * This code is derived from software contributed to Berkeley by
|
|---|
| 13 | * Chris Torek.
|
|---|
| 14 | *
|
|---|
| 15 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 16 | * modification, are permitted provided that the following conditions
|
|---|
| 17 | * are met:
|
|---|
| 18 | * 1. Redistributions of source code must retain the above copyright
|
|---|
| 19 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 20 | * 2. Redistributions in binary form must reproduce the above copyright
|
|---|
| 21 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 22 | * documentation and/or other materials provided with the distribution.
|
|---|
| 23 | * 3. All advertising materials mentioning features or use of this software
|
|---|
| 24 | * must display the following acknowledgement:
|
|---|
| 25 | * This product includes software developed by the University of
|
|---|
| 26 | * California, Berkeley and its contributors.
|
|---|
| 27 | * 4. Neither the name of the University nor the names of its contributors
|
|---|
| 28 | * may be used to endorse or promote products derived from this software
|
|---|
| 29 | * without specific prior written permission.
|
|---|
| 30 | *
|
|---|
| 31 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|---|
| 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|---|
| 33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|---|
| 34 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|---|
| 35 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|---|
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|---|
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|---|
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 39 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|---|
| 40 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|---|
| 41 | * SUCH DAMAGE.
|
|---|
| 42 | *
|
|---|
| 43 | * @(#)stdio.h 8.5 (Berkeley) 4/29/95
|
|---|
| 44 | * $FreeBSD: src/include/stdio.h,v 1.51 2003/01/13 08:41:47 tjr Exp $
|
|---|
| 45 | */
|
|---|
| 46 |
|
|---|
| 47 | #ifndef _STDIO_H_
|
|---|
| 48 | #define _STDIO_H_
|
|---|
| 49 |
|
|---|
| 50 | #include <sys/cdefs.h>
|
|---|
| 51 | #include <sys/_types.h>
|
|---|
| 52 |
|
|---|
| 53 | typedef __off_t fpos_t;
|
|---|
| 54 |
|
|---|
| 55 | #if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */
|
|---|
| 56 | typedef __size_t size_t;
|
|---|
| 57 | #define _SIZE_T_DECLARED
|
|---|
| 58 | #define _SIZE_T /* bird: emx */
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
|
|---|
| 62 | #if !defined(_VA_LIST_DECLARED) && !defined(_VA_LIST) /* bird: emx */
|
|---|
| 63 | typedef __va_list va_list;
|
|---|
| 64 | #define _VA_LIST_DECLARED
|
|---|
| 65 | #define _VA_LIST /* bird: emx */
|
|---|
| 66 | #endif
|
|---|
| 67 | #endif
|
|---|
| 68 |
|
|---|
| 69 | #ifndef NULL
|
|---|
| 70 | #define NULL 0
|
|---|
| 71 | #endif
|
|---|
| 72 |
|
|---|
| 73 | #if 0 /* bird: emx */
|
|---|
| 74 |
|
|---|
| 75 | #define _FSTDIO /* Define for new stdio with functions. */
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | /*
|
|---|
| 79 | * NB: to fit things in six character monocase externals, the stdio
|
|---|
| 80 | * code uses the prefix `__s' for stdio objects, typically followed
|
|---|
| 81 | * by a three-character attempt at a mnemonic.
|
|---|
| 82 | */
|
|---|
| 83 |
|
|---|
| 84 | /* stdio buffers */
|
|---|
| 85 | struct __sbuf {
|
|---|
| 86 | unsigned char *_base;
|
|---|
| 87 | int _size;
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | /* hold a buncha junk that would grow the ABI */
|
|---|
| 91 | struct __sFILEX;
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | * stdio state variables.
|
|---|
| 95 | *
|
|---|
| 96 | * The following always hold:
|
|---|
| 97 | *
|
|---|
| 98 | * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
|
|---|
| 99 | * _lbfsize is -_bf._size, else _lbfsize is 0
|
|---|
| 100 | * if _flags&__SRD, _w is 0
|
|---|
| 101 | * if _flags&__SWR, _r is 0
|
|---|
| 102 | *
|
|---|
| 103 | * This ensures that the getc and putc macros (or inline functions) never
|
|---|
| 104 | * try to write or read from a file that is in `read' or `write' mode.
|
|---|
| 105 | * (Moreover, they can, and do, automatically switch from read mode to
|
|---|
| 106 | * write mode, and back, on "r+" and "w+" files.)
|
|---|
| 107 | *
|
|---|
| 108 | * _lbfsize is used only to make the inline line-buffered output stream
|
|---|
| 109 | * code as compact as possible.
|
|---|
| 110 | *
|
|---|
| 111 | * _ub, _up, and _ur are used when ungetc() pushes back more characters
|
|---|
| 112 | * than fit in the current _bf, or when ungetc() pushes back a character
|
|---|
| 113 | * that does not match the previous one in _bf. When this happens,
|
|---|
| 114 | * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
|
|---|
| 115 | * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
|
|---|
| 116 | *
|
|---|
| 117 | * NB: see WARNING above before changing the layout of this structure!
|
|---|
| 118 | */
|
|---|
| 119 | typedef struct __sFILE {
|
|---|
| 120 | unsigned char *_p; /* current position in (some) buffer */
|
|---|
| 121 | int _r; /* read space left for getc() */
|
|---|
| 122 | int _w; /* write space left for putc() */
|
|---|
| 123 | short _flags; /* flags, below; this FILE is free if 0 */
|
|---|
| 124 | short _file; /* fileno, if Unix descriptor, else -1 */
|
|---|
| 125 | struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
|
|---|
| 126 | int _lbfsize; /* 0 or -_bf._size, for inline putc */
|
|---|
| 127 |
|
|---|
| 128 | /* operations */
|
|---|
| 129 | void *_cookie; /* cookie passed to io functions */
|
|---|
| 130 | int (*_close)(void *);
|
|---|
| 131 | int (*_read)(void *, char *, int);
|
|---|
| 132 | fpos_t (*_seek)(void *, fpos_t, int);
|
|---|
| 133 | int (*_write)(void *, const char *, int);
|
|---|
| 134 |
|
|---|
| 135 | /* separate buffer for long sequences of ungetc() */
|
|---|
| 136 | struct __sbuf _ub; /* ungetc buffer */
|
|---|
| 137 | struct __sFILEX *_extra; /* additions to FILE to not break ABI */
|
|---|
| 138 | int _ur; /* saved _r when _r is counting ungetc data */
|
|---|
| 139 |
|
|---|
| 140 | /* tricks to meet minimum requirements even when malloc() fails */
|
|---|
| 141 | unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
|
|---|
| 142 | unsigned char _nbuf[1]; /* guarantee a getc() buffer */
|
|---|
| 143 |
|
|---|
| 144 | /* separate buffer for fgetln() when line crosses buffer boundary */
|
|---|
| 145 | struct __sbuf _lb; /* buffer for fgetln() */
|
|---|
| 146 |
|
|---|
| 147 | /* Unix stdio files get aligned to block boundaries on fseek() */
|
|---|
| 148 | int _blksize; /* stat.st_blksize (may be != _bf._size) */
|
|---|
| 149 | fpos_t _offset; /* current lseek offset (see WARNING) */
|
|---|
| 150 | } FILE;
|
|---|
| 151 |
|
|---|
| 152 | __BEGIN_DECLS
|
|---|
| 153 | extern FILE *__stdinp;
|
|---|
| 154 | extern FILE *__stdoutp;
|
|---|
| 155 | extern FILE *__stderrp;
|
|---|
| 156 | __END_DECLS
|
|---|
| 157 |
|
|---|
| 158 | #define __SLBF 0x0001 /* line buffered */
|
|---|
| 159 | #define __SNBF 0x0002 /* unbuffered */
|
|---|
| 160 | #define __SRD 0x0004 /* OK to read */
|
|---|
| 161 | #define __SWR 0x0008 /* OK to write */
|
|---|
| 162 | /* RD and WR are never simultaneously asserted */
|
|---|
| 163 | #define __SRW 0x0010 /* open for reading & writing */
|
|---|
| 164 | #define __SEOF 0x0020 /* found EOF */
|
|---|
| 165 | #define __SERR 0x0040 /* found error */
|
|---|
| 166 | #define __SMBF 0x0080 /* _buf is from malloc */
|
|---|
| 167 | #define __SAPP 0x0100 /* fdopen()ed in append mode */
|
|---|
| 168 | #define __SSTR 0x0200 /* this is an sprintf/snprintf string */
|
|---|
| 169 | #define __SOPT 0x0400 /* do fseek() optimization */
|
|---|
| 170 | #define __SNPT 0x0800 /* do not do fseek() optimization */
|
|---|
| 171 | #define __SOFF 0x1000 /* set iff _offset is in fact correct */
|
|---|
| 172 | #define __SMOD 0x2000 /* true => fgetln modified _p text */
|
|---|
| 173 | #define __SALC 0x4000 /* allocate string space dynamically */
|
|---|
| 174 | #define __SIGN 0x8000 /* ignore this file in _fwalk */
|
|---|
| 175 |
|
|---|
| 176 | #else /* bird: EMX specific FILE stuff starts. */
|
|---|
| 177 |
|
|---|
| 178 | #define _FILE_T
|
|---|
| 179 | #define _FILE_MEMBERS_HAVE_UNDERSCORE
|
|---|
| 180 | #define _FILE_STDIO_VERSION (0x06000000 | sizeof(struct __sFILE))
|
|---|
| 181 | typedef struct __sFILE
|
|---|
| 182 | {
|
|---|
| 183 | unsigned __uVersion;
|
|---|
| 184 | char * _ptr;
|
|---|
| 185 | char * _buffer;
|
|---|
| 186 | int _rcount;
|
|---|
| 187 | int _wcount;
|
|---|
| 188 | int _handle;
|
|---|
| 189 | int _flags;
|
|---|
| 190 | int _buf_size;
|
|---|
| 191 | int _tmpidx;
|
|---|
| 192 | int _pid;
|
|---|
| 193 | char _char_buf;
|
|---|
| 194 | unsigned char _ungetc_count;
|
|---|
| 195 | short _mbstate;
|
|---|
| 196 | int (*_flush)(struct __sFILE *, int);
|
|---|
| 197 |
|
|---|
| 198 | /** The Mutex Semaphore. */
|
|---|
| 199 | union
|
|---|
| 200 | {
|
|---|
| 201 | #if defined (_SYS_FMUTEX_H)
|
|---|
| 202 | #define __FILE_FSEM_DECLARED
|
|---|
| 203 | /** @todo replace this by a nested lock construct, see flockfile(). */
|
|---|
| 204 | _fmutex __fsem;
|
|---|
| 205 | #endif
|
|---|
| 206 | char __rsem_ersatz[12];
|
|---|
| 207 | } __u;
|
|---|
| 208 | /** Pointer to the stream vector which this FILE belongs to.
|
|---|
| 209 | * This member is the first which should not be zeroed by _newstream()! */
|
|---|
| 210 | void *__pSV;
|
|---|
| 211 | } FILE;
|
|---|
| 212 |
|
|---|
| 213 | __BEGIN_DECLS
|
|---|
| 214 | extern FILE *__stdinp;
|
|---|
| 215 | extern FILE *__stdoutp;
|
|---|
| 216 | extern FILE *__stderrp;
|
|---|
| 217 | __END_DECLS
|
|---|
| 218 |
|
|---|
| 219 | #endif /* bird: EMX specific FILE stuff ends. */
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | /*
|
|---|
| 223 | * The following three definitions are for ANSI C, which took them
|
|---|
| 224 | * from System V, which brilliantly took internal interface macros and
|
|---|
| 225 | * made them official arguments to setvbuf(), without renaming them.
|
|---|
| 226 | * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
|
|---|
| 227 | *
|
|---|
| 228 | * Although numbered as their counterparts above, the implementation
|
|---|
| 229 | * does not rely on this.
|
|---|
| 230 | */
|
|---|
| 231 | #define _IOFBF 0 /* setvbuf should set fully buffered */
|
|---|
| 232 | #define _IOLBF 0x20 /* bird: emx, was 1 */ /* setvbuf should set line buffered */
|
|---|
| 233 | #define _IONBF 0x40 /* bird: emx, was 2 */ /* setvbuf should set unbuffered */
|
|---|
| 234 |
|
|---|
| 235 | #define BUFSIZ 8192 /* bird: emx, was 1024 */ /* size of buffer used by setbuf */
|
|---|
| 236 | #define EOF (-1)
|
|---|
| 237 |
|
|---|
| 238 | /*
|
|---|
| 239 | * FOPEN_MAX is a minimum maximum, and is the number of streams that
|
|---|
| 240 | * stdio can provide without attempting to allocate further resources
|
|---|
| 241 | * (which could fail). Do not use this for anything.
|
|---|
| 242 | */
|
|---|
| 243 | /* must be == _POSIX_STREAM_MAX <limits.h> */
|
|---|
| 244 | #define FOPEN_MAX 14 /* bird: emx, was 20 */ /* must be <= OPEN_MAX <sys/syslimits.h> */
|
|---|
| 245 | #define FILENAME_MAX 260 /* bird: emx, was 1024 */ /* must be <= PATH_MAX <sys/syslimits.h> */
|
|---|
| 246 |
|
|---|
| 247 | /* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
|
|---|
| 248 | #if __XSI_VISIBLE
|
|---|
| 249 | #define P_tmpdir "." /* bird: emx, was "/var/tmp/" */
|
|---|
| 250 | #endif
|
|---|
| 251 | #define L_tmpnam 260 /* bird: emx, was 1024 */ /* XXX must be == PATH_MAX */
|
|---|
| 252 | #define TMP_MAX 1000 /* bird: emx, was 308915776 */
|
|---|
| 253 |
|
|---|
| 254 | #ifndef SEEK_SET
|
|---|
| 255 | #define SEEK_SET 0 /* set file offset to offset */
|
|---|
| 256 | #endif
|
|---|
| 257 | #ifndef SEEK_CUR
|
|---|
| 258 | #define SEEK_CUR 1 /* set file offset to current plus offset */
|
|---|
| 259 | #endif
|
|---|
| 260 | #ifndef SEEK_END
|
|---|
| 261 | #define SEEK_END 2 /* set file offset to EOF plus offset */
|
|---|
| 262 | #endif
|
|---|
| 263 |
|
|---|
| 264 | #define stdin __stdinp
|
|---|
| 265 | #define stdout __stdoutp
|
|---|
| 266 | #define stderr __stderrp
|
|---|
| 267 |
|
|---|
| 268 | __BEGIN_DECLS
|
|---|
| 269 | /*
|
|---|
| 270 | * Functions defined in ANSI C standard.
|
|---|
| 271 | */
|
|---|
| 272 | void clearerr(FILE *);
|
|---|
| 273 | int fclose(FILE *);
|
|---|
| 274 | int feof(FILE *);
|
|---|
| 275 | int ferror(FILE *);
|
|---|
| 276 | int fflush(FILE *);
|
|---|
| 277 | int fgetc(FILE *);
|
|---|
| 278 | int fgetpos(FILE * __restrict, fpos_t * __restrict);
|
|---|
| 279 | char *fgets(char * __restrict, int, FILE * __restrict);
|
|---|
| 280 | FILE *fopen(const char * __restrict, const char * __restrict);
|
|---|
| 281 | int fprintf(FILE * __restrict, const char * __restrict, ...);
|
|---|
| 282 | int fputc(int, FILE *);
|
|---|
| 283 | int fputs(const char * __restrict, FILE * __restrict);
|
|---|
| 284 | size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
|
|---|
| 285 | FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
|
|---|
| 286 | int fscanf(FILE * __restrict, const char * __restrict, ...);
|
|---|
| 287 | int fseek(FILE *, long, int);
|
|---|
| 288 | int fsetpos(FILE *, const fpos_t *);
|
|---|
| 289 | long ftell(FILE *);
|
|---|
| 290 | size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
|
|---|
| 291 | int getc(FILE *);
|
|---|
| 292 | int getchar(void);
|
|---|
| 293 | char *gets(char *);
|
|---|
| 294 | void perror(const char *);
|
|---|
| 295 | int printf(const char * __restrict, ...);
|
|---|
| 296 | int putc(int, FILE *);
|
|---|
| 297 | int putchar(int);
|
|---|
| 298 | int puts(const char *);
|
|---|
| 299 | int remove(const char *);
|
|---|
| 300 | int rename(const char *, const char *);
|
|---|
| 301 | void rewind(FILE *);
|
|---|
| 302 | int scanf(const char * __restrict, ...);
|
|---|
| 303 | void setbuf(FILE * __restrict, char * __restrict);
|
|---|
| 304 | int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
|
|---|
| 305 | int sprintf(char * __restrict, const char * __restrict, ...);
|
|---|
| 306 | int sscanf(const char * __restrict, const char * __restrict, ...);
|
|---|
| 307 | FILE *tmpfile(void);
|
|---|
| 308 | char *tmpnam(char *);
|
|---|
| 309 | int ungetc(int, FILE *);
|
|---|
| 310 | int vfprintf(FILE * __restrict, const char * __restrict,
|
|---|
| 311 | __va_list);
|
|---|
| 312 | int vprintf(const char * __restrict, __va_list);
|
|---|
| 313 | int vsprintf(char * __restrict, const char * __restrict,
|
|---|
| 314 | __va_list);
|
|---|
| 315 |
|
|---|
| 316 | #if __ISO_C_VISIBLE >= 1999
|
|---|
| 317 | int snprintf(char * __restrict, size_t, const char * __restrict,
|
|---|
| 318 | ...) __printflike(3, 4);
|
|---|
| 319 | int vfscanf(FILE * __restrict, const char * __restrict, __va_list)
|
|---|
| 320 | __scanflike(2, 0);
|
|---|
| 321 | int vscanf(const char * __restrict, __va_list) __scanflike(1, 0);
|
|---|
| 322 | int vsnprintf(char * __restrict, size_t, const char * __restrict,
|
|---|
| 323 | __va_list) __printflike(3, 0);
|
|---|
| 324 | int vsscanf(const char * __restrict, const char * __restrict, __va_list)
|
|---|
| 325 | __scanflike(2, 0);
|
|---|
| 326 | #endif
|
|---|
| 327 |
|
|---|
| 328 | /*
|
|---|
| 329 | * Functions defined in all versions of POSIX 1003.1.
|
|---|
| 330 | */
|
|---|
| 331 | #if __BSD_VISIBLE || __POSIX_VISIBLE <= 199506
|
|---|
| 332 | /* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */
|
|---|
| 333 | #define L_cuserid 9 /* bird: emx, was 17 */ /* legacy */
|
|---|
| 334 | #endif
|
|---|
| 335 |
|
|---|
| 336 | #if __POSIX_VISIBLE
|
|---|
| 337 | #define L_ctermid 260 /* bird: emx, was 1024 */ /* size for ctermid(3); PATH_MAX */
|
|---|
| 338 |
|
|---|
| 339 | /** @todo char *ctermid(char *); */
|
|---|
| 340 | FILE *fdopen(int, const char *);
|
|---|
| 341 | int fileno(FILE *);
|
|---|
| 342 | #endif /* __POSIX_VISIBLE */
|
|---|
| 343 |
|
|---|
| 344 | #if __POSIX_VISIBLE >= 199209
|
|---|
| 345 | int pclose(FILE *);
|
|---|
| 346 | FILE *popen(const char *, const char *);
|
|---|
| 347 | #endif
|
|---|
| 348 |
|
|---|
| 349 | #if __POSIX_VISIBLE >= 199506
|
|---|
| 350 | int ftrylockfile(FILE *);
|
|---|
| 351 | void flockfile(FILE *);
|
|---|
| 352 | void funlockfile(FILE *);
|
|---|
| 353 |
|
|---|
| 354 | /*
|
|---|
| 355 | * These are normally used through macros as defined below, but POSIX
|
|---|
| 356 | * requires functions as well.
|
|---|
| 357 | */
|
|---|
| 358 | int getc_unlocked(FILE *);
|
|---|
| 359 | int getchar_unlocked(void);
|
|---|
| 360 | int putc_unlocked(int, FILE *);
|
|---|
| 361 | int putchar_unlocked(int);
|
|---|
| 362 | #endif
|
|---|
| 363 | #if __BSD_VISIBLE
|
|---|
| 364 | void clearerr_unlocked(FILE *);
|
|---|
| 365 | int feof_unlocked(FILE *);
|
|---|
| 366 | int ferror_unlocked(FILE *);
|
|---|
| 367 | int fileno_unlocked(FILE *);
|
|---|
| 368 | #endif
|
|---|
| 369 | #ifdef __USE_MISC
|
|---|
| 370 | int fflush_unlocked(FILE *);
|
|---|
| 371 | size_t fwrite_unlocked(const void * __restrict, size_t, size_t, FILE * __restrict);
|
|---|
| 372 | size_t fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict);
|
|---|
| 373 | int fgetc_unlocked(FILE *);
|
|---|
| 374 | int fputc_unlocked(int, FILE *);
|
|---|
| 375 | int fputs_unlocked(const char * __restrict, FILE * __restrict);
|
|---|
| 376 | char *fgets_unlocked(char * __restrict, int, FILE * __restrict);
|
|---|
| 377 | int puts_unlocked(const char *);
|
|---|
| 378 | char *gets_unlocked(char *);
|
|---|
| 379 | #endif
|
|---|
| 380 |
|
|---|
| 381 | #if __POSIX_VISIBLE >= 200112
|
|---|
| 382 | int fseeko(FILE *, __off_t, int);
|
|---|
| 383 | __off_t ftello(FILE *);
|
|---|
| 384 | #endif
|
|---|
| 385 |
|
|---|
| 386 | #if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600
|
|---|
| 387 | int getw(FILE *);
|
|---|
| 388 | int putw(int, FILE *);
|
|---|
| 389 | #endif /* BSD or X/Open before issue 6 */
|
|---|
| 390 |
|
|---|
| 391 | #if __XSI_VISIBLE
|
|---|
| 392 | char *tempnam(const char *, const char *);
|
|---|
| 393 | #endif
|
|---|
| 394 |
|
|---|
| 395 | /*
|
|---|
| 396 | * Routines that are purely local.
|
|---|
| 397 | */
|
|---|
| 398 | #if __BSD_VISIBLE
|
|---|
| 399 | int asprintf(char **, const char *, ...) __printflike(2, 3);
|
|---|
| 400 | /** @todo char *ctermid_r(char *); */
|
|---|
| 401 | /** @todo char *fgetln(FILE *, size_t *); */
|
|---|
| 402 | #if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3
|
|---|
| 403 | #define __ATTR_FORMAT_ARG __attribute__((__format_arg__(2)))
|
|---|
| 404 | #else
|
|---|
| 405 | #define __ATTR_FORMAT_ARG
|
|---|
| 406 | #endif
|
|---|
| 407 | /** @todo __const char *fmtcheck(const char *, const char *) __ATTR_FORMAT_ARG; */
|
|---|
| 408 | /** @todo int fpurge(FILE *); */
|
|---|
| 409 | void setbuffer(FILE *, char *, int);
|
|---|
| 410 | int setlinebuf(FILE *);
|
|---|
| 411 | int vasprintf(char **, const char *, __va_list)
|
|---|
| 412 | __printflike(2, 0);
|
|---|
| 413 |
|
|---|
| 414 | /*
|
|---|
| 415 | * The system error table contains messages for the first sys_nerr
|
|---|
| 416 | * positive errno values. Use strerror() or strerror_r() from <string.h>
|
|---|
| 417 | * instead.
|
|---|
| 418 | */
|
|---|
| 419 | extern __const int sys_nerr;
|
|---|
| 420 | extern __const char *__const sys_errlist[];
|
|---|
| 421 |
|
|---|
| 422 | /*
|
|---|
| 423 | * Stdio function-access interface.
|
|---|
| 424 | */
|
|---|
| 425 | /** @todo FILE *funopen(const void *,
|
|---|
| 426 | int (*)(void *, char *, int),
|
|---|
| 427 | int (*)(void *, const char *, int),
|
|---|
| 428 | fpos_t (*)(void *, fpos_t, int),
|
|---|
| 429 | int (*)(void *)); */
|
|---|
| 430 | /** @todo #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) */
|
|---|
| 431 | /** @todo #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) */
|
|---|
| 432 |
|
|---|
| 433 | /*
|
|---|
| 434 | * Portability hacks. See <sys/types.h>.
|
|---|
| 435 | */
|
|---|
| 436 | #ifndef _FTRUNCATE_DECLARED
|
|---|
| 437 | #define _FTRUNCATE_DECLARED
|
|---|
| 438 | int ftruncate(int, __off_t);
|
|---|
| 439 | #endif
|
|---|
| 440 | #ifndef _LSEEK_DECLARED
|
|---|
| 441 | #define _LSEEK_DECLARED
|
|---|
| 442 | __off_t lseek(int, __off_t, int);
|
|---|
| 443 | #endif
|
|---|
| 444 | #ifndef _MMAP_DECLARED
|
|---|
| 445 | #define _MMAP_DECLARED
|
|---|
| 446 | void *mmap(void *, size_t, int, int, int, __off_t);
|
|---|
| 447 | #endif
|
|---|
| 448 | #ifndef _TRUNCATE_DECLARED
|
|---|
| 449 | #define _TRUNCATE_DECLARED
|
|---|
| 450 | int truncate(const char *, __off_t);
|
|---|
| 451 | #endif
|
|---|
| 452 | #endif /* __BSD_VISIBLE */
|
|---|
| 453 |
|
|---|
| 454 | #if 0 /* bird: Skip FreeBSD sepcific LIBC stuff. */
|
|---|
| 455 | /*
|
|---|
| 456 | * Functions internal to the implementation.
|
|---|
| 457 | */
|
|---|
| 458 | int __srget(FILE *);
|
|---|
| 459 | int __swbuf(int, FILE *);
|
|---|
| 460 |
|
|---|
| 461 | /*
|
|---|
| 462 | * The __sfoo macros are here so that we can
|
|---|
| 463 | * define function versions in the C library.
|
|---|
| 464 | */
|
|---|
| 465 | #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
|
|---|
| 466 | #if defined(__GNUC__) && defined(__STDC__)
|
|---|
| 467 | static __inline int __sputc(int _c, FILE *_p) {
|
|---|
| 468 | if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
|
|---|
| 469 | return (*_p->_p++ = _c);
|
|---|
| 470 | else
|
|---|
| 471 | return (__swbuf(_c, _p));
|
|---|
| 472 | }
|
|---|
| 473 | #else
|
|---|
| 474 | /*
|
|---|
| 475 | * This has been tuned to generate reasonable code on the vax using pcc.
|
|---|
| 476 | */
|
|---|
| 477 | #define __sputc(c, p) \
|
|---|
| 478 | (--(p)->_w < 0 ? \
|
|---|
| 479 | (p)->_w >= (p)->_lbfsize ? \
|
|---|
| 480 | (*(p)->_p = (c)), *(p)->_p != '\n' ? \
|
|---|
| 481 | (int)*(p)->_p++ : \
|
|---|
| 482 | __swbuf('\n', p) : \
|
|---|
| 483 | __swbuf((int)(c), p) : \
|
|---|
| 484 | (*(p)->_p = (c), (int)*(p)->_p++))
|
|---|
| 485 | #endif
|
|---|
| 486 |
|
|---|
| 487 | #define __sfeof(p) (((p)->_flags & __SEOF) != 0)
|
|---|
| 488 | #define __sferror(p) (((p)->_flags & __SERR) != 0)
|
|---|
| 489 | #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
|
|---|
| 490 | #define __sfileno(p) ((p)->_file)
|
|---|
| 491 |
|
|---|
| 492 | #if __BSD_VISIBLE
|
|---|
| 493 | /*
|
|---|
| 494 | * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
|
|---|
| 495 | * B.8.2.7 for the rationale behind the *_unlocked() macros.
|
|---|
| 496 | */
|
|---|
| 497 | #define feof_unlocked(p) __sfeof(p)
|
|---|
| 498 | #define ferror_unlocked(p) __sferror(p)
|
|---|
| 499 | #define clearerr_unlocked(p) __sclearerr(p)
|
|---|
| 500 | #define fileno_unlocked(p) __sfileno(p)
|
|---|
| 501 | #endif
|
|---|
| 502 | #if __POSIX_VISIBLE >= 199506
|
|---|
| 503 | #define getc_unlocked(fp) __sgetc(fp)
|
|---|
| 504 | #define putc_unlocked(x, fp) __sputc(x, fp)
|
|---|
| 505 |
|
|---|
| 506 | #define getchar_unlocked() getc_unlocked(stdin)
|
|---|
| 507 | #define putchar_unlocked(x) putc_unlocked(x, stdout)
|
|---|
| 508 | #endif
|
|---|
| 509 |
|
|---|
| 510 | #endif /* bird: Skip FreeBSD specific LIBC stuff. */
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 | /* bird: start of EMX isms. */
|
|---|
| 514 |
|
|---|
| 515 | #if !defined (_IOREAD)
|
|---|
| 516 | /** @todo change to double underscore prefix to prevent confusion with
|
|---|
| 517 | * setvbuf() constants. See the short rant about it above. */
|
|---|
| 518 | #define _IOREAD 0x01
|
|---|
| 519 | #define _IOWRT 0x02
|
|---|
| 520 | #define _IORW 0x04
|
|---|
| 521 | #define _IOEOF 0x08
|
|---|
| 522 | #define _IOERR 0x10
|
|---|
| 523 | #endif
|
|---|
| 524 |
|
|---|
| 525 | int _fill (FILE *);
|
|---|
| 526 | int _flush (int, FILE *);
|
|---|
| 527 | int _rmtmp (void);
|
|---|
| 528 |
|
|---|
| 529 | extern __inline__ int feof (FILE *_s)
|
|---|
| 530 | {
|
|---|
| 531 | return (_s->_flags & _IOEOF ? 1 : 0);
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | extern __inline__ int ferror (FILE *_s)
|
|---|
| 535 | {
|
|---|
| 536 | return (_s->_flags & _IOERR ? 1 : 0);
|
|---|
| 537 | }
|
|---|
| 538 |
|
|---|
| 539 | extern __inline__ int getchar (void) { return getc (stdin); }
|
|---|
| 540 | extern __inline__ int putchar (int _c) { return putc (_c, stdout); }
|
|---|
| 541 |
|
|---|
| 542 | #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
|
|---|
| 543 |
|
|---|
| 544 | char *cuserid (char *);
|
|---|
| 545 | int fcloseall (void);
|
|---|
| 546 | int fgetchar (void);
|
|---|
| 547 | int flushall (void);
|
|---|
| 548 | int fputchar (int);
|
|---|
| 549 |
|
|---|
| 550 | #endif
|
|---|
| 551 |
|
|---|
| 552 |
|
|---|
| 553 | #if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
|
|---|
| 554 |
|
|---|
| 555 | int _fcloseall (void);
|
|---|
| 556 | FILE *_fdopen (int, __const__ char *);
|
|---|
| 557 | int _fgetchar (void);
|
|---|
| 558 | int _flushall (void);
|
|---|
| 559 | int _fputchar (int);
|
|---|
| 560 | int _fseek_hdr (FILE *);
|
|---|
| 561 | int _fsetmode (FILE *, __const__ char *);
|
|---|
| 562 | FILE *_fsopen (__const__ char *, __const__ char *, int);
|
|---|
| 563 | int _getw (FILE *);
|
|---|
| 564 | char *_mfclose (FILE *);
|
|---|
| 565 | FILE *_mfopen (char *, __const__ char *, size_t, int);
|
|---|
| 566 | int _pclose (FILE *);
|
|---|
| 567 | FILE *_popen (__const__ char *, __const__ char *);
|
|---|
| 568 | int _putw (int, FILE *);
|
|---|
| 569 | void _setbuffer (FILE *, char *, int);
|
|---|
| 570 | int _snprintf (char *, size_t, __const__ char *, ...);
|
|---|
| 571 | char *_tempnam (__const__ char *, __const__ char *);
|
|---|
| 572 | int _vsnprintf (char *, size_t, __const__ char *, va_list);
|
|---|
| 573 |
|
|---|
| 574 | #endif
|
|---|
| 575 | /* bird: end of EMX isms. */
|
|---|
| 576 |
|
|---|
| 577 | /* bird: GNU extensions */
|
|---|
| 578 | #ifdef __USE_GNU
|
|---|
| 579 |
|
|---|
| 580 | #if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T) /* bird: emx */
|
|---|
| 581 | typedef __ssize_t ssize_t;
|
|---|
| 582 | #define _SSIZE_T_DECLARED
|
|---|
| 583 | #define _SSIZE_T /* bird: emx */
|
|---|
| 584 | #endif
|
|---|
| 585 |
|
|---|
| 586 | ssize_t getline(char **, size_t *, FILE *);
|
|---|
| 587 | ssize_t getdelim(char **, size_t *, int, FILE *);
|
|---|
| 588 | #endif
|
|---|
| 589 | /* bird: GNU extensions - end */
|
|---|
| 590 |
|
|---|
| 591 |
|
|---|
| 592 | __END_DECLS
|
|---|
| 593 | #endif /* !_STDIO_H_ */
|
|---|
| 594 |
|
|---|