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