1 #ifndef CYGONCE_LIBC_STDIO_STDIO_H
2 #define CYGONCE_LIBC_STDIO_STDIO_H
3 //========================================================================
7 // ISO C standard I/O routines - with some POSIX 1003.1 extensions
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.
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.
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
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.
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.
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.
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####
45 // Author(s): jlarmour
48 // Purpose: ISO C standard I/O routines
50 // Usage: Do not include this file directly - use #include <stdio.h>
52 //####DESCRIPTIONEND####
54 //========================================================================
58 #include <pkgconf/libc_stdio.h> // Configuration header
62 #include <cyg/infra/cyg_type.h> // common type definitions and support
63 #include <stdarg.h> // va_list from compiler
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.
70 // _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used
71 // with setvbuf() - ISO C standard chap 7.9.1
77 // EOF is a macro defined to any negative integer constant - ISO C standard
81 // SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position
82 // anchors - ISO C standard chap. 7.9.1
90 // A type capable of specifying uniquely every file position - ISO C
91 // standard chap 7.9.1
92 typedef cyg_ucount32 fpos_t;
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.
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];
106 // EXTERNAL VARIABLES
108 // Default file streams for input/output. These only need to be
109 // expressions, not l-values - ISO C standard chap. 7.9.1
111 // CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing
112 // stdin/out/err privately inside the C library
114 #ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
115 __externC FILE *stdin, *stdout, *stderr;
118 // FUNCTION PROTOTYPES
120 //========================================================================
122 // ISO C89 7.9.4 Functions for operations on files
125 remove( const char * /* pathname */ ) __THROW;
128 rename( const char * /* oldpath */, const char * /* newpath */ ) __THROW;
131 tmpfile( void ) __THROW;
134 tmpnam(char * /* s */ ) __THROW;
136 //========================================================================
138 // ISO C89 7.9.5 File access functions
141 fclose( FILE * /* stream */ ) __THROW;
144 fflush( FILE * /* stream */ ) __THROW;
147 fopen( const char * /* filename */, const char * /* mode */ ) __THROW;
150 freopen( const char * /* filename */, const char * /* mode */,
151 FILE * /* stream */ ) __THROW;
154 setbuf( FILE * /* stream */, char * /* buffer */ ) __THROW;
157 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */,
158 size_t /* size */ ) __THROW;
160 //========================================================================
162 // ISO C89 7.9.6 Formatted input/output functions
165 fprintf( FILE * /* stream */, const char * /* format */, ... ) __THROW
166 CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
169 fscanf( FILE * /* stream */, const char * /* format */, ... ) __THROW
170 CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
173 printf( const char * /* format */, ... ) __THROW
174 CYGBLD_ATTRIB_PRINTF_FORMAT(1, 2);
177 scanf( const char * /* format */, ... ) __THROW
178 CYGBLD_ATTRIB_SCANF_FORMAT(1, 2);;
181 sprintf( char * /* str */, const char * /* format */, ... ) __THROW
182 CYGBLD_ATTRIB_PRINTF_FORMAT(2, 3);
185 sscanf( const char * /* str */, const char * /* format */, ... ) __THROW
186 CYGBLD_ATTRIB_SCANF_FORMAT(2, 3);
189 vfprintf( FILE * /* stream */, const char * /* format */,
190 va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
193 vprintf( const char * /* format */, va_list /* args */ ) __THROW
194 CYGBLD_ATTRIB_PRINTF_FORMAT(1, 0);
197 vsprintf( char * /* str */, const char * /* format */,
198 va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
200 //========================================================================
202 // ISO C89 7.9.7 Character input/output functions
205 fgetc( FILE * /* stream */ ) __THROW;
208 fgets( char * /* str */, int /* length */, FILE * /* stream */ ) __THROW;
211 fputc( int /* c */, FILE * /* stream */ ) __THROW;
214 putc( int /* c */, FILE * /* stream */ ) __THROW;
217 putchar( int /* c */ ) __THROW;
220 fputs( const char * /* str */, FILE * /* stream */ ) __THROW;
223 gets( char * ) __THROW;
226 getc( FILE * /* stream */ ) __THROW;
229 getchar( void ) __THROW;
232 puts( const char * /* str */ ) __THROW;
235 ungetc( int /* c */, FILE * /* stream */ ) __THROW;
237 // no function equivalent is required for getchar() or putchar(), so we can
240 #define getchar() fgetc( stdin )
242 #define putchar(__c) fputc(__c, stdout)
244 //========================================================================
246 // ISO C89 7.9.8 Direct input/output functions
249 fread( void * /* ptr */, size_t /* object_size */,
250 size_t /* num_objects */, FILE * /* stream */ ) __THROW;
253 fwrite( const void * /* ptr */, size_t /* object_size */,
254 size_t /* num_objects */, FILE * /* stream */ ) __THROW;
256 //========================================================================
258 // ISO C89 7.9.9 File positioning functions
261 fgetpos( FILE * /* stream */, fpos_t * /* pos */ ) __THROW;
264 fseek( FILE * /* stream */, long int /* offset */, int /* whence */ ) __THROW;
267 fsetpos( FILE * /* stream */, const fpos_t * /* pos */ ) __THROW;
270 ftell( FILE * /* stream */ ) __THROW;
273 rewind( FILE * /* stream */ ) __THROW;
275 //========================================================================
277 // ISO C89 7.9.10 Error-handling functions
280 clearerr( FILE * /* stream */ ) __THROW;
283 feof( FILE * /* stream */ ) __THROW;
286 ferror( FILE * /* stream */ ) __THROW;
289 perror( const char * /* prefix_str */ ) __THROW;
291 //========================================================================
293 // Other non-ISO C functions
296 fnprintf( FILE * /* stream */, size_t /* length */,
297 const char * /* format */, ... ) __THROW
298 CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
301 snprintf( char * /* str */, size_t /* length */, const char * /* format */,
302 ... ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
305 vfnprintf( FILE * /* stream */, size_t /* length */,
306 const char * /* format */, va_list /* args */ ) __THROW
307 CYGBLD_ATTRIB_PRINTF_FORMAT(3, 0);
310 vsnprintf( char * /* str */, size_t /* length */,
311 const char * /* format */, va_list /* args */ ) __THROW
312 CYGBLD_ATTRIB_PRINTF_FORMAT(3, 0);
315 vscanf( const char * /* format */, va_list /* args */ ) __THROW
316 CYGBLD_ATTRIB_SCANF_FORMAT(1, 0);
319 vsscanf( const char * /* str */, const char * /* format */,
320 va_list /* args */ ) __THROW CYGBLD_ATTRIB_SCANF_FORMAT(2, 0);
323 vfscanf( FILE * /* stream */, const char * /* format */,
324 va_list /* args */ ) __THROW CYGBLD_ATTRIB_PRINTF_FORMAT(2, 0);
329 #ifdef CYGIMP_LIBC_STDIO_INLINES
330 # include <cyg/libc/stdio/stdio.inl>
333 #endif // CYGONCE_LIBC_STDIO_STDIO_H multiple inclusion protection