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