1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINC/STDIO.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,229 @@
1.4 +/* STDIO.H
1.5 + *
1.6 + * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
1.7 + * All rights reserved.
1.8 + */
1.9 +
1.10 +/** @file
1.11 +@publishedAll
1.12 +@released
1.13 +*/
1.14 +
1.15 +/*
1.16 + * Copyright (c) 1990 The Regents of the University of California.
1.17 + * All rights reserved.
1.18 + *
1.19 + * Redistribution and use in source and binary forms are permitted
1.20 + * provided that the above copyright notice and this paragraph are
1.21 + * duplicated in all such forms and that any documentation,
1.22 + * advertising materials, and other materials related to such
1.23 + * distribution and use acknowledge that the software was developed
1.24 + * by the University of California, Berkeley. The name of the
1.25 + * University may not be used to endorse or promote products derived
1.26 + * from this software without specific prior written permission.
1.27 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1.28 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1.29 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1.30 + *
1.31 + * @(#)stdio.h 5.3 (Berkeley) 3/15/86
1.32 + */
1.33 +
1.34 +/*
1.35 + * NB: to fit things in six character monocase externals, the
1.36 + * stdio code uses the prefix `__s' for stdio objects, typically
1.37 + * followed by a three-character attempt at a mnemonic.
1.38 + */
1.39 +
1.40 +#ifndef _STDIO_H_
1.41 +#define _STDIO_H_
1.42 +
1.43 +#ifdef __cplusplus
1.44 +extern "C" {
1.45 +#endif
1.46 +
1.47 +#include "_ansi.h"
1.48 +
1.49 +#define _FSTDIO /* ``function stdio'' */
1.50 +
1.51 +#define __need_size_t
1.52 +#include <stddef.h>
1.53 +
1.54 +#include <stdarg_e.h> /* defines __e32_va_list */
1.55 +
1.56 +#include <sys/stdio_t.h> /* Definition of _fpos_t and struct __sFILE */
1.57 +
1.58 +typedef _fpos_t fpos_t;
1.59 +typedef struct __sFILE FILE;
1.60 +
1.61 +#define __SLBF 0x0001 /* line buffered */
1.62 +#define __SNBF 0x0002 /* unbuffered */
1.63 +#define __SRD 0x0004 /* OK to read */
1.64 +#define __SWR 0x0008 /* OK to write */
1.65 + /* RD and WR are never simultaneously asserted */
1.66 +#define __SRW 0x0010 /* open for reading & writing */
1.67 +#define __SEOF 0x0020 /* found EOF */
1.68 +#define __SERR 0x0040 /* found error */
1.69 +#define __SMBF 0x0080 /* _buf is from malloc */
1.70 +#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
1.71 +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */
1.72 +#define __SOPT 0x0400 /* do fseek() optimisation */
1.73 +#define __SNPT 0x0800 /* do not do fseek() optimisation */
1.74 +#define __SOFF 0x1000 /* set iff _offset is in fact correct */
1.75 +#define __SMOD 0x2000 /* true => fgetline modified _p text */
1.76 +
1.77 +/**
1.78 +The following three definitions are for ANSI C, which took them
1.79 +from System V, which stupidly took internal interface macros and
1.80 +made them official arguments to setvbuf(), without renaming them.
1.81 +Hence, these ugly _IOxxx names are *supposed* to appear in user code.
1.82 +
1.83 +Although these happen to match their counterparts above, the
1.84 +implementation does not rely on that (so these could be renumbered).
1.85 +*/
1.86 +#define _IOFBF 0 /* setvbuf should set fully buffered */
1.87 +#define _IOLBF 1 /* setvbuf should set line buffered */
1.88 +#define _IONBF 2 /* setvbuf should set unbuffered */
1.89 +
1.90 +#ifndef NULL
1.91 +#define NULL 0L
1.92 +#endif
1.93 +
1.94 +#define BUFSIZ 1024
1.95 +#define EOF (-1)
1.96 +
1.97 +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
1.98 +#define FILENAME_MAX 256 /* must be <= PATH_MAX <sys/syslimits.h> */
1.99 +#define P_tmpdir "/System/temp/"
1.100 +#define WIDEP_tmpdir L"/System/temp/"
1.101 +#define L_tmpnam 34 /* ?:/System/temp/t%x.%x */
1.102 +
1.103 +#ifndef SEEK_SET
1.104 +#define SEEK_SET 0 /* set file offset to offset */
1.105 +#endif
1.106 +#ifndef SEEK_CUR
1.107 +#define SEEK_CUR 1 /* set file offset to current plus offset */
1.108 +#endif
1.109 +#ifndef SEEK_END
1.110 +#define SEEK_END 2 /* set file offset to EOF plus offset */
1.111 +#endif
1.112 +
1.113 +#define TMP_MAX 26
1.114 +
1.115 +/**
1.116 +Function interface to the "constants" stdin, stdout and stderr.
1.117 +These functions guarantee to return a fixed value, so that it
1.118 +will be possible to use expressions such as
1.119 +if (fp != stdout)
1.120 + fclose(fp);
1.121 +
1.122 +with complete confidence. Unfortunately it will rule out initialising
1.123 +global variables with stdin/stdout/stderr, as in the common idiom:
1.124 +
1.125 +static FILE *log = stderr;
1.126 +
1.127 +This isn't currently possible with EPOC32.
1.128 +*/
1.129 +IMPORT_C FILE *__stdin (void);
1.130 +IMPORT_C FILE *__stdout (void);
1.131 +IMPORT_C FILE *__stderr (void);
1.132 +
1.133 +#define stdin (__stdin())
1.134 +#define stdout (__stdout())
1.135 +#define stderr (__stderr())
1.136 +
1.137 +/**
1.138 +Functions defined in ANSI C standard.
1.139 +*/
1.140 +IMPORT_C FILE * tmpfile (void);
1.141 +IMPORT_C char * tmpnam (char *);
1.142 +IMPORT_C wchar_t * wtmpnam (wchar_t *);
1.143 +IMPORT_C int fclose (FILE *);
1.144 +IMPORT_C int fflush (FILE *);
1.145 +IMPORT_C FILE * freopen (const char *, const char *, FILE *);
1.146 +IMPORT_C FILE * wfreopen (const wchar_t *, const wchar_t *, FILE *);
1.147 +IMPORT_C void setbuf (FILE *, char *);
1.148 +IMPORT_C int setvbuf (FILE *, char *, int, size_t);
1.149 +IMPORT_C int fprintf (FILE *, const char *, ...);
1.150 +IMPORT_C int fscanf (FILE *, const char *, ...);
1.151 +IMPORT_C int printf (const char *, ...);
1.152 +IMPORT_C int scanf (const char *, ...);
1.153 +IMPORT_C int sscanf (const char *, const char *, ...);
1.154 +IMPORT_C int vfprintf (FILE *, const char *, __e32_va_list);
1.155 +IMPORT_C int vprintf (const char *, __e32_va_list);
1.156 +IMPORT_C int vsprintf (char *, const char *, __e32_va_list);
1.157 +IMPORT_C int fgetc (FILE *);
1.158 +IMPORT_C char * fgets (char *, int, FILE *);
1.159 +IMPORT_C int fputc (int, FILE *);
1.160 +IMPORT_C int fputs (const char *, FILE *);
1.161 +IMPORT_C int getc (FILE *);
1.162 +IMPORT_C int getchar (void);
1.163 +IMPORT_C char * gets (char *);
1.164 +IMPORT_C int putc (int, FILE *);
1.165 +IMPORT_C int putchar (int);
1.166 +IMPORT_C int puts (const char *);
1.167 +IMPORT_C int ungetc (int, FILE *);
1.168 +IMPORT_C size_t fread (void*, size_t _size, size_t _n, FILE *);
1.169 +IMPORT_C size_t fwrite (const void* , size_t _size, size_t _n, FILE *);
1.170 +IMPORT_C int fgetpos (FILE *, fpos_t *);
1.171 +IMPORT_C int fseek (FILE *, long, int);
1.172 +IMPORT_C int fsetpos (FILE *, const fpos_t *);
1.173 +IMPORT_C long ftell (FILE *);
1.174 +IMPORT_C void rewind (FILE *);
1.175 +IMPORT_C void clearerr (FILE *);
1.176 +IMPORT_C int feof (FILE *);
1.177 +IMPORT_C int ferror (FILE *);
1.178 +IMPORT_C void perror (const char *);
1.179 +#ifndef _REENT_ONLY
1.180 +IMPORT_C FILE * fopen (const char *_name, const char *_type);
1.181 +IMPORT_C FILE * wfopen (const wchar_t *_name, const wchar_t *_type);
1.182 +IMPORT_C int sprintf (char *, const char *, ...);
1.183 +#endif
1.184 +
1.185 +/**
1.186 +Routines in POSIX 1003.1.
1.187 +*/
1.188 +IMPORT_C int fileno (FILE *);
1.189 +
1.190 +#ifndef _REENT_ONLY
1.191 +IMPORT_C FILE * fdopen (int, const char *);
1.192 +IMPORT_C FILE * wfdopen (int, const wchar_t *);
1.193 +#endif
1.194 +
1.195 +/**
1.196 +The name _cleanup is rather well-known...
1.197 +*/
1.198 +IMPORT_C void _cleanup (void);
1.199 +
1.200 +/**
1.201 +EPOC32 support for multiple processes
1.202 +*/
1.203 +IMPORT_C int popen3 (const char *cmd, const char *mode, char** envp, int fids[3]);
1.204 +IMPORT_C int wpopen3 (const wchar_t *cmd, const wchar_t *mode, wchar_t** envp, int fids[3]);
1.205 +
1.206 +#ifndef _STRICT_ANSI
1.207 +int getw (FILE *);
1.208 +int putw (int, FILE *);
1.209 +void setbuffer (FILE *, char *, int);
1.210 +int setlinebuf (FILE *);
1.211 +
1.212 +/**
1.213 +Stdio function-access interface.
1.214 +*/
1.215 +FILE *funopen (const void* _cookie,
1.216 + int (*readfn) (void* _cookie, char *_buf, int _n),
1.217 + int (*writefn)(void* _cookie, const char *_buf, int _n),
1.218 + fpos_t (*seekfn) (void* _cookie, fpos_t _off, int _whence),
1.219 + int (*closefn)(void* _cookie));
1.220 +
1.221 +#define fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0)
1.222 +#define fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0)
1.223 +#define getchar() getc(stdin)
1.224 +#define putchar(x) putc(x, stdout)
1.225 +#define L_cuserid 9 /* posix says it goes in stdio.h :( */
1.226 +
1.227 +#endif /* _STRICT_ANSI */
1.228 +
1.229 +#ifdef __cplusplus
1.230 +}
1.231 +#endif
1.232 +#endif /* _STDIO_H_ */