mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-23 10:01:58 +03:00
0154018363
* FBT: cdefines to env, libs order * API: strtod, modf, itoa, calloc * Apps: elk js * Apps: mjs * JS: scripts as assets * mjs: composite resolver * mjs: stack trace * ELK JS example removed * MJS thread, MJS lib modified to support script interruption * JS console UI * Module system, BadUSB bindings rework * JS notifications, simple dialog, BadUSB demo * Custom dialogs, dialog demo * MJS as system library, some dirty hacks to make it compile * Plugin-based js modules * js_uart(BadUART) module * js_uart: support for byte array arguments * Script icon and various fixes * File browser: multiple extensions filter, running js scripts from app loader * Running js scripts from archive browser * JS Runner as system app * Example scripts moved to /ext/apps/Scripts * JS bytecode listing generation * MJS builtin printf cleanup * JS examples cleanup * mbedtls version fix * Unused lib cleanup * Making PVS happy & TODOs cleanup * TODOs cleanup #2 * MJS: initial typed arrays support * JS: fix mem leak in uart destructor Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
60 lines
1.7 KiB
C
60 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 2014-2018 Cesanta Software Limited
|
|
* All rights reserved
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the ""License"");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an ""AS IS"" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef CS_COMMON_CS_VARINT_H_
|
|
#define CS_COMMON_CS_VARINT_H_
|
|
|
|
#if defined(_WIN32) && _MSC_VER < 1700
|
|
typedef unsigned char uint8_t;
|
|
typedef unsigned __int64 uint64_t;
|
|
#else
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Returns number of bytes required to encode `num`. */
|
|
size_t cs_varint_llen(uint64_t num);
|
|
|
|
/*
|
|
* Encodes `num` into `buf`.
|
|
* Returns number of bytes required to encode `num`.
|
|
* Note: return value may be greater than `buf_size` but the function will only
|
|
* write `buf_size` bytes.
|
|
*/
|
|
size_t cs_varint_encode(uint64_t num, uint8_t *buf, size_t buf_size);
|
|
|
|
/*
|
|
* Decodes varint stored in `buf`.
|
|
* Stores the number of bytes consumed into `llen`.
|
|
* If there aren't enough bytes in `buf` to decode a number, returns false.
|
|
*/
|
|
bool cs_varint_decode(const uint8_t *buf, size_t buf_size, uint64_t *num,
|
|
size_t *llen);
|
|
|
|
uint64_t cs_varint_decode_unsafe(const uint8_t *buf, int *llen);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* CS_COMMON_CS_VARINT_H_ */
|