EZwgl provides a timer-like mechanism for reading and writing files in a event-driven fashion.
To queue file events, use
EZ_Input *EZ_AddInput(int fd, int mask, EZ_InputCallBack callback, void *data);
This function registers a new source of events: the status change of
the specifed file descripter. From the time a fd
is registered on,
the specified status of fd
is watched by the main event
dispatcher. Whenever the specified status changes, callback
is
invoked.
Here fd
specifies a file descriptor.
mask
specifies what status to watch for. It is an or'ed
combination of EZ_READABLE_MASK
,
EZ_WRITABLE_MASK
and EZ_EXCEPTION_MASK
.
callback
spcifies a procedure. It will be invoked whenever
the specified status of fd
changes.
data
specifies an arbitary client data to be passed
to callback
when invoked.
EZ_InputCallBack
is a procedure of the following type.
void inputcallback(EZ_Input *obj, void *data, int fd, int mask)
To remove file events, use
void EZ_RemoveInput(EZ_Input inputId);
In this example, we watch the readable status of stdin, if there are anything to read, we read up to 1024 characters a time and append the string at the end of the text widget.
/******************* ExampleInput ***************************************/
#include