summaryrefslogtreecommitdiff
path: root/src/iodevice.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/iodevice.cc')
-rw-r--r--src/iodevice.cc49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/iodevice.cc b/src/iodevice.cc
index 7197354..c2bc9ee 100644
--- a/src/iodevice.cc
+++ b/src/iodevice.cc
@@ -5,38 +5,39 @@
* @date 2002, 2003
* ----------------------------------------------------------------- **/
#include "iodevice.h"
-#include "convert.h" // BincStream
-#include "session.h" // getEnv/hasEnv
+
+#include "convert.h" // BincStream
+#include "session.h" // getEnv/hasEnv
#include <stdlib.h>
+
#include <unistd.h>
using namespace ::std;
using namespace ::Binc;
//------------------------------------------------------------------------
-IODevice::IODevice(int f) : flags(f | IsEnabled),
- maxInputBufferSize(0),
- maxOutputBufferSize(0),
- timeout(0),
- readCount(0), writeCount(0),
- outputLevel(ErrorLevel),
- outputLevelLimit(ErrorLevel),
- error(Unknown), errorString("Unknown device error"),
- dumpfd(0)
-{
-}
+IODevice::IODevice(int f)
+ : flags(f | IsEnabled)
+ , maxInputBufferSize(0)
+ , maxOutputBufferSize(0)
+ , timeout(0)
+ , readCount(0)
+ , writeCount(0)
+ , outputLevel(ErrorLevel)
+ , outputLevelLimit(ErrorLevel)
+ , error(Unknown)
+ , errorString("Unknown device error")
+ , dumpfd(0)
+{}
//------------------------------------------------------------------------
-IODevice::~IODevice(void)
-{
-}
+IODevice::~IODevice(void) {}
//------------------------------------------------------------------------
-IODevice &IODevice::operator <<(ostream &(*source)(ostream &))
+IODevice &IODevice::operator<<(ostream &(*source)(ostream &))
{
- if (!(flags & IsEnabled) || outputLevel > outputLevelLimit)
- return *this;
+ if (!(flags & IsEnabled) || outputLevel > outputLevelLimit) return *this;
static std::ostream &(*endl_funcptr)(ostream &) = endl;
@@ -49,8 +50,7 @@ IODevice &IODevice::operator <<(ostream &(*source)(ostream &))
if (flags & FlushesOnEndl)
flush();
else if (flags & HasOutputLimit)
- if (outputBuffer.getSize() > maxOutputBufferSize)
- flush();
+ if (outputBuffer.getSize() > maxOutputBufferSize) flush();
return *this;
}
@@ -163,7 +163,7 @@ bool IODevice::readStr(string *dest, unsigned int max)
// If max is != 0, wait until we have max.
while (max && inputBuffer.getSize() < max) {
- if (!fillInputBuffer()) return false;
+ if (!fillInputBuffer()) return false;
}
unsigned int bytesToRead = max ? max : inputBuffer.getSize();
@@ -171,7 +171,7 @@ bool IODevice::readStr(string *dest, unsigned int max)
if (dumpfd) {
::write(dumpfd, inputBuffer.str().substr(0, bytesToRead).c_str(), bytesToRead);
}
-
+
inputBuffer.popString(bytesToRead);
readCount += bytesToRead;
@@ -274,8 +274,7 @@ unsigned int IODevice::getWriteCount(void) const
void IODevice::enableProtocolDumping(void)
{
BincStream ss;
- ss << "/tmp/bincimap-dump-" << (int) time(0) << "-"
- << Session::getInstance().getIP() << "-XXXXXX";
+ ss << "/tmp/bincimap-dump-" << (int)time(0) << "-" << Session::getInstance().getIP() << "-XXXXXX";
char *safename = strdup(ss.str().c_str());
dumpfd = mkstemp(safename);
if (dumpfd == -1) dumpfd = 0;