Defines | Functions

gnulliver.c File Reference

#include "gnulliver.h"

Go to the source code of this file.

Defines

#define GNULLIVER_TEST   ( 16.0 + ( 1.0 / 8.0 + 1.0 / 4096.0 ) )

Functions

unsigned char gnulliver ()
unsigned short gnulliver16 (unsigned short input)
unsigned gnulliver32 (unsigned input)
unsigned long gnulliver64 (unsigned long input)
unsigned long long gnulliver128 (unsigned long long input)
float gnulliver32f (float input)
double gnulliver64f (double input)
long double gnulliver128f (long double input)
unsigned char * gnulliver64c (unsigned char *ch)

Detailed Description

Source code for the gnulliver library.

Definition in file gnulliver.c.


Define Documentation

#define GNULLIVER_TEST   ( 16.0 + ( 1.0 / 8.0 + 1.0 / 4096.0 ) )

Definition at line 74 of file gnulliver.c.


Function Documentation

unsigned char gnulliver (  ) 

Discover the endianess of the host.

Returns:
GNULLIVER_LITTLE, GNULLIVER_DEC, GNULLIVER_BIG depending on whether the host uses little-, DEC-, or big-endian order for its bytes. This information is used to swap bytes between host byte order and assumed network order (big-endian) for the binary file. Alternatively, gnulliver() returns GNULLIVER_NATIVE for the case where no byte swaps are desired for i/o on a binary file.

Definition at line 86 of file gnulliver.c.

unsigned long long gnulliver128 ( unsigned long long  input  ) 

Optional byteswap of long long depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of integer to be optionally byteswapped.
Returns:
(optionally) byteswapped integer.

Definition at line 232 of file gnulliver.c.

long double gnulliver128f ( long double  input  ) 

Optional byteswap of long double depending on gnulliver() result. Note: This function's result will be unpredictable if the type long double is not a 128-bit word.

Parameters:
input [IN ONLY]Value of floating-point variable to be optionally byteswapped.
Returns:
(optionally) byteswapped floating point value.

Definition at line 370 of file gnulliver.c.

unsigned short gnulliver16 ( unsigned short  input  ) 

Optional byteswap of short depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of integer to be optionally byteswapped.
Returns:
(optionally) byteswapped integer.

Definition at line 120 of file gnulliver.c.

unsigned gnulliver32 ( unsigned  input  ) 

Optional byteswap of integer depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of integer to be optionally byteswapped.
Returns:
(optionally) byteswapped integer.

Definition at line 150 of file gnulliver.c.

float gnulliver32f ( float  input  ) 

Optional byteswap of float depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of floating-point variable to be optionally byteswapped.
Returns:
(optionally) byteswapped floating point value.

Definition at line 284 of file gnulliver.c.

unsigned long gnulliver64 ( unsigned long  input  ) 

Optional byteswap of long depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of integer to be optionally byteswapped.
Returns:
(optionally) byteswapped integer.

Definition at line 189 of file gnulliver.c.

unsigned char* gnulliver64c ( unsigned char *  ch  ) 

Optional swap of char array elements depending on gnulliver() result.

Parameters:
ch [IN AND OUT ]Pointer to char array containing 8 elements which upon return will be optionally swapped.
Returns:
pointer to char array which contains the (optionally) swapped elements.

Definition at line 424 of file gnulliver.c.

double gnulliver64f ( double  input  ) 

Optional byteswap of double depending on gnulliver() result.

Parameters:
input [IN ONLY]Value of floating-point variable to be optionally byteswapped.
Returns:
(optionally) byteswapped floating point value.

Definition at line 324 of file gnulliver.c.