rtxBuffer.h File Reference
Common runtime functions for reading from or writing to the message buffer defined within the context structure. More...
#include "rtxsrc/rtxContext.h"
Go to the source code of this file.
Functions | |
EXTERNRT int | rtxReadBytesSafe (OSCTXT *pctxt, OSOCTET *buffer, size_t bufsize, size_t nocts) |
This function safely reads bytes from the currently open stream or memory buffer into the given static buffer. | |
EXTERNRT int | rtxReadBytes (OSCTXT *pctxt, OSOCTET *pdata, size_t nocts) |
This function reads bytes from the currently open stream or memory buffer. | |
EXTERNRT int | rtxReadBytesDynamic (OSCTXT *pctxt, OSOCTET **ppdata, size_t nocts, OSBOOL *pMemAlloc) |
This function reads bytes from the currently open stream or memory buffer. | |
EXTERNRT int | rtxWriteBytes (OSCTXT *pctxt, const OSOCTET *pdata, size_t nocts) |
This function writes bytes to the currently open stream or memory buffer. |
Detailed Description
Common runtime functions for reading from or writing to the message buffer defined within the context structure.
Definition in file rtxBuffer.h.
Function Documentation
EXTERNRT int rtxReadBytes | ( | OSCTXT * | pctxt, | |
OSOCTET * | pdata, | |||
size_t | nocts | |||
) |
This function reads bytes from the currently open stream or memory buffer.
- Parameters:
-
pctxt Pointer to a context structure. pdata Pointer to byte array where bytes are to be copied. nocts Number of bytes (octets) to read.
- Returns:
- Status of the operation: 0 if success, negative value if error.
EXTERNRT int rtxReadBytesDynamic | ( | OSCTXT * | pctxt, | |
OSOCTET ** | ppdata, | |||
size_t | nocts, | |||
OSBOOL * | pMemAlloc | |||
) |
This function reads bytes from the currently open stream or memory buffer.
In this case the function MAY allocate memory to hold the read bytes. It will only do this if the requested number of bytes will not fit in the context buffer; othwerwise, a pointer to a location in the context buffer is returned. If memory was allocated, it should be freed using rtxMemFreePtr.
- Parameters:
-
pctxt Pointer to a context structure. ppdata Pointer to byte buffer pointer. nocts Number of bytes (octets) to read. pMemAlloc Pointer to boolean value which is set to true if memory was allocated to hold requested bytes.
- Returns:
- Status of the operation: 0 if success, negative value if error.
EXTERNRT int rtxReadBytesSafe | ( | OSCTXT * | pctxt, | |
OSOCTET * | buffer, | |||
size_t | bufsize, | |||
size_t | nocts | |||
) |
This function safely reads bytes from the currently open stream or memory buffer into the given static buffer.
This function is preferred over rtxReadBytes
because it will detect buffer overflow.
- Parameters:
-
pctxt Pointer to a context structure. buffer Static buffer into which bytes are to be read. bufsize Size of the static buffer. nocts Number of bytes (octets) to read.
- Returns:
- Status of the operation: 0 if success, negative value if error.
EXTERNRT int rtxWriteBytes | ( | OSCTXT * | pctxt, | |
const OSOCTET * | pdata, | |||
size_t | nocts | |||
) |
This function writes bytes to the currently open stream or memory buffer.
- Parameters:
-
pctxt Pointer to a context structure. pdata Pointer to location where bytes are to be copied. nocts Number of bytes to read.
- Returns:
- I/O byte count.