|
0
|
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 Cygnus eCos Public License |
|
|
12 // Version 1.0 (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://sourceware.cygnus.com/ecos |
|
|
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 Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //=========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): jlarmour |
|
|
33 // Contributors: jlarmour@cygnus.co.uk |
|
|
34 // Date: 1998-02-13 |
|
|
35 // Purpose: |
|
|
36 // Description: |
|
|
37 // Usage: |
|
|
38 // |
|
|
39 //####DESCRIPTIONEND#### |
|
|
40 // |
|
|
41 //=========================================================================== |
|
|
42 |
|
|
43 // CONFIGURATION |
|
|
44 |
|
|
45 #include <pkgconf/libc.h> // Configuration header |
|
|
46 |
|
|
47 // Include the C library? And do we want the stdio stuff? |
|
|
48 #if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_STDIO) |
|
|
49 |
|
|
50 // INCLUDES |
|
|
51 |
|
|
52 // We don't want the inline versions of stdio functions defined here |
|
|
53 |
|
|
54 #ifdef CYGIMP_LIBC_STDIO_INLINES |
|
|
55 #undef CYGIMP_LIBC_STDIO_INLINES |
|
|
56 #endif |
|
|
57 |
|
|
58 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
|
|
59 #include <stddef.h> // NULL and size_t from compiler |
|
|
60 #include <stdarg.h> // va_list |
|
|
61 #include <stdio.h> // Header for this file |
|
|
62 #include <errno.h> // Definition of error codes and errno |
|
|
63 #include <string.h> // Definition of strerror() for perror() |
|
|
64 #include <limits.h> // INT_MAX |
|
|
65 #include "clibincl/stdiosupp.hxx" // Support for stdio |
|
|
66 |
|
|
67 |
|
|
68 // EXPORTED SYMBOLS |
|
|
69 |
|
|
70 externC void |
|
|
71 setbuf( FILE *, char * ) CYGPRI_LIBC_WEAK_ALIAS("_setbuf"); |
|
|
72 |
|
|
73 externC int |
|
|
74 vfprintf( FILE *, const char *, va_list ) CYGPRI_LIBC_WEAK_ALIAS("_vfprintf"); |
|
|
75 |
|
|
76 externC int |
|
|
77 vprintf( const char *, va_list ) CYGPRI_LIBC_WEAK_ALIAS("_vprintf"); |
|
|
78 |
|
|
79 externC int |
|
|
80 vsprintf( char *, const char *, va_list ) CYGPRI_LIBC_WEAK_ALIAS("_vsprintf"); |
|
|
81 |
|
|
82 externC int |
|
|
83 puts( const char *s ) CYGPRI_LIBC_WEAK_ALIAS("_puts"); |
|
|
84 |
|
|
85 externC void |
|
|
86 perror( const char * ) CYGPRI_LIBC_WEAK_ALIAS("_perror"); |
|
|
87 |
|
|
88 #ifdef CYGFUN_LIBC_STDIO_ungetc |
|
|
89 externC int |
|
|
90 vscanf( const char *, va_list ) CYGPRI_LIBC_WEAK_ALIAS("_vscanf"); |
|
|
91 #endif |
|
|
92 |
|
|
93 // FUNCTIONS |
|
|
94 |
|
|
95 //=========================================================================== |
|
|
96 |
|
|
97 // 7.9.5 File access functions |
|
|
98 |
|
|
99 externC void |
|
|
100 _setbuf( FILE *stream, char *buf ) |
|
|
101 { |
|
|
102 if (buf == NULL) |
|
|
103 _setvbuf( stream, NULL, _IOFBF, BUFSIZE ); |
|
|
104 else |
|
|
105 _setvbuf( stream, buf, _IONBF, BUFSIZE ); |
|
|
106 |
|
|
107 } // _setbuf() |
|
|
108 |
|
|
109 //=========================================================================== |
|
|
110 |
|
|
111 // 7.9.6 Formatted input/output functions |
|
|
112 |
|
|
113 |
|
|
114 externC int |
|
|
115 _vfprintf( FILE *stream, const char *format, va_list arg ) |
|
|
116 { |
|
|
117 return _vfnprintf(stream, INT_MAX, format, arg); |
|
|
118 } // _vfprintf() |
|
|
119 |
|
|
120 |
|
|
121 externC int |
|
|
122 _vprintf( const char *format, va_list arg) |
|
|
123 { |
|
|
124 return _vfnprintf( stdout, INT_MAX, format, arg ); |
|
|
125 } // _vprintf() |
|
|
126 |
|
|
127 |
|
|
128 externC int |
|
|
129 _vsprintf( char *s, const char *format, va_list arg ) |
|
|
130 { |
|
|
131 return _vsnprintf(s, INT_MAX, format, arg); |
|
|
132 } // _vsprintf() |
|
|
133 |
|
|
134 |
|
|
135 //=========================================================================== |
|
|
136 |
|
|
137 // 7.9.7 Character input/output functions |
|
|
138 |
|
|
139 externC int |
|
|
140 _puts( const char *s ) |
|
|
141 { |
|
|
142 int rc; |
|
|
143 |
|
|
144 rc = _fputs( s, stdout ); |
|
|
145 |
|
|
146 if (rc >= 0) |
|
|
147 rc = _fputc('\n', stdout ); |
|
|
148 |
|
|
149 return rc; |
|
|
150 } // _puts() |
|
|
151 |
|
|
152 |
|
|
153 //=========================================================================== |
|
|
154 |
|
|
155 // 7.9.10 Error-handling functions |
|
|
156 |
|
|
157 externC void |
|
|
158 _perror( const char *s ) |
|
|
159 { |
|
|
160 if (s && *s) |
|
|
161 _fprintf( stderr, "%s: %s\n", s, strerror(errno) ); |
|
|
162 else |
|
|
163 _fputs( strerror(errno), stderr ); |
|
|
164 |
|
|
165 } // _perror() |
|
|
166 |
|
|
167 //=========================================================================== |
|
|
168 |
|
|
169 // Other non-ANSI functions |
|
|
170 |
|
|
171 #ifdef CYGFUN_LIBC_STDIO_ungetc |
|
|
172 externC int |
|
|
173 _vscanf( const char *format, va_list arg ) |
|
|
174 { |
|
|
175 return _vfscanf( stdin, format, arg ); |
|
|
176 } // _vscanf() |
|
|
177 #endif |
|
|
178 |
|
|
179 #endif // if defined(CYGPKG_LIBC) && defined(CYGPKG_LIBC_STDIO) |
|
|
180 |
|
|
181 // EOF stdioinlines.cxx |