Show More
@@ -9,26 +9,21 b' static inline uint32_t getbe32(const cha' | |||||
9 | { |
|
9 | { | |
10 | const unsigned char *d = (const unsigned char *)c; |
|
10 | const unsigned char *d = (const unsigned char *)c; | |
11 |
|
11 | |||
12 | return ((d[0] << 24) | |
|
12 | return ((d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3])); | |
13 | (d[1] << 16) | |
|
|||
14 | (d[2] << 8) | |
|
|||
15 | (d[3])); |
|
|||
16 | } |
|
13 | } | |
17 |
|
14 | |||
18 | static inline int16_t getbeint16(const char *c) |
|
15 | static inline int16_t getbeint16(const char *c) | |
19 | { |
|
16 | { | |
20 | const unsigned char *d = (const unsigned char *)c; |
|
17 | const unsigned char *d = (const unsigned char *)c; | |
21 |
|
18 | |||
22 | return ((d[0] << 8) | |
|
19 | return ((d[0] << 8) | (d[1])); | |
23 | (d[1])); |
|
|||
24 | } |
|
20 | } | |
25 |
|
21 | |||
26 | static inline uint16_t getbeuint16(const char *c) |
|
22 | static inline uint16_t getbeuint16(const char *c) | |
27 | { |
|
23 | { | |
28 | const unsigned char *d = (const unsigned char *)c; |
|
24 | const unsigned char *d = (const unsigned char *)c; | |
29 |
|
25 | |||
30 | return ((d[0] << 8) | |
|
26 | return ((d[0] << 8) | (d[1])); | |
31 | (d[1])); |
|
|||
32 | } |
|
27 | } | |
33 |
|
28 | |||
34 | static inline void putbe32(uint32_t x, char *c) |
|
29 | static inline void putbe32(uint32_t x, char *c) | |
@@ -36,7 +31,7 b' static inline void putbe32(uint32_t x, c' | |||||
36 | c[0] = (x >> 24) & 0xff; |
|
31 | c[0] = (x >> 24) & 0xff; | |
37 | c[1] = (x >> 16) & 0xff; |
|
32 | c[1] = (x >> 16) & 0xff; | |
38 | c[2] = (x >> 8) & 0xff; |
|
33 | c[2] = (x >> 8) & 0xff; | |
39 |
c[3] = (x) |
|
34 | c[3] = (x)&0xff; | |
40 | } |
|
35 | } | |
41 |
|
36 | |||
42 | static inline double getbefloat64(const char *c) |
|
37 | static inline double getbefloat64(const char *c) | |
@@ -46,7 +41,7 b' static inline double getbefloat64(const ' | |||||
46 | int i; |
|
41 | int i; | |
47 | uint64_t t = 0; |
|
42 | uint64_t t = 0; | |
48 | for (i = 0; i < 8; i++) { |
|
43 | for (i = 0; i < 8; i++) { | |
49 | t = (t<<8) + d[i]; |
|
44 | t = (t << 8) + d[i]; | |
50 | } |
|
45 | } | |
51 | memcpy(&ret, &t, sizeof(t)); |
|
46 | memcpy(&ret, &t, sizeof(t)); | |
52 | return ret; |
|
47 | return ret; |
General Comments 0
You need to be logged in to leave comments.
Login now