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