summaryrefslogtreecommitdiff
path: root/toxcore/state.c
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2018-10-31 19:21:00 +0100
committeriphydf <iphydf@users.noreply.github.com>2019-01-05 15:01:29 +0000
commita122ee9e01a1614366350537e1b49299eb355c1d (patch)
tree71dac74aa73f90bce66b8cc9299408e0c4e52c42 /toxcore/state.c
parentebf3a82de8709270cb46266f1c06a3c1cee0649d (diff)
Expose offline conference peers in API
Diffstat (limited to 'toxcore/state.c')
-rw-r--r--toxcore/state.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/toxcore/state.c b/toxcore/state.c
index 919c2e8c..bca7a151 100644
--- a/toxcore/state.c
+++ b/toxcore/state.c
@@ -84,6 +84,28 @@ uint16_t host_to_lendian16(uint16_t host)
84 return lendian_to_host16(host); 84 return lendian_to_host16(host);
85} 85}
86 86
87void host_to_lendian_bytes64(uint8_t *dest, uint64_t num)
88{
89#ifdef WORDS_BIGENDIAN
90 num = ((num << 8) & 0xFF00FF00FF00FF00) | ((num >> 8) & 0xFF00FF00FF00FF);
91 num = ((num << 16) & 0xFFFF0000FFFF0000) | ((num >> 16) & 0xFFFF0000FFFF);
92 num = (num << 32) | (num >> 32);
93#endif
94 memcpy(dest, &num, sizeof(uint64_t));
95}
96
97void lendian_bytes_to_host64(uint64_t *dest, const uint8_t *lendian)
98{
99 uint64_t d;
100 memcpy(&d, lendian, sizeof(uint64_t));
101#ifdef WORDS_BIGENDIAN
102 d = ((d << 8) & 0xFF00FF00FF00FF00) | ((d >> 8) & 0xFF00FF00FF00FF);
103 d = ((d << 16) & 0xFFFF0000FFFF0000) | ((d >> 16) & 0xFFFF0000FFFF);
104 d = (d << 32) | (d >> 32);
105#endif
106 *dest = d;
107}
108
87void host_to_lendian_bytes32(uint8_t *dest, uint32_t num) 109void host_to_lendian_bytes32(uint8_t *dest, uint32_t num)
88{ 110{
89#ifdef WORDS_BIGENDIAN 111#ifdef WORDS_BIGENDIAN