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