|
0
|
1 #ifndef CYGONCE_LIBC_STDIO_H |
|
|
2 #define CYGONCE_LIBC_STDIO_H |
|
|
3 //======================================================================== |
|
|
4 // |
|
|
5 // stdio.h |
|
|
6 // |
|
|
7 // ISO C standard I/O routines - with some POSIX 1003.1 extensions |
|
|
8 // |
|
|
9 //======================================================================== |
|
|
10 //####COPYRIGHTBEGIN#### |
|
|
11 // |
|
|
12 // ------------------------------------------- |
|
|
13 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
14 // Version 1.0 (the "License"); you may not use this file except in |
|
|
15 // compliance with the License. You may obtain a copy of the License at |
|
|
16 // http://sourceware.cygnus.com/ecos |
|
|
17 // |
|
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
20 // License for the specific language governing rights and limitations under |
|
|
21 // the License. |
|
|
22 // |
|
|
23 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
24 // September 30, 1998. |
|
|
25 // |
|
|
26 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
27 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
28 // ------------------------------------------- |
|
|
29 // |
|
|
30 //####COPYRIGHTEND#### |
|
|
31 //======================================================================== |
|
|
32 //#####DESCRIPTIONBEGIN#### |
|
|
33 // |
|
|
34 // Author(s): jlarmour |
|
2
|
35 // Contributors: jlarmour |
|
|
36 // Date: 1999-01-19 |
|
|
37 // Purpose: ISO C standard I/O routines |
|
0
|
38 // Description: |
|
|
39 // Usage: #include <stdio.h> |
|
|
40 // |
|
|
41 //####DESCRIPTIONEND#### |
|
|
42 // |
|
|
43 //======================================================================== |
|
|
44 |
|
|
45 // CONFIGURATION |
|
|
46 |
|
|
47 #include <pkgconf/libc.h> // Configuration header |
|
|
48 |
|
|
49 // Include the C library? |
|
|
50 #ifdef CYGPKG_LIBC |
|
|
51 |
|
|
52 // INCLUDES |
|
|
53 |
|
|
54 #include <cyg/infra/cyg_type.h> // common type definitions and support |
|
|
55 #include <stddef.h> // NULL and size_t from compiler |
|
|
56 #include <stdarg.h> // va_list from compiler |
|
|
57 |
|
|
58 // CONSTANTS |
|
|
59 |
|
|
60 // Some of these values are odd to ensure that asserts have better effect |
|
|
61 // should spurious values be passed to functions expecting these constants. |
|
|
62 |
|
|
63 // _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used |
|
|
64 // with setvbuf() - ISO C standard chap 7.9.1 |
|
|
65 |
|
|
66 #define _IOFBF (-2) |
|
|
67 #define _IOLBF (-4) |
|
|
68 #define _IONBF (-8) |
|
|
69 |
|
|
70 // EOF is a macro defined to any negative integer constant - ISO C standard |
|
|
71 // chap. 7.9.1 |
|
|
72 #define EOF (-1) |
|
|
73 |
|
|
74 // SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position |
|
|
75 // anchors - ISO C standard chap. 7.9.1 |
|
2
|
76 #define SEEK_SET 0 |
|
|
77 #define SEEK_CUR 1 |
|
|
78 #define SEEK_END 2 |
|
0
|
79 |
|
|
80 |
|
|
81 // TYPE DEFINITIONS |
|
|
82 |
|
|
83 // A type capable of specifying uniquely every file position - ISO C |
|
|
84 // standard chap 7.9.1 |
|
|
85 typedef cyg_ucount32 fpos_t; |
|
|
86 |
|
|
87 |
|
2
|
88 typedef CYG_ADDRESS FILE; // FILE is just cast to an address here. It is |
|
|
89 // uncast internally to the C library in stream.hxx |
|
|
90 // as the C++ Cyg_StdioStream class. Optional |
|
|
91 // run-time checking can be enabled to ensure that |
|
|
92 // the cast is valid, using the standard assertion |
|
|
93 // functionality |
|
|
94 |
|
0
|
95 // EXTERNAL VARIABLES |
|
|
96 |
|
|
97 // Default file streams for input/output. These only need to be |
|
|
98 // expressions, not l-values - ISO C standard chap. 7.9.1 |
|
2
|
99 // |
|
|
100 // cyg_libc_stdio_stdin/out/err aren't really files of course, |
|
|
101 // but they are only named here so that we can take the address of |
|
|
102 // them, in which case it doesn't matter what type they point to really |
|
|
103 // |
|
|
104 // CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing |
|
|
105 // cyg_libc_stdio_stdin/out/err privately inside the C library |
|
0
|
106 |
|
2
|
107 #ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS |
|
|
108 extern FILE cyg_libc_stdio_stdin, cyg_libc_stdio_stdout, |
|
|
109 cyg_libc_stdio_stderr; |
|
|
110 |
|
|
111 #define stdin (&cyg_libc_stdio_stdin) |
|
|
112 #define stdout (&cyg_libc_stdio_stdout) |
|
|
113 #define stderr (&cyg_libc_stdio_stderr) |
|
|
114 #endif |
|
0
|
115 |
|
|
116 // FUNCTION PROTOTYPES |
|
|
117 |
|
|
118 //======================================================================== |
|
|
119 |
|
|
120 // ISO C 7.9.5 File access functions |
|
|
121 |
|
|
122 externC int |
|
|
123 fclose( FILE * /* stream */ ); |
|
|
124 |
|
|
125 externC int |
|
|
126 fflush( FILE * /* stream */ ); |
|
|
127 |
|
|
128 externC FILE * |
|
|
129 fopen( const char * /* filename */, const char * /* mode */ ); |
|
|
130 |
|
|
131 externC FILE * |
|
|
132 freopen( const char * /* filename */, const char * /* mode */, |
|
|
133 FILE * /* stream */ ); |
|
|
134 |
|
|
135 externC void |
|
|
136 setbuf( FILE * /* stream */, char * /* buffer */ ); |
|
|
137 |
|
|
138 externC int |
|
|
139 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */, |
|
|
140 size_t /* size */ ); |
|
|
141 |
|
|
142 //======================================================================== |
|
|
143 |
|
|
144 // ISO C 7.9.6 Formatted input/output functions |
|
|
145 |
|
|
146 externC int |
|
|
147 fprintf( FILE * /* stream */, const char * /* format */, ... ); |
|
|
148 |
|
|
149 externC int |
|
|
150 fscanf( FILE * /* stream */, const char * /* format */, ... ); |
|
|
151 |
|
|
152 externC int |
|
|
153 printf( const char * /* format */, ... ); |
|
|
154 |
|
|
155 externC int |
|
|
156 scanf( const char * /* format */, ... ); |
|
|
157 |
|
|
158 externC int |
|
|
159 sprintf( char * /* str */, const char * /* format */, ... ); |
|
|
160 |
|
|
161 externC int |
|
|
162 sscanf( const char * /* str */, const char * /* format */, ... ); |
|
|
163 |
|
|
164 externC int |
|
|
165 vfprintf( FILE * /* stream */, const char * /* format */, |
|
|
166 va_list /* args */ ); |
|
|
167 |
|
|
168 externC int |
|
|
169 vprintf( const char * /* format */, va_list /* args */ ); |
|
|
170 |
|
|
171 externC int |
|
|
172 vsprintf( char * /* str */, const char * /* format */, |
|
|
173 va_list /* args */ ); |
|
|
174 |
|
|
175 //======================================================================== |
|
|
176 |
|
|
177 // ISO C 7.9.7 Character input/output functions |
|
|
178 |
|
|
179 externC int |
|
|
180 fgetc( FILE * /* stream */ ); |
|
|
181 |
|
|
182 externC char * |
|
|
183 fgets( char * /* str */, int /* length */, FILE * /* stream */ ); |
|
|
184 |
|
|
185 externC int |
|
|
186 fputc( int /* c */, FILE * /* stream */ ); |
|
|
187 |
|
|
188 externC int |
|
|
189 fputs( const char * /* str */, FILE * /* stream */ ); |
|
|
190 |
|
|
191 // no function equivalent is required for these, so we can just #define |
|
|
192 // them |
|
|
193 |
|
|
194 #define getc( __stream ) fgetc( __stream ) |
|
|
195 |
|
|
196 #define getchar() fgetc( stdin ) |
|
|
197 |
|
|
198 externC char * |
|
|
199 gets( char * ); |
|
|
200 |
|
|
201 #define putc(__c, __stream) fputc(__c, __stream) |
|
|
202 |
|
|
203 #define putchar(__c) fputc(__c, stdout) |
|
|
204 |
|
|
205 externC int |
|
|
206 puts( const char * /* str */ ); |
|
|
207 |
|
|
208 externC int |
|
|
209 ungetc( int /* c */, FILE * /* stream */ ); |
|
|
210 |
|
|
211 //======================================================================== |
|
|
212 |
|
|
213 // ISO C 7.9.8 Direct input/output functions |
|
|
214 |
|
|
215 externC size_t |
|
|
216 fread( void * /* ptr */, size_t /* object_size */, |
|
|
217 size_t /* num_objects */, FILE * /* stream */ ); |
|
|
218 |
|
|
219 externC size_t |
|
|
220 fwrite( const void * /* ptr */, size_t /* object_size */, |
|
|
221 size_t /* num_objects */, FILE * /* stream */ ); |
|
|
222 |
|
|
223 |
|
|
224 //======================================================================== |
|
|
225 |
|
|
226 // ISO C 7.9.10 Error-handling functions |
|
|
227 |
|
|
228 externC void |
|
|
229 clearerr( FILE * /* stream */ ); |
|
|
230 |
|
|
231 externC int |
|
|
232 feof( FILE * /* stream */ ); |
|
|
233 |
|
|
234 externC int |
|
|
235 ferror( FILE * /* stream */ ); |
|
|
236 |
|
|
237 externC void |
|
|
238 perror( const char * /* prefix_str */ ); |
|
|
239 |
|
|
240 //======================================================================== |
|
|
241 |
|
|
242 // Other non-ISO C functions |
|
|
243 |
|
|
244 externC int |
|
|
245 fnprintf( FILE * /* stream */, size_t /* length */, |
|
|
246 const char * /* format */, ... ); |
|
|
247 |
|
|
248 externC int |
|
|
249 snprintf( char * /* str */, size_t /* length */, const char * /* format */, |
|
|
250 ... ); |
|
|
251 |
|
|
252 externC int |
|
|
253 vfnprintf( FILE * /* stream */, size_t /* length */, |
|
|
254 const char * /* format */, va_list /* args */ ); |
|
|
255 |
|
|
256 externC int |
|
|
257 vsnprintf( char * /* str */, size_t /* length */, |
|
|
258 const char * /* format */, va_list /* args */ ); |
|
|
259 |
|
|
260 externC int |
|
|
261 vscanf( const char * /* format */, va_list /* args */ ); |
|
|
262 |
|
|
263 externC int |
|
|
264 vsscanf( const char * /* str */, const char * /* format */, |
|
|
265 va_list /* args */ ); |
|
|
266 |
|
|
267 externC int |
|
|
268 vfscanf( FILE * /* stream */, const char * /* format */, |
|
|
269 va_list /* args */ ); |
|
|
270 |
|
|
271 |
|
|
272 // INLINE FUNCTIONS |
|
|
273 |
|
|
274 #ifdef CYGIMP_LIBC_STDIO_INLINES |
|
|
275 #include <stdio.inl> |
|
|
276 #endif |
|
|
277 |
|
|
278 #endif // ifdef CYGPKG_LIBC |
|
|
279 |
|
|
280 #endif // CYGONCE_LIBC_STDIO_H multiple inclusion protection |
|
|
281 |
|
|
282 // EOF stdio.h |