15 #define _GNU_SOURCE 1 // for ::getline
35 namespace externalprogram {
37 ExternalDataSource::ExternalDataSource (FILE *ifile, FILE *ofile)
58 bool success = fwrite (buffer, length, 1,
outputfile) != 0;
70 DBG <<
"send (" << s <<
")";
71 return send(s.data(), s.length());
80 std::ostringstream datas;
84 if (readc == EOF)
break;
86 if ((
char)readc == c)
break;
98 return fread (buffer, 1, length,
inputfile);
112 int flags = ::fcntl(fd,F_GETFL);
118 flags = flags | O_NONBLOCK;
119 else if(flags & O_NONBLOCK)
120 flags = flags ^ O_NONBLOCK;
122 flags = ::fcntl(fd,F_SETFL,flags);
std::string receiveUpto(char c)
Read characters into a string until character c is read.
size_t receive(char *buffer, size_t length)
Read some data from the input stream.
std::string getline(std::istream &str)
Read one line from stream.
virtual int close()
Close the input and output streams.
std::string receiveLine()
Read one line from the input stream.
void setBlocking(bool mode)
Set the blocking mode of the input stream.
virtual ~ExternalDataSource()
Implicitly close the connection.
std::string strerror(int errno_r)
Return string describing the error_r code.
bool send(const char *buffer, size_t length)
Send some data to the output stream.