PageRenderTime 93ms CodeModel.GetById 23ms app.highlight 63ms RepoModel.GetById 1ms app.codeStats 0ms

/project/jni/stlport/src/_stdio_file.h

https://github.com/aichunyu/FFPlayer
C Header | 823 lines | 545 code | 157 blank | 121 comment | 34 complexity | 7052993cd85d1111b23c4ce5e6987512 MD5 | raw file
  1/*
  2 * Copyright (c) 1999
  3 * Silicon Graphics Computer Systems, Inc.
  4 *
  5 * Copyright (c) 1999
  6 * Boris Fomitchev
  7 *
  8 * This material is provided "as is", with absolutely no warranty expressed
  9 * or implied. Any use is at your own risk.
 10 *
 11 * Permission to use or copy this software for any purpose is hereby granted
 12 * without fee, provided the above notices are retained on all copies.
 13 * Permission to modify the code and to distribute modified code is granted,
 14 * provided the above notices are retained, and a notice that the code was
 15 * modified is included with the above copyright notice.
 16 *
 17 */
 18
 19
 20// WARNING: This is an internal header file, included by other C++
 21// standard library headers.  You should not attempt to use this header
 22// file directly.
 23
 24
 25#ifndef _STLP_STDIO_FILE_H
 26#define _STLP_STDIO_FILE_H
 27
 28// This file provides a low-level interface between the internal
 29// representation of struct FILE, from the C stdio library, and
 30// the C++ I/O library.  The C++ I/O library views a FILE object as
 31// a collection of three pointers: the beginning of the buffer, the
 32// current read/write position, and the end of the buffer.
 33
 34// The interface:
 35// - char* _FILE_[IO]_begin(const FILE *__f);
 36//       Returns a pointer to the beginning of the buffer.
 37// - char* _FILE_[IO]_next(const FILE *__f);
 38//       Returns the current read/write position within the buffer.
 39// - char* _FILE_[IO]_end(const FILE *__f);
 40//       Returns a pointer immediately past the end of the buffer.
 41// - char* _FILE_[IO]_avail(const FILE *__f);
 42//       Returns the number of characters remaining in the buffer, i.e.
 43//       _FILE_[IO]_end(__f) - _FILE_[IO]_next(__f).
 44// - char& _FILE_[IO]_preincr(FILE *__f)
 45//       Increments the current read/write position by 1, returning the
 46//       character at the old position.
 47// - char& _FILE_[IO]_postincr(FILE *__f)
 48//       Increments the current read/write position by 1, returning the
 49//       character at the old position.
 50// - char& _FILE_[IO]_predecr(FILE *__f)
 51//       Decrements the current read/write position by 1, returning the
 52//       character at the old position.
 53// - char& _FILE_[IO]_postdecr(FILE *__f)
 54//       Decrements the current read/write position by 1, returning the
 55//       character at the old position.
 56// - void _FILE_[IO]_bump(FILE *__f, int __n)
 57//       Increments the current read/write position by __n.
 58// - void _FILE_[IO]_set(FILE *__f, char* __begin, char* __next, char* __end);
 59//       Sets the beginning of the bufer to __begin, the current read/write
 60//       position to __next, and the buffer's past-the-end pointer to __end.
 61//       If any of those pointers is null, then all of them must be null.
 62
 63// Each function comes in two versions, one for a FILE used as an input
 64// buffer and one for a FILE used as an output buffer.  In some stdio
 65// implementations the two functions are identical, but in others they are
 66// not.
 67
 68#ifndef _STLP_CSTDIO
 69# include <cstdio>
 70#endif
 71#ifndef _STLP_CSTDDEF
 72# include <cstddef>
 73#endif
 74
 75#if defined(__MSL__) && !defined(N_PLAT_NLM)
 76# include <unix.h>  // get the definition of fileno
 77#endif
 78
 79_STLP_BEGIN_NAMESPACE
 80
 81//----------------------------------------------------------------------
 82// Implementation for eMbedded Visual C++ 3.0 and 4.2 (.NET)
 83#if defined (_STLP_WCE)
 84
 85inline int _FILE_fd(const FILE *__f) { return (int)::_fileno((FILE*)__f); }
 86
 87# undef _STLP_FILE_I_O_IDENTICAL
 88
 89// Implementation for the IRIX C library.
 90// Solaris interface looks to be identical.
 91#elif !defined(_STLP_USE_GLIBC) && \
 92    ( defined(__sgi) || \
 93      ( defined(__sun) && ! defined (_LP64) )  || \
 94      defined (__osf__) || defined(__DECCXX) || \
 95      (defined (_STLP_MSVC) && !defined (_STLP_WCE_EVC3)) || \
 96      defined (__ICL) || defined (__MINGW32__) || defined(__DJGPP) || defined (_AIX) || defined (_CRAY))
 97
 98#if defined (_STLP_MSVC) || defined (__ICL) || defined (__MINGW32__) || defined(__DJGPP)
 99typedef  char* _File_ptr_type;
