]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/language/c/libc/stdio/v2_0/include/stdio.h
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / language / c / libc / stdio / v2_0 / include / stdio.h
1 #ifndef CYGONCE_LIBC_STDIO_STDIO_H
2 #define CYGONCE_LIBC_STDIO_STDIO_H
3 //========================================================================
4 //
5 //      stdio.h
6 //
7 //      ISO C standard I/O routines - with some POSIX 1003.1 extensions
8 //
9 //========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 //
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //========================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):     jlarmour
46 // Contributors:  
47 // Date:          2000-04-19
48 // Purpose:       ISO C standard I/O routines
49 // Description: 
50 // Usage:         Do not include this file directly - use #include <stdio.h>
51 //
52 //####DESCRIPTIONEND####
53 //
54 //========================================================================
55
56 // CONFIGURATION
57
58 #include <pkgconf/libc_stdio.h>   // Configuration header
59
60 // INCLUDES
61
62 #include <cyg/infra/cyg_type.h> // common type definitions and support
63 #include <stdarg.h>             // va_list from compiler
64
65 // CONSTANTS
66
67 // Some of these values are odd to ensure that asserts have better effect
68 // should spurious values be passed to functions expecting these constants.
69
70 // _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used
71 // with setvbuf() - ISO C standard chap 7.9.1
72
73 #define _IOFBF      (-2)
74 #define _IOLBF      (-4)
75 #define _IONBF      (-8)
76
77 // EOF is a macro defined to any negative integer constant - ISO C standard
78 // chap. 7.9.1
79 #define EOF         (-1)
80
81 // SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position
82 // anchors - ISO C standard chap. 7.9.1
83 #define SEEK_SET    0
84 #define SEEK_CUR    1
85 #define SEEK_END    2
86
87
88 // TYPE DEFINITIONS
89
90 // A type capable of specifying uniquely every file position - ISO C
91 // standard chap 7.9.1
92 typedef cyg_count32 fpos_t;
93
94
95 // FILE is just cast to an address here. It is uncast internally to the
96 // C library in stream.hxx  as the C++ Cyg_StdioStream class.
97 // Optional run-time checking can be enabled to ensure that the cast is
98 // valid, using the standard assertion functionality.
99 //
100 // The array size is irrelevant other than being more than 8, and is present
101 // to stop references to FILEs being marked as able to be put in the small
102 // data section. We can't just mark it as in the ".data" section as on some
103 // targets it may actually be ".common".
104 typedef CYG_ADDRESS FILE[9999];
105
106 // EXTERNAL VARIABLES
107
108 // Default file streams for input/output. These only need to be
109 // expressions, not l-values - ISO C standard chap. 7.9.1
110 //
111 // CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing
112 // stdin/out/err privately inside the C library
113
114 #ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
115 __externC FILE *stdin, *stdout, *stderr;
116 #endif
117
118 // FUNCTION PROTOTYPES
119
120 //========================================================================
121
122 // ISO C89 7.9.4 Functions for operations on files
123
124 __externC int
125 remove( const char * /* pathname */ ) __THROW;
126
127 __externC int
128 rename( const char * /* oldpath */, const char * /* newpath */ ) __THROW;
129
130 __externC FILE *
131 tmpfile( void ) __THROW;
132
133 __externC char *
134 tmpnam(char * /* s */ ) __THROW;
135
136 //========================================================================
137
138 // ISO C89 7.9.5 File access functions
139
140 __externC int
141 fclose( FILE * /* stream */ ) __THROW;
142
143 __externC int
144 fflush( FILE * /* stream */ ) __THROW;
145
146 __externC FILE *
147 fopen( const char * /* filename */, const char * /* mode */ ) __THROW;
148
149 __externC FILE *
150 freopen( const char * /* filename */, const char * /* mode */,
151          FILE * /* stream */ ) __THROW;
152
153 __externC void
154 setbuf( FILE * /* stream */, char * /* buffer */ ) __THROW;
155
156 __externC int
157 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */,
158          size_t /* size */ ) __THROW;
159
160 //========================================================================
161
162 // ISO C89 7.9.6 Formatted input/output functions
163
164 __externC int
165 fprintf( FILE * /* stream */, const char * /* format */, ... ) __THROW 
166     CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
167
168 __externC int
169 fscanf( FILE * /* stream */, const char * /* format */, ... ) __THROW 
170     CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
171
172 __externC int
173 printf( const char * /* format */, ... ) __THROW 
174     CYGBLD_ATTRIB_PRINTF_FORMAT(1, 2);
175
176 __externC int
177 scanf( const char * /* format */, ... ) __THROW 
178     CYGBLD_ATTRIB_SCANF_FORMAT(1, 2);;
179
180 __externC int
181 sprintf( char * /* str */, const char * /* format */, ... ) __THROW
182     CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
183
184 __externC int
185 sscanf( const char * /* str */, const char * /* format */, ... ) __THROW
186     CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
187
188 __externC int
189 vfprintf( FILE * /* stream */, const char * /* format */,
190           va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
191
192 __externC int
193 vprintf( const char * /* format */, va_list /* args */ ) __THROW
194     CYGBLD_ATTRIB_PRINTF_FORMAT(1, 0);
195
196 __externC int
197 vsprintf( char * /* str */, const char * /* format */,
198           va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
199
200 //========================================================================
201
202 // ISO C89 7.9.7 Character input/output functions
203
204 __externC int
205 fgetc( FILE * /* stream */ ) __THROW;
206
207 __externC char *
208 fgets( char * /* str */, int /* length */, FILE * /* stream */ ) __THROW;
209
210 __externC int
211 fputc( int /* c */, FILE * /* stream */ ) __THROW;
212
213 __externC int
214 putc( int /* c */, FILE * /* stream */ ) __THROW;
215
216 __externC int
217 putchar( int /* c */ ) __THROW;
218
219 __externC int
220 fputs( const char * /* str */, FILE * /* stream */ ) __THROW;
221
222 __externC char *
223 gets( char * ) __THROW;
224
225 __externC int
226 getc( FILE * /* stream */ ) __THROW;
227
228 __externC int
229 getchar( void ) __THROW;
230
231 __externC int
232 puts( const char * /* str */ ) __THROW;
233
234 __externC int
235 ungetc( int /* c */, FILE * /* stream */ ) __THROW;
236
237 // no function equivalent is required for getchar() or putchar(), so we can
238 // just #define them
239
240 #define getchar() fgetc( stdin )
241
242 #define putchar(__c) fputc(__c, stdout)
243
244 //========================================================================
245
246 // ISO C89 7.9.8 Direct input/output functions
247
248 __externC size_t
249 fread( void * /* ptr */, size_t /* object_size */,
250        size_t /* num_objects */, FILE * /* stream */ ) __THROW;
251
252 __externC size_t
253 fwrite( const void * /* ptr */, size_t /* object_size */,
254         size_t /* num_objects */, FILE * /* stream */ ) __THROW;
255
256 //========================================================================
257
258 // ISO C89 7.9.9 File positioning functions
259
260 __externC int
261 fgetpos( FILE * /* stream */, fpos_t * /* pos */ ) __THROW;
262
263 __externC int
264 fseek( FILE * /* stream */, long int /* offset */, int /* whence */ ) __THROW;
265
266 __externC int
267 fsetpos( FILE * /* stream */, const fpos_t * /* pos */ ) __THROW;
268
269 __externC long int
270 ftell( FILE * /* stream */ ) __THROW;
271
272 __externC void
273 rewind( FILE * /* stream */ ) __THROW;
274
275 //========================================================================
276
277 // ISO C89 7.9.10 Error-handling functions
278
279 __externC void
280 clearerr( FILE * /* stream */ ) __THROW;
281
282 __externC int
283 feof( FILE * /* stream */ ) __THROW;
284
285 __externC int
286 ferror( FILE * /* stream */ ) __THROW;
287
288 __externC void
289 perror( const char * /* prefix_str */ ) __THROW;
290
291 //========================================================================
292
293 // Other non-ISO C functions
294
295 __externC int
296 fnprintf( FILE * /* stream */, size_t /* length */,
297           const char * /* format */, ... ) __THROW 
298     CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
299
300 __externC int
301 snprintf( char * /* str */, size_t /* length */, const char * /* format */,
302           ... ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
303
304 __externC int
305 vfnprintf( FILE * /* stream */, size_t /* length */,
306            const char * /* format */, va_list /* args */ ) __THROW
307     CYGBLD_ATTRIB_PRINTF_FORMAT(3, 0);
308
309 __externC int
310 vsnprintf( char * /* str */, size_t /* length */,
311            const char * /* format */, va_list /* args */ ) __THROW
312     CYGBLD_ATTRIB_PRINTF_FORMAT(3, 0);
313
314 __externC int
315 vscanf( const char * /* format */, va_list /* args */ ) __THROW
316     CYGBLD_ATTRIB_SCANF_FORMAT(1, 0);
317
318 __externC int
319 vsscanf( const char * /* str */, const char * /* format */,
320          va_list /* args */ ) __THROW CYGBLD_ATTRIB_SCANF_FORMAT(2, 0);
321
322 __externC int
323 vfscanf( FILE * /* stream */, const char * /* format */,
324          va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
325
326
327 // INLINE FUNCTIONS
328
329 #ifdef CYGIMP_LIBC_STDIO_INLINES
330 # include <cyg/libc/stdio/stdio.inl>
331 #endif
332
333 #endif // CYGONCE_LIBC_STDIO_STDIO_H multiple inclusion protection
334
335 // EOF stdio.h