13#error This is a C++ include file and cannot be used from plain C
58 sprintf(
ErrMsg(),
"unable to start streaming thread");
61 else if (!stream_->Initialized())
65 sprintf(
ErrMsg(),
"unable to initialize streaming thread");
97 buffer_ = (
char *)malloc(bufferSize);
101 sprintf(
ErrMsg(),
"unable to allocate streaming buffer");
104 bufferSize_ = bufferSize;
115 sprintf(
ErrMsg(),
"unable to start streaming thread");
118 else if (!stream_->Initialized())
125 sprintf(
ErrMsg(),
"unable to initialize streaming thread");
141 if (transfer_ && (semAck_ != NULL)) semAck_->Wait();
146 if (semSig_ != NULL) semSig_->Post();
151 if (stream_ != NULL)
delete stream_;
152 if (semSig_ != NULL)
delete semSig_;
153 if (semAck_ != NULL)
delete semAck_;
154 if (buffer_ != NULL) free(buffer_);
158 size_t Write(
const char *buffer,
size_t size) {
163 if (bufferSize_ == 0)
168 if (fwrite(buffer, 1, size, fd_) != size)
170 strcpy(
ErrMsg(), strerror(errno));
179 strcpy(
ErrMsg(),
"invalid stream");
185 if (b2w <= bufferSize_) tx = b2w;
186 else tx = bufferSize_;
202 delete stream_; stream_ = NULL;
209 memcpy(buffer_, buffer + offset, tx);
215 source_ = (
const char *)buffer_;
227 int Send(
const char *buffer,
size_t size) {
231 strcpy(
ErrMsg(),
"invalid stream");
249 delete stream_; stream_ = NULL;
314 void Init_(FILE *fd) {
358 if (fwrite(source_, 1, size_, fd_) != size_)
360 strcpy(
ErrMsg(), strerror(errno));
366 strcpy(
ErrMsg(),
"invalid buffer source (NULL)");
Definition ngcbTHREAD.hpp:68
int Initialized()
Check class initialization.
Definition ngcbSTREAM.hpp:272
size_t Write(const char *buffer, size_t size)
Write size bytes of buffer to the stream.
Definition ngcbSTREAM.hpp:158
ngcbSTREAM(FILE *fd, ssize_t bufferSize)
Constructor defining a streaming buffer size.
Definition ngcbSTREAM.hpp:76
char * ErrMsg()
Return error message.
Definition ngcbSTREAM.hpp:269
ngcbSTREAM(FILE *fd)
Constructor for parallel stram.
Definition ngcbSTREAM.hpp:46
virtual ~ngcbSTREAM()
Destructor.
Definition ngcbSTREAM.hpp:137
int Send(const char *buffer, size_t size)
Send size bytes of buffer to the stream.
Definition ngcbSTREAM.hpp:227
Definition ngcbTHREAD.hpp:186
ngcbTHREAD()
Normal constructor.
Definition ngcbTHREAD.cpp:53
void ThrExit()
Thread exit.
Definition ngcbTHREAD.cpp:213
virtual ngcbTHREAD * NewThread(ngcbTHREAD *app, ngcbPROCESS_T process, void *arg, size_t stack=0)
Process to be overloaded.
Definition ngcbTHREAD.cpp:169
void(ngcbTHREAD::* ngcbPROCESS_T)(ngcbTHREAD *thread, void *arg)
Definition ngcbTHREAD.hpp:181
ngcb_fb_t()
Constructor.
Definition ngcbSTREAM.hpp:36
int automatic
Automatic open/close.
Definition ngcbSTREAM.hpp:33
FILE * chan
Stream channel.
Definition ngcbSTREAM.hpp:30