]> git.draconx.ca Git - upkg.git/blob - src/pack.h
pack: Relax licensing of integer serialisation routines.
[upkg.git] / src / pack.h
1 /*
2  *  Portable binary serialisation of integral types.
3  *  Copyright (C) 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
16 void pack_16_be(unsigned char *, unsigned short);
17 void pack_32_be(unsigned char *, unsigned long);
18 #ifdef ULLONG_MAX
19 void pack_64_be(unsigned char *, unsigned long long);
20 #endif
21
22 void pack_16_le(unsigned char *, unsigned short);
23 void pack_32_le(unsigned char *, unsigned long);
24 #ifdef ULLONG_MAX
25 void pack_64_le(unsigned char *, unsigned long long);
26 #endif
27
28 unsigned short unpack_16_be(const unsigned char *);
29 unsigned long  unpack_32_be(const unsigned char *);
30 #ifdef ULLONG_MAX
31 unsigned long long unpack_64_be(const unsigned char *);
32 #endif
33
34 unsigned short unpack_16_le(const unsigned char *);
35 unsigned long  unpack_32_le(const unsigned char *);
36 #ifdef ULLONG_MAX
37 unsigned long long unpack_64_le(const unsigned char *);
38 #endif
39
40 short unpack_s16_be(const unsigned char *);
41 long  unpack_s32_be(const unsigned char *);
42 #ifdef LLONG_MAX
43 long long unpack_s64_be(const unsigned char *);
44 #endif
45
46 short unpack_s16_le(const unsigned char *);
47 long  unpack_s32_le(const unsigned char *);
48 #ifdef LLONG_MAX
49 long long unpack_s64_le(const unsigned char *);
50 #endif
51
52 #endif