ws server +proto
This commit is contained in:
30
inc/proto/pack.h
Normal file
30
inc/proto/pack.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef __PROTO_PACK_H__
|
||||
#define __PROTO_PACK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
uint64_t decodeBytesToU64(const uint8_t* bytes);
|
||||
uint32_t decodeBytesToU32(const uint8_t* bytes);
|
||||
uint16_t decodeBytesToU16(const uint8_t* bytes);
|
||||
|
||||
|
||||
|
||||
void encodeUint8ToBytes(uint8_t num, uint8_t* tgt);
|
||||
void encodeUint16ToBytes(uint16_t num, uint8_t* tgt);
|
||||
void encodeUint32ToBytes(uint32_t num, uint8_t* tgt);
|
||||
void encodeUint64ToBytes(uint64_t num, uint8_t* tgt);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define encodeUintToBytes(num, tgt) _Generic((num), \
|
||||
uint8_t: encodeUint8ToBytes, \
|
||||
uint16_t: encodeUint16ToBytes, \
|
||||
uint32_t: encodeUint32ToBytes, \
|
||||
uint64_t: encodeUint64ToBytes \
|
||||
)(num, tgt)
|
||||
|
||||
#endif //ifndef __PROTO_PACK_H__
|
||||
Reference in New Issue
Block a user