2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: streambuf.C /main/8 1996/08/21 15:55:14 drk $ */
24 #include "utility/c_streambuf.h"
26 #if defined(USL) || defined(__osf__) || defined(linux) || \
27 defined(CSRG_BASED) || defined(sun)
33 #define DEF_BUF_SIZ 4096
35 streambuf::streambuf() : _size(0), _capacity(DEF_BUF_SIZ), _alloc(1),
36 _pcount(0), _gcount(0)
38 base = (char*)malloc(DEF_BUF_SIZ);
39 end = base + DEF_BUF_SIZ;
40 get_ptr = put_ptr = base;
43 streambuf::streambuf(char* p, int l, int bufferFull) :
44 base(p), end(p+l), put_ptr(p), get_ptr(p), _size(0), _capacity(l),
45 _alloc(0), _pcount(0), _gcount(0)
52 streambuf::~streambuf()
58 int streambuf::examine()
62 if ( empty() && underflow() == EOF )
65 return (unsigned char)(*get_ptr);
72 if ( empty() && underflow() == EOF )
75 int x = (unsigned char)(*get_ptr);
86 int streambuf::putback(char c)
99 int streambuf::put(char c)
103 if ( full() && overflow() == EOF )
116 int streambuf::move_get_ptr(int one)
122 if ( get_ptr == end )
130 if ( get_ptr == base-1 )
141 int streambuf::move_put_ptr(int one)
151 if ( put_ptr == end )