forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69
git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 67badf69416a74e74f6d7eb51dd96f37282b8455
This commit is contained in:
142
toxcore/tox_unpack.c
Normal file
142
toxcore/tox_unpack.c
Normal file
@ -0,0 +1,142 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* Copyright © 2022 The TokTok team.
|
||||
*/
|
||||
|
||||
#include "tox_unpack.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bin_unpack.h"
|
||||
#include "ccompat.h"
|
||||
|
||||
bool tox_unpack_conference_type(Bin_Unpack *bu, Tox_Conference_Type *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Conference_Type)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_connection(Bin_Unpack *bu, Tox_Connection *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Connection)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_file_control(Bin_Unpack *bu, Tox_File_Control *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_File_Control)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_message_type(Bin_Unpack *bu, Tox_Message_Type *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Message_Type)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_user_status(Bin_Unpack *bu, Tox_User_Status *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_User_Status)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_privacy_state(Bin_Unpack *bu, Tox_Group_Privacy_State *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Privacy_State)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_voice_state(Bin_Unpack *bu, Tox_Group_Voice_State *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Voice_State)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_topic_lock(Bin_Unpack *bu, Tox_Group_Topic_Lock *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Topic_Lock)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_join_fail(Bin_Unpack *bu, Tox_Group_Join_Fail *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Join_Fail)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_mod_event(Bin_Unpack *bu, Tox_Group_Mod_Event *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Mod_Event)u32;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tox_unpack_group_exit_type(Bin_Unpack *bu, Tox_Group_Exit_Type *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
|
||||
if (!bin_unpack_u32(bu, &u32)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Exit_Type)u32;
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user