|
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 |
|
|
27 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
28 // ------------------------------------------- |
|
|
29 // |
|
|
30 //####COPYRIGHTEND#### |
|
|
31 //======================================================================== |
|
|
32 //#####DESCRIPTIONBEGIN#### |
|
|
33 // |
|
|
34 // Author(s): jlarmour |
|
|
35 // Contributors: jlarmour@cygnus.co.uk |
|
|
36 // Date: 1998-02-13 |
|
|
37 // Purpose: |
|
|
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 #include <sys/file_if.h> // FILE definition |
|
|
58 |
|
|
59 // CONSTANTS |
|
|
60 |
|
|
61 // Some of these values are odd to ensure that asserts have better effect |
|
|
62 // should spurious values be passed to functions expecting these constants. |
|
|
63 |
|
|
64 // _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used |
|
|
65 // with setvbuf() - ISO C standard chap 7.9.1 |
|
|
66 |
|
|
67 #define _IOFBF (-2) |
|
|
68 #define _IOLBF (-4) |
|
|
69 #define _IONBF (-8) |
|
|
70 |
|
|
71 // EOF is a macro defined to any negative integer constant - ISO C standard |
|
|
72 // chap. 7.9.1 |
|
|
73 #define EOF (-1) |
|
|
74 |
|
|
75 // SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position |
|
|
76 // anchors - ISO C standard chap. 7.9.1 |
|
|
77 #define SEEK_CUR (-16) |
|
|
78 #define SEEK_END (-32) |
|
|
79 #define SEEK_SET (-64) |
|
|
80 |
|
|
81 |
|
|
82 // TYPE DEFINITIONS |
|
|
83 |
|
|
84 // A type capable of specifying uniquely every file position - ISO C |
|
|
85 // standard chap 7.9.1 |
|
|
86 typedef cyg_ucount32 fpos_t; |
|
|
87 |
|
|
88 |
|
|
89 // EXTERNAL VARIABLES |
|
|
90 |
|
|
91 // Default file streams for input/output. These only need to be |
|
|
92 // expressions, not l-values - ISO C standard chap. 7.9.1 |
|
|
93 |
|
|
94 externC FILE *stdin, *stdout, *stderr; |
|
|
95 |
|
|
96 // FUNCTION PROTOTYPES |
|
|
97 |
|
|
98 //======================================================================== |
|
|
99 |
|
|
100 // ISO C 7.9.5 File access functions |
|
|
101 |
|
|
102 externC int |
|
|
103 fclose( FILE * /* stream */ ); |
|
|
104 |
|
|
105 externC int |
|
|
106 fflush( FILE * /* stream */ ); |
|
|
107 |
|
|
108 externC FILE * |
|
|
109 fopen( const char * /* filename */, const char * /* mode */ ); |
|
|
110 |
|
|
111 externC FILE * |
|
|
112 freopen( const char * /* filename */, const char * /* mode */, |
|
|
113 FILE * /* stream */ ); |
|
|
114 |
|
|
115 externC void |
|
|
116 setbuf( FILE * /* stream */, char * /* buffer */ ); |
|
|
117 |
|
|
118 externC int |
|
|
119 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */, |
|
|
120 size_t /* size */ ); |
|
|
121 |
|
|
122 //======================================================================== |
|
|
123 |
|
|
124 // ISO C 7.9.6 Formatted input/output functions |
|
|
125 |
|
|
126 externC int |
|
|
127 fprintf( FILE * /* stream */, const char * /* format */, ... ); |
|
|
128 |
|
|
129 externC int |
|
|
130 fscanf( FILE * /* stream */, const char * /* format */, ... ); |
|
|
131 |
|
|
132 externC int |
|
|
133 printf( const char * /* format */, ... ); |
|
|
134 |
|
|
135 externC int |
|
|
136 scanf( const char * /* format */, ... ); |
|
|
137 |
|
|
138 externC int |
|
|
139 sprintf( char * /* str */, const char * /* format */, ... ); |
|
|
140 |
|
|
141 externC int |
|
|
142 sscanf( const char * /* str */, const char * /* format */, ... ); |
|
|
143 |
|
|
144 externC int |
|
|
145 vfprintf( FILE * /* stream */, const char * /* format */, |
|
|
146 va_list /* args */ ); |
|
|
147 |
|
|
148 externC int |
|
|
149 vprintf( const char * /* format */, va_list /* args */ ); |
|
|
150 |
|
|
151 externC int |
|
|
152 vsprintf( char * /* str */, const char * /* format */, |
|
|
153 va_list /* args */ ); |
|
|
154 |
|
|
155 //======================================================================== |
|
|
156 |
|
|
157 // ISO C 7.9.7 Character input/output functions |
|
|
158 |
|
|
159 externC int |
|
|
160 fgetc( FILE * /* stream */ ); |
|
|
161 |
|
|
162 externC char * |
|
|
163 fgets( char * /* str */, int /* length */, FILE * /* stream */ ); |
|
|
164 |
|
|
165 externC int |
|
|
166 fputc( int /* c */, FILE * /* stream */ ); |
|
|
167 |
|
|
168 externC int |
|
|
169 fputs( const char * /* str */, FILE * /* stream */ ); |
|
|
170 |
|
|
171 // no function equivalent is required for these, so we can just #define |
|
|
172 // them |
|
|
173 |
|
|
174 #define getc( __stream ) fgetc( __stream ) |
|
|
175 |
|
|
176 #define getchar() fgetc( stdin ) |
|
|
177 |
|
|
178 externC char * |
|
|
179 gets( char * ); |
|
|
180 |
|
|
181 #define putc(__c, __stream) fputc(__c, __stream) |
|
|
182 |
|
|
183 #define putchar(__c) fputc(__c, stdout) |
|
|
184 |
|
|
185 externC int |
|
|
186 puts( const char * /* str */ ); |
|
|
187 |
|
|
188 externC int |
|
|
189 ungetc( int /* c */, FILE * /* stream */ ); |
|
|
190 |
|
|
191 //======================================================================== |
|
|
192 |
|
|
193 // ISO C 7.9.8 Direct input/output functions |
|
|
194 |
|
|
195 externC size_t |
|
|
196 fread( void * /* ptr */, size_t /* object_size */, |
|
|
197 size_t /* num_objects */, FILE * /* stream */ ); |
|
|
198 |
|
|
199 externC size_t |
|
|
200 fwrite( const void * /* ptr */, size_t /* object_size */, |
|
|
201 size_t /* num_objects */, FILE * /* stream */ ); |
|
|
202 |
|
|
203 |
|
|
204 //======================================================================== |
|
|
205 |
|
|
206 // ISO C 7.9.10 Error-handling functions |
|
|
207 |
|
|
208 externC void |
|
|
209 clearerr( FILE * /* stream */ ); |
|
|
210 |
|
|
211 externC int |
|
|
212 feof( FILE * /* stream */ ); |
|
|
213 |
|
|
214 externC int |
|
|
215 ferror( FILE * /* stream */ ); |
|
|
216 |
|
|
217 externC void |
|
|
218 perror( const char * /* prefix_str */ ); |
|
|
219 |
|
|
220 //======================================================================== |
|
|
221 |
|
|
222 // Other non-ISO C functions |
|
|
223 |
|
|
224 externC int |
|
|
225 fnprintf( FILE * /* stream */, size_t /* length */, |
|
|
226 const char * /* format */, ... ); |
|
|
227 |
|
|
228 externC int |
|
|
229 snprintf( char * /* str */, size_t /* length */, const char * /* format */, |
|
|
230 ... ); |
|
|
231 |
|
|
232 externC int |
|
|
233 vfnprintf( FILE * /* stream */, size_t /* length */, |
|
|
234 const char * /* format */, va_list /* args */ ); |
|
|
235 |
|
|
236 externC int |
|
|
237 vsnprintf( char * /* str */, size_t /* length */, |
|
|
238 const char * /* format */, va_list /* args */ ); |
|
|
239 |
|
|
240 externC int |
|
|
241 vscanf( const char * /* format */, va_list /* args */ ); |
|
|
242 |
|
|
243 externC int |
|
|
244 vsscanf( const char * /* str */, const char * /* format */, |
|
|
245 va_list /* args */ ); |
|
|
246 |
|
|
247 externC int |
|
|
248 vfscanf( FILE * /* stream */, const char * /* format */, |
|
|
249 va_list /* args */ ); |
|
|
250 |
|
|
251 |
|
|
252 // INLINE FUNCTIONS |
|
|
253 |
|
|
254 #ifdef CYGIMP_LIBC_STDIO_INLINES |
|
|
255 #include <stdio.inl> |
|
|
256 #endif |
|
|
257 |
|
|
258 #endif // ifdef CYGPKG_LIBC |
|
|
259 |
|
|
260 #endif // CYGONCE_LIBC_STDIO_H multiple inclusion protection |
|
|
261 |
|
|
262 // EOF stdio.h |