Fresco/Prague/src/Filter bzbuf.cc,1.3,1.4 xdrbuf.cc,1.3,1.4
Stefan Seefeld <[email protected]> Mon, 14 Jul 2003 22:50:46 -0500
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Prague/src/Filter In directory purcel:/tmp/cvs-serv9086/Prague/src/Filter Modified Files: bzbuf.cc xdrbuf.cc Log Message: little compatibility fixes Index: bzbuf.cc =================================================================== RCS file: /cvs/fresco/Fresco/Prague/src/Filter/bzbuf.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bzbuf.cc 23 Sep 2000 21:18:36 -0000 1.3 +++ bzbuf.cc 15 Jul 2003 03:50:44 -0000 1.4 @@ -1,8 +1,8 @@ /*$Id$ * - * This source file is a part of the Berlin Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> - * http://www.berlin-consortium.org + * This source file is a part of the Fresco Project. + * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * http://www.fresco.org * * this file defines a C++ interface to zlib * written by Kevin Ruland <[email protected]> @@ -27,23 +27,23 @@ using namespace Prague; -bzbuf::bzbuf(streambuf *b, int mode) - : comp(new char_type [BUFSIZ]), back(b) +bzbuf::bzbuf(std::streambuf *b, int mode) + : my_comp(new char_type [BUFSIZ]), my_back(b) { - char_type *buf = new char_type [BUFSIZ]; - if (mode & ios::in) + char_type *buf = new char_type[BUFSIZ]; + if (mode & std::ios::in) { setg (buf, buf + BUFSIZ, buf + BUFSIZ); - next_in = comp; + next_in = my_comp; avail_in = BUFSIZ; - pout = eback(); + my_pout = eback(); } - else if (mode & ios::out) + else if (mode & std::ios::out) { setp (buf, buf + BUFSIZ); - next_out = comp; + next_out = my_comp; avail_out = BUFSIZ; - pout = pbase(); + my_pout = pbase(); } bzalloc = 0; bzfree = 0; @@ -52,10 +52,10 @@ int verbosity = 4; int workFactor = 30; int small = 0; - if (mode &= ios::out) - int ret = bzCompressInit (this, blocksize, verbosity, workFactor); + if (mode &= std::ios::out) + int ret = BZ2_bzCompressInit(this, blocksize, verbosity, workFactor); else - int ret = bzDecompressInit (this, verbosity, small); + int ret = BZ2_bzDecompressInit(this, verbosity, small); } bzbuf::~bzbuf() @@ -66,45 +66,45 @@ bool done; do { - done = bzCompress(this, BZ_FINISH) == BZ_STREAM_END; - if (avail_out) pout = next_out; + done = BZ2_bzCompress(this, BZ_FINISH) == BZ_STREAM_END; + if (avail_out) my_pout = next_out; else { - pout = next_out = cbase(); + my_pout = next_out = cbase(); avail_out = BUFSIZ; } - streamsize l = next_out - cout();//comp + BUFSIZ - next_out; - if (l) l = back->sputn(cout(), l), ::cout << "writing " << l << " bytes " << endl; + std::streamsize l = next_out - cout();//comp + BUFSIZ - next_out; + if (l) l = my_back->sputn(cout(), l); next_out -= l; avail_out += l; } while (!done); - bzCompressEnd(this); + BZ2_bzCompressEnd(this); delete [] pbase(); } else delete [] eback(); - delete [] comp; - back->sync(); + delete [] my_comp; + my_back->pubsync(); } int bzbuf::sync() { if (pptr() && avail_in) { - bzCompress(this, BZ_RUN); + BZ2_bzCompress(this, BZ_RUN); if (cin() == epptr()) next_in = pbase(); setp (cin(), epptr()); - streamsize l = next_out - cout(); + std::streamsize l = next_out - cout(); /* * what if sputn returns less than l ??? */ - if (l) l = back->sputn(cout(), l), ::cout << "writing " << l << " bytes " << endl; - pout += l; - if (avail_out) pout = next_out; + if (l) l = my_back->sputn(cout(), l); + my_pout += l; + if (avail_out) my_pout = next_out; else { - pout = next_out = cbase(); + my_pout = next_out = cbase(); avail_out = BUFSIZ; } } @@ -113,11 +113,11 @@ bzbuf::int_type bzbuf::overflow (int c) { - if (pbase () == 0) return EOF; + if (pbase() == 0) return EOF; if (c == EOF) return sync(); - if (pptr () == epptr()) sync(); + if (pptr() == epptr()) sync(); *pptr() = (char_type) c; - pbump (1); + pbump(1); avail_in++; return c; } @@ -134,11 +134,11 @@ if (!avail_in) { if (cin() == ecptr()) next_in = cbase(); - streamsize l = back->sgetn(cin(), ecptr() - cin()); + std::streamsize l = my_back->sgetn(cin(), ecptr() - cin()); if (l == EOF) return EOF; avail_in += l; } - bzDecompress(this); + BZ2_bzDecompress(this); setg (cout(), cout(), next_out); return (unsigned char) *gptr(); } @@ -152,6 +152,6 @@ int_type ret = underflow (); if (ret == EOF) return EOF; gbump(1); - pout++; + my_pout++; return ret; } Index: xdrbuf.cc =================================================================== RCS file: /cvs/fresco/Fresco/Prague/src/Filter/xdrbuf.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- xdrbuf.cc 23 Sep 2000 21:18:36 -0000 1.3 +++ xdrbuf.cc 15 Jul 2003 03:50:44 -0000 1.4 @@ -1,8 +1,8 @@ /*$Id$ * - * This source file is a part of the Berlin Project. - * Copyright (C) 1999 Stefan Seefeld <[email protected]> - * http://www.berlin-consortium.org + * This source file is a part of the Fresco Project. + * Copyright (C) 1999 Stefan Seefeld <[email protected]> + * http://www.fresco.org * * this code is based on binio from Dietmar Kuehl: * @@ -32,10 +32,6 @@ // 'pubsync()' for 'streambuf' but has no access restrictions on 'sync() // => Use this function. -#ifdef __GNUG__ -# define pubsync sync -#endif - // The following somewhat defeats the naming of 'long' but then... #if LONG_BIT == 64 @@ -69,7 +65,7 @@ xdrbuf_destroy, }; -void xdrbuf_create(XDR *xdrs, streambuf *sb, xdr_op op) +void xdrbuf_create(XDR *xdrs, std::streambuf *sb, xdr_op op) { xdrs->x_op = op; xdrs->x_ops = &xdrsb_ops; @@ -85,16 +81,16 @@ * like for 'iostream' the 'streambuf' is owned by someone else. * However, synchronization would be nice: */ - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); if (sb != 0) sb->pubsync(); } -void xdrbuf_reseat(XDR *xdrs, streambuf *sb) +void xdrbuf_reseat(XDR *xdrs, std::streambuf *sb) { /* * A method to implement the 'rdbuf()' mechanism of 'binios' */ - reinterpret_cast<streambuf *> (xdrs->x_private)->pubsync(); + reinterpret_cast<std::streambuf *> (xdrs->x_private)->pubsync(); xdrs->x_private = reinterpret_cast<caddr_t> (sb); } @@ -104,7 +100,7 @@ * Why is 'x_getlong()' defined to work on 'long'? 'ntohl' and family works * on 'unsigned long'! */ - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); if (sb->sgetn(reinterpret_cast<char *> (ptr), 4) == 4) { *ptr = ntohl(*ptr); @@ -115,7 +111,7 @@ bool_t xdrbuf_putlong(XDR *xdrs, const long_t *ptr) { - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); long l = htonl(*ptr); if (sb->sputn(reinterpret_cast<char *> (&l), 4) == 4) return TRUE; else return FALSE; @@ -123,31 +119,32 @@ bool_t xdrbuf_getbytes(XDR *xdrs, caddr_t ptr, unsigned int len) { - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); if (sb->sgetn(reinterpret_cast<char *> (ptr), len) == (int) len) return TRUE; else return FALSE; } bool_t xdrbuf_putbytes(XDR *xdrs, const char *ptr, unsigned int len) { - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); if (sb->sputn(const_cast<char *> (ptr), len) == (int) len) return TRUE; else return FALSE; } unsigned int xdrbuf_getpostn(const XDR *xdrs) { - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); - streampos pos = sb->pubseekoff(0, ios::cur, xdrs->x_op == XDR_ENCODE? ios::out : ios::in); + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); + std::streampos pos = sb->pubseekoff(0, std::ios::cur, + xdrs->x_op == XDR_ENCODE? std::ios::out : std::ios::in); return static_cast<unsigned int> (pos); } bool_t xdrbuf_setpostn(XDR *xdrs, unsigned int p) { - streambuf *sb = reinterpret_cast<streambuf *> (xdrs->x_private); - streampos pos = static_cast<streampos> (p); - ios::openmode which = xdrs->x_op == XDR_ENCODE? ios::out: ios::in; - if (sb->pubseekpos(pos, which) != static_cast<streampos> (streamoff(-1))) return TRUE; + std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private); + std::streampos pos = static_cast<std::streampos> (p); + std::ios::openmode which = xdrs->x_op == XDR_ENCODE? std::ios::out : std::ios::in; + if (sb->pubseekpos(pos, which) != static_cast<std::streampos> (streamoff(-1))) return TRUE; else return FALSE; }