/src/gnupg/common/host2net.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* host2net.h - Endian conversion macros |
2 | | * Copyright (C) 1998, 2014, 2015 Werner Koch |
3 | | * |
4 | | * This file is part of GnuPG. |
5 | | * |
6 | | * This file is free software; you can redistribute it and/or modify |
7 | | * it under the terms of either |
8 | | * |
9 | | * - the GNU Lesser General Public License as published by the Free |
10 | | * Software Foundation; either version 3 of the License, or (at |
11 | | * your option) any later version. |
12 | | * |
13 | | * or |
14 | | * |
15 | | * - the GNU General Public License as published by the Free |
16 | | * Software Foundation; either version 2 of the License, or (at |
17 | | * your option) any later version. |
18 | | * |
19 | | * or both in parallel, as here. |
20 | | * |
21 | | * This file is distributed in the hope that it will be useful, |
22 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 | | * GNU General Public License for more details. |
25 | | * |
26 | | * You should have received a copy of the GNU General Public License |
27 | | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
28 | | */ |
29 | | |
30 | | #ifndef GNUPG_COMMON_HOST2NET_H |
31 | | #define GNUPG_COMMON_HOST2NET_H |
32 | | |
33 | | #include "types.h" |
34 | | |
35 | | #define ulongtobuf( p, a ) do { \ |
36 | | ((byte*)p)[0] = a >> 24; \ |
37 | | ((byte*)p)[1] = a >> 16; \ |
38 | | ((byte*)p)[2] = a >> 8; \ |
39 | | ((byte*)p)[3] = a ; \ |
40 | | } while(0) |
41 | | #define ushorttobuf( p, a ) do { \ |
42 | | ((byte*)p)[0] = a >> 8; \ |
43 | | ((byte*)p)[1] = a ; \ |
44 | | } while(0) |
45 | | |
46 | | |
47 | | static inline unsigned long |
48 | | buf16_to_ulong (const void *buffer) |
49 | 0 | { |
50 | 0 | const unsigned char *p = buffer; |
51 | |
|
52 | 0 | return (((unsigned long)p[0] << 8) | p[1]); |
53 | 0 | } Unexecuted instantiation: keybox-blob.c:buf16_to_ulong Unexecuted instantiation: keybox-search.c:buf16_to_ulong Unexecuted instantiation: keybox-update.c:buf16_to_ulong Unexecuted instantiation: keybox-openpgp.c:buf16_to_ulong Unexecuted instantiation: kbx-client-util.c:buf16_to_ulong |
54 | | |
55 | | static inline unsigned int |
56 | | buf16_to_uint (const void *buffer) |
57 | 0 | { |
58 | 0 | const unsigned char *p = buffer; |
59 | |
|
60 | 0 | return (((unsigned int)p[0] << 8) | p[1]); |
61 | 0 | } Unexecuted instantiation: keybox-blob.c:buf16_to_uint Unexecuted instantiation: keybox-search.c:buf16_to_uint Unexecuted instantiation: keybox-update.c:buf16_to_uint Unexecuted instantiation: keybox-openpgp.c:buf16_to_uint Unexecuted instantiation: kbx-client-util.c:buf16_to_uint |
62 | | |
63 | | static inline unsigned short |
64 | | buf16_to_ushort (const void *buffer) |
65 | 0 | { |
66 | 0 | const unsigned char *p = buffer; |
67 | 0 |
|
68 | 0 | return (((unsigned short)p[0] << 8) | p[1]); |
69 | 0 | } Unexecuted instantiation: keybox-blob.c:buf16_to_ushort Unexecuted instantiation: keybox-search.c:buf16_to_ushort Unexecuted instantiation: keybox-update.c:buf16_to_ushort Unexecuted instantiation: keybox-openpgp.c:buf16_to_ushort Unexecuted instantiation: kbx-client-util.c:buf16_to_ushort |
70 | | |
71 | | static inline u16 |
72 | | buf16_to_u16 (const void *buffer) |
73 | 0 | { |
74 | 0 | const unsigned char *p = buffer; |
75 | 0 |
|
76 | 0 | return (((u16)p[0] << 8) | p[1]); |
77 | 0 | } Unexecuted instantiation: keybox-blob.c:buf16_to_u16 Unexecuted instantiation: keybox-search.c:buf16_to_u16 Unexecuted instantiation: keybox-update.c:buf16_to_u16 Unexecuted instantiation: keybox-openpgp.c:buf16_to_u16 Unexecuted instantiation: kbx-client-util.c:buf16_to_u16 |
78 | | |
79 | | static inline size_t |
80 | | buf32_to_size_t (const void *buffer) |
81 | 0 | { |
82 | 0 | const unsigned char *p = buffer; |
83 | |
|
84 | 0 | return (((size_t)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); |
85 | 0 | } Unexecuted instantiation: keybox-blob.c:buf32_to_size_t Unexecuted instantiation: keybox-search.c:buf32_to_size_t Unexecuted instantiation: keybox-update.c:buf32_to_size_t Unexecuted instantiation: keybox-openpgp.c:buf32_to_size_t Unexecuted instantiation: kbx-client-util.c:buf32_to_size_t |
86 | | |
87 | | static inline unsigned long |
88 | | buf32_to_ulong (const void *buffer) |
89 | 0 | { |
90 | 0 | const unsigned char *p = buffer; |
91 | |
|
92 | 0 | return (((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); |
93 | 0 | } Unexecuted instantiation: keybox-blob.c:buf32_to_ulong Unexecuted instantiation: keybox-search.c:buf32_to_ulong Unexecuted instantiation: keybox-update.c:buf32_to_ulong Unexecuted instantiation: keybox-openpgp.c:buf32_to_ulong Unexecuted instantiation: kbx-client-util.c:buf32_to_ulong |
94 | | |
95 | | static inline unsigned int |
96 | | buf32_to_uint (const void *buffer) |
97 | 0 | { |
98 | 0 | const unsigned char *p = buffer; |
99 | 0 |
|
100 | 0 | return (((unsigned int)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); |
101 | 0 | } Unexecuted instantiation: keybox-blob.c:buf32_to_uint Unexecuted instantiation: keybox-search.c:buf32_to_uint Unexecuted instantiation: keybox-update.c:buf32_to_uint Unexecuted instantiation: keybox-openpgp.c:buf32_to_uint Unexecuted instantiation: kbx-client-util.c:buf32_to_uint |
102 | | |
103 | | static inline u32 |
104 | | buf32_to_u32 (const void *buffer) |
105 | 1 | { |
106 | 1 | const unsigned char *p = buffer; |
107 | | |
108 | 1 | return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); |
109 | 1 | } Unexecuted instantiation: keybox-blob.c:buf32_to_u32 Unexecuted instantiation: keybox-search.c:buf32_to_u32 keybox-update.c:buf32_to_u32 Line | Count | Source | 105 | 1 | { | 106 | 1 | const unsigned char *p = buffer; | 107 | | | 108 | 1 | return (((u32)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); | 109 | 1 | } |
Unexecuted instantiation: keybox-openpgp.c:buf32_to_u32 Unexecuted instantiation: kbx-client-util.c:buf32_to_u32 |
110 | | |
111 | | |
112 | | #endif /*GNUPG_COMMON_HOST2NET_H*/ |