]> git.draconx.ca Git - upkg.git/blob - src/pack.h
Fix silent-rules alignment in recent Automake.
[upkg.git] / src / pack.h
1 /*
2  *  Portable binary serialisation of integral types.
3  *  Copyright © 2009 Nick Bowler
4  *
5  *  Copying and distribution of this file, with or without modification,
6  *  are permitted in any medium without royalty provided the copyright
7  *  notice and this notice are preserved.  This file is offered as-is,
8  *  without any warranty.
9  */
10
11 #ifndef PACK_H_
12 #define PACK_H_
13
14 #include <limits.h>
15 #if !defined(PACK_HAVE_64BIT) && defined(ULLONG_MAX) && defined(LLONG_MAX)
16 #       define PACK_HAVE_64BIT 1
17 #endif
18
19 void pack_16_be(unsigned char *, unsigned short);
20 void pack_32_be(unsigned char *, unsigned long);
21 #if PACK_HAVE_64BIT
22 void pack_64_be(unsigned char *, unsigned long long);
23 #endif
24
25 void pack_16_le(unsigned char *, unsigned short);
26 void pack_32_le(unsigned char *, unsigned long);
27 #if PACK_HAVE_64BIT
28 void pack_64_le(unsigned char *, unsigned long long);
29 #endif
30
31 unsigned short unpack_16_be(const unsigned char *);
32 unsigned long  unpack_32_be(const unsigned char *);
33 #if PACK_HAVE_64BIT
34 unsigned long long unpack_64_be(const unsigned char *);
35 #endif
36
37 unsigned short unpack_16_le(const unsigned char *);
38 unsigned long  unpack_32_le(const unsigned char *);
39 #if PACK_HAVE_64BIT
40 unsigned long long unpack_64_le(const unsigned char *);
41 #endif
42
43 short unpack_s16_be(const unsigned char *);
44 long  unpack_s32_be(const unsigned char *);
45 #if PACK_HAVE_64BIT
46 long long unpack_s64_be(const unsigned char *);
47 #endif
48
49 short unpack_s16_le(const unsigned char *);
50 long  unpack_s32_le(const unsigned char *);
51 #if PACK_HAVE_64BIT
52 long long unpack_s64_le(const unsigned char *);
53 #endif
54
55 #endif