100#else
101typedef  unsigned char* _File_ptr_type;
102#endif
103
104inline int   _FILE_fd(const FILE *__f) { return __f->_file; }
105inline char* _FILE_I_begin(const FILE *__f) { return (char*) __f->_base; }
106inline char* _FILE_I_next(const FILE *__f) { return (char*) __f->_ptr; }
107inline char* _FILE_I_end(const FILE *__f)
108  { return (char*) __f->_ptr + __f->_cnt; }
109
110inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_cnt; }
111
112inline char& _FILE_I_preincr(FILE *__f)
113  { --__f->_cnt; return *(char*) (++__f->_ptr); }
114inline char& _FILE_I_postincr(FILE *__f)
115  { --__f->_cnt; return *(char*) (__f->_ptr++); }
116inline char& _FILE_I_predecr(FILE *__f)
117  { ++__f->_cnt; return *(char*) (--__f->_ptr); }
118inline char& _FILE_I_postdecr(FILE *__f)
119  { ++__f->_cnt; return *(char*) (__f->_ptr--); }
120inline void  _FILE_I_bump(FILE *__f, int __n)
121  { __f->_ptr += __n; __f->_cnt -= __n; }
122
123inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
124  __f->_base = (_File_ptr_type) __begin;
125  __f->_ptr  = (_File_ptr_type) __next;
126  __f->_cnt  = __end - __next;
127}
128
129# define _STLP_FILE_I_O_IDENTICAL 1
130
131#elif defined(__EMX__)
132
133inline int   _FILE_fd(const FILE* __f) { return __f->_handle; }
134inline char* _FILE_I_begin(const FILE* __f) { return (char*) __f->_buffer; }
135inline char* _FILE_I_next(const FILE* __f) { return (char*) __f->_ptr; }
136inline char* _FILE_I_end(const FILE* __f) { return (char *) __f->_ptr + __f->_rcount; }
137inline ptrdiff_t _FILE_I_avail(const FILE* __f) { return __f->_rcount; }
138inline char& _FILE_I_preincr(FILE* __f) { --__f->_rcount; return *(char*) (++__f->_ptr); }
139inline char& _FILE_I_postincr(FILE* __f) { --__f->_rcount; return *(char*) (__f->_ptr++); }
140inline char& _FILE_I_predecr(FILE* __f) { ++__f->_rcount; return *(char*) (--__f->_ptr); }
141inline char& _FILE_I_postdecr(FILE* __f) { ++__f->_rcount; return *(char*) (__f->_ptr--); }
142inline void  _FILE_I_bump(FILE* __f, int __n) { __f->_ptr += __n; __f->_rcount -= __n; }
143inline void _FILE_I_set(FILE* __f, char* __begin, char* __next, char* __end) {
144  __f->_buffer = __begin;
145  __f->_ptr  = __next;
146  __f->_rcount  = __end - __next;
147}
148
149inline char* _FILE_O_begin(const FILE* __f) { return (char*) __f->_buffer; }
150inline char* _FILE_O_next(const FILE* __f) { return (char*) __f->_ptr; }
151inline char* _FILE_O_end(const FILE* __f) { return (char*) __f->_ptr + __f->_wcount; }
152inline ptrdiff_t _FILE_O_avail(const FILE* __f) { return __f->_wcount; }
153inline char& _FILE_O_preincr(FILE* __f) { --__f->_wcount; return *(char*) (++__f->_ptr); }
154inline char& _FILE_O_postincr(FILE* __f) { --__f->_wcount; return *(char*) (__f->_ptr++); }
155inline char& _FILE_O_predecr(FILE* __f) { ++__f->_wcount; return *(char*) (--__f->_ptr); }
156inline char& _FILE_O_postdecr(FILE* __f) { ++__f->_wcount; return *(char*) (__f->_ptr--); }
157inline void _FILE_O_bump(FILE* __f, int __n) { __f->_ptr += __n; __f->_wcount -= __n; }
158inline void _FILE_O_set(FILE* __f, char* __begin, char* __next, char* __end) {
159  __f->_buffer = __begin;
160  __f->_ptr  = __next;
161  __f->_wcount  = __end - __next;
162}
163
164
165# undef _STLP_FILE_I_O_IDENTICAL
166
167# elif defined(_STLP_SCO_OPENSERVER) || defined(__NCR_SVR)
168
169typedef  unsigned char* _File_ptr_type;
170
171inline int   _FILE_fd(const FILE *__f) { return __f->__file; }
172inline char* _FILE_I_begin(const FILE *__f) { return (char*) __f->__base; }
173inline char* _FILE_I_next(const FILE *__f) { return (char*) __f->__ptr; }
174inline char* _FILE_I_end(const FILE *__f)
175  { return (char*) __f->__ptr + __f->__cnt; }
176
177inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->__cnt; }
178
179inline char& _FILE_I_preincr(FILE *__f)
180  { --__f->__cnt; return *(char*) (++__f->__ptr); }
181inline char& _FILE_I_postincr(FILE *__f)
182  { --__f->__cnt; return *(char*) (__f->__ptr++); }
183inline char& _FILE_I_predecr(FILE *__f)
184  { ++__f->__cnt; return *(char*) (--__f->__ptr); }
185inline char& _FILE_I_postdecr(FILE *__f)
186  { ++__f->__cnt; return *(char*) (__f->__ptr--); }
187inline void  _FILE_I_bump(FILE *__f, int __n)
188  { __f->__ptr += __n; __f->__cnt -= __n; }
189
190inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
191  __f->__base = (_File_ptr_type) __begin;
192  __f->__ptr  = (_File_ptr_type) __next;
193  __f->__cnt  = __end - __next;
194}
195
196# define _STLP_FILE_I_O_IDENTICAL 1
197
198# elif defined(__sun) && defined( _LP64)
199
200typedef long _File_ptr_type;
201
202inline int _FILE_fd(const FILE *__f) { return (int) __f->__pad[2]; }
203inline char* _FILE_I_begin(const FILE *__f) { return (char*)
204__f->__pad[1]; }
205inline char* _FILE_I_next(const FILE *__f) { return (char*)
206__f->__pad[0]; }
207inline char* _FILE_I_end(const FILE *__f)
208{ return (char*) __f->__pad[0] + __f->__pad[3]; }
209
210inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->__pad[3]; }
211
212inline char& _FILE_I_preincr(FILE *__f)
213{ --__f->__pad[3]; return *(char*) (++__f->__pad[0]); }
214inline char& _FILE_I_postincr(FILE *__f)
215{ --__f->__pad[3]; return *(char*) (__f->__pad[0]++); }
216inline char& _FILE_I_predecr(FILE *__f)
217{ ++__f->__pad[3]; return *(char*) (--__f->__pad[0]); }
218inline char& _FILE_I_postdecr(FILE *__f)
219{ ++__f->__pad[3]; return *(char*) (__f->__pad[0]--); }
220inline void _FILE_I_bump(FILE *__f, long __n)
221{ __f->__pad[0] += __n; __f->__pad[3] -= __n; }
222
223inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char*
224__end) {
225__f->__pad[1] = (_File_ptr_type) __begin;
226__f->__pad[0] = (_File_ptr_type) __next;
227__f->__pad[3] = __end - __next;
228}
229
230# define _STLP_FILE_I_O_IDENTICAL
231
232#elif defined (__CYGWIN__) || defined(__FreeBSD__)  || defined(__NetBSD__) || defined(__OpenBSD__) \
233  || defined(__amigaos__) || ( defined(__GNUC__) && defined(__APPLE__) )
234
235inline int _FILE_fd(const FILE *__f) { return __f->_file; }
236inline char* _FILE_I_begin(const FILE *__f) { return (char*)   __f->_bf._base; }
237inline char* _FILE_I_next(const FILE *__f) { return (char*) __f->_p; }
238inline char* _FILE_I_end(const FILE *__f)
239{ return (char*) __f->_p + __f->_r; }
240
241inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_r; }
242
243#if ( defined(__GNUC__) && defined(__APPLE__) )
244inline char& _FILE_I_preincr(FILE *__f)
245{ --__f->_r; return *(char*) (++__f->_p); }
246inline char& _FILE_I_postincr(FILE *__f)
247{ --__f->_r; return *(char*) (__f->_p++); }
248inline char& _FILE_I_predecr(FILE *__f)
249{ ++__f->_r; return *(char*) (--__f->_p); }
250inline char& _FILE_I_postdecr(FILE *__f)
251{ ++__f->_r; return *(char*) (__f->_p--); }
252inline void _FILE_I_bump(FILE *__f, int __n)
253{ __f->_p += __n; __f->_r -= __n; }
254#else
255inline char& _FILE_I_preincr(FILE *__f)
256{ --__f->_r; --__f->_bf._size; return *(char*) (++__f->_p); }
257inline char& _FILE_I_postincr(FILE *__f)
258{ --__f->_r; --__f->_bf._size; return *(char*) (__f->_p++); }
259inline char& _FILE_I_predecr(FILE *__f)
260{ ++__f->_r; ++ __f->_bf._size; return *(char*) (--__f->_p); }
261inline char& _FILE_I_postdecr(FILE *__f)
262{ ++__f->_r; ++__f->_bf._size; return *(char*) (__f->_p--); }
263inline void _FILE_I_bump(FILE *__f, int __n)
264{ __f->_p += __n; __f->_bf._size+=__n; __f->_r -= __n; }
265#endif
266
267inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
268  __f->_bf._base = (unsigned char*) __begin;
269  __f->_p = (unsigned char*) __next;
270  __f->_r = __f->_bf._size = __end - __next;
271}
272inline char* _FILE_O_begin(const FILE *__f) { return (char*) __f->_bf._base; }
273inline char* _FILE_O_next(const FILE *__f) { return (char*) __f->_p; }
274inline char* _FILE_O_end(const FILE *__f)
275{ return (char*) __f->_p + __f->_w; }
276
277inline ptrdiff_t _FILE_O_avail(const FILE *__f) { return __f->_w; }
278
279#if ( defined(__GNUC__) && defined(__APPLE__) )
280inline char& _FILE_O_preincr(FILE *__f)
281{ --__f->_w; return *(char*) (++__f->_p); }
282inline char& _FILE_O_postincr(FILE *__f)
283{ --__f->_w; return *(char*) (__f->_p++); }
284inline char& _FILE_O_predecr(FILE *__f)
285{ ++__f->_w; return *(char*) (--__f->_p); }
286inline char& _FILE_O_postdecr(FILE *__f)
287{ ++__f->_w; return *(char*) (__f->_p--); }
288inline void _FILE_O_bump(FILE *__f, int __n)
289{ __f->_p += __n; __f->_w -= __n; }
290#else
291inline char& _FILE_O_preincr(FILE *__f)
292{ --__f->_w; --__f->_bf._size; return *(char*) (++__f->_p); }
293inline char& _FILE_O_postincr(FILE *__f)
294{ --__f->_w; --__f->_bf._size; return *(char*) (__f->_p++); }
295inline char& _FILE_O_predecr(FILE *__f)
296{ ++__f->_w; ++__f->_bf._size; return *(char*) (--__f->_p); }
297inline char& _FILE_O_postdecr(FILE *__f)
298{ ++__f->_w; ++__f->_bf._size; return *(char*) (__f->_p--); }
299inline void _FILE_O_bump(FILE *__f, int __n)
300{ __f->_p += __n; __f->_bf._size+=__n; __f->_w -= __n; }
301#endif
302
303inline void _FILE_O_set(FILE *__f, char* __begin, char* __next, char* __end) {
304  __f->_bf._base = (unsigned char*) __begin;
305  __f->_p = (unsigned char*) __next;
306  __f->_w = __f->_bf._size = __end - __next;
307}
308
309# undef _STLP_FILE_I_O_IDENTICAL
310
311#elif defined(_STLP_USE_UCLIBC) /* should be before _STLP_USE_GLIBC */
312inline int   _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE *,__f)); }
313#elif defined(ANDROID) /* should be before _STLP_USE_GLIBC */
314inline int   _FILE_fd(const FILE *__f) { return __f->_file; }
315#elif defined(_STLP_USE_GLIBC)
316
317inline int   _FILE_fd(const FILE *__f) { return __f->_fileno; }
318inline char* _FILE_I_begin(const FILE *__f) { return __f->_IO_read_base; }
319inline char* _FILE_I_next(const FILE *__f)  { return __f->_IO_read_ptr; }
320inline char* _FILE_I_end(const FILE *__f)   { return __f->_IO_read_end; }
321
322inline ptrdiff_t _FILE_I_avail(const FILE *__f)
323  { return __f->_IO_read_end - __f->_IO_read_ptr; }
324
325inline char& _FILE_I_preincr(FILE *__f)  { return *++__f->_IO_read_ptr; }
326inline char& _FILE_I_postincr(FILE *__f) { return *__f->_IO_read_ptr++; }
327inline char& _FILE_I_predecr(FILE *__f)  { return *--__f->_IO_read_ptr; }
328inline char& _FILE_I_postdecr(FILE *__f) { return *__f->_IO_read_ptr--; }
329inline void  _FILE_I_bump(FILE *__f, int __n) { __f->_IO_read_ptr += __n; }
330
331inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
332  __f->_IO_read_base = __begin;
333  __f->_IO_read_ptr  = __next;
334  __f->_IO_read_end  = __end;
335}
336
337inline char* _FILE_O_begin(const FILE *__f) { return __f->_IO_write_base; }
338inline char* _FILE_O_next(const FILE *__f)  { return __f->_IO_write_ptr; }
339inline char* _FILE_O_end(const FILE *__f)   { return __f->_IO_write_end; }
340
341inline ptrdiff_t _FILE_O_avail(const FILE *__f)
342  { return __f->_IO_write_end - __f->_IO_write_ptr; }
343
344inline char& _FILE_O_preincr(FILE *__f)  { return *++__f->_IO_write_ptr; }
345inline char& _FILE_O_postincr(FILE *__f) { return *__f->_IO_write_ptr++; }
346inline char& _FILE_O_predecr(FILE *__f)  { return *--__f->_IO_write_ptr; }
347inline char& _FILE_O_postdecr(FILE *__f) { return *__f->_IO_write_ptr--; }
348inline void  _FILE_O_bump(FILE *__f, int __n) { __f->_IO_write_ptr += __n; }
349
350inline void _FILE_O_set(FILE *__f, char* __begin, char* __next, char* __end) {
351  __f->_IO_write_base = __begin;
352  __f->_IO_write_ptr  = __next;
353  __f->_IO_write_end  = __end;
354
355}
356
357#elif defined(__hpux) /* && defined(__hppa) && defined(__HP_aCC)) */
358
359#ifndef _INCLUDE_HPUX_SOURCE
360extern "C" unsigned char *__bufendtab[];
361#  undef  _bufend
362#  define _bufend(__p) \
363     (*(((__p)->__flag & _IOEXT)  ? &(((_FILEX *)(__p))->__bufendp)      \
364             : &(__bufendtab[(__p) - __iob])))
365
366#  define _bufsiz(__p)  (_bufend(__p) - (__p)->__base)
367#endif /* _INCLUDE_HPUX_SOURCE */
368
369#if defined(_STLP_HPACC_BROKEN_BUFEND)
370#  undef  _bufend
371#  define _bufend(__p) \
372     (*(((__p)->__flag & _IOEXT)  ? &((__REINTERPRET_CAST(_FILEX*,(__p)))->__bufendp)  \
373                               : &(__bufendtab[__REINTERPRET_CAST(FILE*,(__p)) - __iob])))
374#endif
375
376inline int   _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE *,__f)); }
377inline char* _FILE_I_begin(const FILE *__f) { return (__REINTERPRET_CAST(char*, __f->__base)); }
378inline char* _FILE_I_next(const FILE *__f)  { return (__REINTERPRET_CAST(char*, __f->__ptr)); }
379inline char* _FILE_I_end(const FILE *__f)   { return (__REINTERPRET_CAST(char*, __f->__ptr +__f->__cnt)); }
380
381inline ptrdiff_t _FILE_I_avail(const FILE *__f)  { return __f->__cnt; }
382
383inline char& _FILE_I_preincr(FILE *__f)  { --__f->__cnt; return *__REINTERPRET_CAST(char*, ++__f->__ptr); }
384inline char& _FILE_I_postincr(FILE *__f) { --__f->__cnt; return *__REINTERPRET_CAST(char*, __f->__ptr++); }
385inline char& _FILE_I_predecr(FILE *__f)  { ++__f->__cnt; return *__REINTERPRET_CAST(char*,--__f->__ptr); }
386inline char& _FILE_I_postdecr(FILE *__f) { ++__f->__cnt; return *__REINTERPRET_CAST(char*,__f->__ptr--); }
387inline void  _FILE_I_bump(FILE *__f, int __n) { __f->__cnt -= __n; __f->__ptr += __n; }
388
389inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
390# if defined(__hpux)
391   if( (unsigned long) (__f - &__iob[0]) > _NFILE)
392        __f->__flag |= _IOEXT;  // used by stdio's _bufend macro and goodness knows what else...
393# endif
394  __f->__cnt  = __end - __next;
395  __f->__base = __REINTERPRET_CAST(unsigned char*, __begin);
396  __f->__ptr  = __REINTERPRET_CAST(unsigned char*, __next);
397  _bufend(__f) = __REINTERPRET_CAST(unsigned char*, __end);
398}
399
400// For HPUX stdio, input and output FILE manipulation is identical.
401
402# define _STLP_FILE_I_O_IDENTICAL
403
404#elif defined (__BORLANDC__)
405
406typedef unsigned char* _File_ptr_type;
407
408inline int _FILE_fd(const FILE *__f) { return __f->fd; }
409inline char* _FILE_I_begin(const FILE *__f) { return (char*) __f->buffer;
410}
411inline char* _FILE_I_next(const FILE *__f)
412{ return (char*)__f->curp; }
413inline char* _FILE_I_end(const FILE *__f)
414{ return (char*) __f->curp + __f->level; }
415
416inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->level; }
417
418inline char& _FILE_I_preincr(FILE *__f)
419{ --__f->level; return *(char*) (++__f->curp); }
420inline char& _FILE_I_postincr(FILE *__f)
421{ --__f->level; return *(char*) (__f->curp++); }
422inline char& _FILE_I_predecr(FILE *__f)
423{ ++__f->level; return *(char*) (--__f->curp); }
424inline char& _FILE_I_postdecr(FILE *__f)
425{ ++__f->level; return *(char*) (__f->curp--); }
426inline void _FILE_I_bump(FILE *__f, int __n)
427{ __f->curp += __n; __f->level -= __n; }
428
429inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
430  __f->buffer = (_File_ptr_type) __begin;
431  __f->curp = (_File_ptr_type) __next;
432  __f->level = __end - __next;
433}
434
435# define _STLP_FILE_I_O_IDENTICAL
436
437#elif defined( __MWERKS__ )
438
439// using MWERKS-specific defines here to detect other OS targets
440// dwa: I'm not sure they provide fileno for all OS's, but this should
441// work for Win32 and WinCE
442
443#ifndef N_PLAT_NLM
444// Hmm, at least for Novell NetWare __dest_os == __mac_os true too..
445// May be both __dest_os and __mac_os defined and empty?   - ptr
446# if __dest_os == __mac_os
447inline int   _FILE_fd(const FILE *__f) { return ::fileno(__CONST_CAST(FILE*, __f)); }
448# else
449inline int   _FILE_fd(const FILE *__f) { return ::_fileno(__CONST_CAST(FILE*, __f)); }
450# endif // __dest_os == __mac_os
451
452//       Returns a pointer to the beginning of the buffer.
453inline char* _FILE_I_begin(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->buffer); }
454//       Returns the current read/write position within the buffer.
455inline char* _FILE_I_next(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->buffer_ptr); }
456
457//       Returns a pointer immediately past the end of the buffer.
458inline char* _FILE_I_end(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->buffer_ptr + __f->buffer_len); }
459
460//       Returns the number of characters remaining in the buffer, i.e.
461//       _FILE_[IO]_end(__f) - _FILE_[IO]_next(__f).
462inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->buffer_len; }
463
464//       Increments the current read/write position by 1, returning the
465//       character at the old position.
466inline char& _FILE_I_preincr(FILE *__f)
467  { --__f->buffer_len; return *(char*) (++__f->buffer_ptr); }
468inline char& _FILE_I_postincr(FILE *__f)
469  { --__f->buffer_len; return *(char*) (__f->buffer_ptr++); }
470inline char& _FILE_I_predecr(FILE *__f)
471  { ++__f->buffer_len; return *(char*) (--__f->buffer_ptr); }
472inline char& _FILE_I_postdecr(FILE *__f)
473  { ++__f->buffer_len; return *(char*) (__f->buffer_ptr--); }
474inline void  _FILE_I_bump(FILE *__f, int __n)
475  { __f->buffer_ptr += __n; __f->buffer_len -= __n; }
476
477inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
478  __f->buffer = __REINTERPRET_CAST(unsigned char*, __begin);
479  __f->buffer_ptr   = __REINTERPRET_CAST(unsigned char*, __next);
480  __f->buffer_len  = __end - __next;
481  __f->buffer_size = __end - __begin;
482}
483#else // N_PLAT_NLM   - ptr
484inline int   _FILE_fd(const FILE *__f) { return __f->_file; }
485inline char* _FILE_I_begin(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_base); }
486//       Returns the current read/write position within the buffer.
487inline char* _FILE_I_next(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_ptr); }
488
489//       Returns a pointer immediately past the end of the buffer.
490inline char* _FILE_I_end(const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_ptr + __f->_avail); }
491
492//       Returns the number of characters remaining in the buffer, i.e.
493//       _FILE_[IO]_end(__f) - _FILE_[IO]_next(__f).
494inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_avail; }
495
496//       Increments the current read/write position by 1, returning the
497//       character at the old position.
498inline char& _FILE_I_preincr(FILE *__f)
499  { --__f->_avail; return *(char*) (++__f->_ptr); }
500inline char& _FILE_I_postincr(FILE *__f)
501  { --__f->_avail; return *(char*) (__f->_ptr++); }
502inline char& _FILE_I_predecr(FILE *__f)
503  { ++__f->_avail; return *(char*) (--__f->_ptr); }
504inline char& _FILE_I_postdecr(FILE *__f)
505  { ++__f->_avail; return *(char*) (__f->_ptr--); }
506inline void  _FILE_I_bump(FILE *__f, int __n)
507  { __f->_ptr += __n; __f->_avail -= __n; }
508
509inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
510  __f->_base  = __REINTERPRET_CAST(unsigned char*, __begin);
511  __f->_ptr   = __REINTERPRET_CAST(unsigned char*, __next);
512  __f->_avail = __end - __next;
513}
514#endif // N_PLAT_NLM
515
516
517# define _STLP_FILE_I_O_IDENTICAL
518
519#elif defined(__DMC__)
520
521inline int   _FILE_fd(const FILE *__f) { return __f->_file; }
522
523//       Returns a pointer to the beginning of the buffer.
524inline char* _FILE_I_begin(const FILE *__f) { return __f->_base; }
525
526//       Returns the current read/write position within the buffer.
527inline char* _FILE_I_next(const FILE *__f) { return __f->_ptr; }
528
529//       Returns a pointer immediately past the end of the buffer.
530inline char* _FILE_I_end(const FILE *__f) { return __f->_ptr + __f->_cnt; }
531
532//       Returns the number of characters remaining in the buffer, i.e.
533//       _FILE_[IO]_end(__f) - _FILE_[IO]_next(__f).
534inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_cnt; }
535
536//       Increments the current read/write position by 1, returning the
537//       character at the NEW position.
538inline char& _FILE_I_preincr(FILE *__f) { --__f->_cnt; return *(++__f->_ptr); }
539
540
541//       Increments the current read/write position by 1, returning the
542//       character at the old position.
543inline char& _FILE_I_postincr(FILE *__f) { --__f->_cnt; return *(__f->_ptr++); }
544
545//       Decrements the current read/write position by 1, returning the
546//       character at the NEW position.
547inline char& _FILE_I_predecr(FILE *__f) { ++__f->_cnt; return *(--__f->_ptr); }
548
549//       Decrements the current read/write position by 1, returning the
550//       character at the old position.
551inline char& _FILE_I_postdecr(FILE *__f) { ++__f->_cnt; return *(__f->_ptr--); }
552
553//       Increments the current read/write position by __n.
554inline void _FILE_I_bump(FILE *__f, int __n) { __f->_cnt -= __n; __f->_ptr += __n; }
555
556//       Sets the beginning of the bufer to __begin, the current read/write
557//       position to __next, and the buffer's past-the-end pointer to __end.
558//       If any of those pointers is null, then all of them must be null.
559inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end)
560{
561  __f->_base = __begin;
562  __f->_ptr = __next;
563  __f->_cnt = __end - __next;
564  __f->_bufsiz = __end - __begin;
565}
566
567# define _STLP_FILE_I_O_IDENTICAL
568
569#elif defined(__MRC__) || defined(__SC__)    //*TY 02/24/2000 - added support for MPW
570
571inline int   _FILE_fd(const FILE *__f) { return __f->_file; }
572
573//       Returns a pointer to the beginning of the buffer.
574inline char* _FILE_I_begin(const FILE *__f) { return (char*) __f->_base; }
575
576//       Returns the current read/write position within the buffer.
577inline char* _FILE_I_next(const FILE *__f) { return (char*) __f->_ptr; }
578
579//       Returns a pointer immediately past the end of the buffer.
580inline char* _FILE_I_end(const FILE *__f) { return (char*)__f->_end; }
581
582//       Returns the number of characters remaining in the buffer, i.e.
583//       _FILE_[IO]_end(__f) - _FILE_[IO]_next(__f).
584inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_cnt; }
585
586//       Increments the current read/write position by 1, returning the
587//       character at the NEW position.
588inline char& _FILE_I_preincr(FILE *__f) { --__f->_cnt; return*(char*) (++__f->_ptr); }
589
590
591//       Increments the current read/write position by 1, returning the
592//       character at the old position.
593inline char& _FILE_I_postincr(FILE *__f) { --__f->_cnt; return*(char*) (__f->_ptr++); }
594
595//       Decrements the current read/write position by 1, returning the
596//       character at the NEW position.
597inline char& _FILE_I_predecr(FILE *__f) { ++__f->_cnt; return*(char*) (--__f->_ptr); }
598
599//       Decrements the current read/write position by 1, returning the
600//       character at the old position.
601inline char& _FILE_I_postdecr(FILE *__f) { ++__f->_cnt; return*(char*) (__f->_ptr--); }
602
603//       Increments the current read/write position by __n.
604inline void _FILE_I_bump(FILE *__f, int __n) { __f->_cnt -= __n; __f->_ptr += __n; }
605
606//       Sets the beginning of the bufer to __begin, the current read/write
607//       position to __next, and the buffer's past-the-end pointer to __end.
608//       If any of those pointers is null, then all of them must be null.
609inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end)
610{
611  __f->_base = (unsigned char*)__begin;
612  __f->_ptr  = (unsigned char*)__next;
613  __f->_end  = (unsigned char*)__end;
614  __f->_cnt  = __end - __next;
615  __f->_size = __end - __begin;
616}
617
618# define _STLP_FILE_I_O_IDENTICAL
619
620#elif defined (__MVS__)
621
622typedef unsigned char* _File_ptr_type;
623
624inline int _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE
625                  *,__f)); }
626inline char* _FILE_I_begin(const FILE *__f) { return (char*)
627            __f->__fp->__bufPtr; }
628inline char* _FILE_I_next(const FILE *__f) { return (char*)
629                 __f->__fp->__bufPtr; }
630inline char* _FILE_I_end(const FILE *__f)
631{ return (char*) __f->__fp->__bufPtr + __f->__fp->__countIn; }
632
633inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return
634                __f->__fp->__countIn; }
635
636inline char& _FILE_I_preincr(FILE *__f)
637{ --__f->__fp->__countIn; return *(char*) (++__f->__fp->__bufPtr); }
638inline char& _FILE_I_postincr(FILE *__f)
639{ --__f->__fp->__countIn; return *(char*) (__f->__fp->__bufPtr++); }
640inline char& _FILE_I_predecr(FILE *__f)
641{ ++__f->__fp->__countIn; return *(char*) (--__f->__fp->__bufPtr); }
642inline char& _FILE_I_postdecr(FILE *__f)
643{ ++__f->__fp->__countIn; return *(char*) (__f->__fp->__bufPtr--); }
644inline void _FILE_I_bump(FILE *__f, int __n)
645{ __f->__fp->__bufPtr += __n; __f->__fp->__countIn -= __n; }
646
647inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char*
648      __end) {
649  // __f->_base = (_File_ptr_type) __begin;
650  if(__f->__fp) {
651    __f->__fp->__bufPtr = (_File_ptr_type) __next;
652    __f->__fp->__countIn = __end - __next;
653  }
654}
655
656inline char* _FILE_O_begin(const FILE *__f) { return (char*)__f->__fp->__bufPtr;}
657inline char* _FILE_O_next(const FILE *__f) { return (char*) __f->__fp->__bufPtr;}
658inline char* _FILE_O_end(const FILE *__f) { return (char*) __f->__fp->__bufPtr + __f->__fp->__countOut; }
659inline ptrdiff_t _FILE_O_avail(const FILE *__f) { return __f->__fp->__countOut; }
660
661inline char& _FILE_O_preincr(FILE *__f)
662{ --__f->__fp->__countOut; return *(char*) (++__f->__fp->__bufPtr); }
663inline char& _FILE_O_postincr(FILE *__f)
664{ --__f->__fp->__countOut; return *(char*) (__f->__fp->__bufPtr++); }
665inline char& _FILE_O_predecr(FILE *__f)
666{ ++__f->__fp->__countOut; return *(char*) (--__f->__fp->__bufPtr); }
667inline char& _FILE_O_postdecr(FILE *__f)
668{ ++__f->__fp->__countOut; return *(char*) (__f->__fp->__bufPtr--); }
669inline void _FILE_O_bump(FILE *__f, int __n)
670{ __f->__fp->__bufPtr += __n; __f->__fp->__countOut -= __n; }
671
672inline void _FILE_O_set(FILE *__f, char* __begin, char* __next, char*
673      __end) {
674  // __f->_base = (_File_ptr_type) __begin;
675  if(__f->__fp) {
676    __f->__fp->__bufPtr = (_File_ptr_type) __next;
677    __f->__fp->__countOut = __end - __next;
678  }
679}
680
681#elif defined(__QNXNTO__)
682
683inline int _FILE_fd(const FILE *__f) { return __f->_handle;
684}
685inline char* _FILE_I_begin(const FILE *__f) { return
686                                                (char*) __f->_base; }
687inline char* _FILE_I_next(const FILE *__f) { return
688                                               (char*) __f->_ptr; }
689inline char* _FILE_I_end(const FILE *__f)
690{ return (char*) __f->_ptr + __f->_cnt; }
691
692inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return
693                                                    __f->_cnt; }
694
695inline char& _FILE_I_preincr(FILE *__f)
696{ --__f->_cnt; return *(char*) (++__f->_ptr); }
697inline char& _FILE_I_postincr(FILE *__f)
698{ --__f->_cnt; return *(char*) (__f->_ptr++); }
699inline char& _FILE_I_predecr(FILE *__f)
700{ ++__f->_cnt; return *(char*) (--__f->_ptr); }
701inline char& _FILE_I_postdecr(FILE *__f)
702{ ++__f->_cnt; return *(char*) (__f->_ptr--); }
703inline void _FILE_I_bump(FILE *__f, int __n)
704{ __f->_ptr += __n; __f->_cnt -= __n; }
705
706inline void _FILE_I_set(FILE *__f, char* __begin, char*
707                        __next, char*
708                        __end) {
709  __f->_base = (unsigned char*) __begin;
710  __f->_ptr = (unsigned char*) __next;
711  __f->_cnt = __end - __next;
712}
713
714# define _STLP_FILE_I_O_IDENTICAL
715
716#elif defined(__WATCOMC__)                   // Nikolaev
717
718inline int       _FILE_fd      (const FILE *__f) { return __f->_handle;}
719inline char*     _FILE_I_begin (const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_link); }
720inline char*     _FILE_I_next  (const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_ptr); }
721inline char*     _FILE_I_end   (const FILE *__f) { return __REINTERPRET_CAST(char*, __f->_ptr + __f->_cnt); }
722inline ptrdiff_t _FILE_I_avail (const FILE *__f) { return __f->_cnt; }
723
724inline char& _FILE_I_preincr(FILE *__f)
725{
726  --__f->_cnt;
727  return *__REINTERPRET_CAST(char*, ++__f->_ptr);
728}
729
730inline char& _FILE_I_postincr(FILE *__f)
731{
732  --__f->_cnt;
733  return *__REINTERPRET_CAST(char*, __f->_ptr++);
734}
735
736inline char& _FILE_I_predecr(FILE *__f)
737{
738  ++__f->_cnt;
739  return *__REINTERPRET_CAST(char*, --__f->_ptr);
740}
741
742inline char& _FILE_I_postdecr(FILE *__f)
743{
744  ++__f->_cnt;
745  return *__REINTERPRET_CAST(char*, __f->_ptr--);
746}
747
748inline void _FILE_I_bump(FILE *__f, int __n)
749{
750  __f->_ptr += __n;
751  __f->_cnt -= __n;
752}
753
754inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end)
755{
756  __f->_link = __REINTERPRET_CAST(__stream_link*, __begin);
757  __f->_ptr  = __REINTERPRET_CAST(unsigned char*, __next);
758  __f->_cnt  = __end - __next;
759}
760
761# define _STLP_FILE_I_O_IDENTICAL
762
763#elif defined (__Lynx__)
764
765// the prototypes are taken from LynxOS patch for STLport 4.0
766inline int   _FILE_fd(const FILE *__f) { return __f->_fd; }
767inline char* _FILE_I_begin(const FILE *__f) { return (char*) __f->_base; }
768inline char* _FILE_I_next(const FILE *__f) { return (char*) __f->_ptr; }
769inline char* _FILE_I_end(const FILE *__f)
770  { return (char*) __f->_ptr + __f->_cnt; }
771
772inline ptrdiff_t _FILE_I_avail(const FILE *__f) { return __f->_cnt; }
773
774inline char& _FILE_I_preincr(FILE *__f)
775  { --__f->_cnt; return *(char*) (++__f->_ptr); }
776inline char& _FILE_I_postincr(FILE *__f)
777  { --__f->_cnt; return *(char*) (__f->_ptr++); }
778inline char& _FILE_I_predecr(FILE *__f)
779   { ++__f->_cnt; return *(char*) (--__f->_ptr); }
780inline char& _FILE_I_postdecr(FILE *__f)
781  { ++__f->_cnt; return *(char*) (__f->_ptr--); }
782inline void  _FILE_I_bump(FILE *__f, int __n)
783  { __f->_ptr += __n; __f->_cnt -= __n; }
784
785inline void _FILE_I_set(FILE *__f, char* __begin, char* __next, char* __end) {
786  __f->_base = __begin;
787  __f->_ptr  = __next;
788  __f->_cnt  = __end - __next;
789}
790# define _STLP_FILE_I_O_IDENTICAL
791
792#else  /* A C library that we don't have an implementation for. */
793
794# error The C++ I/O library is not configured for this compiler
795
796#endif
797
798
799// For most stdio's , input and output FILE manipulation is identical.
800# ifdef _STLP_FILE_I_O_IDENTICAL
801inline char* _FILE_O_begin(const FILE *__f) { return _FILE_I_begin(__f); }
802inline char* _FILE_O_next(const FILE *__f)  { return _FILE_I_next(__f); }
803inline char* _FILE_O_end(const FILE *__f)   { return _FILE_I_end(__f); }
804
805inline ptrdiff_t _FILE_O_avail(const FILE *__f) { return _FILE_I_avail(__f); }
806
807inline char& _FILE_O_preincr(FILE *__f)  { return _FILE_I_preincr(__f); }
808inline char& _FILE_O_postincr(FILE *__f) { return _FILE_I_postincr(__f); }
809inline char& _FILE_O_predecr(FILE *__f)  { return _FILE_I_predecr(__f); }
810inline char& _FILE_O_postdecr(FILE *__f) { return _FILE_I_postdecr(__f); }
811
812inline void  _FILE_O_bump(FILE *__f, int __n) { _FILE_I_bump(__f, __n); }
813inline void _FILE_O_set(FILE *__f, char* __begin, char* __next, char* __end)
814  { _FILE_I_set(__f, __begin, __next, __end); }
815# endif
816
817_STLP_END_NAMESPACE
818
819#endif /* _STLP_STDIO_FILE_H */
820
821// Local Variables:
822// mode:C++
823// End: