Added twc_uint32_reverse_bytes function.
This commit is contained in:
parent
069c4540ec
commit
1d64f5ac50
@ -148,3 +148,18 @@ twc_get_friend_id_short(Tox *tox, int32_t friend_number)
|
||||
return hex_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the bytes of a 32-bit integer.
|
||||
*/
|
||||
uint32_t
|
||||
twc_uint32_reverse_bytes(uint32_t num)
|
||||
{
|
||||
uint32_t res = 0;
|
||||
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF; num >>= 8; res <<= 8;
|
||||
res += num & 0xFF;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -48,5 +48,8 @@ twc_get_self_name_nt(Tox *tox);
|
||||
char *
|
||||
twc_get_friend_id_short(Tox *tox, int32_t friend_number);
|
||||
|
||||
uint32_t
|
||||
twc_uint32_reverse_bytes(uint32_t num);
|
||||
|
||||
#endif // TOX_WEECHAT_UTILS_H
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user