resmgr_msggetsize()
Get the size of a message and its local and remote parts
Synopsis:
#include <sys/resmgr.h>
size_t resmgr_msggetsize( resmgr_context_t * const ctp,
size_t start_offset,
size_t * const local_size,
size_t * const remote_size );
Arguments:
- ctp
- A pointer to a resmgr_context_t structure that the resource manager library uses to pass context information between functions. This function extracts message-related parameters from the resmgr_context_t.
- start_offset
- An offset into the current message that the local and remote sizes are relative to. The value of offset referenced by ctp cannot be included in this parameter.
- local_size
- NULL, or a pointer to the location where the function can store the size of the message's local part.
- remote_size
- NULL, or a pointer to the location where the function can store the size of the message's remote part.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The resmgr_msggetsize() function is a convenience function that you can use in a resource manager to get the total, local, and remote sizes of a received message. The local_size argument is the number of bytes of data available for the current message at start_offset in the receive buffer, that is, the number of bytes that have already been received from the client. If start_offset is within ctp->size for the current message, local_size will be ctp->size - start_offset. Otherwise, it will be 0. The remote_size argument is the number of bytes of data available for the current message that were not copied from the client's send buffer when the client's message was first received, accounting for start_offset.
For combine messages (those with the _IO_COMBINE_FLAG set), this function always takes into account the ctp->offset value. The passed-in start_offset value is just the offset from the start of the message that is currently being processed. The size returned to the caller is limited to that found in the ctp->size field. This size might be smaller than info.srcmsglen less the offset field in the resmgr_context_t referenced by ctp, because any data past size bytes is part of a subsequent message.
For more information, see Layers in a resource
manager
in the Bones of a Resource Manager chapter of Writing a Resource
Manager.
Returns:
The total size of the message, taking into account the start offset.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |