1.1 --- a/epoc32/include/stdapis/stdio.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stdio.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,554 @@
1.4 -stdio.h
1.5 +/*-
1.6 +
1.7 + * © Portions copyright (c) 2006 Symbian Software Ltd. All rights reserved.
1.8 + * Copyright (c) 1990, 1993
1.9 + * The Regents of the University of California. All rights reserved.
1.10 + *
1.11 + * This code is derived from software contributed to Berkeley by
1.12 + * Chris Torek.
1.13 + *
1.14 + * Redistribution and use in source and binary forms, with or without
1.15 + * modification, are permitted provided that the following conditions
1.16 + * are met:
1.17 + * 1. Redistributions of source code must retain the above copyright
1.18 + * notice, this list of conditions and the following disclaimer.
1.19 + * 2. Redistributions in binary form must reproduce the above copyright
1.20 + * notice, this list of conditions and the following disclaimer in the
1.21 + * documentation and/or other materials provided with the distribution.
1.22 + * 4. Neither the name of the University nor the names of its contributors
1.23 + * may be used to endorse or promote products derived from this software
1.24 + * without specific prior written permission.
1.25 + *
1.26 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.27 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.28 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.29 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.30 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.31 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.32 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.33 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.34 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.35 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.36 + * SUCH DAMAGE.
1.37 + *
1.38 + * @(#)stdio.h 8.5 (Berkeley) 4/29/95
1.39 + * $FreeBSD: src/include/stdio.h,v 1.56 2004/06/20 10:01:30 tjr Exp $
1.40 + * © Portions copyright (c) 2005-2006 Nokia Corporation. All rights reserved.
1.41 + * © Portions copyright (c) 2007-2008 Symbian Software Ltd. All rights reserved.
1.42 + */
1.43 +
1.44 +#ifndef _STDIO_H_
1.45 +#define _STDIO_H_
1.46 +
1.47 +#ifdef __cplusplus
1.48 +extern "C" {
1.49 +#endif
1.50 +
1.51 +#include <sys/cdefs.h>
1.52 +#include <sys/_null.h>
1.53 +#include <sys/_types.h>
1.54 +
1.55 +#ifdef __SYMBIAN32__
1.56 +#include <_ansi.h>
1.57 +#include <errno.h>
1.58 +#include <sys/types.h>
1.59 +#endif
1.60 +
1.61 +
1.62 +
1.63 +typedef __off_t fpos_t;
1.64 +
1.65 +#ifndef _SIZE_T_DECLARED
1.66 +typedef __size_t size_t;
1.67 +#define _SIZE_T_DECLARED
1.68 +#endif
1.69 +
1.70 +#ifndef __SYMBIAN32__
1.71 +//#ifndef __DOXYGEN__
1.72 +#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE) && !__SYMBIAN32__
1.73 +#ifndef _VA_LIST_DECLARED
1.74 +typedef __va_list va_list;
1.75 +#define va_list __e32_va_list
1.76 +#define _VA_LIST_DECLARED
1.77 +#endif
1.78 +#endif
1.79 +//#endif //__DOXYGEN__
1.80 +#else //__SYMBIAN32__
1.81 +#include <stdarg_e.h>
1.82 +#include <stdarg.h>
1.83 +#endif //__SYMBIAN32__
1.84 +
1.85 +#ifdef __SYMBIAN32__
1.86 +#ifndef __DOXYGEN__
1.87 +#define vfscanf __vfscanf
1.88 +#endif //__DOXYGEN__
1.89 +#ifndef _VA_COPY_DEFINED
1.90 +#define va_copy(dst,src) (dst = src)
1.91 +#define _VA_COPY_DEFINED
1.92 +#endif //_VA_COPY_DEFINED
1.93 +#endif // __SYMBIAN32__
1.94 +#define _FSTDIO /* Define for new stdio with functions. */
1.95 +
1.96 +/*
1.97 + * NB: to fit things in six character monocase externals, the stdio
1.98 + * code uses the prefix `__s' for stdio objects, typically followed
1.99 + * by a three-character attempt at a mnemonic.
1.100 + */
1.101 +
1.102 +/* stdio buffers */
1.103 +struct __sbuf {
1.104 + unsigned char *_base;
1.105 + int _size;
1.106 +};
1.107 +
1.108 +/* hold a buncha junk that would grow the ABI */
1.109 +struct __sFILEX;
1.110 +
1.111 +/*
1.112 + * stdio state variables.
1.113 + *
1.114 + * The following always hold:
1.115 + *
1.116 + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
1.117 + * _lbfsize is -_bf._size, else _lbfsize is 0
1.118 + * if _flags&__SRD, _w is 0
1.119 + * if _flags&__SWR, _r is 0
1.120 + *
1.121 + * This ensures that the getc and putc macros (or inline functions) never
1.122 + * try to write or read from a file that is in `read' or `write' mode.
1.123 + * (Moreover, they can, and do, automatically switch from read mode to
1.124 + * write mode, and back, on "r+" and "w+" files.)
1.125 + *
1.126 + * _lbfsize is used only to make the inline line-buffered output stream
1.127 + * code as compact as possible.
1.128 + *
1.129 + * _ub, _up, and _ur are used when ungetc() pushes back more characters
1.130 + * than fit in the current _bf, or when ungetc() pushes back a character
1.131 + * that does not match the previous one in _bf. When this happens,
1.132 + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
1.133 + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
1.134 + */
1.135 +typedef struct __sFILE {
1.136 + unsigned char *_p; /* current position in (some) buffer */
1.137 + int _r; /* read space left for getc() */
1.138 + int _w; /* write space left for putc() */
1.139 + short _flags; /* flags, below; this FILE is free if 0 */
1.140 + short _file; /* fileno, if Unix descriptor, else -1 */
1.141 + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
1.142 + int _lbfsize; /* 0 or -_bf._size, for inline putc */
1.143 +
1.144 + /* operations */
1.145 + void *_cookie; /* cookie passed to io functions */
1.146 + int (*_close)(void *);
1.147 + int (*_read)(void *, char *, int);
1.148 + fpos_t (*_seek)(void *, fpos_t, int);
1.149 + int (*_write)(void *, const char *, int);
1.150 +
1.151 + /* separate buffer for long sequences of ungetc() */
1.152 + struct __sbuf _ub; /* ungetc buffer */
1.153 + struct __sFILEX *_extra; /* additions to FILE to not break ABI */
1.154 + int _ur; /* saved _r when _r is counting ungetc data */
1.155 +
1.156 + /* tricks to meet minimum requirements even when malloc() fails */
1.157 + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
1.158 + unsigned char _nbuf[1]; /* guarantee a getc() buffer */
1.159 +
1.160 + /* separate buffer for fgetln() when line crosses buffer boundary */
1.161 + struct __sbuf _lb; /* buffer for fgetln() */
1.162 +
1.163 + /* Unix stdio files get aligned to block boundaries on fseek() */
1.164 + int _blksize; /* stat.st_blksize (may be != _bf._size) */
1.165 + fpos_t _offset; /* current lseek offset */
1.166 +} FILE;
1.167 +
1.168 +#ifndef _STDSTREAM_DECLARED
1.169 +__BEGIN_DECLS
1.170 +#if (!defined(__SYMBIAN32__) && (!defined(__WINSCW__) || !defined(__WINS__)))
1.171 +extern FILE *__stdinp;
1.172 +extern FILE *__stdoutp;
1.173 +extern FILE *__stderrp;
1.174 +#endif //EMULATOR
1.175 +__END_DECLS
1.176 +#define _STDSTREAM_DECLARED
1.177 +#endif
1.178 +
1.179 +#define __SLBF 0x0001 /* line buffered */
1.180 +#define __SNBF 0x0002 /* unbuffered */
1.181 +#define __SRD 0x0004 /* OK to read */
1.182 +#define __SWR 0x0008 /* OK to write */
1.183 + /* RD and WR are never simultaneously asserted */
1.184 +#define __SRW 0x0010 /* open for reading & writing */
1.185 +#define __SEOF 0x0020 /* found EOF */
1.186 +#define __SERR 0x0040 /* found error */
1.187 +#define __SMBF 0x0080 /* _buf is from malloc */
1.188 +#define __SAPP 0x0100 /* fdopen()ed in append mode */
1.189 +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
1.190 +#define __SOPT 0x0400 /* do fseek() optimization */
1.191 +#define __SNPT 0x0800 /* do not do fseek() optimization */
1.192 +#define __SOFF 0x1000 /* set iff _offset is in fact correct */
1.193 +#define __SMOD 0x2000 /* true => fgetln modified _p text */
1.194 +#define __SALC 0x4000 /* allocate string space dynamically */
1.195 +#define __SIGN 0x8000 /* ignore this file in _fwalk */
1.196 +
1.197 +/*
1.198 + * The following three definitions are for ANSI C, which took them
1.199 + * from System V, which brilliantly took internal interface macros and
1.200 + * made them official arguments to setvbuf(), without renaming them.
1.201 + * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
1.202 + *
1.203 + * Although numbered as their counterparts above, the implementation
1.204 + * does not rely on this.
1.205 + */
1.206 +#define _IOFBF 0 /* setvbuf should set fully buffered */
1.207 +#define _IOLBF 1 /* setvbuf should set line buffered */
1.208 +#define _IONBF 2 /* setvbuf should set unbuffered */
1.209 +
1.210 +#define BUFSIZ 1024 /* size of buffer used by setbuf */
1.211 +#define EOF (-1)
1.212 +
1.213 +/*
1.214 + * FOPEN_MAX is a minimum maximum, and is the number of streams that
1.215 + * stdio can provide without attempting to allocate further resources
1.216 + * (which could fail). Do not use this for anything.
1.217 + */
1.218 + /* must be == _POSIX_STREAM_MAX <limits.h> */
1.219 +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
1.220 +#ifndef __SYMBIAN32__
1.221 +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */
1.222 +#else
1.223 +#define FILENAME_MAX 256 /* must be <= PATH_MAX <sys/syslimits.h> */
1.224 +#endif /* __SYMBIAN32__ */
1.225 +
1.226 +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
1.227 +#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
1.228 +#define GET_WSD_VAR_NAME(var,varprefix) _##varprefix##_##var
1.229 +char **GET_WSD_VAR_NAME(tmpdirptr, g)();
1.230 +#define __tmpdirptr (*GET_WSD_VAR_NAME(tmpdirptr, g)())
1.231 +#else
1.232 +extern char* __tmpdirptr;
1.233 +#endif
1.234 +
1.235 +#if __XSI_VISIBLE
1.236 +#ifndef __SYMBIAN32__
1.237 +#define P_tmpdir "/var/tmp/"
1.238 +#else
1.239 +#define P_tmpdir (tmpdirname())
1.240 +#define WIDEP_tmpdir (tmpdirname())
1.241 +#endif //__SYMBIAN32__
1.242 +#endif
1.243 +#ifndef __SYMBIAN32__
1.244 +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
1.245 +#else
1.246 +#define L_tmpnam 256 /* XXX must be == PATH_MAX */
1.247 +#endif /* __SYMBIAN32__ */
1.248 +#define TMP_MAX 308915776
1.249 +
1.250 +#ifndef SEEK_SET
1.251 +#define SEEK_SET 0 /* set file offset to offset */
1.252 +#endif
1.253 +#ifndef SEEK_CUR
1.254 +#define SEEK_CUR 1 /* set file offset to current plus offset */
1.255 +#endif
1.256 +#ifndef SEEK_END
1.257 +#define SEEK_END 2 /* set file offset to EOF plus offset */
1.258 +#endif
1.259 +
1.260 +#if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
1.261 +
1.262 +#define GET_WSD_VAR_NAME(var,varprefix) _##varprefix##_##var
1.263 +
1.264 +FILE **GET_WSD_VAR_NAME(__stdinp, g)();
1.265 +FILE **GET_WSD_VAR_NAME(__stdoutp, g)();
1.266 +FILE **GET_WSD_VAR_NAME(__stderrp, g)();
1.267 +
1.268 +#define __stdinp (*GET_WSD_VAR_NAME(__stdinp, g)())
1.269 +#define __stdoutp (*GET_WSD_VAR_NAME(__stdoutp, g)())
1.270 +#define __stderrp (*GET_WSD_VAR_NAME(__stderrp, g)())
1.271 +#endif //EMULATOR
1.272 +
1.273 +#ifndef __SYMBIAN32__
1.274 +#define stdin __stdinp
1.275 +#define stdout __stdoutp
1.276 +#define stderr __stderrp
1.277 +#else
1.278 +__BEGIN_DECLS
1.279 +IMPORT_C FILE *__stdin (void);
1.280 +IMPORT_C FILE *__stdout (void);
1.281 +IMPORT_C FILE *__stderr (void);
1.282 +IMPORT_C char * tmpdirname(void);
1.283 +__END_DECLS
1.284 +#define stdin (__stdin())
1.285 +#define stdout (__stdout())
1.286 +#define stderr (__stderr())
1.287 +#endif
1.288 +
1.289 +__BEGIN_DECLS
1.290 +/*
1.291 + * Functions defined in ANSI C standard.
1.292 + */
1.293 +IMPORT_C void clearerr(FILE *);
1.294 +IMPORT_C int fclose(FILE *);
1.295 +IMPORT_C int feof(FILE *);
1.296 +IMPORT_C int ferror(FILE *);
1.297 +IMPORT_C int fflush(FILE *);
1.298 +IMPORT_C int fgetc(FILE *);
1.299 +IMPORT_C int fgetpos(FILE * __restrict, fpos_t * __restrict);
1.300 +IMPORT_C char *fgets(char * __restrict, int, FILE * __restrict);
1.301 +IMPORT_C FILE *fopen(const char * __restrict, const char * __restrict);
1.302 +IMPORT_C int fprintf(FILE * __restrict, const char * __restrict, ...);
1.303 +IMPORT_C int fputc(int, FILE *);
1.304 +IMPORT_C int fputs(const char * __restrict, FILE * __restrict);
1.305 +IMPORT_C size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
1.306 +IMPORT_C FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
1.307 +IMPORT_C int fscanf(FILE * __restrict, const char * __restrict, ...);
1.308 +IMPORT_C int fseek(FILE *, long, int);
1.309 +IMPORT_C int fsetpos(FILE *, const fpos_t *);
1.310 +IMPORT_C long ftell(FILE *);
1.311 +IMPORT_C size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
1.312 +IMPORT_C int getc(FILE *);
1.313 +IMPORT_C int getchar(void);
1.314 +IMPORT_C char *gets(char *);
1.315 +IMPORT_C void perror(const char *);
1.316 +IMPORT_C int printf(const char * __restrict, ...);
1.317 +IMPORT_C int putc(int, FILE *);
1.318 +IMPORT_C int putchar(int);
1.319 +IMPORT_C int puts(const char *);
1.320 +IMPORT_C int remove(const char *);
1.321 +IMPORT_C int rename(const char *, const char *);
1.322 +IMPORT_C void rewind(FILE *);
1.323 +IMPORT_C int scanf(const char * __restrict, ...);
1.324 +IMPORT_C void setbuf(FILE * __restrict, char * __restrict);
1.325 +IMPORT_C int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
1.326 +IMPORT_C int sprintf(char * __restrict, const char * __restrict, ...);
1.327 +IMPORT_C int sscanf(const char * __restrict, const char * __restrict, ...);
1.328 +IMPORT_C FILE *tmpfile(void);
1.329 +IMPORT_C char *tmpnam(char *);
1.330 +IMPORT_C int ungetc(int, FILE *);
1.331 +IMPORT_C int vfprintf(FILE * __restrict, const char * __restrict,
1.332 + va_list);
1.333 +IMPORT_C int vprintf(const char * __restrict, va_list);
1.334 +IMPORT_C int vsprintf(char * __restrict, const char * __restrict,
1.335 + va_list);
1.336 +
1.337 +#if __ISO_C_VISIBLE >= 1999
1.338 +IMPORT_C int snprintf(char * __restrict, size_t, const char * __restrict,
1.339 + ...) __printflike(3, 4);
1.340 +IMPORT_C int vfscanf(FILE * __restrict, const char * __restrict, va_list)
1.341 + __scanflike(2, 0);
1.342 +IMPORT_C int vscanf(const char * __restrict, va_list) __scanflike(1, 0);
1.343 +IMPORT_C int vsnprintf(char * __restrict, size_t, const char * __restrict,
1.344 + va_list) __printflike(3, 0);
1.345 +IMPORT_C int vsscanf(const char * __restrict, const char * __restrict, va_list)
1.346 + __scanflike(2, 0);
1.347 +#endif
1.348 +
1.349 +/*
1.350 + * Functions defined in all versions of POSIX 1003.1.
1.351 + */
1.352 +#if __BSD_VISIBLE || __POSIX_VISIBLE <= 199506
1.353 +/* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */
1.354 +#define L_cuserid 17 /* legacy */
1.355 +#endif
1.356 +
1.357 +#if __POSIX_VISIBLE
1.358 +#ifndef __SYMBIAN32__
1.359 +#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */
1.360 +#else
1.361 +#define L_ctermid 256 /* size for ctermid(3); PATH_MAX */
1.362 +#endif /* __SYMBIAN32__ */
1.363 +IMPORT_C FILE *fdopen(int, const char *);
1.364 +IMPORT_C int fileno(FILE *);
1.365 +IMPORT_C int __sfileno(FILE* p);
1.366 +#endif /* __POSIX_VISIBLE */
1.367 +
1.368 +#if __POSIX_VISIBLE >= 199209
1.369 +IMPORT_C int pclose(FILE *);
1.370 +IMPORT_C FILE *popen(const char *, const char *);
1.371 +#endif
1.372 +
1.373 +#ifdef __SYMBIAN32__
1.374 +IMPORT_C int popen3(const char *file, const char *cmd, char** envp, int fds[3]);
1.375 +#endif
1.376 +
1.377 +#if __POSIX_VISIBLE >= 199506
1.378 +IMPORT_C int ftrylockfile(FILE *);
1.379 +IMPORT_C void flockfile(FILE *);
1.380 +IMPORT_C void funlockfile(FILE *);
1.381 +
1.382 +/*
1.383 + * These are normally used through macros as defined below, but POSIX
1.384 + * requires functions as well.
1.385 + */
1.386 +IMPORT_C int getc_unlocked(FILE *);
1.387 +IMPORT_C int getchar_unlocked(void);
1.388 +IMPORT_C int putc_unlocked(int, FILE *);
1.389 +IMPORT_C int putchar_unlocked(int);
1.390 +#endif
1.391 +
1.392 +#if __POSIX_VISIBLE >= 200112
1.393 +int fseeko(FILE *, __off_t, int);
1.394 +__off_t ftello(FILE *);
1.395 +#endif
1.396 +
1.397 +#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600
1.398 +IMPORT_C int getw(FILE *);
1.399 +IMPORT_C int putw(int, FILE *);
1.400 +#endif /* BSD or X/Open before issue 6 */
1.401 +
1.402 +#if __XSI_VISIBLE
1.403 +IMPORT_C char *tempnam(const char *, const char *);
1.404 +#endif
1.405 +
1.406 +/*
1.407 + * Routines that are purely local.
1.408 + */
1.409 +#if __BSD_VISIBLE
1.410 +IMPORT_C int asprintf(char **, const char *, ...) __printflike(2, 3);
1.411 +#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3
1.412 +#define __ATTR_FORMAT_ARG __attribute__((__format_arg__(2)))
1.413 +#else
1.414 +#define __ATTR_FORMAT_ARG
1.415 +#endif
1.416 +IMPORT_C void setbuffer(FILE *, char *, int);
1.417 +IMPORT_C int setlinebuf(FILE *);
1.418 +IMPORT_C int vasprintf(char **, const char *, va_list)
1.419 + __printflike(2, 0);
1.420 +
1.421 +#ifndef __SYMBIAN32__
1.422 +/*
1.423 + * The system error table contains messages for the first sys_nerr
1.424 + * positive errno values. Use strerror() or strerror_r() from <string.h>
1.425 + * instead.
1.426 + */
1.427 +
1.428 +/* Provide the declarations for `sys_errlist' and `sys_nerr' if they
1.429 + * are available on this system. Even if available, these variables
1.430 + * should not be used directly. The `strerror' function provides
1.431 + * all the necessary functionality.
1.432 + */
1.433 +
1.434 +extern __const int sys_nerr;
1.435 +extern __const char *__const sys_errlist[];
1.436 +#endif /* __SYMBIAN32__ */
1.437 +
1.438 +/*
1.439 + * Portability hacks. See <sys/types.h>.
1.440 + */
1.441 +#ifndef _FTRUNCATE_DECLARED
1.442 +#define _FTRUNCATE_DECLARED
1.443 +IMPORT_C int ftruncate(int, __off_t);
1.444 +#endif
1.445 +#ifndef _LSEEK_DECLARED
1.446 +#define _LSEEK_DECLARED
1.447 +IMPORT_C __off_t lseek(int, __off_t, int);
1.448 +#endif
1.449 +#ifndef _MMAP_DECLARED
1.450 +#define _MMAP_DECLARED
1.451 +IMPORT_C void *mmap(void *, size_t, int, int, int, __off_t);
1.452 +#endif
1.453 +#ifndef _TRUNCATE_DECLARED
1.454 +#define _TRUNCATE_DECLARED
1.455 +IMPORT_C int truncate(const char *, __off_t);
1.456 +#endif
1.457 +#endif /* __BSD_VISIBLE */
1.458 +
1.459 +#ifdef __SYMBIAN32__
1.460 +IMPORT_C int setecho(int fd, uint8_t echoval);
1.461 +#endif
1.462 +
1.463 +/*
1.464 + * Functions internal to the implementation.
1.465 + */
1.466 +#ifdef __SYMBIAN32__
1.467 +IMPORT_C int __srget(FILE *);
1.468 +IMPORT_C int __swbuf(int, FILE *);
1.469 +#else
1.470 +int __srget(FILE *);
1.471 +int __swbuf(int, FILE *);
1.472 +#endif /*__SYMBIAN32__ */
1.473 +
1.474 +/*
1.475 + * The __sfoo macros are here so that we can
1.476 + * define function versions in the C library.
1.477 + */
1.478 +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
1.479 +#if defined(__GNUC__) && defined(__STDC__)
1.480 +static __inline int __sputc(int _c, FILE *_p) {
1.481 + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
1.482 + return (*_p->_p++ = _c);
1.483 + else
1.484 + return (__swbuf(_c, _p));
1.485 +}
1.486 +#else
1.487 +/*
1.488 + * This has been tuned to generate reasonable code on the vax using pcc.
1.489 + */
1.490 +#define __sputc(c, p) \
1.491 + (--(p)->_w < 0 ? \
1.492 + (p)->_w >= (p)->_lbfsize ? \
1.493 + (*(p)->_p = (c)), *(p)->_p != '\n' ? \
1.494 + (int)*(p)->_p++ : \
1.495 + __swbuf('\n', p) : \
1.496 + __swbuf((int)(c), p) : \
1.497 + (*(p)->_p = (c), (int)*(p)->_p++))
1.498 +#endif
1.499 +
1.500 +#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
1.501 +#define __sferror(p) (((p)->_flags & __SERR) != 0)
1.502 +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
1.503 +
1.504 +#ifndef __SYMBIAN32__
1.505 +extern int __isthreaded;
1.506 +
1.507 +#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
1.508 +#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
1.509 +#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
1.510 +
1.511 +#if __POSIX_VISIBLE
1.512 +#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
1.513 +#endif
1.514 +
1.515 +#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
1.516 +#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
1.517 +
1.518 +#define getchar() getc(stdin)
1.519 +#define putchar(x) putc(x, stdout)
1.520 +
1.521 +#else
1.522 +IMPORT_C int* isthreaded(void);
1.523 +#define __isthreaded (*isthreaded())
1.524 +
1.525 +#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
1.526 +#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
1.527 +#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p))
1.528 +
1.529 +#if __POSIX_VISIBLE
1.530 +#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p))
1.531 +#endif
1.532 +
1.533 +#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp))
1.534 +#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp))
1.535 +
1.536 +#define getchar() getc(stdin)
1.537 +#define putchar(x) putc(x, stdout)
1.538 +#endif //__SYMBIAN32__
1.539 +
1.540 +
1.541 +#if __POSIX_VISIBLE >= 199506
1.542 +#ifndef __SYMBIAN32__
1.543 +#define getc_unlocked(fp) __sgetc(fp)
1.544 +#define putc_unlocked(x, fp) __sputc(x, fp)
1.545 +
1.546 +#define getchar_unlocked() getc_unlocked(stdin)
1.547 +#define putchar_unlocked(x) putc_unlocked(x, stdout)
1.548 +#endif
1.549 +#endif
1.550 +
1.551 +//---
1.552 +#ifdef __cplusplus
1.553 +}
1.554 +#endif
1.555 +//---
1.556 +
1.557 +__END_DECLS
1.558 +#endif /* !_STDIO_H_ */