Mercurial > flash_v2
comparison packages/language/c/libc/stdio/current/src/common/stdioinlines.cxx @ 115:6ed91473a1cd ecos-sw-2000-08-21
Merge from eCos master repository on 2000-08-21-22:40:54-BST
| author | jlarmour |
|---|---|
| date | Fri, 25 Aug 2000 17:32:38 +0000 |
| parents | |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 114:5ad2b71d525e | 115:6ed91473a1cd |
|---|---|
| 1 //=========================================================================== | |
| 2 // | |
| 3 // stdioinlines.cxx | |
| 4 // | |
| 5 // ANSI standard I/O routines - real alternatives for inlined functions | |
| 6 // | |
| 7 //=========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://www.redhat.com/ | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //=========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): jlarmour | |
| 35 // Contributors: | |
| 36 // Date: 2000-04-20 | |
| 37 // Purpose: | |
| 38 // Description: | |
| 39 // Usage: | |
| 40 // | |
| 41 //####DESCRIPTIONEND#### | |
| 42 // | |
| 43 //=========================================================================== | |
| 44 | |
| 45 // CONFIGURATION | |
| 46 | |
| 47 #include <pkgconf/libc_stdio.h> // Configuration header | |
| 48 | |
| 49 // INCLUDES | |
| 50 | |
| 51 // We don't want the inline versions of stdio functions defined here | |
| 52 | |
| 53 #ifdef CYGIMP_LIBC_STDIO_INLINES | |
| 54 #undef CYGIMP_LIBC_STDIO_INLINES | |
| 55 #endif | |
| 56 | |
| 57 #include <cyg/infra/cyg_type.h> // Common type definitions and support | |
| 58 #include <stddef.h> // NULL and size_t from compiler | |
| 59 #include <stdarg.h> // va_list | |
| 60 #include <stdio.h> // Header for this file | |
| 61 #include <errno.h> // Definition of error codes and errno | |
| 62 #include <string.h> // Definition of strerror() for perror() | |
| 63 #include <limits.h> // INT_MAX | |
| 64 | |
| 65 | |
| 66 // FUNCTIONS | |
| 67 | |
| 68 //=========================================================================== | |
| 69 | |
| 70 // 7.9.5 File access functions | |
| 71 | |
| 72 externC void | |
| 73 setbuf( FILE *stream, char *buf ) | |
| 74 { | |
| 75 if (buf == NULL) | |
| 76 setvbuf( stream, NULL, _IONBF, BUFSIZ ); | |
| 77 else | |
| 78 // NB: Should use full buffering by default ordinarily, but in | |
| 79 // the current system we're always connected to an interactive | |
| 80 // terminal, so use line buffering | |
| 81 setvbuf( stream, buf, _IOLBF, BUFSIZ ); | |
| 82 | |
| 83 } // setbuf() | |
| 84 | |
| 85 //=========================================================================== | |
| 86 | |
| 87 // 7.9.6 Formatted input/output functions | |
| 88 | |
| 89 | |
| 90 externC int | |
| 91 vfprintf( FILE *stream, const char *format, va_list arg ) | |
| 92 { | |
| 93 return vfnprintf(stream, INT_MAX, format, arg); | |
| 94 } // vfprintf() | |
| 95 | |
| 96 | |
| 97 externC int | |
| 98 vprintf( const char *format, va_list arg) | |
| 99 { | |
| 100 return vfnprintf( stdout, INT_MAX, format, arg ); | |
| 101 } // vprintf() | |
| 102 | |
| 103 | |
| 104 externC int | |
| 105 vsprintf( char *s, const char *format, va_list arg ) | |
| 106 { | |
| 107 return vsnprintf(s, INT_MAX, format, arg); | |
| 108 } // vsprintf() | |
| 109 | |
| 110 | |
| 111 //=========================================================================== | |
| 112 | |
| 113 // 7.9.7 Character input/output functions | |
| 114 | |
| 115 externC int | |
| 116 puts( const char *s ) | |
| 117 { | |
| 118 int rc; | |
| 119 | |
| 120 rc = fputs( s, stdout ); | |
| 121 | |
| 122 if (rc >= 0) | |
| 123 rc = fputc('\n', stdout ); | |
| 124 | |
| 125 return rc; | |
| 126 } // puts() | |
| 127 | |
| 128 | |
| 129 //=========================================================================== | |
| 130 | |
| 131 // 7.9.10 Error-handling functions | |
| 132 | |
| 133 externC void | |
| 134 perror( const char *s ) | |
| 135 { | |
| 136 if (s && *s) | |
| 137 fprintf( stderr, "%s: %s\n", s, strerror(errno) ); | |
| 138 else | |
| 139 fputs( strerror(errno), stderr ); | |
| 140 | |
| 141 } // perror() | |
| 142 | |
| 143 //=========================================================================== | |
| 144 | |
| 145 // Other non-ANSI functions | |
| 146 | |
| 147 #ifdef CYGFUN_LIBC_STDIO_ungetc | |
| 148 externC int | |
| 149 vscanf( const char *format, va_list arg ) | |
| 150 { | |
| 151 return vfscanf( stdin, format, arg ); | |
| 152 } // vscanf() | |
| 153 #endif | |
| 154 | |
| 155 // EOF stdioinlines.cxx |
