Typedefs | |
typedef xfreader_s | xfreader_t |
typedef int(*) | XFREADER_MSG_HOOK (xfreader_t *preader, xf_instance_t *pinst) |
message object input hook | |
typedef int(*) | XFREADER_EXIT_HOOK (xfreader_t *preader) |
exit handler | |
Functions | |
int | xfreader_init (void) |
initialize the xfer stream reader library | |
xfreader_t * | xfreader_new (xf_refl_t **pprefl, int fd, char *info) |
Constructor of a xfer stream reader. | |
int | xfreader_setuserarg (xfreader_t *preader, void *puserarg) |
Set an arbitrary user argument to the xfer stream reader. | |
void * | xfreader_getuserarg (xfreader_t *preader) |
Get the user argument of the xfer stream reader. | |
xf_t * | xfreader_getxfer (xfreader_t *preader) |
Get the underlying xfer stream. | |
int | xfreader_add (xf_refl_t *prefl, XFREADER_MSG_HOOK msg_hook) |
Set the hook function for some message object reflection. | |
int | xfreader_setexithook (xfreader_t *preader, XFREADER_EXIT_HOOK exit_hook) |
Set the exit hook for the xfer stream reader. | |
XFREADER_EXIT_HOOK | xfreader_getexithook (xfreader_t *preader) |
Get the exit hook. | |
int | xfreader_kick (xfreader_t *preader) |
Kick reading of the stream. | |
int | xfreader_free (xfreader_t *preader) |
Free resources of xfer reader. |
typedef int(*) XFREADER_EXIT_HOOK(xfreader_t *preader) |
exit handler
The exit hook is called when the underlying xfer stream has been closed by xfer_free()
preader | xfer stream reader handle which has been closed |
typedef int(*) XFREADER_MSG_HOOK(xfreader_t *preader, xf_instance_t *pinst) |
message object input hook
The input hook is called by an internal thread when a complete message object is available. The object has to be processed in the hook.
preader | xfer stream reader handle on which an input message object arrived | |
pinst | the instance of an input message object |
typedef struct xfreader_s xfreader_t |
The xfer stream reader object
int xfreader_add | ( | xf_refl_t * | prefl, | |
XFREADER_MSG_HOOK | msg_hook | |||
) |
Set the hook function for some message object reflection.
Unfortunately quite an ugly hack: this function utilizes the user argument of the reflection info of some object class to set the message hook function
prefl | Pointer to some reflection structure, keep in mind that the corresponding initialization of the reflection structures had to be done before | |
msg_hook | Hook function is called whenever some object object is available on the xfer stream. The hook is called by the internal reader thread to decouple object-message processing from reading and parsing of the input stream |
int xfreader_free | ( | xfreader_t * | preader | ) |
Free resources of xfer reader.
preader | xfer stream reader
|
XFREADER_EXIT_HOOK xfreader_getexithook | ( | xfreader_t * | preader | ) |
Get the exit hook.
preader | xfer stream reader |
void* xfreader_getuserarg | ( | xfreader_t * | preader | ) |
Get the user argument of the xfer stream reader.
preader | xfer stream reader |
xf_t* xfreader_getxfer | ( | xfreader_t * | preader | ) |
Get the underlying xfer stream.
preader | xfer stream reader |
int xfreader_init | ( | void | ) |
initialize the xfer stream reader library
You must call the init function before use of any xfreader functionality
int xfreader_kick | ( | xfreader_t * | preader | ) |
Kick reading of the stream.
to be called when input available on stream
preader | xfer stream reader |
xfreader_t* xfreader_new | ( | xf_refl_t ** | pprefl, | |
int | fd, | |||
char * | info | |||
) |
Constructor of a xfer stream reader.
pprefl | NULL terminated array of reflections we expect on the xfer stream. The user data of the reflection has to be set to the message processing hook function. See xfreader_add() | |
fd | Filedescriptor the reader gets the objects from | |
info | arbritary informational string, maybe NULL |
int xfreader_setexithook | ( | xfreader_t * | preader, | |
XFREADER_EXIT_HOOK | exit_hook | |||
) |
Set the exit hook for the xfer stream reader.
preader | xfer stream reader | |
exit_hook | This function is called when xfer stream reader is closed via xfreader_free() |
int xfreader_setuserarg | ( | xfreader_t * | preader, | |
void * | puserarg | |||
) |
Set an arbitrary user argument to the xfer stream reader.
preader | xfer stream reader | |
puserarg | User argument |