Merge branch 'fz-dev' into dev

This commit is contained in:
MX
2022-10-05 19:27:46 +03:00
368 changed files with 5461 additions and 3819 deletions

View File

@@ -30,8 +30,8 @@ bool flipper_format_stream_write_eol(Stream* stream) {
return flipper_format_stream_write(stream, &flipper_format_eoln, 1);
}
static bool flipper_format_stream_read_valid_key(Stream* stream, string_t key) {
string_reset(key);
static bool flipper_format_stream_read_valid_key(Stream* stream, FuriString* key) {
furi_string_reset(key);
const size_t buffer_size = 32;
uint8_t buffer[buffer_size];
@@ -48,7 +48,7 @@ static bool flipper_format_stream_read_valid_key(Stream* stream, string_t key) {
uint8_t data = buffer[i];
if(data == flipper_format_eoln) {
// EOL found, clean data, start accumulating data and set the new_line flag
string_reset(key);
furi_string_reset(key);
accumulate = true;
new_line = true;
} else if(data == flipper_format_eolr) {
@@ -64,7 +64,7 @@ static bool flipper_format_stream_read_valid_key(Stream* stream, string_t key) {
// this can only be if we have previously found some kind of key, so
// clear the data, set the flag that we no longer want to accumulate data
// and reset the new_line flag
string_reset(key);
furi_string_reset(key);
accumulate = false;
new_line = false;
} else {
@@ -86,7 +86,7 @@ static bool flipper_format_stream_read_valid_key(Stream* stream, string_t key) {
new_line = false;
if(accumulate) {
// and accumulate data if we want
string_push_back(key, data);
furi_string_push_back(key, data);
}
}
}
@@ -99,13 +99,13 @@ static bool flipper_format_stream_read_valid_key(Stream* stream, string_t key) {
bool flipper_format_stream_seek_to_key(Stream* stream, const char* key, bool strict_mode) {
bool found = false;
string_t read_key;
FuriString* read_key;
string_init(read_key);
read_key = furi_string_alloc();
while(!stream_eof(stream)) {
if(flipper_format_stream_read_valid_key(stream, read_key)) {
if(string_cmp_str(read_key, key) == 0) {
if(furi_string_cmp_str(read_key, key) == 0) {
if(!stream_seek(stream, 2, StreamOffsetFromCurrent)) break;
found = true;
@@ -116,7 +116,7 @@ bool flipper_format_stream_seek_to_key(Stream* stream, const char* key, bool str
}
}
}
string_clear(read_key);
furi_string_free(read_key);
return found;
}
@@ -189,8 +189,8 @@ static bool flipper_format_stream_read_value(Stream* stream, string_t value, boo
return result;
}
static bool flipper_format_stream_read_line(Stream* stream, string_t str_result) {
string_reset(str_result);
static bool flipper_format_stream_read_line(Stream* stream, FuriString* str_result) {
furi_string_reset(str_result);
const size_t buffer_size = 32;
uint8_t buffer[buffer_size];
@@ -214,7 +214,7 @@ static bool flipper_format_stream_read_line(Stream* stream, string_t str_result)
} else if(data == flipper_format_eolr) {
// Ignore
} else {
string_push_back(str_result, data);
furi_string_push_back(str_result, data);
}
}
@@ -223,7 +223,7 @@ static bool flipper_format_stream_read_line(Stream* stream, string_t str_result)
}
} while(true);
return string_size(str_result) != 0;
return furi_string_size(str_result) != 0;
}
static bool flipper_format_stream_seek_to_next_line(Stream* stream) {
@@ -267,8 +267,8 @@ bool flipper_format_stream_write_value_line(Stream* stream, FlipperStreamWriteDa
if(write_data->type == FlipperStreamValueIgnore) {
result = true;
} else {
string_t value;
string_init(value);
FuriString* value;
value = furi_string_alloc();
do {
if(!flipper_format_stream_write_key(stream, write_data->key)) break;
@@ -280,45 +280,45 @@ bool flipper_format_stream_write_value_line(Stream* stream, FlipperStreamWriteDa
switch(write_data->type) {
case FlipperStreamValueStr: {
const char* data = write_data->data;
string_printf(value, "%s", data);
furi_string_printf(value, "%s", data);
}; break;
case FlipperStreamValueHex: {
const uint8_t* data = write_data->data;
string_printf(value, "%02X", data[i]);
furi_string_printf(value, "%02X", data[i]);
}; break;
#ifndef FLIPPER_STREAM_LITE
case FlipperStreamValueFloat: {
const float* data = write_data->data;
string_printf(value, "%f", (double)data[i]);
furi_string_printf(value, "%f", (double)data[i]);
}; break;
#endif
case FlipperStreamValueInt32: {
const int32_t* data = write_data->data;
string_printf(value, "%" PRIi32, data[i]);
furi_string_printf(value, "%" PRIi32, data[i]);
}; break;
case FlipperStreamValueUint32: {
const uint32_t* data = write_data->data;
string_printf(value, "%" PRId32, data[i]);
furi_string_printf(value, "%" PRId32, data[i]);
}; break;
case FlipperStreamValueHexUint64: {
const uint64_t* data = write_data->data;
string_printf(
furi_string_printf(
value, "%08lX%08lX", (uint32_t)(data[i] >> 32), (uint32_t)data[i]);
}; break;
case FlipperStreamValueBool: {
const bool* data = write_data->data;
string_printf(value, data[i] ? "true" : "false");
furi_string_printf(value, data[i] ? "true" : "false");
}; break;
default:
furi_crash("Unknown FF type");
}
if((size_t)(i + 1) < write_data->data_size) {
string_cat(value, " ");
furi_string_cat(value, " ");
}
if(!flipper_format_stream_write(
stream, string_get_cstr(value), string_size(value))) {
stream, furi_string_get_cstr(value), furi_string_size(value))) {
cycle_error = true;
break;
}
@@ -329,7 +329,7 @@ bool flipper_format_stream_write_value_line(Stream* stream, FlipperStreamWriteDa
result = true;
} while(false);
string_clear(value);
furi_string_free(value);
}
return result;
@@ -348,15 +348,15 @@ bool flipper_format_stream_read_value_line(
if(!flipper_format_stream_seek_to_key(stream, key, strict_mode)) break;
if(type == FlipperStreamValueStr) {
string_ptr data = (string_ptr)_data;
FuriString* data = (FuriString*)_data;
if(flipper_format_stream_read_line(stream, data)) {
result = true;
break;
}
} else {
result = true;
string_t value;
string_init(value);
FuriString* value;
value = furi_string_alloc();
for(size_t i = 0; i < data_size; i++) {
bool last = false;
@@ -367,11 +367,11 @@ bool flipper_format_stream_read_value_line(
switch(type) {
case FlipperStreamValueHex: {
uint8_t* data = _data;
if(string_size(value) >= 2) {
if(furi_string_size(value) >= 2) {
// sscanf "%02X" does not work here
if(hex_char_to_uint8(
string_get_char(value, 0),
string_get_char(value, 1),
furi_string_get_char(value, 0),
furi_string_get_char(value, 1),
&data[i])) {
scan_values = 1;
}
@@ -381,9 +381,9 @@ bool flipper_format_stream_read_value_line(
case FlipperStreamValueFloat: {
float* data = _data;
// newlib-nano does not have sscanf for floats
// scan_values = sscanf(string_get_cstr(value), "%f", &data[i]);
// scan_values = sscanf(furi_string_get_cstr(value), "%f", &data[i]);
char* end_char;
data[i] = strtof(string_get_cstr(value), &end_char);
data[i] = strtof(furi_string_get_cstr(value), &end_char);
if(*end_char == 0) {
// most likely ok
scan_values = 1;
@@ -392,23 +392,23 @@ bool flipper_format_stream_read_value_line(
#endif
case FlipperStreamValueInt32: {
int32_t* data = _data;
scan_values = sscanf(string_get_cstr(value), "%" PRIi32, &data[i]);
scan_values = sscanf(furi_string_get_cstr(value), "%" PRIi32, &data[i]);
}; break;
case FlipperStreamValueUint32: {
uint32_t* data = _data;
scan_values = sscanf(string_get_cstr(value), "%" PRId32, &data[i]);
scan_values = sscanf(furi_string_get_cstr(value), "%" PRId32, &data[i]);
}; break;
case FlipperStreamValueHexUint64: {
uint64_t* data = _data;
if(string_size(value) >= 16) {
if(hex_chars_to_uint64(string_get_cstr(value), &data[i])) {
if(furi_string_size(value) >= 16) {
if(hex_chars_to_uint64(furi_string_get_cstr(value), &data[i])) {
scan_values = 1;
}
}
}; break;
case FlipperStreamValueBool: {
bool* data = _data;
data[i] = !string_cmpi_str(value, "true");
data[i] = !furi_string_cmpi(value, "true");
scan_values = 1;
}; break;
default:
@@ -429,7 +429,7 @@ bool flipper_format_stream_read_value_line(
}
}
string_clear(value);
furi_string_free(value);
}
} while(false);
@@ -444,8 +444,8 @@ bool flipper_format_stream_get_value_count(
bool result = false;
bool last = false;
string_t value;
string_init(value);
FuriString* value;
value = furi_string_alloc();
uint32_t position = stream_tell(stream);
do {
@@ -469,7 +469,7 @@ bool flipper_format_stream_get_value_count(
result = false;
}
string_clear(value);
furi_string_free(value);
return result;
}