unleashed-firmware/lib/toolbox/varint.h
hedger ffa3996a5e
[FL-3867] Code formatting update (#3765)
* clang-format: AllowShortEnumsOnASingleLine: false
* clang-format: InsertNewlineAtEOF: true
* clang-format: Standard:        c++20
* clang-format: AlignConsecutiveBitFields
* clang-format: AlignConsecutiveMacros
* clang-format: RemoveParentheses: ReturnStatement
* clang-format: RemoveSemicolon: true
* Restored RemoveParentheses: Leave, retained general changes for it
* formatting: fixed logging TAGs
* Formatting update for dev

Co-authored-by: あく <alleteam@gmail.com>
2024-07-15 13:38:49 +09:00

35 lines
849 B
C

#pragma once
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Pack uint32 to varint
* @param value value from UINT32_MIN to UINT32_MAX
* @param output output array, need to be at least 5 bytes long
* @return size_t
*/
size_t varint_uint32_pack(uint32_t value, uint8_t* output);
size_t varint_uint32_unpack(uint32_t* value, const uint8_t* input, size_t input_size);
size_t varint_uint32_length(uint32_t value);
/**
* Pack int32 to varint
* @param value value from (INT32_MIN / 2 + 1) to INT32_MAX
* @param output output array, need to be at least 5 bytes long
* @return size_t
*/
size_t varint_int32_pack(int32_t value, uint8_t* output);
size_t varint_int32_unpack(int32_t* value, const uint8_t* input, size_t input_size);
size_t varint_int32_length(int32_t value);
#ifdef __cplusplus
}
#endif