]>
Commit | Line | Data |
---|---|---|
faeb1b64 KZ |
1 | /* |
2 | * No copyright is claimed. This code is in the public domain; do with | |
3 | * it what you wish. | |
4 | */ | |
1f10f4af DD |
5 | #ifndef UTIL_LINUX_ISO_H |
6 | #define UTIL_LINUX_ISO_H | |
7 | ||
8 | #include <stdbool.h> | |
9fc18efe | 9 | #include <stdint.h> |
1f10f4af DD |
10 | |
11 | #include "c.h" | |
12 | ||
9fc18efe | 13 | static inline uint16_t isonum_721(const unsigned char *p) |
1f10f4af DD |
14 | { |
15 | return ((p[0] & 0xff) | |
16 | | ((p[1] & 0xff) << 8)); | |
17 | } | |
18 | ||
9fc18efe | 19 | static inline uint16_t isonum_722(const unsigned char *p) |
1f10f4af DD |
20 | { |
21 | return ((p[1] & 0xff) | |
22 | | ((p[0] & 0xff) << 8)); | |
23 | } | |
24 | ||
9fc18efe | 25 | static inline uint16_t isonum_723(const unsigned char *p, bool check_match) |
1f10f4af | 26 | { |
9fc18efe TW |
27 | uint16_t le = isonum_721(p); |
28 | uint16_t be = isonum_722(p + 2); | |
1f10f4af DD |
29 | |
30 | if (check_match && le != be) | |
31 | /* translation is useless */ | |
32 | warnx("723error: le=%d be=%d", le, be); | |
33 | return (le); | |
34 | } | |
35 | ||
9fc18efe | 36 | static inline uint32_t isonum_731(const unsigned char *p) |
1f10f4af DD |
37 | { |
38 | return ((p[0] & 0xff) | |
39 | | ((p[1] & 0xff) << 8) | |
40 | | ((p[2] & 0xff) << 16) | |
893fe60d | 41 | | (((uint32_t) p[3] & 0xff) << 24)); |
1f10f4af DD |
42 | } |
43 | ||
9fc18efe | 44 | static inline uint32_t isonum_732(const unsigned char *p) |
1f10f4af DD |
45 | { |
46 | return ((p[3] & 0xff) | |
47 | | ((p[2] & 0xff) << 8) | |
48 | | ((p[1] & 0xff) << 16) | |
893fe60d | 49 | | (((uint32_t) p[0] & 0xff) << 24)); |
1f10f4af DD |
50 | } |
51 | ||
9fc18efe | 52 | static inline uint32_t isonum_733(const unsigned char *p, bool check_match) |
1f10f4af | 53 | { |
9fc18efe TW |
54 | uint32_t le = isonum_731(p); |
55 | uint32_t be = isonum_732(p + 4); | |
1f10f4af DD |
56 | |
57 | if (check_match && le != be) | |
58 | /* translation is useless */ | |
59 | warnx("733error: le=%d be=%d", le, be); | |
60 | return(le); | |
61 | } | |
62 | ||
63 | #endif |