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 libraries 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(linux) || defined(CSRG_BASED) || defined(sun)
32 #define DEF_BUF_SIZ 4096
34 streambuf::streambuf() : _size(0), _capacity(DEF_BUF_SIZ), _alloc(1),
35 _pcount(0), _gcount(0)
37 base = (char*)malloc(DEF_BUF_SIZ);
38 end = base + DEF_BUF_SIZ;
39 get_ptr = put_ptr = base;
42 streambuf::streambuf(char* p, int l, int bufferFull) :
43 base(p), end(p+l), put_ptr(p), get_ptr(p), _size(0), _capacity(l),
44 _alloc(0), _pcount(0), _gcount(0)
51 streambuf::~streambuf()
57 int streambuf::examine()
61 if ( empty() && underflow() == EOF )
64 return (unsigned char)(*get_ptr);
71 if ( empty() && underflow() == EOF )
74 int x = (unsigned char)(*get_ptr);
85 int streambuf::putback(char c)
98 int streambuf::put(char c)
102 if ( full() && overflow() == EOF )
115 int streambuf::move_get_ptr(int one)
121 if ( get_ptr == end )
129 if ( get_ptr == base-1 )
140 int streambuf::move_put_ptr(int one)
150 if ( put_ptr == end )