diff options
Diffstat (limited to 'src/stdiodevice.cc')
-rw-r--r-- | src/stdiodevice.cc | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/stdiodevice.cc b/src/stdiodevice.cc index 9eb5f9c..a9cce91 100644 --- a/src/stdiodevice.cc +++ b/src/stdiodevice.cc @@ -5,27 +5,25 @@ * @date 2003/2023 * ---------------------------------------------------------------- **/ #include "stdiodevice.h" + #include <string> -#include <sys/types.h> +#include <errno.h> + #include <sys/ioctl.h> #include <sys/select.h> #include <sys/time.h> +#include <sys/types.h> #include <unistd.h> -#include <errno.h> using namespace ::std; using namespace ::Binc; //------------------------------------------------------------------------ -StdIODevice::StdIODevice(int f) : IODevice(f) -{ -} +StdIODevice::StdIODevice(int f) : IODevice(f) {} //------------------------------------------------------------------------ -StdIODevice::~StdIODevice(void) -{ -} +StdIODevice::~StdIODevice(void) {} //------------------------------------------------------------------------ string StdIODevice::service(void) const @@ -37,7 +35,7 @@ string StdIODevice::service(void) const bool StdIODevice::canRead(void) const { size_t bytes; - return ioctl(fileno(stdin), FIONREAD, (char *) &bytes) > 0; + return ioctl(fileno(stdin), FIONREAD, (char *)&bytes) > 0; } //------------------------------------------------------------------------ @@ -76,8 +74,7 @@ bool StdIODevice::waitForRead(void) const IODevice::WriteResult StdIODevice::write(void) { for (;;) { - ssize_t wrote = ::write(fileno(stdout), outputBuffer.str().c_str(), - outputBuffer.getSize()); + ssize_t wrote = ::write(fileno(stdout), outputBuffer.str().c_str(), outputBuffer.getSize()); if (wrote == -1) { if (errno == EINTR) @@ -88,8 +85,7 @@ IODevice::WriteResult StdIODevice::write(void) outputBuffer.popString(wrote); - if (wrote == (ssize_t) outputBuffer.getSize()) - return WriteDone; + if (wrote == (ssize_t)outputBuffer.getSize()) return WriteDone; return WriteWait; } } @@ -97,13 +93,11 @@ IODevice::WriteResult StdIODevice::write(void) //------------------------------------------------------------------------ bool StdIODevice::fillInputBuffer(void) { - if (!waitForRead()) - return false; + if (!waitForRead()) return false; char buf[4096]; ssize_t red = read(fileno(stdin), buf, sizeof(buf) - 1); - if (red <= 0) - return false; + if (red <= 0) return false; buf[red] = '\0'; inputBuffer << buf; |