xfreader API


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_txfreader_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.

Detailed Description

This module describe the methods of usage of xfreader

Typedef Documentation

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()

Parameters:
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.

Parameters:
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


Function Documentation

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

Parameters:
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
Returns:
  • 0 Ok
  • <0 Error

int xfreader_free ( xfreader_t preader  ) 

Free resources of xfer reader.

Parameters:
preader xfer stream reader
  • 0 Ok
  • <0 Error

XFREADER_EXIT_HOOK xfreader_getexithook ( xfreader_t preader  ) 

Get the exit hook.

Parameters:
preader xfer stream reader
Returns:
  • NULL: error
  • the exit hook of the xfer stream reader

void* xfreader_getuserarg ( xfreader_t preader  ) 

Get the user argument of the xfer stream reader.

Parameters:
preader xfer stream reader
Returns:
User argument

xf_t* xfreader_getxfer ( xfreader_t preader  ) 

Get the underlying xfer stream.

Parameters:
preader xfer stream reader
Returns:
the xfer stream you need to send your replies to the client sender of the input objects

int xfreader_init ( void   ) 

initialize the xfer stream reader library

You must call the init function before use of any xfreader functionality

Returns:
  • 0 OK
  • else error

int xfreader_kick ( xfreader_t preader  ) 

Kick reading of the stream.

to be called when input available on stream

Parameters:
preader xfer stream reader
Returns:
  • 1 End of input
  • 0 Ok
  • <0 Error

xfreader_t* xfreader_new ( xf_refl_t **  pprefl,
int  fd,
char *  info 
)

Constructor of a xfer stream reader.

Parameters:
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
Returns:
preader xfer stream reader

int xfreader_setexithook ( xfreader_t preader,
XFREADER_EXIT_HOOK  exit_hook 
)

Set the exit hook for the xfer stream reader.

Parameters:
preader xfer stream reader
exit_hook This function is called when xfer stream reader is closed via xfreader_free()
Returns:
  • 0 Ok
  • <0 Error

int xfreader_setuserarg ( xfreader_t preader,
void *  puserarg 
)

Set an arbitrary user argument to the xfer stream reader.

Parameters:
preader xfer stream reader
puserarg User argument
Returns:
  • 0 Ok
  • <0 Error


Generated on 4 Mar 2014 for xfreader by  doxygen 1.4.7