WvStreams
wvstreamex6.cc
1 /*
2  * A WvStream example
3  *
4  * Some text about this example...
5  */
6 
7 #include <wvstream.h>
8 
9 void mycallback(WvStream &s, void *userdata)
10 {
11  WvStream *outstream = (WvStream *)userdata;
12 
13  char *str = s.getline();
14  if (str)
15  outstream->print("You said: %s\n", str);
16 }
17 
18 int main()
19 {
20  wvcon->setcallback(mycallback, wvcon);
21 
22  while (wvcon->isok())
23  {
24  if (wvcon->select(-1))
25  wvcon->callback();
26  }
27 }
WvStream::select
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
Definition: wvstream.h:376
WvStream::callback
virtual void callback()
if the stream has a callback function defined, call it now.
Definition: wvstream.cc:401
WvStream::getline
char * getline(time_t wait_msec=0, char separator='\n', int readahead=1024)
Read up to one line of data from the stream and return a pointer to the internal buffer containing th...
Definition: wvstream.h:175
WvStream::isok
virtual bool isok() const
return true if the stream is actually usable right now
Definition: wvstream.cc:445
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
WvStream::setcallback
void setcallback(IWvStreamCallback _callfunc)
define the callback function for this stream, called whenever the callback() member is run,...
Definition: wvstream.cc:1130