12#error This is a C++ include file and cannot be used from plain C
57 sprintf(
ErrMsg(),
"unable to start streaming thread");
60 else if (!stream_->Initialized())
64 sprintf(
ErrMsg(),
"unable to initialize streaming thread");
96 buffer_ = (
char *)malloc(bufferSize);
100 sprintf(
ErrMsg(),
"unable to allocate streaming buffer");
103 bufferSize_ = bufferSize;
114 sprintf(
ErrMsg(),
"unable to start streaming thread");
117 else if (!stream_->Initialized())
124 sprintf(
ErrMsg(),
"unable to initialize streaming thread");
140 if (transfer_ && (semAck_ != NULL)) semAck_->Wait();
145 if (semSig_ != NULL) semSig_->Post();
150 if (stream_ != NULL)
delete stream_;
151 if (semSig_ != NULL)
delete semSig_;
152 if (semAck_ != NULL)
delete semAck_;
153 if (buffer_ != NULL) free(buffer_);
157 size_t Write(
const char *buffer,
size_t size) {
162 if (bufferSize_ == 0)
167 if (fwrite(buffer, 1, size, fd_) != size)
169 strcpy(
ErrMsg(), strerror(errno));
178 strcpy(
ErrMsg(),
"invalid stream");
184 if (b2w <= bufferSize_) tx = b2w;
185 else tx = bufferSize_;
201 delete stream_; stream_ = NULL;
208 memcpy(buffer_, buffer + offset, tx);
214 source_ = (
const char *)buffer_;
226 int Send(
const char *buffer,
size_t size) {
230 strcpy(
ErrMsg(),
"invalid stream");
248 delete stream_; stream_ = NULL;
313 void Init_(FILE *fd) {
357 if (fwrite(source_, 1, size_, fd_) != size_)
359 strcpy(
ErrMsg(), strerror(errno));
365 strcpy(
ErrMsg(),
"invalid buffer source (NULL)");
Definition ngcbTHREAD.hpp:67
int Initialized()
Check class initialization.
Definition ngcbSTREAM.hpp:271
size_t Write(const char *buffer, size_t size)
Write size bytes of buffer to the stream.
Definition ngcbSTREAM.hpp:157
ngcbSTREAM(FILE *fd, ssize_t bufferSize)
Constructor defining a streaming buffer size.
Definition ngcbSTREAM.hpp:75
char * ErrMsg()
Return error message.
Definition ngcbSTREAM.hpp:268
ngcbSTREAM(FILE *fd)
Constructor for parallel stram.
Definition ngcbSTREAM.hpp:45
virtual ~ngcbSTREAM()
Destructor.
Definition ngcbSTREAM.hpp:136
int Send(const char *buffer, size_t size)
Send size bytes of buffer to the stream.
Definition ngcbSTREAM.hpp:226
Definition ngcbTHREAD.hpp:185
ngcbTHREAD()
Normal constructor.
Definition ngcbTHREAD.cpp:52
void ThrExit()
Thread exit.
Definition ngcbTHREAD.cpp:212
virtual ngcbTHREAD * NewThread(ngcbTHREAD *app, ngcbPROCESS_T process, void *arg, size_t stack=0)
Process to be overloaded.
Definition ngcbTHREAD.cpp:168
void(ngcbTHREAD::* ngcbPROCESS_T)(ngcbTHREAD *thread, void *arg)
Definition ngcbTHREAD.hpp:180
ngcb_fb_t()
Constructor.
Definition ngcbSTREAM.hpp:35
int automatic
Automatic open/close.
Definition ngcbSTREAM.hpp:32
FILE * chan
Stream channel.
Definition ngcbSTREAM.hpp:29