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