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