gen-strtab.awk: Work around ULTRIX 4.5 nawk bug.
[dxcommon.git] / src / pack.h
blobe14a10d9f502f06b7f9344da95b193f8121c46be
1 /*
2 * Copyright © 2009, 2023 Nick Bowler
4 * Portable binary (de-)serialisation of integral types.
6 * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 * This is free software: you are free to do what the fuck you want to.
8 * There is NO WARRANTY, to the extent permitted by law.
9 */
11 #ifndef DX_PACK_H_
12 #define DX_PACK_H_
14 #ifndef PACK_HAVE_64BIT
15 # if HAVE_LONG_LONG_INT
16 # define PACK_HAVE_64BIT 1
17 # else
18 # include <limits.h>
19 # if defined(LLONG_MAX) || defined(LONG_LONG_MAX)
20 # define PACK_HAVE_64BIT 1
21 # endif
22 # endif
23 #endif
25 short unpack_s16_be(const unsigned char *);
26 short unpack_s16_le(const unsigned char *);
27 unsigned short unpack_16_be(const unsigned char *);
28 unsigned short unpack_16_le(const unsigned char *);
29 void pack_16_be(unsigned char *, unsigned short);
30 void pack_16_le(unsigned char *, unsigned short);
32 long unpack_s32_be(const unsigned char *);
33 long unpack_s32_le(const unsigned char *);
34 unsigned long unpack_32_be(const unsigned char *);
35 unsigned long unpack_32_le(const unsigned char *);
36 void pack_32_be(unsigned char *, unsigned long);
37 void pack_32_le(unsigned char *, unsigned long);
39 #if PACK_HAVE_64BIT
40 long long unpack_s64_be(const unsigned char *);
41 long long unpack_s64_le(const unsigned char *);
42 unsigned long long unpack_64_be(const unsigned char *);
43 unsigned long long unpack_64_le(const unsigned char *);
44 void pack_64_be(unsigned char *, unsigned long long);
45 void pack_64_le(unsigned char *, unsigned long long);
46 #endif
48 #endif