OLE Developer Guide  Latest Git
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
utils.h File Reference

Detailed Description

Helper utilities.

Include dependency graph for utils.h:

Go to the source code of this file.

Functions

static uint8_t ShortLSB (uint16_t s)
 Return the LSB from a 16bit value. More...
 
static uint8_t ShortMSB (uint16_t s)
 Return the MSB from a 16bit value. More...
 
static uint16_t JoinShort (uint8_t upper, uint8_t lower)
 Combine two 8-bit values to a 16-bit value. More...
 
static uint8_t UInt32Byte0 (uint32_t s)
 Return the MSB from a 32bit value. More...
 
static uint8_t UInt32Byte1 (uint32_t s)
 Return the second-highest byte from a 32bit value. More...
 
static uint8_t UInt32Byte2 (uint32_t s)
 Return the second-lowest byte from a 32bit value. More...
 
static uint8_t UInt32Byte3 (uint32_t s)
 Return the lowest byte from a 32bit value. More...
 
static uint32_t ExtractUInt16 (const uint8_t *ptr)
 Extract a uint16_t in network-byte order from a memory location. More...
 
static uint32_t ExtractUInt32 (const uint8_t *ptr)
 Extract a uint32_t in network-byte order from a memory location. More...
 
static uint8_t * PushUInt16 (uint8_t *ptr, uint16_t value)
 Copy a 16-bit value to a memory location in network-byte order. More...
 
static uint8_t * PushUInt32 (uint8_t *ptr, uint32_t value)
 Copy a 32-bit value to a memory location in network-byte order. More...
 

Function Documentation

static uint32_t ExtractUInt16 ( const uint8_t *  ptr)
inlinestatic

Extract a uint16_t in network-byte order from a memory location.

Parameters
ptrA pointer to the memory.
Returns
A 16-bit value.
static uint32_t ExtractUInt32 ( const uint8_t *  ptr)
inlinestatic

Extract a uint32_t in network-byte order from a memory location.

Parameters
ptrA pointer to the memory.
Returns
A 32-bit value.
static uint16_t JoinShort ( uint8_t  upper,
uint8_t  lower 
)
inlinestatic

Combine two 8-bit values to a 16-bit value.

Parameters
upperthe MSB,
lowerthe LSB,
Returns
A 16-bit value.
static uint8_t* PushUInt16 ( uint8_t *  ptr,
uint16_t  value 
)
inlinestatic

Copy a 16-bit value to a memory location in network-byte order.

Parameters
ptrA pointer to the memory.
valueThe value to push.
Returns
A pointer to the next byte after the last one that was copied.
static uint8_t* PushUInt32 ( uint8_t *  ptr,
uint32_t  value 
)
inlinestatic

Copy a 32-bit value to a memory location in network-byte order.

Parameters
ptrA pointer to the memory.
valueThe value to push.
Returns
A pointer to the next byte after the last one that was copied.
static uint8_t ShortLSB ( uint16_t  s)
inlinestatic

Return the LSB from a 16bit value.

Parameters
sThe 16bit value to split.
Returns
The lower 8 bits of the uint16_t.
static uint8_t ShortMSB ( uint16_t  s)
inlinestatic

Return the MSB from a 16bit value.

Parameters
sThe 16bit value to split.
Returns
The upper 8 bits of the uint16_t.
static uint8_t UInt32Byte0 ( uint32_t  s)
inlinestatic

Return the MSB from a 32bit value.

Parameters
sThe 32bit value to split.
Returns
The first 8 bits of the uint32_t.
static uint8_t UInt32Byte1 ( uint32_t  s)
inlinestatic

Return the second-highest byte from a 32bit value.

Parameters
sThe 32bit value to split.
Returns
Bits 9-16 bits of the uint32_t.
static uint8_t UInt32Byte2 ( uint32_t  s)
inlinestatic

Return the second-lowest byte from a 32bit value.

Parameters
sThe 32bit value to split.
Returns
Bits 17-24 bits of the uint32_t.
static uint8_t UInt32Byte3 ( uint32_t  s)
inlinestatic

Return the lowest byte from a 32bit value.

Parameters
sThe 32bit value to split.
Returns
Bits 25-32 bits of the uint32_t.