Update of /cvs/fresco/Fresco/Prague/src/Filter
In directory purcel:/tmp/cvs-serv28781/Prague/src/Filter
Modified Files:
bzbuf.cc gzbuf.cc xdrbuf.cc
Log Message:
Fix up indention according to the coding style guide.
Index: bzbuf.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Filter/bzbuf.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- bzbuf.cc 15 Jul 2003 03:50:44 -0000 1.4
+++ bzbuf.cc 31 Oct 2003 22:33:11 -0000 1.5
@@ -1,7 +1,7 @@
/*$Id$
*
* This source file is a part of the Fresco Project.
- * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxx>
+ * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxx>
* http://www.fresco.org
*
* this file defines a C++ interface to zlib
@@ -27,131 +27,128 @@
using namespace Prague;
-bzbuf::bzbuf(std::streambuf *b, int mode)
- : my_comp(new char_type [BUFSIZ]), my_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 & std::ios::in)
+ char_type *buf = new char_type[BUFSIZ];
+ if (mode & std::ios::in)
{
- setg (buf, buf + BUFSIZ, buf + BUFSIZ);
- next_in = my_comp;
- avail_in = BUFSIZ;
- my_pout = eback();
+ setg (buf, buf + BUFSIZ, buf + BUFSIZ);
+ next_in = my_comp;
+ avail_in = BUFSIZ;
+ my_pout = eback();
}
- else if (mode & std::ios::out)
+ else if (mode & std::ios::out)
{
- setp (buf, buf + BUFSIZ);
- next_out = my_comp;
- avail_out = BUFSIZ;
- my_pout = pbase();
+ setp (buf, buf + BUFSIZ);
+ next_out = my_comp;
+ avail_out = BUFSIZ;
+ my_pout = pbase();
}
- bzalloc = 0;
- bzfree = 0;
- opaque = 0;
- int blocksize = 9;
- int verbosity = 4;
- int workFactor = 30;
- int small = 0;
- if (mode &= std::ios::out)
- int ret = BZ2_bzCompressInit(this, blocksize, verbosity, workFactor);
- else
- int ret = BZ2_bzDecompressInit(this, verbosity, small);
+ bzalloc = 0;
+ bzfree = 0;
+ opaque = 0;
+ int blocksize = 9;
+ int verbosity = 4;
+ int workFactor = 30;
+ int small = 0;
+ if (mode &= std::ios::out)
+ int ret = BZ2_bzCompressInit(this, blocksize, verbosity, workFactor);
+ else
+ int ret = BZ2_bzDecompressInit(this, verbosity, small);
}
bzbuf::~bzbuf()
{
- overflow(EOF);
- if (pbase())
+ overflow(EOF);
+ if (pbase())
{
- bool done;
- do
- {
- done = BZ2_bzCompress(this, BZ_FINISH) == BZ_STREAM_END;
- if (avail_out) my_pout = next_out;
- else
- {
- my_pout = next_out = cbase();
- avail_out = BUFSIZ;
- }
- 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);
- BZ2_bzCompressEnd(this);
- delete [] pbase();
+ bool done;
+ do
+ {
+ done = BZ2_bzCompress(this, BZ_FINISH) == BZ_STREAM_END;
+ if (avail_out) my_pout = next_out;
+ else
+ {
+ my_pout = next_out = cbase();
+ avail_out = BUFSIZ;
+ }
+ 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);
+ BZ2_bzCompressEnd(this);
+ delete [] pbase();
}
- else delete [] eback();
- delete [] my_comp;
- my_back->pubsync();
+ else delete [] eback();
+ delete [] my_comp;
+ my_back->pubsync();
}
int bzbuf::sync()
{
- if (pptr() && avail_in)
+ if (pptr() && avail_in)
{
- BZ2_bzCompress(this, BZ_RUN);
- if (cin() == epptr()) next_in = pbase();
- setp (cin(), epptr());
-
- std::streamsize l = next_out - cout();
- /*
- * what if sputn returns less than l ???
- */
- if (l) l = my_back->sputn(cout(), l);
- my_pout += l;
- if (avail_out) my_pout = next_out;
- else
- {
- my_pout = next_out = cbase();
- avail_out = BUFSIZ;
- }
+ BZ2_bzCompress(this, BZ_RUN);
+ if (cin() == epptr()) next_in = pbase();
+ setp (cin(), epptr());
+
+ std::streamsize l = next_out - cout();
+ // what if sputn returns less than l ???
+ if (l) l = my_back->sputn(cout(), l);
+ my_pout += l;
+ if (avail_out) my_pout = next_out;
+ else
+ {
+ my_pout = next_out = cbase();
+ avail_out = BUFSIZ;
+ }
}
- return 0;
+ return 0;
}
bzbuf::int_type bzbuf::overflow (int c)
{
- if (pbase() == 0) return EOF;
- if (c == EOF) return sync();
- if (pptr() == epptr()) sync();
- *pptr() = (char_type) c;
- pbump(1);
- avail_in++;
- return c;
+ if (pbase() == 0) return EOF;
+ if (c == EOF) return sync();
+ if (pptr() == epptr()) sync();
+ *pptr() = (char_type) c;
+ pbump(1);
+ avail_in++;
+ return c;
}
bzbuf::int_type bzbuf::underflow ()
{
- if (gptr() == 0) return EOF;
- if (gptr() < next_out) return (unsigned char) *gptr();
- if (!avail_out)
+ if (gptr() == 0) return EOF;
+ if (gptr() < next_out) return (unsigned char) *gptr();
+ if (!avail_out)
{
- next_out = eback();
- avail_out = egptr() - eback();
+ next_out = eback();
+ avail_out = egptr() - eback();
}
- if (!avail_in)
+ if (!avail_in)
{
- if (cin() == ecptr()) next_in = cbase();
- std::streamsize l = my_back->sgetn(cin(), ecptr() - cin());
- if (l == EOF) return EOF;
- avail_in += l;
+ if (cin() == ecptr()) next_in = cbase();
+ std::streamsize l = my_back->sgetn(cin(), ecptr() - cin());
+ if (l == EOF) return EOF;
+ avail_in += l;
}
- BZ2_bzDecompress(this);
- setg (cout(), cout(), next_out);
- return (unsigned char) *gptr();
+ BZ2_bzDecompress(this);
+ setg (cout(), cout(), next_out);
+ return (unsigned char) *gptr();
}
-/* @Method{bzbuf::int_type ipcbuf::uflow ()}
- *
- * @Description{}
- */
+//. @Method{bzbuf::int_type ipcbuf::uflow ()}
+//.
+//. @Description{}
bzbuf::int_type bzbuf::uflow ()
{
- int_type ret = underflow ();
- if (ret == EOF) return EOF;
- gbump(1);
- my_pout++;
- return ret;
+ int_type ret = underflow ();
+ if (ret == EOF) return EOF;
+ gbump(1);
+ my_pout++;
+ return ret;
}
Index: gzbuf.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Filter/gzbuf.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gzbuf.cc 27 Mar 2001 05:38:42 -0000 1.4
+++ gzbuf.cc 31 Oct 2003 22:33:11 -0000 1.5
@@ -1,8 +1,8 @@
/*$Id$
*
- * This source file is a part of the Berlin Project.
- * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxxxxxxxxxxxxx>
- * http://www.berlin-consortium.org
+ * This source file is a part of the Fresco Project.
+ * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxx>
+ * http://www.fresco.org
*
* this file defines a C++ interface to zlib
* written by Kevin Ruland <kevin@xxxxxxxxxxxxxxx>
@@ -28,170 +28,159 @@
using namespace Prague;
-gzbuf::gzbuf() : _file(0), _mode(0), _owner(false), _buf(new char[BUFSIZ]) {}
+gzbuf::gzbuf() : _file(0), _mode(0), _owner(false), _buf(new char[BUFSIZ]) { }
gzbuf::~gzbuf()
{
- sync();
- delete _buf;
- if (_owner) close();
+ sync();
+ delete _buf;
+ if (_owner) close();
}
gzbuf *gzbuf::open(const char *name, int io_mode)
{
- if (is_open()) return 0;
- char char_mode[10];
- char *p;
- memset(char_mode, '\0', 10);
- p = char_mode;
- if (io_mode & std::ios::in)
- {
- _mode = std::ios::in;
- *p++ = 'r';
- }
- else if
- (io_mode & std::ios::app)
+ if (is_open()) return 0;
+ char char_mode[10];
+ char *p;
+ memset(char_mode, '\0', 10);
+ p = char_mode;
+ if (io_mode & std::ios::in)
{
- _mode = std::ios::app;
- *p++ = 'a';
+ _mode = std::ios::in;
+ *p++ = 'r';
}
- else
+ else if (io_mode & std::ios::app)
{
- _mode = std::ios::out;
- *p++ = 'w';
+ _mode = std::ios::app;
+ *p++ = 'a';
}
- if (io_mode & std::ios::binary)
+ else
{
- _mode |= std::ios::binary;
- *p++ = 'b';
+ _mode = std::ios::out;
+ *p++ = 'w';
}
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
+ if (io_mode & std::ios::binary)
{
- *p++ = '9';
+ _mode |= std::ios::binary;
+ *p++ = 'b';
}
- if ((_file = gzopen(name, char_mode)) == 0) return 0;
- _owner = true;
- return this;
+ // Hard code the compression level
+ if (io_mode & (std::ios::out|std::ios::app))
+ *p++ = '9';
+ if ((_file = gzopen(name, char_mode)) == 0) return 0;
+ _owner = true;
+ return this;
}
gzbuf *gzbuf::attach(int fd, int io_mode)
{
- if (is_open()) return 0;
- char char_mode[10];
- char *p;
- memset(char_mode,'\0',10);
- p = char_mode;
- if (io_mode & std::ios::in)
- {
- _mode = std::ios::in;
- *p++ = 'r';
- }
- else if (io_mode & std::ios::app)
+ if (is_open()) return 0;
+ char char_mode[10];
+ char *p;
+ memset(char_mode,'\0',10);
+ p = char_mode;
+ if (io_mode & std::ios::in)
{
- _mode = std::ios::app;
- *p++ = 'a';
+ _mode = std::ios::in;
+ *p++ = 'r';
}
- else
+ else if (io_mode & std::ios::app)
{
- _mode = std::ios::out;
- *p++ = 'w';
+ _mode = std::ios::app;
+ *p++ = 'a';
}
- if (io_mode & std::ios::binary)
+ else
{
- _mode |= std::ios::binary;
- *p++ = 'b';
+ _mode = std::ios::out;
+ *p++ = 'w';
}
- // Hard code the compression level
- if (io_mode & (std::ios::out|std::ios::app))
+ if (io_mode & std::ios::binary)
{
- *p++ = '9';
+ _mode |= std::ios::binary;
+ *p++ = 'b';
}
- if ((_file = gzdopen(fd, char_mode)) == 0) return 0;
- _owner = false;
- return this;
+ // Hard code the compression level
+ if (io_mode & (std::ios::out|std::ios::app))
+ *p++ = '9';
+ if ((_file = gzdopen(fd, char_mode)) == 0) return 0;
+ _owner = false;
+ return this;
}
gzbuf *gzbuf::close()
{
- if (is_open())
+ if (is_open())
{
- sync();
- gzclose(_file);
- _file = 0;
+ sync();
+ gzclose(_file);
+ _file = 0;
}
- return this;
+ return this;
}
int gzbuf::setcompressionlevel(short comp_level)
-{
- return gzsetparams(_file, comp_level, -2);
-}
+{ return gzsetparams(_file, comp_level, -2); }
int gzbuf::setcompressionstrategy(short comp_strategy)
-{
- return gzsetparams(_file, -2, comp_strategy);
-}
+{ return gzsetparams(_file, -2, comp_strategy); }
std::streampos gzbuf::seekoff(std::streamoff off, std::ios::seekdir dir, int
which)
-{
- return std::streampos(EOF);
-}
+{ return std::streampos(EOF); }
int gzbuf::underflow()
{
- // If the file hasn't been opened for reading, error.
- if (!is_open() || !(_mode & std::ios::in)) return EOF;
- // if a buffer doesn't exists, allocate one.
- if (in_avail()) return (unsigned char) *gptr();
- // Attempt to fill the buffer.
- int result = fillbuf();
- if (result == EOF)
+ // If the file hasn't been opened for reading, error.
+ if (!is_open() || !(_mode & std::ios::in)) return EOF;
+ // if a buffer doesn't exists, allocate one.
+ if (in_avail()) return (unsigned char) *gptr();
+ // Attempt to fill the buffer.
+ int result = fillbuf();
+ if (result == EOF)
{
- // disable get area
- setg(0,0,0);
- return EOF;
+ // disable get area
+ setg(0,0,0);
+ return EOF;
}
- return (unsigned char) *gptr();
+ return (unsigned char) *gptr();
}
int gzbuf::overflow(int c)
{
- if (!is_open() || !(_mode & std::ios::out)) return EOF;
- if (pptr() - pbase())
+ if (!is_open() || !(_mode & std::ios::out)) return EOF;
+ if (pptr() - pbase())
{
- if (flushbuf() == EOF) return EOF;
+ if (flushbuf() == EOF) return EOF;
}
- setp(_buf, _buf + BUFSIZ);
- if (c != EOF)
+ setp(_buf, _buf + BUFSIZ);
+ if (c != EOF)
{
- *pptr() = c;
- pbump(1);
+ *pptr() = c;
+ pbump(1);
}
- return 0;
+ return 0;
}
int gzbuf::sync()
{
- if (!is_open()) return EOF;
- if (pptr() - pbase()) return flushbuf();
- return 0;
+ if (!is_open()) return EOF;
+ if (pptr() - pbase()) return flushbuf();
+ return 0;
}
int gzbuf::flushbuf()
{
- int n;
- char *q;
- q = pbase();
- n = pptr() - q;
- if (gzwrite(_file, q, n) < n) return EOF;
- setp(0, 0);
- return 0;
+ int n;
+ char *q;
+ q = pbase();
+ n = pptr() - q;
+ if (gzwrite(_file, q, n) < n) return EOF;
+ setp(0, 0);
+ return 0;
}
int gzbuf::fillbuf()
{
- int t = gzread(_file, _buf, BUFSIZ);
- if (t <= 0) return EOF;
- setg(_buf, _buf, _buf + t);
- return t;
+ int t = gzread(_file, _buf, BUFSIZ);
+ if (t <= 0) return EOF;
+ setg(_buf, _buf, _buf + t);
+ return t;
}
Index: xdrbuf.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Filter/xdrbuf.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- xdrbuf.cc 15 Jul 2003 03:50:44 -0000 1.4
+++ xdrbuf.cc 31 Oct 2003 22:33:11 -0000 1.5
@@ -1,7 +1,7 @@
/*$Id$
*
* This source file is a part of the Fresco Project.
- * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxx>
+ * Copyright (C) 1999 Stefan Seefeld <stefan@xxxxxxxxxx>
* http://www.fresco.org
*
* this code is based on binio from Dietmar Kuehl:
@@ -55,107 +55,101 @@
static XDR::xdr_ops xdrsb_ops =
#endif
{
- xdrbuf_getlong,
- xdrbuf_putlong,
- xdrbuf_getbytes,
- xdrbuf_putbytes,
- xdrbuf_getpostn,
- xdrbuf_setpostn,
- xdrbuf_inline,
- xdrbuf_destroy,
+ xdrbuf_getlong,
+ xdrbuf_putlong,
+ xdrbuf_getbytes,
+ xdrbuf_putbytes,
+ xdrbuf_getpostn,
+ xdrbuf_setpostn,
+ xdrbuf_inline,
+ xdrbuf_destroy,
};
void xdrbuf_create(XDR *xdrs, std::streambuf *sb, xdr_op op)
{
- xdrs->x_op = op;
- xdrs->x_ops = &xdrsb_ops;
- xdrs->x_public = 0; // bring into a defined state
- xdrs->x_private = reinterpret_cast<caddr_t> (sb);
- xdrs->x_base = 0; // what is this for?
- xdrs->x_handy = 0; // not used
+ xdrs->x_op = op;
+ xdrs->x_ops = &xdrsb_ops;
+ xdrs->x_public = 0; // bring into a defined state
+ xdrs->x_private = reinterpret_cast<caddr_t> (sb);
+ xdrs->x_base = 0; // what is this for?
+ xdrs->x_handy = 0; // not used
}
void xdrbuf_destroy(XDR *xdrs)
{
- /*
- * like for 'iostream' the 'streambuf' is owned by someone else.
- * However, synchronization would be nice:
- */
- std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private);
- if (sb != 0) sb->pubsync();
+ // like for 'iostream' the 'streambuf' is owned by someone else.
+ // However, synchronization would be nice:
+ std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private);
+ if (sb != 0) sb->pubsync();
}
void xdrbuf_reseat(XDR *xdrs, std::streambuf *sb)
{
- /*
- * A method to implement the 'rdbuf()' mechanism of 'binios'
- */
- reinterpret_cast<std::streambuf *> (xdrs->x_private)->pubsync();
- xdrs->x_private = reinterpret_cast<caddr_t> (sb);
+ // A method to implement the 'rdbuf()' mechanism of 'binios'
+ reinterpret_cast<std::streambuf *> (xdrs->x_private)->pubsync();
+ xdrs->x_private = reinterpret_cast<caddr_t> (sb);
}
bool_t xdrbuf_getlong(XDR *xdrs, long_t *ptr)
{
-/*
- * Why is 'x_getlong()' defined to work on 'long'? 'ntohl' and family works
- * on 'unsigned long'!
- */
- std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private);
- if (sb->sgetn(reinterpret_cast<char *> (ptr), 4) == 4)
+ // Why is 'x_getlong()' defined to work on 'long'? 'ntohl' and family works
+ // on 'unsigned long'!
+ std::streambuf *sb = reinterpret_cast<std::streambuf *> (xdrs->x_private);
+ if (sb->sgetn(reinterpret_cast<char *> (ptr), 4) == 4)
{
- *ptr = ntohl(*ptr);
- return TRUE;
+ *ptr = ntohl(*ptr);
+ return TRUE;
}
- else return FALSE;
+ else return FALSE;
}
bool_t xdrbuf_putlong(XDR *xdrs, const long_t *ptr)
{
- 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;
+ 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;
}
bool_t xdrbuf_getbytes(XDR *xdrs, caddr_t ptr, unsigned int len)
{
- 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;
+ 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)
{
- 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;
+ 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)
{
- 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);
+ 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)
{
- 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;
+ 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;
}
long_t *xdrbuf_inline(XDR * /* xdrs */, int /* len */)
{
- /*
- * To implement this, it would be necessary to gain specific access
- * to the 'streambuf' which cannot be guaranteed by all
- * 'streambuf's. I'm not sure whether this method can usefully be
- * implemented... I hope, that it is at least not necessary to
- * implement this method to make the XDR conversions work!
- */
- return 0;
+ /*
+ * To implement this, it would be necessary to gain specific access
+ * to the 'streambuf' which cannot be guaranteed by all
+ * 'streambuf's. I'm not sure whether this method can usefully be
+ * implemented... I hope, that it is at least not necessary to
+ * implement this method to make the XDR conversions work!
+ */
+ return 0;
}
|