next up previous contents
Next: Configuration Module (CFG) Up: OPEN C PLATFORM Previous: Data Unit Management (DU_)   Contents

Subsections

Buffer (BUF)

ReturnCode
BUF_alloc(OS_Uint16 minSize, void ** phBuf)

void
BUF_free(void * hBuf)

ReturnCode
BUF_addOctet(void * hBuf, OS_Uint8 octet)

ReturnCode
BUF_getOctet(void * hBuf, OS_Uint8 * pOctet)

ReturnCode
BUF_ungetOctet(void * hBuf)

ReturnCode
BUF_prependChunk(void * hBuf,
                 STR_String string)

ReturnCode
BUF_prependBuffer(void * hBuf,
                  void * hPrependThisBuf);

ReturnCode
BUF_getChunk(void * hBuf,
             OS_Uint16 * pChunkLength,
             unsigned char ** ppData)

ReturnCode
BUF_appendChunk(void * hBuf,
                STR_String string)

ReturnCode
BUF_appendBuffer(void * hBuf,
                 void * hAppendThisBuf)

void
BUF_resetParse(void * hBuf)

ReturnCode
BUF_copy(void * hBufSrc,
               void ** phBufDest);

ReturnCode
BUF_cloneBufferPortion(void * hBuf,
                       OS_Uint32 len,
                       OS_Boolean bStripClonedPortion,
                       void ** phNewBuf)

OS_Uint32
BUF_getBufferLength(void * hBuf)

void
BUF_dump(void * hBuf, char * pMsg)

Allocate and Free a Buffer

ReturnCode
BUF_alloc(OS_Uint16 minSize, void ** phBuf);

Allocate a new buffer. The buffer will contain, initially, one segment which is large enough to hold (at least) the specified number of octets.

If the minimum size is not known, zero may be passed, and a default zero-size buffer segment will be allocated, initially.

Parameters:
        minSize --
                Minimum size of for the data area within the
                buffer segment.  A buffer segment will be
                provided (if possible) which has at least this
                much space available.

        phBuf --
                Pointer to memory where a buffer handle is to be
                placed.

Returns:

        Success or ResourceError or one of the BUF_RC_* return
        codes.

void
BUF_free(void * hBuf);

Free the specified buffer and all of its associated segments.

Parameters:

        hBuf -- Handle to a buffer, previously returned by
                BUF_alloc(), which is to be freed.

Returns:
        Nothing.

Add, Get, and Unget an Octet

ReturnCode
BUF_addOctet(void * hBuf, OS_Uint8 octet);

Prepend a single octet to a buffer. If there is insufficient space in the current segment, a new segment is allocated, of the default size.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                BUF_alloc(), in which the octet is to be
                prepended.
        octet --
                The octet value to be prepended to the buffer.
 
Returns:
        Success upon success;
        Fail if allocating a new segment failed.

ReturnCode
BUF_getOctet(void * hBuf, OS_Uint8 * pOctet);

Get the next octet in the buffer.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                Buf_alloc(), from which the octet is to be
                obtained.

        pOctet --
                Pointer to a memory location in which the
                retrieved octet is to be placed.

Returns:
        Success if an octet was available; Fail otherwise.

ReturnCode
BUF_ungetOctet(void * hBuf);

Return the most recently retrieved octet to the input buffer stream.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                Buf_alloc(), from which an octet is to be
                returned.

Returns:
        Nothing.

Allocate and Assign a New Buffer Segment

ReturnCode
BUF_prependChunk(void * hBuf,
                 STR_String string);

This function allocates a new buffer segment, and assigns the specified string to that segment. The internal buffer pointers are left in such a state as to allow prepending additional octets. Any additional octets prepended will cause a new buffer segment to be created, as the segment for this prepended chunk takes up its own whole segment.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                BUF_alloc(), in which space is being requested.

        string --
                A string handle, which is to be prepended to the
                buffer.

Returns:

        On error, ResourceError is returned.

Prepend a Buffer

ReturnCode
BUF_prependBuffer(void * hBuf,
                  void * hPrependThisBuf);

This function prepends one buffer to another. The internal buffer pointers are left in such a state as to allow prepending additional octets.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                BUF_alloc(), in which space is being requested.

        hPrependThisBuf --
                Handle to the buffer, previous returned by
                BUF_alloc(), which is to be prepended to hBuf.

Returns:
                
        Currently, this function always returns Success.

Get the Next Chunk of a PDU

ReturnCode
BUF_getChunk(void * hBuf,
             OS_Uint16 * pChunkLength,
             unsigned char ** ppData);

