Mercurial > ecos
annotate packages/language/c/libc/current/include/stdio.h @ 16:4f2df4ab82c8 ecos-sw-1999-06-18
Merge from eCos master repository on 1999-06-18-15:25:04-BST
| author | jlarmour |
|---|---|
| date | Fri, 18 Jun 1999 07:59:09 +0000 |
| parents | 443894e2e912 |
| children | 4741a3c3496a |
| rev | line source |
|---|---|
| 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 | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
88 // FILE is just cast to an address here. It is uncast internally to the |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
89 // C library in stream.hxx as the C++ Cyg_StdioStream class. |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
90 // Optional run-time checking can be enabled to ensure that the cast is |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
91 // valid, using the standard assertion functionality. |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
92 // |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
93 // The array size is irrelevant other than being more than 8, and is present |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
94 // to stop references to FILEs being marked as able to be put in the small |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
95 // data section. We can't just mark it as in the ".data" section as on some |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
96 // targets it may actually be ".common". Maybe this doesn't matter? |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
97 // FIXME: This doesn't work if things are larger than 16 are put in sdata, |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
98 // e.g. on mips by specifying -G 32 |
|
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
99 typedef CYG_ADDRESS FILE[16]; |
| 2 | 100 |
| 0 | 101 // EXTERNAL VARIABLES |
| 102 | |
| 103 // Default file streams for input/output. These only need to be | |
| 104 // expressions, not l-values - ISO C standard chap. 7.9.1 | |
| 2 | 105 // |
| 106 // cyg_libc_stdio_stdin/out/err aren't really files of course, | |
| 107 // but they are only named here so that we can take the address of | |
| 108 // them, in which case it doesn't matter what type they point to really | |
| 109 // | |
| 110 // CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing | |
| 111 // cyg_libc_stdio_stdin/out/err privately inside the C library | |
| 0 | 112 |
| 2 | 113 #ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS |
| 114 extern FILE cyg_libc_stdio_stdin, cyg_libc_stdio_stdout, | |
|
16
4f2df4ab82c8
Merge from eCos master repository on 1999-06-18-15:25:04-BST
jlarmour
parents:
2
diff
changeset
|
115 cyg_libc_stdio_stderr; |
| 2 | 116 |
| 117 #define stdin (&cyg_libc_stdio_stdin) | |
| 118 #define stdout (&cyg_libc_stdio_stdout) | |
| 119 #define stderr (&cyg_libc_stdio_stderr) | |
| 120 #endif | |
| 0 | 121 |
| 122 // FUNCTION PROTOTYPES | |
| 123 | |
| 124 //======================================================================== | |
| 125 | |
| 126 // ISO C 7.9.5 File access functions | |
| 127 | |
| 128 externC int | |
| 129 fclose( FILE * /* stream */ ); | |
| 130 | |
| 131 externC int | |
| 132 fflush( FILE * /* stream */ ); | |
| 133 | |
| 134 externC FILE * | |
| 135 fopen( const char * /* filename */, const char * /* mode */ ); | |
| 136 | |
| 137 externC FILE * | |
| 138 freopen( const char * /* filename */, const char * /* mode */, | |
| 139 FILE * /* stream */ ); | |
| 140 | |
| 141 externC void | |
| 142 setbuf( FILE * /* stream */, char * /* buffer */ ); | |
| 143 | |
| 144 externC int | |
| 145 setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */, | |
| 146 size_t /* size */ ); | |
| 147 | |
| 148 //======================================================================== | |
| 149 | |
| 150 // ISO C 7.9.6 Formatted input/output functions | |
| 151 | |
| 152 externC int | |
| 153 fprintf( FILE * /* stream */, const char * /* format */, ... ); | |
| 154 | |
| 155 externC int | |
| 156 fscanf( FILE * /* stream */, const char * /* format */, ... ); | |
| 157 | |
| 158 externC int | |
| 159 printf( const char * /* format */, ... ); | |
| 160 | |
| 161 externC int | |
| 162 scanf( const char * /* format */, ... ); | |
| 163 | |
| 164 externC int | |
| 165 sprintf( char * /* str */, const char * /* format */, ... ); | |
| 166 | |
| 167 externC int | |
| 168 sscanf( const char * /* str */, const char * /* format */, ... ); | |
| 169 | |
| 170 externC int | |
| 171 vfprintf( FILE * /* stream */, const char * /* format */, | |
| 172 va_list /* args */ ); | |
| 173 | |
| 174 externC int | |
| 175 vprintf( const char * /* format */, va_list /* args */ ); | |
| 176 | |
| 177 externC int | |
| 178 vsprintf( char * /* str */, const char * /* format */, | |
| 179 va_list /* args */ ); | |
| 180 | |
| 181 //======================================================================== | |
| 182 | |
| 183 // ISO C 7.9.7 Character input/output functions | |
| 184 | |
| 185 externC int | |
| 186 fgetc( FILE * /* stream */ ); | |
| 187 | |
| 188 externC char * | |
| 189 fgets( char * /* str */, int /* length */, FILE * /* stream */ ); | |
| 190 | |
| 191 externC int | |
| 192 fputc( int /* c */, FILE * /* stream */ ); | |
| 193 | |
| 194 externC int | |
| 195 fputs( const char * /* str */, FILE * /* stream */ ); | |
| 196 | |
| 197 // no function equivalent is required for these, so we can just #define | |
| 198 // them | |
| 199 | |
| 200 #define getc( __stream ) fgetc( __stream ) | |
| 201 | |
| 202 #define getchar() fgetc( stdin ) | |
| 203 | |
| 204 externC char * | |
| 205 gets( char * ); | |
| 206 | |
| 207 #define putc(__c, __stream) fputc(__c, __stream) | |
| 208 | |
| 209 #define putchar(__c) fputc(__c, stdout) | |
| 210 | |
| 211 externC int | |
| 212 puts( const char * /* str */ ); | |
| 213 | |
| 214 externC int | |
| 215 ungetc( int /* c */, FILE * /* stream */ ); | |
| 216 | |
| 217 //======================================================================== | |
| 218 | |
| 219 // ISO C 7.9.8 Direct input/output functions | |
| 220 | |
| 221 externC size_t | |
| 222 fread( void * /* ptr */, size_t /* object_size */, | |
| 223 size_t /* num_objects */, FILE * /* stream */ ); | |
| 224 | |
| 225 externC size_t | |
| 226 fwrite( const void * /* ptr */, size_t /* object_size */, | |
| 227 size_t /* num_objects */, FILE * /* stream */ ); | |
| 228 | |
| 229 | |
| 230 //======================================================================== | |
| 231 | |
| 232 // ISO C 7.9.10 Error-handling functions | |
| 233 | |
| 234 externC void | |
| 235 clearerr( FILE * /* stream */ ); | |
| 236 | |
| 237 externC int | |
| 238 feof( FILE * /* stream */ ); | |
| 239 | |
| 240 externC int | |
| 241 ferror( FILE * /* stream */ ); | |
| 242 | |
| 243 externC void | |
| 244 perror( const char * /* prefix_str */ ); | |
| 245 | |
| 246 //======================================================================== | |
| 247 | |
| 248 // Other non-ISO C functions | |
| 249 | |
| 250 externC int | |
| 251 fnprintf( FILE * /* stream */, size_t /* length */, | |
| 252 const char * /* format */, ... ); | |
| 253 | |
| 254 externC int | |
| 255 snprintf( char * /* str */, size_t /* length */, const char * /* format */, | |
| 256 ... ); | |
| 257 | |
| 258 externC int | |
| 259 vfnprintf( FILE * /* stream */, size_t /* length */, | |
| 260 const char * /* format */, va_list /* args */ ); | |
| 261 | |
| 262 externC int | |
| 263 vsnprintf( char * /* str */, size_t /* length */, | |
| 264 const char * /* format */, va_list /* args */ ); | |
| 265 | |
| 266 externC int | |
| 267 vscanf( const char * /* format */, va_list /* args */ ); | |
| 268 | |
| 269 externC int | |
| 270 vsscanf( const char * /* str */, const char * /* format */, | |
| 271 va_list /* args */ ); | |
| 272 | |
| 273 externC int | |
| 274 vfscanf( FILE * /* stream */, const char * /* format */, | |
| 275 va_list /* args */ ); | |
| 276 | |
| 277 | |
| 278 // INLINE FUNCTIONS | |
| 279 | |
| 280 #ifdef CYGIMP_LIBC_STDIO_INLINES | |
| 281 #include <stdio.inl> | |
| 282 #endif | |
| 283 | |
| 284 #endif // ifdef CYGPKG_LIBC | |
| 285 | |
| 286 #endif // CYGONCE_LIBC_STDIO_H multiple inclusion protection | |
| 287 | |
| 288 // EOF stdio.h |
