Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
multilogdevice.cc
Go to the documentation of this file.
1
7#include "multilogdevice.h"
8#include <string>
9
10#include <sys/types.h>
11#include <sys/select.h>
12#include <sys/time.h>
13#include <unistd.h>
14#include <errno.h>
15
16using namespace ::std;
17using namespace ::Binc;
18
19//------------------------------------------------------------------------
20MultilogDevice::MultilogDevice(int f) : IODevice(f)
21{
22}
23
24//------------------------------------------------------------------------
26{
27}
28
29//------------------------------------------------------------------------
30string MultilogDevice::service(void) const
31{
32 return "log";
33}
34
35//------------------------------------------------------------------------
37{
38 fd_set writeMask;
39 FD_ZERO(&writeMask);
40 FD_SET(fileno(stderr), &writeMask);
41
42 struct timeval tv;
43 tv.tv_sec = getTimeout();
44 tv.tv_usec = 0;
45
46 int result = select(fileno(stderr) + 1, 0, &writeMask,
47 0, tv.tv_sec ? &tv : 0);
48
49 return result > 0;
50}
51
52//------------------------------------------------------------------------
54{
55 return false;
56}
57
58//------------------------------------------------------------------------
60{
61 for (;;) {
62 ssize_t wrote = ::write(fileno(stderr), outputBuffer.str().c_str(),
64
65 if (wrote == -1) {
66 if (errno == EINTR)
67 continue;
68 else
69 return WriteError;
70 }
71
72 if ((unsigned int) wrote == outputBuffer.getSize()) {
74 return WriteDone;
75 }
76
78 return WriteWait;
79 }
80}
81
82//------------------------------------------------------------------------
84{
85 return false;
86}
const std::string & str(void) const
Definition: convert.cc:58
std::string popString(unsigned int size)
Definition: convert.cc:25
unsigned int getSize(void) const
Definition: convert.cc:70
void clear(void)
Definition: convert.cc:64
The IODevice class provides a framework for reading and writing to device.
Definition: iodevice.h:31
unsigned int getTimeout(void) const
Definition: iodevice.cc:129
BincStream outputBuffer
Definition: iodevice.h:340
bool waitForRead(void) const
bool waitForWrite(void) const
WriteResult write(void)
std::string service(void) const
bool fillInputBuffer(void)
Declaration of the MultilogDevice class.
Definition: bincimapd.cc:9