|
TPCCLIB
|
Byte swapping between little and big endian. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <math.h>#include "tpcextensions.h"Go to the source code of this file.
Functions | |
| int | endianness () |
| int | endianLittle () |
| void | swap (void *from, void *to, int size) |
| void | swabip (void *buf, int size) |
| void | swawbip (void *buf, int size) |
| void | swawip (void *buf, int size) |
| void | swap64ip (void *buf, unsigned long long size) |
| void | swap32ip (void *buf, unsigned long long size) |
| void | swap16ip (void *buf, unsigned long long size) |
Byte swapping between little and big endian.
Definition in file endian.c.
| int endianLittle | ( | ) |
Check whether current platform uses little endian byte order.
Definition at line 53 of file endian.c.
Referenced by anaReadHeader(), dcmFileWrite(), dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileTag(), dcmWriteFileVRVL(), ecatMListRead(), ecatReadMainheader(), ecatWriteMainheader(), imgReadNifti(), imgSetNiftiHeader(), niftiReadHeader(), and niftiWriteHeader().
| int endianness | ( | ) |
Detect endianness at run-time. From https://sourceforge.net/p/predef/wiki/Endianness/
Definition at line 26 of file endian.c.
Referenced by endianLittle().
| void swabip | ( | void * | buf, |
| int | size ) |
In-place swab, replaces the non-ANSI function swab(), which may not work if data is overlapping.
| buf | Pointer to memory |
| size | Size of buf in bytes |
Definition at line 115 of file endian.c.
Referenced by anaReadHeader(), dcmFileWrite(), dcmWriteFileTag(), niftiReadHeader(), and niftiWriteHeader().
| void swap | ( | void * | from, |
| void * | to, | ||
| int | size ) |
Swap the specified short int, int, long int, float, or double from little endian to big endian or vice versa.
Arguments are allowed to overlap.
| from | Pointer to a short int, int, long int, float, or double variable. |
| to | Pointer to a short int, int, long int, float, or double variable. |
| size | Size of from and to (byte nr) must be 1, 2, 4 or 8. |
Definition at line 69 of file endian.c.
Referenced by dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileVRVL(), and swap().
| void swap16ip | ( | void * | buf, |
| unsigned long long | size ) |
In-place big-little endian swapping of an array of 16 bit (2 byte) integers.
| buf | Pointer to memory. |
| size | Nr of 16 bit values in the array. |
Definition at line 234 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
| void swap32ip | ( | void * | buf, |
| unsigned long long | size ) |
In-place big-little endian swapping of an array of 32 bit (4 byte) integers or floating point values.
| buf | Pointer to memory. |
| size | Nr of 32 bit values in the array. |
Definition at line 210 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
| void swap64ip | ( | void * | buf, |
| unsigned long long | size ) |
In-place big-little endian swapping of an array of 64 bit (8 byte) integers or floating point values.
| buf | Pointer to memory. |
| size | Nr of 64 bit values in the array. |
Definition at line 184 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
| void swawbip | ( | void * | buf, |
| int | size ) |
In-place swab and swaw, switches words and bytes from an array of 4-byte ints or floats.
| buf | Pointer to memory |
| size | Size of buf in bytes |
Definition at line 138 of file endian.c.
Referenced by anaReadHeader(), ecatMListRead(), niftiReadHeader(), and niftiWriteHeader().
| void swawip | ( | void * | buf, |
| int | size ) |
In-place swaw, switches words (but not bytes) from an array of 4-byte ints or floats.
| buf | Pointer to memory |
| size | Size of buf in bytes |
Definition at line 161 of file endian.c.