From d2fafbffad77a0f94fa1f435774544c0702111cc Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Tue, 12 Dec 2000 23:24:16 +0000 Subject: [PATCH] more new stuff --- dtool/src/dtoolutil/pfstreamBuf.cxx | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 dtool/src/dtoolutil/pfstreamBuf.cxx diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx new file mode 100644 index 0000000000..cba92f109d --- /dev/null +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -0,0 +1,54 @@ +// Filename: pfstreamBuf.cxx +// Created by: cary (12Dec00) +// +//////////////////////////////////////////////////////////////////// + +#include "pfstreamBuf.h" + +#ifndef HAVE_STREAMSIZE +// Some compilers (notably SGI) don't define this for us +typedef int streamsize; +#endif /* HAVE_STREAMSIZE */ + +PipeStreamBuf::PipeStreamBuf(void) { +#ifndef WIN32_VC + // taken from Dr. Ose. + // These lines, which are essential on Irix and Linux, seem to be + // unnecessary and not understood on Windows. + allocate(); + setp(base(), ebuf()); +#endif /* WIN32_VC */ +} + +PipeStreamBuf::~PipeStreamBuf(void) { + sync(); + // any other cleanup needed (pclose, etc) +} + +void PipeStreamBuf::flush(void) { + // if there's anything to do here +} + +int PipeStreamBuf::overflow(int c) { + streamsize n = pptr() - pbase(); + if (n != 0) { + write_chars(pbase(), n, false); + pbump(-n); // reset pptr() + } + if (c != EOF) { + // write one more character + char ch = c; + write_chars(&ch, 1, false); + } + return 0; +} + +int PipeStreamBuf::sync(void) { + streamsize n = pptr() - pbase(); + write_chars(pbase(), n, false); + pbump(-n); + return 0; +} + +int PipeStreamBuf::underflow(void) { +}