When parsing, this function returns a pointer to the next chunk of the PDU. The size of the chunk is determined by the value of *pChunkLength when this function is called, and by the amount of data remaining in the current (or first non-zero-length) segment. A chunk of no more then the requested chunk length will be provided.

Parameters:
        hBuf --
                Handle to a buffer, previously returned by
                BUF_alloc(), from which a chunk of data is being
                requested.

        pChunkLength --
                Pointer to memory containing the number of octets
                being requested in the chunk.  This value may be
                zero, to indicate that a pointer to as many
                octets as possible should be returned.

        ppData --
                A pointer to a location in which a pointer to the
                data in the chunk is placed.  Also, the value
                pointed to by pChunkLength is updated to contain
                the length of data being provided.  This value
                may equal the requested chunk length, or may be
                less then that length.

Returns:

        Success or ResourceError or one of the BUF_RC_* return
        codes.

Append a String to a Buffer

ReturnCode
BUF_appendChunk(void * hBuf,
                STR_String string);

Append a string to the end of a buffer. This function is primarily for use when receiving data from the network, which is to later be parsed.

Parameters:
        hBuf --
                Handle to a buffer, previously returned by
                BUF_alloc(), to which a chunk of data is to be
                added.

        string --
                String to be appended to the buffer.
                
Returns:
        Success or ResourceError.

Append One Buffer to Another

ReturnCode
BUF_appendBuffer(void * hBuf,
                 void * hAppendThisBuf);

This function appends one buffer to another. The internal buffer pointers are left in such a state as to allow appending additional octets.

Parameters:
        hBuf --
                Handle to the buffer, previously returned by
                BUF_alloc(), in which space is being requested.

        hAppendThisBuf --
                Handle to the buffer, previous returned by
                BUF_alloc(), which is to be appended to hBuf.

Returns:
                
        Currently, this function always returns Success.

Reset Buffer Pointers

void
BUF_resetParse(void * hBuf);

Reset the internal buffer pointers for another parse of the buffer.

Parameters:

        hBuf --
                Handle to a buffer, previously returned by
                BUF_alloc(), which is to be freed.

Returns:
        Nothing.

Copy a Buffer

ReturnCode
BUF_copy(void * hBufSrc,
               void ** phBufDest);

Copy an entire buffer. All data is copied, so string data is independent of the source buffer (as opposed to the way BUF_cloneBufferPortion() works).

Parameters:

     hBufSrc --
             Handle to a buffer, previously returned by
             BUF_alloc(), which contains the data to be copied

     phBufDest --
             Pointer to a buffer handle.  A new buffer is allocated
             by this function, the data from hBufSrc is copied to
             it, and the location pointed to by this parameter is
             set to be the new buffer handle.

Returns:
     Success or ResourceError

Clone a Portion of a Buffer

ReturnCode
BUF_cloneBufferPortion(void * hBuf,
                       OS_Uint32 len,
                       OS_Boolean bStripClonedPortion,
                       void ** phNewBuf);

Clone a portion of a buffer. A new buffer handle is provided, that contains a (possibly) partial list of the segments from the cloned buffer. The new buffer and original buffer may each be freed or manipulated independently, with the caveat that the String Data pointed to by the segments is the same in both buffers. Any modifications to the data within the cloned buffer that is in the common portion to the original buffer will be reflected in both buffers.

Parameters:
        hBuf --
                Handle to a buffer, previously returned by
                BUF_alloc(), a portion of which is to be cloned.

        len --
                Length of data, beginning at the current location
                within the buffer indicated by hBuf, which is to
                be cloned.  If len is BUF_REMAINDER, the buffer
                portion beginning at the current buffer pointer
                and ending at the end of the buffer is cloned.

        bStripClonedPortion --
                If TRUE, update the start of the data in the buffer
                to be just beyond the cloned portion.

        phNewBuf --
                Pointer to location to put the handle of the new
                cloned buffer.
                
Returns:
        Success or ResourceError.

Get the Length of a Buffer

OS_Uint32
BUF_getBufferLength(void * hBuf);

Determine the length of the buffer, by adding the lengths of the data strings of each of the buffer segments.

Parameters:
        hBuf --
                Handle to a buffer, previously returned by
                BUF_alloc(), a portion of which is to be cloned.
                
Returns:
        The length of the buffer.

Display a Buffer

void
BUF_dump(void * hBuf, char * pMsg);

Display, on STDOUT, the entire contents of the buffer.


next up previous contents
Next: Configuration Module (CFG) Up: OPEN C PLATFORM Previous: Data Unit Management (DU_)   Contents