Home > Support > Documentation

Bit String Functions

Bit string functions allow bits to be set, cleared, or tested in arbitrarily sized byte arrays. More...

Classes

struct  OSBitMapItem

Functions

int rtxSetBit (OSOCTET *pBits, OSUINT32 numbits, OSUINT32 bitIndex)
 This function sets the specified bit in the bit string.
int rtxClearBit (OSOCTET *pBits, OSUINT32 numbits, OSUINT32 bitIndex)
 This function clears the specified bit in the bit string.
OSBOOL rtxTestBit (const OSOCTET *pBits, OSUINT32 numbits, OSUINT32 bitIndex)
 This function tests the specified bit in the bit string.
int rtxUTF8StrToNamedBits (OSCTXT *pctxt, const OSUTF8CHAR *utf8str, const OSBitMapItem *pBitMap, OSOCTET *pvalue, OSUINT32 *pnbits, OSUINT32 bufsize)
 This function converts the given null-terminated UTF-8 string to named bit items.

Detailed Description

Bit string functions allow bits to be set, cleared, or tested in arbitrarily sized byte arrays.


Function Documentation

int rtxClearBit ( OSOCTET *  pBits,
OSUINT32  numbits,
OSUINT32  bitIndex 
)

This function clears the specified bit in the bit string.

Parameters:
pBits Pointer to octets of bit string.
numbits Number of bits in the bit string.
bitIndex Index of bit to be cleared. The bit with index 0 is a most significant bit in the octet with index 0.
Returns:
If successful, returns the previous state of bit. If bit was set the return value is positive, if bit was not set the return value is zero. Otherwise, return value is an error code:
  • RTERR_OUTOFBND = bitIndex is out of bounds

int rtxSetBit ( OSOCTET *  pBits,
OSUINT32  numbits,
OSUINT32  bitIndex 
)

This function sets the specified bit in the bit string.

Parameters:
pBits Pointer to octets of bit string.
numbits Number of bits in the bit string.
bitIndex Index of bit to be set. The bit with index 0 is a most significant bit in the octet with index 0.
Returns:
If successful, returns the previous state of bit. If bit was set the return value is positive, if bit was not set the return value is zero. Otherwise, return value is an error code:
  • RTERR_OUTOFBND = bitIndex is out of bounds

OSBOOL rtxTestBit ( const OSOCTET *  pBits,
OSUINT32  numbits,
OSUINT32  bitIndex 
)

This function tests the specified bit in the bit string.

Parameters:
pBits Pointer to octets of bit string.
numbits Number of bits in the bit string.
bitIndex Index of bit to be tested. The bit with index 0 is a most significant bit in the octet with index 0.
Returns:
True if bit set or false if not set or array index is beyond range of number of bits in the string.

int rtxUTF8StrToNamedBits ( OSCTXT pctxt,
const OSUTF8CHAR *  utf8str,
const OSBitMapItem pBitMap,
OSOCTET *  pvalue,
OSUINT32 *  pnbits,
OSUINT32  bufsize 
)

This function converts the given null-terminated UTF-8 string to named bit items.

The token-to-bit mappings are defined by a bit map table that is passed into the function. It is assumed the string contains a space-separated list of named bit token values.

Parameters:
pctxt Context structure
utf8str Null-terminated UTF-8 string to convert
pBitMap Bit map defining bit to otken mappings
pvalue Pointer to byte array to receive result.
pnbits Pointer to integer to received number of bits.
bufsize Size of byte array to received decoded bits.
Returns:
Status: 0 = OK, negative value = error