The details the functions available in the greio library.
int gre_io_add_mdata ( gre_io_serialized_data_t ** mbuffer, const char * key_name, const char * data_format, const void * data, int data_nbytes )
Add a data key/value pair to a serialized buffer. This call can be used to add serialize multiple data sets into a single send. This buffer can be later sent via the gre_io_send_mdata call.
Parameters:
buffer The buffer containing the serialized data
key_name The data key which is to be set
data_format The format for the data to be set
data The data value to set
data_nbytes The number of bytes used for the data
Returns:
-1 on failure anything else is success
void gre_io_close ( gre_io_t * handle )
Close an io connection. Any pending clients will return with an error on their action.
Parameters:
handle A valid handle created with gre_io_open()
void gre_io_free_buffer ( gre_io_serialized_data_t * buffer )
This de-allocates a buffer that has been allocated through the calls to gre_io_* functions.
Parameters:
buffer The buffer to be de-allocated
gre_io_t* gre_io_open ( const char * io_name, int flag, ... )
Open an IO connection using a named connection.
Parameters:
io_name The name of the io-channel to use
flags The mode you want to open the queue in
Flags define how the connection is opend. Possible flags are:
GRE_IO_TYPE_RDONLY: open read only
GRE_IO_TYPE_XRDONLY: open for exclusive read
GRE_IO_TYPE_WRONLY: open write only
GRE_IO_FLAG_NONBLOCK: open non-blocking
int gre_io_receive ( gre_io_t * handle, gre_io_serialized_data_t ** buffer )
Receive a serialized event. This call blocks until an event is received or until the channel is destroyed. If the GRE_IO_FLAG_NONBLOCK flag was passed on the open this call will be non-blocking.
Parameters:
handle A valid handle created with gre_io_open()
buffer A pointer to a serialized buffer pointer. If the buffer is NULL then a new
buffer is allocated otherwise the buffer provided is used to store the received event.
Returns:
The size of the message received or -1 on failure.
int gre_io_send ( gre_io_t * handle, gre_io_serialized_data_t * buffer )
Send a serialized buffer to the handle.
Parameters:
handle A valid handle created with gre_io_open()
buffer A data buffer containing a serialized event
Returns:
-1 on failure anything else is success
int gre_io_send_mdata ( gre_io_t * handle, gre_io_serialized_data_t * md_buffer )
Send a serialized buffer of mdata (data manager key/value pairs) to the handle.
Parameters:
handle A valid handle created with gre_io_open()
buffer A data buffer containing a serialized data
Returns:
-1 on failure anything else is success
gre_io_serialized_data_t* gre_io_serialize ( gre_io_serialized_data_t * buffer, const char * event_addr, const char * event_name, const char * event_format, const void * event_data, int event_nbytes )
Transform event data elements (see <io_mgr.h>) into a serialized data buffer.
Parameters:
buffer The buffer that will contain the serialized data or NULL if a new buffer should be allocated
event_addr The name of the event target, or NULL to send to the default target
event_name The name of the event to send, or NULL to send an empty event
event_format The format of the data (see <data_format.h>, or NULL if no data is being sent
event_data A pointer do the data to transmit, or NULL if no data is transmitted
event_nbytes The number of data bytes to transmit, or NULL if no data is transmitted
Returns:
A buffer with the serialized data or NULL on error (errno is set)
gre_io_serialized_data_t* gre_io_size_buffer ( gre_io_serialized_data_t * buffer, int nbytes )
This creates a data buffer to hold the serialized event data required for transmission. This allows a resizable buffer to be allocated once and then re-used for multiple event transmissions.
Parameters:
buffer The buffer to be sized, or NULL to allocate a new buffer
nbytes The number of bytes this buffer should be able to support
Returns:
A buffer with room for a message nbytes in size or NULL if no space available
int gre_io_unserialize ( gre_io_serialized_data_t * buffer, char ** event_addr, char ** event_name, char ** event_format, void ** event_data )
Transform a serialized buffer into event data elements (see <io_mgr.h>). The pointers returned point back into the content of the serialized buffer so the buffer can't be de-allocated until clients are finished manipulating the data elements.
Parameters:
buffer The buffer containing the serialized data
event_addr Location to store the event target
event_name Location to store the event name
event_format Location to store the event format
event_data Location to store the event data
Returns:
The number of bytes in the event_data structure