3 * Portions copyright (c) 1990-1999 Symbian Ltd. All rights reserved.
12 * Copyright (c) 1990 The Regents of the University of California.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms are permitted
16 * provided that the above copyright notice and this paragraph are
17 * duplicated in all such forms and that any documentation,
18 * advertising materials, and other materials related to such
19 * distribution and use acknowledge that the software was developed
20 * by the University of California, Berkeley. The name of the
21 * University may not be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 * @(#)stdio.h 5.3 (Berkeley) 3/15/86
31 * NB: to fit things in six character monocase externals, the
32 * stdio code uses the prefix `__s' for stdio objects, typically
33 * followed by a three-character attempt at a mnemonic.
45 #define _FSTDIO /* ``function stdio'' */
50 #include <stdarg_e.h> /* defines __e32_va_list */
52 #include <sys/stdio_t.h> /* Definition of _fpos_t and struct __sFILE */
54 typedef _fpos_t fpos_t;
55 typedef struct __sFILE FILE;
57 #define __SLBF 0x0001 /* line buffered */
58 #define __SNBF 0x0002 /* unbuffered */
59 #define __SRD 0x0004 /* OK to read */
60 #define __SWR 0x0008 /* OK to write */
61 /* RD and WR are never simultaneously asserted */
62 #define __SRW 0x0010 /* open for reading & writing */
63 #define __SEOF 0x0020 /* found EOF */
64 #define __SERR 0x0040 /* found error */
65 #define __SMBF 0x0080 /* _buf is from malloc */
66 #define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */
67 #define __SSTR 0x0200 /* this is an sprintf/snprintf string */
68 #define __SOPT 0x0400 /* do fseek() optimisation */
69 #define __SNPT 0x0800 /* do not do fseek() optimisation */
70 #define __SOFF 0x1000 /* set iff _offset is in fact correct */
71 #define __SMOD 0x2000 /* true => fgetline modified _p text */
74 The following three definitions are for ANSI C, which took them
75 from System V, which stupidly took internal interface macros and
76 made them official arguments to setvbuf(), without renaming them.
77 Hence, these ugly _IOxxx names are *supposed* to appear in user code.
79 Although these happen to match their counterparts above, the
80 implementation does not rely on that (so these could be renumbered).
82 #define _IOFBF 0 /* setvbuf should set fully buffered */
83 #define _IOLBF 1 /* setvbuf should set line buffered */
84 #define _IONBF 2 /* setvbuf should set unbuffered */
93 #define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */
94 #define FILENAME_MAX 256 /* must be <= PATH_MAX <sys/syslimits.h> */
95 #define P_tmpdir "/System/temp/"
96 #define WIDEP_tmpdir L"/System/temp/"
97 #define L_tmpnam 34 /* ?:/System/temp/t%x.%x */
100 #define SEEK_SET 0 /* set file offset to offset */
103 #define SEEK_CUR 1 /* set file offset to current plus offset */
106 #define SEEK_END 2 /* set file offset to EOF plus offset */
112 Function interface to the "constants" stdin, stdout and stderr.
113 These functions guarantee to return a fixed value, so that it
114 will be possible to use expressions such as
118 with complete confidence. Unfortunately it will rule out initialising
119 global variables with stdin/stdout/stderr, as in the common idiom:
121 static FILE *log = stderr;
123 This isn't currently possible with EPOC32.
125 IMPORT_C FILE *__stdin (void);
126 IMPORT_C FILE *__stdout (void);
127 IMPORT_C FILE *__stderr (void);
129 #define stdin (__stdin())
130 #define stdout (__stdout())
131 #define stderr (__stderr())
134 Functions defined in ANSI C standard.
136 IMPORT_C FILE * tmpfile (void);
137 IMPORT_C char * tmpnam (char *);
138 IMPORT_C wchar_t * wtmpnam (wchar_t *);
139 IMPORT_C int fclose (FILE *);
140 IMPORT_C int fflush (FILE *);
141 IMPORT_C FILE * freopen (const char *, const char *, FILE *);
142 IMPORT_C FILE * wfreopen (const wchar_t *, const wchar_t *, FILE *);
143 IMPORT_C void setbuf (FILE *, char *);
144 IMPORT_C int setvbuf (FILE *, char *, int, size_t);
145 IMPORT_C int fprintf (FILE *, const char *, ...);
146 IMPORT_C int fscanf (FILE *, const char *, ...);
147 IMPORT_C int printf (const char *, ...);
148 IMPORT_C int scanf (const char *, ...);
149 IMPORT_C int sscanf (const char *, const char *, ...);
150 IMPORT_C int vfprintf (FILE *, const char *, __e32_va_list);
151 IMPORT_C int vprintf (const char *, __e32_va_list);
152 IMPORT_C int vsprintf (char *, const char *, __e32_va_list);
153 IMPORT_C int fgetc (FILE *);
154 IMPORT_C char * fgets (char *, int, FILE *);
155 IMPORT_C int fputc (int, FILE *);
156 IMPORT_C int fputs (const char *, FILE *);
157 IMPORT_C int getc (FILE *);
158 IMPORT_C int getchar (void);
159 IMPORT_C char * gets (char *);
160 IMPORT_C int putc (int, FILE *);
161 IMPORT_C int putchar (int);
162 IMPORT_C int puts (const char *);
163 IMPORT_C int ungetc (int, FILE *);
164 IMPORT_C size_t fread (void*, size_t _size, size_t _n, FILE *);
165 IMPORT_C size_t fwrite (const void* , size_t _size, size_t _n, FILE *);
166 IMPORT_C int fgetpos (FILE *, fpos_t *);
167 IMPORT_C int fseek (FILE *, long, int);
168 IMPORT_C int fsetpos (FILE *, const fpos_t *);
169 IMPORT_C long ftell (FILE *);
170 IMPORT_C void rewind (FILE *);
171 IMPORT_C void clearerr (FILE *);
172 IMPORT_C int feof (FILE *);
173 IMPORT_C int ferror (FILE *);
174 IMPORT_C void perror (const char *);
176 IMPORT_C FILE * fopen (const char *_name, const char *_type);
177 IMPORT_C FILE * wfopen (const wchar_t *_name, const wchar_t *_type);
178 IMPORT_C int sprintf (char *, const char *, ...);
182 Routines in POSIX 1003.1.
184 IMPORT_C int fileno (FILE *);
187 IMPORT_C FILE * fdopen (int, const char *);
188 IMPORT_C FILE * wfdopen (int, const wchar_t *);
192 The name _cleanup is rather well-known...
194 IMPORT_C void _cleanup (void);
197 EPOC32 support for multiple processes
199 IMPORT_C int popen3 (const char *cmd, const char *mode, char** envp, int fids[3]);
200 IMPORT_C int wpopen3 (const wchar_t *cmd, const wchar_t *mode, wchar_t** envp, int fids[3]);
204 int putw (int, FILE *);
205 void setbuffer (FILE *, char *, int);
206 int setlinebuf (FILE *);
209 Stdio function-access interface.
211 FILE *funopen (const void* _cookie,
212 int (*readfn) (void* _cookie, char *_buf, int _n),
213 int (*writefn)(void* _cookie, const char *_buf, int _n),
214 fpos_t (*seekfn) (void* _cookie, fpos_t _off, int _whence),
215 int (*closefn)(void* _cookie));
217 #define fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0)
218 #define fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0)
219 #define getchar() getc(stdin)
220 #define putchar(x) putc(x, stdout)
221 #define L_cuserid 9 /* posix says it goes in stdio.h :( */
223 #endif /* _STRICT_ANSI */
228 #endif /* _STDIO_H_ */