source: trunk/include/incl_vac/stdio.h@ 21916

Last change on this file since 21916 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 13.3 KB
Line 
1#if (defined(__IBMC__) || defined(__IBMCPP__))
2#pragma info( none )
3#ifndef __CHKHDR__
4 #pragma info( none )
5#endif
6#pragma info( restore )
7#endif
8
9#ifndef __stdio_h
10 #define __stdio_h
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #ifndef _LNK_CONV
17 #ifdef _M_I386
18 #define _LNK_CONV _Optlink
19 #else
20 #define _LNK_CONV
21 #endif
22 #endif
23
24 #ifndef _IMPORT
25 #ifdef __IMPORTLIB__
26 #define _IMPORT _Import
27 #else
28 #define _IMPORT
29 #endif
30 #endif
31
32 /********************************************************************/
33 /* <stdio.h> header file */
34 /* */
35 /* IBM VisualAge C++ for OS/2, Version 3.00 */
36 /* (C) Copyright IBM Corp. 1991, 1995. */
37 /* - Licensed Material - Program-Property of IBM */
38 /* - All rights reserved */
39 /* */
40 /********************************************************************/
41
42 #ifndef __size_t
43 #define __size_t
44 typedef unsigned int size_t;
45 #endif
46
47 enum _OPERATIONS { _IOINIT, _IOREAD, _IOWRITE, _IOREPOSITION,
48 _IOFLUSH, _IOUNDEFOP };
49
50 #define _MAX_UNGET 2
51
52 #if (defined(__IBMC__) || defined(__IBMCPP__))
53 #pragma pack( 1 )
54 typedef struct __file /* visible portion of the FILE struct */
55 {
56 unsigned char *_bufPtr;
57 unsigned long int _count;
58 unsigned long int _userFlags;
59 unsigned long int _bufLen;
60 unsigned long int _ungetCount;
61 int _tempStore;
62 unsigned char _ungetBuf[_MAX_UNGET];
63 enum _OPERATIONS _lastOp;
64 char _filler;
65 } FILE;
66 #pragma pack( )
67 #else
68 typedef struct __file /* visible portion of the FILE struct */
69 {
70 unsigned char *_bufPtr;
71 unsigned long int _count;
72 unsigned long int _userFlags;
73 unsigned long int _bufLen;
74 unsigned long int _ungetCount;
75 int _tempStore;
76 enum _OPERATIONS _lastOp;
77 unsigned char _ungetBuf[_MAX_UNGET];
78 char _filler;
79 } FILE;
80 #endif
81
82 typedef struct __fpos_t /* Definition of file positioning structure */
83 {
84 long int __fpos_elem[2];
85 } fpos_t;
86
87 #ifndef NULL
88 #if (defined(__EXTENDED__) || defined( __cplusplus ))
89 #define NULL 0
90 #else
91 #define NULL ((void *)0)
92 #endif
93 #endif
94
95 #define _IOFBF 1 /* Buffer modes */
96 #define _IOLBF 2
97 #define _IONBF 3
98 #define BUFSIZ 4096 /* Default buffer size */
99 #define EOF (-1)
100 #define L_tmpnam 260 /* Maximum length of temporary names */
101 #define FOPEN_MAX 20 /* Minimum number of open files guaranteed */
102 #define FILENAME_MAX 260 /* Maximum file name length */
103 #define SEEK_SET 0 /* fseek constants */
104 #define SEEK_CUR 1
105 #define SEEK_END 2
106 #define TMP_MAX 100000 /* Maximum guaranteed unique file names */
107
108 #define _IOEOF 0x0001 /* EOF flag mask */
109 #define _IOERR 0x0002 /* ERR flag mask */
110
111#ifdef _M_I386
112 typedef char *__va_list;
113#endif
114
115#ifdef __THW_PPC__
116 #include <stdarg.h>
117#endif
118
119 /* Standard stream pointers. */
120
121 extern FILE * const _IMPORT stdin;
122 extern FILE * const _IMPORT stdout;
123 extern FILE * const _IMPORT stderr;
124
125 #define stdin stdin
126 #define stdout stdout
127 #define stderr stderr
128
129 /* Function declarations. */
130
131 #ifndef CRTWRAP
132 #define CRTWRAP(a) odin_##a
133 #endif
134#ifndef ORIGINAL_VAC_FUNCTIONS
135//// #define fprintf CRTWRAP(fprintf)
136 #define fscanf CRTWRAP(fscanf)
137//// #define printf CRTWRAP(printf)
138 #define scanf CRTWRAP(scanf)
139//// #define sprintf CRTWRAP(sprintf)
140//// #define sscanf CRTWRAP(sscanf)
141 #define clearerr CRTWRAP(clearerr)
142 #define fclose CRTWRAP(fclose)
143 #define fdopen CRTWRAP(fdopen)
144 #define feof CRTWRAP(feof)
145 #define ferror CRTWRAP(ferror)
146 #define fflush CRTWRAP(fflush)
147 #define fgetc CRTWRAP(fgetc)
148 #define fgetpos CRTWRAP(fgetpos)
149 #define fgets CRTWRAP(fgets)
150 #define fopen CRTWRAP(fopen)
151 #define fputc CRTWRAP(fputc)
152 #define fputs CRTWRAP(fputs)
153 #define fread CRTWRAP(fread)
154 #define freopen CRTWRAP(freopen)
155 #define fseek CRTWRAP(fseek)
156 #define fsetpos CRTWRAP(fsetpos)
157 #define ftell CRTWRAP(ftell)
158 #define fwrite CRTWRAP(fwrite)
159 #define getc CRTWRAP(getc)
160 #define getchar CRTWRAP(getchar)
161 #define gets CRTWRAP(gets)
162 #define perror CRTWRAP(perror)
163 #define putc CRTWRAP(putc)
164 #define putchar CRTWRAP(putchar)
165 #define puts CRTWRAP(puts)
166 #define remove CRTWRAP(remove)
167 #define rename CRTWRAP(rename)
168 #define rewind CRTWRAP(rewind)
169 #define setbuf CRTWRAP(setbuf)
170 #define setvbuf CRTWRAP(setvbuf)
171 #define tmpfile CRTWRAP(tmpfile)
172 #define tmpnam CRTWRAP(tmpnam)
173 #define ungetc CRTWRAP(ungetc)
174 #define vfprintf CRTWRAP(vfprintf)
175 #define vprintf CRTWRAP(vprintf)
176//// #define vsprintf CRTWRAP(vsprintf)
177#endif
178
179 int _IMPORT _LNK_CONV fprintf( FILE *, const char *, ... );
180 int _IMPORT _LNK_CONV fscanf( FILE *, const char *, ... );
181 int _IMPORT _LNK_CONV printf( const char *, ... );
182 int _IMPORT _LNK_CONV scanf( const char *, ... );
183 int _IMPORT _LNK_CONV sprintf( char *, const char *, ... );
184 int _IMPORT _LNK_CONV sscanf( const char *, const char *, ... );
185 void _IMPORT _LNK_CONV clearerr( FILE * );
186 int _IMPORT _LNK_CONV fclose( FILE * );
187 int _IMPORT _LNK_CONV feof( FILE * );
188 int _IMPORT _LNK_CONV ferror( FILE * );
189 int _IMPORT _LNK_CONV fflush( FILE * );
190 int _IMPORT _LNK_CONV fgetc( FILE * );
191 int _IMPORT _LNK_CONV fgetpos( FILE *, fpos_t * );
192 char * _IMPORT _LNK_CONV fgets( char *, int, FILE * );
193 FILE * _IMPORT _LNK_CONV fopen( const char *, const char * );
194 int _IMPORT _LNK_CONV fputc( int, FILE * );
195 int _IMPORT _LNK_CONV fputs( const char *, FILE * );
196 size_t _IMPORT _LNK_CONV fread( void *, size_t, size_t, FILE * );
197 FILE * _IMPORT _LNK_CONV freopen( const char *, const char *, FILE * );
198 int _IMPORT _LNK_CONV fseek( FILE *, long int, int );
199 int _IMPORT _LNK_CONV fsetpos( FILE *, const fpos_t * );
200 long int _IMPORT _LNK_CONV ftell( FILE * );
201 size_t _IMPORT _LNK_CONV fwrite( const void *, size_t, size_t, FILE * );
202 int _LNK_CONV getc( FILE * );
203 int _LNK_CONV getchar( void );
204 char * _IMPORT _LNK_CONV gets( char * );
205 void _IMPORT _LNK_CONV perror( const char * );
206 int _LNK_CONV putc( int, FILE * );
207 int _LNK_CONV putchar( int );
208 int _IMPORT _LNK_CONV puts( const char * );
209 int _IMPORT _LNK_CONV remove( const char * );
210 int _IMPORT _LNK_CONV rename( const char *, const char * );
211 void _IMPORT _LNK_CONV rewind( FILE * );
212 void _IMPORT _LNK_CONV setbuf( FILE *, char * );
213 int _IMPORT _LNK_CONV setvbuf( FILE *, char *, int, size_t );
214 FILE * _IMPORT _LNK_CONV tmpfile( void );
215 char * _IMPORT _LNK_CONV tmpnam( char * );
216 int _IMPORT _LNK_CONV ungetc( int, FILE * );
217 int _IMPORT _LNK_CONV vfprintf( FILE *, const char *, __va_list );
218 int _IMPORT _LNK_CONV vprintf( const char *, __va_list );
219 int _IMPORT _LNK_CONV vsprintf( char *, const char *, __va_list );
220
221 #define __getc(p) ( \
222 ( ((p)->_ungetCount==0) && ((p)->_count!=0))? \
223 (--(p)->_count, (int)(*(p)->_bufPtr++)) :\
224 fgetc((p)) )
225
226 #define __putc(c, p) ( \
227 ((((p)->_tempStore = (c)) != '\n') && \
228 ((p)->_lastOp == _IOWRITE) && ((p)->_count < (p)->_bufLen)) ? \
229 (++(p)->_count, *(p)->_bufPtr++ = (p)->_tempStore): \
230 fputc((p)->_tempStore,(p)) )
231
232 #ifndef __MULTI__
233 #ifdef __cplusplus
234 inline int getc( FILE * p ) { return __getc( p ); }
235 inline int putc( int c, FILE * p ) { return __putc( c, p ); }
236 #else
237 #define getc( p ) __getc( (p) )
238 #define putc( c, p ) __putc( (c), (p) )
239 #endif
240 #else
241 #ifdef __cplusplus
242 inline int getc( FILE * p ) { return fgetc( p ); }
243 inline int putc( int c, FILE * p ) { return fputc( c, p ); }
244 #else
245#ifndef ORIGINAL_VAC_FUNCTIONS
246 #undef getc
247 #undef putc
248#endif
249 #define getc( p ) fgetc( (p) )
250 #define putc( c, p ) fputc( (c), (p) )
251 #endif
252 #endif
253
254 #ifdef __cplusplus
255 inline int getchar( void ) { return getc( stdin ); }
256 inline int putchar( int c ) { return putc( c, stdout ); }
257 #else
258#ifndef ORIGINAL_VAC_FUNCTIONS
259 #undef getchar
260 #undef putchar
261#endif
262 #define getchar( ) getc( stdin )
263 #define putchar( c ) putc( (c), stdout )
264 #endif
265
266 /* clearerr, feof, and ferror macros - single threaded only */
267
268 #ifndef __MULTI__
269 #define clearerr( stream ) ( ( void )( (stream)->_userFlags = 0L ) )
270 #define feof( stream ) ( ( int )( (stream)->_userFlags & _IOEOF ) )
271 #define ferror( stream ) ( ( int )( (stream)->_userFlags & _IOERR ) )
272 #endif
273
274 #if (defined(__EXTENDED__) || defined( __cplusplus ))
275
276 #define _IO_WRITETHRU 0x0004 /* WRITETHRU mask */
277
278 #if (defined(__IBMC__) || defined(__IBMCPP__))
279 #if defined(_M_I386) || !defined(NO_PROTOTYPE)
280 #pragma map( fprintf, "_fprintfieee" )
281 #pragma map( printf , "_printfieee" )
282 #pragma map( sprintf, "_sprintfieee" )
283 #pragma map( fscanf , "_fscanfieee" )
284 #pragma map( scanf , "_scanfieee" )
285 #pragma map( sscanf , "_sscanfieee" )
286 #endif
287
288 #pragma map( vfprintf, "_vfprintfieee" )
289 #pragma map( vprintf , "_vprintfieee" )
290 #pragma map( vsprintf, "_vsprintfieee" )
291 #else
292 #ifndef NO_PROTOTYPE
293 #pragma Alias( fprintf, "_fprintfieee" )
294 #pragma Alias( printf , "_printfieee" )
295 #pragma Alias( sprintf, "_sprintfieee" )
296 #pragma Alias( fscanf , "_fscanfieee" )
297 #pragma Alias( scanf , "_scanfieee" )
298 #pragma Alias( sscanf , "_sscanfieee" )
299 #endif
300
301 #pragma Alias( vfprintf, "_vfprintfieee" )
302 #pragma Alias( vprintf , "_vprintfieee" )
303 #pragma Alias( vsprintf, "_vsprintfieee" )
304 #endif
305
306 int _LNK_CONV _fcloseall( void );
307 int _LNK_CONV _rmtmp( void );
308
309 #define P_tmpdir "\\"
310 FILE * _LNK_CONV fdopen( int, const char *);
311 int _LNK_CONV fgetchar( void );
312 int _LNK_CONV fileno( FILE * );
313 int _LNK_CONV flushall( void );
314 int _LNK_CONV fputchar( int );
315 char * _LNK_CONV tempnam( char *, char * );
316 int _LNK_CONV unlink( const char * );
317
318 FILE * _LNK_CONV _fdopen( int, const char *);
319 int _LNK_CONV _fgetchar( void );
320 int _LNK_CONV _fileno( FILE * );
321 int _LNK_CONV _flushall( void );
322 int _LNK_CONV _fputchar( int );
323 char * _LNK_CONV _tempnam( char *, char * );
324 int _LNK_CONV _unlink( const char * );
325
326 int _LNK_CONV _set_crt_msg_handle( int );
327
328 #if (defined(__IBMC__) || defined(__IBMCPP__))
329 /*RLW - this ensures fdopen() will be remapped to odin_fdopen()
330 except when we explicitly want the unwrapped version */
331 #ifdef ORIGINAL_VAC_FUNCTIONS
332 #pragma map( fdopen , "_fdopen" )
333 #endif
334 #pragma map( fgetchar, "_fgetchar" )
335 #pragma map( fileno , "_fileno" )
336 #pragma map( flushall, "_flushall" )
337 #pragma map( fputchar, "_fputchar" )
338 #pragma map( tempnam , "_tempnam" )
339 #ifndef __unlink
340 #define __unlink
341 #pragma map( unlink , "_unlink" )
342 #endif
343 #else
344 #pragma Alias( fdopen , "_fdopen" )
345 #pragma Alias( fgetchar, "_fgetchar" )
346 #pragma Alias( fileno , "_fileno" )
347 #pragma Alias( flushall, "_flushall" )
348 #pragma Alias( fputchar, "_fputchar" )
349 #pragma Alias( tempnam , "_tempnam" )
350 #ifndef __unlink
351 #define __unlink
352 #pragma Alias( unlink , "_unlink" )
353 #endif
354 #endif
355
356 #else
357
358 #if defined(__IBMC__) || defined(__IBMCPP__)
359 #if defined(_M_I386) || !defined(NO_PROTOTYPE)
360 #pragma map( fprintf, "_fprintf_ansi" )
361 #pragma map( printf , "_printf_ansi" )
362 #pragma map( sprintf, "_sprintf_ansi" )
363 #pragma map( fscanf , "_fscanf_ansi" )
364 #pragma map( scanf , "_scanf_ansi" )
365 #pragma map( sscanf , "_sscanf_ansi" )
366 #endif
367 #else
368 #ifndef NO_PROTOTYPE
369 #pragma Alias( fprintf, "_fprintf_ansi" )
370 #pragma Alias( printf , "_printf_ansi" )
371 #pragma Alias( sprintf, "_sprintf_ansi" )
372 #pragma Alias( fscanf , "_fscanf_ansi" )
373 #pragma Alias( scanf , "_scanf_ansi" )
374 #pragma Alias( sscanf , "_sscanf_ansi" )
375 #endif
376 #endif
377
378 #endif
379
380 #ifdef __cplusplus
381 }
382 #endif
383
384#endif
385
386#if (defined(__IBMC__) || defined(__IBMCPP__))
387#pragma info( none )
388#ifndef __CHKHDR__
389 #pragma info( restore )
390#endif
391#pragma info( restore )
392#endif
Note: See TracBrowser for help on using the repository browser.