libarmutils  1.4
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups
Endian Swapping

Macros

#define SWAP_BYTES_16(x)
 Swap byes in 16 bit value.
#define SWAP_BYTES_32(x)
 Swap byes in 32 bit value.
#define SWAP_BYTES_64(x)
 Swap byes in 64 bit value.

Functions

void * bton_16 (void *data, size_t nvals)
 Convert array of 16 bit big endian values to native byte order.
void * bton_32 (void *data, size_t nvals)
 Convert array of 32 bit big endian values to native byte order.
void * bton_64 (void *data, size_t nvals)
 Convert array of 64 bit big endian values to native byte order.
void * lton_16 (void *data, size_t nvals)
 Convert array of 16 bit little endian values to native byte order.
void * lton_32 (void *data, size_t nvals)
 Convert array of 32 bit little endian values to native byte order.
void * lton_64 (void *data, size_t nvals)
 Convert array of 64 bit little endian values to native byte order.
int bton_read_16 (int fd, void *data, size_t nvals)
 Read 16 bit values from a big endian binary file.
int bton_read_32 (int fd, void *data, size_t nvals)
 Read 32 bit values from a big endian binary file.
int bton_read_64 (int fd, void *data, size_t nvals)
 Read 64 bit values from a big endian binary file.
int lton_read_16 (int fd, void *data, size_t nvals)
 Read 16 bit values from a little endian binary file.
int lton_read_32 (int fd, void *data, size_t nvals)
 Read 32 bit values from a little endian binary file.
int lton_read_64 (int fd, void *data, size_t nvals)
 Read 64 bit values from a little endian binary file.

Detailed Description


Macro Definition Documentation

#define SWAP_BYTES_16 (   x)
Value:
( ( ((x) & 0xff00) >> 8) | \
( ((x) & 0x00ff) << 8) )

Swap byes in 16 bit value.

Definition at line 38 of file endian_swap.h.

#define SWAP_BYTES_32 (   x)
Value:
( ( ((x) & 0xff000000) >> 24) | \
( ((x) & 0x00ff0000) >> 8) | \
( ((x) & 0x0000ff00) << 8) | \
( ((x) & 0x000000ff) << 24) )

Swap byes in 32 bit value.

Definition at line 43 of file endian_swap.h.

#define SWAP_BYTES_64 (   x)
Value:
( ( ((x) & 0xff00000000000000LL) >> 56) | \
( ((x) & 0x00ff000000000000LL) >> 40) | \
( ((x) & 0x0000ff0000000000LL) >> 24) | \
( ((x) & 0x000000ff00000000LL) >> 8) | \
( ((x) & 0x00000000ff000000LL) << 8) | \
( ((x) & 0x0000000000ff0000LL) << 24) | \
( ((x) & 0x000000000000ff00LL) << 40) | \
( ((x) & 0x00000000000000ffLL) << 56) )

Swap byes in 64 bit value.

Definition at line 50 of file endian_swap.h.


Function Documentation

void* bton_16 ( void *  data,
size_t  nvals 
)

Convert array of 16 bit big endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 49 of file endian_swap.c.

void* bton_32 ( void *  data,
size_t  nvals 
)

Convert array of 32 bit big endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 71 of file endian_swap.c.

void* bton_64 ( void *  data,
size_t  nvals 
)

Convert array of 64 bit big endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 93 of file endian_swap.c.

int bton_read_16 ( int  fd,
void *  data,
size_t  nvals 
)

Read 16 bit values from a big endian binary file.

This function will read 16 bit values from a big endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 190 of file endian_swap.c.

int bton_read_32 ( int  fd,
void *  data,
size_t  nvals 
)

Read 32 bit values from a big endian binary file.

This function will read 32 bit values from a big endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 237 of file endian_swap.c.

int bton_read_64 ( int  fd,
void *  data,
size_t  nvals 
)

Read 64 bit values from a big endian binary file.

This function will read 64 bit values from a big endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 284 of file endian_swap.c.

void* lton_16 ( void *  data,
size_t  nvals 
)

Convert array of 16 bit little endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 115 of file endian_swap.c.

void* lton_32 ( void *  data,
size_t  nvals 
)

Convert array of 32 bit little endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 137 of file endian_swap.c.

void* lton_64 ( void *  data,
size_t  nvals 
)

Convert array of 64 bit little endian values to native byte order.

Parameters:
data- pointer to the array of data values
nvals- number of values in the data array
Returns:
pointer to the array of data values

Definition at line 159 of file endian_swap.c.

int lton_read_16 ( int  fd,
void *  data,
size_t  nvals 
)

Read 16 bit values from a little endian binary file.

This function will read 16 bit values from a little endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 331 of file endian_swap.c.

int lton_read_32 ( int  fd,
void *  data,
size_t  nvals 
)

Read 32 bit values from a little endian binary file.

This function will read 32 bit values from a little endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 378 of file endian_swap.c.

int lton_read_64 ( int  fd,
void *  data,
size_t  nvals 
)

Read 64 bit values from a little endian binary file.

This function will read 64 bit values from a little endian binary file and convert them to the native byte order.

Error messages from this function are sent to the message handler (see msngr_init_log() and msngr_init_mail()).

Parameters:
fd- file descriptor
data- pointer to the output data array
nvals- number of data values to read
Returns:
  • number of data values successfully read
  • -1 if an error occurred

Definition at line 425 of file endian_swap.c.