Mercurial > hg > th-libs
comparison th_endian.h @ 0:bd61a80a6c54
Initial import into Mercurial repository. Discarding old cvs/svn history
here, because it's cluttered and commit messages are mostly crap.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 26 Mar 2008 04:41:58 +0200 |
parents | |
children | 8552edc844a7 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bd61a80a6c54 |
---|---|
1 /* | |
2 * Endianess handling | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2002-2007 Tecnic Software productions (TNSP) | |
5 * | |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #ifndef _TH_ENDIAN_H | |
9 #define _TH_ENDIAN_H | |
10 | |
11 #ifdef __cplusplus | |
12 extern "C" { | |
13 #endif | |
14 | |
15 #ifdef HAVE_CONFIG_H | |
16 #include "config.h" | |
17 #endif | |
18 #include <stdio.h> | |
19 #include "th_types.h" | |
20 | |
21 /* | |
22 * Data endianess conversion routines | |
23 */ | |
24 #ifdef TH_BIGENDIAN | |
25 void TH_NE16(uint16_t *); | |
26 void TH_NE32(uint32_t *); | |
27 uint16_t TH_LE16(uint16_t); | |
28 uint32_t TH_LE32(uint32_t); | |
29 #else | |
30 #define TH_NE16(X) | |
31 #define TH_NE32(X) | |
32 #define TH_LE16(X) X | |
33 #define TH_LE32(X) X | |
34 #endif | |
35 | |
36 | |
37 /* | |
38 * Endian-handling file read/write routines | |
39 */ | |
40 BOOL TH_READ_STR(FILE *f, uint8_t *s, size_t l); | |
41 uint16_t TH_READ_BE16(FILE *f); | |
42 uint32_t TH_READ_BE32(FILE *f); | |
43 uint16_t TH_READ_LE16(FILE *f); | |
44 uint32_t TH_READ_LE32(FILE *f); | |
45 | |
46 BOOL TH_WRITE_STR(FILE *f, uint8_t *s, size_t l); | |
47 void TH_WRITE_BE16(FILE *f, uint16_t v); | |
48 void TH_WRITE_BE32(FILE *f, uint32_t v); | |
49 void TH_WRITE_LE16(FILE *f, uint16_t v); | |
50 void TH_WRITE_LE32(FILE *f, uint32_t v); | |
51 | |
52 #ifdef __cplusplus | |
53 } | |
54 #endif | |
55 #endif /* _TH_ENDIAN_H */ |