binary.h 1.45 KB
Newer Older
Thomas Jahns's avatar
Thomas Jahns committed
1
2
#ifndef BINARY_H
#define BINARY_H
Uwe Schulzweida's avatar
Uwe Schulzweida committed
3

4
5
6
7
8
#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <inttypes.h>
Uwe Schulzweida's avatar
Uwe Schulzweida committed
9
10
11
12
#include <stdio.h>

#include "dtypes.h"

13
14
15
16
17
18
19
20
21
#ifndef HOST_ENDIANNESS
#ifdef __cplusplus
static const uint32_t HOST_ENDIANNESS_temp[1] = { UINT32_C(0x00030201) };
#define HOST_ENDIANNESS (((const unsigned char *)HOST_ENDIANNESS_temp)[0])
#else
#define HOST_ENDIANNESS (((const unsigned char *)&(const uint32_t[1]){UINT32_C(0x00030201)})[0])
#endif
#endif

Uwe Schulzweida's avatar
Uwe Schulzweida committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

UINT32 get_UINT32(unsigned char *x);
UINT32 get_SUINT32(unsigned char *x);
UINT64 get_UINT64(unsigned char *x);
UINT64 get_SUINT64(unsigned char *x);


size_t binReadF77Block(int fileID, int byteswap);
void   binWriteF77Block(int fileID, int byteswap, size_t blocksize);

int binReadInt32(int fileID, int byteswap, size_t size, INT32 *ptr);
int binReadInt64(int fileID, int byteswap, size_t size, INT64 *ptr);

int binWriteInt32(int fileID, int byteswap, size_t size, INT32 *ptr);
int binWriteInt64(int fileID, int byteswap, size_t size, INT64 *ptr);

Uwe Schulzweida's avatar
Uwe Schulzweida committed
38
39
int binReadFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr);
int binReadFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
40

Uwe Schulzweida's avatar
Uwe Schulzweida committed
41
42
int binWriteFlt32(int fileID, int byteswap, size_t size, FLT32 *ptr);
int binWriteFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr);
Uwe Schulzweida's avatar
Uwe Schulzweida committed
43

Thomas Jahns's avatar
Thomas Jahns committed
44
#endif  /* BINARY_H */
45
46
47
48
49
50
51
52
53
/*
 * Local Variables:
 * c-file-style: "Java"
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * show-trailing-whitespace: t
 * require-trailing-newline: t
 * End:
 */