Loading...
Searching...
No Matches
flipper_format.h
Go to the documentation of this file.
1
87#pragma once
88#include <stdint.h>
89#include <storage/storage.h>
90
91#ifdef __cplusplus
92extern "C" {
93#endif
94
95typedef struct FlipperFormat FlipperFormat;
96
97typedef enum {
98 FlipperFormatOffsetFromCurrent,
99 FlipperFormatOffsetFromStart,
100 FlipperFormatOffsetFromEnd,
101} FlipperFormatOffset;
102
108
116
124
132bool flipper_format_file_open_existing(FlipperFormat* flipper_format, const char* path);
133
142bool flipper_format_buffered_file_open_existing(FlipperFormat* flipper_format, const char* path);
143
152bool flipper_format_file_open_append(FlipperFormat* flipper_format, const char* path);
153
162bool flipper_format_file_open_always(FlipperFormat* flipper_format, const char* path);
163
173bool flipper_format_buffered_file_open_always(FlipperFormat* flipper_format, const char* path);
174
183bool flipper_format_file_open_new(FlipperFormat* flipper_format, const char* path);
184
192bool flipper_format_file_close(FlipperFormat* flipper_format);
193
202
207void flipper_format_free(FlipperFormat* flipper_format);
208
215void flipper_format_set_strict_mode(FlipperFormat* flipper_format, bool strict_mode);
216
223bool flipper_format_rewind(FlipperFormat* flipper_format);
224
231size_t flipper_format_tell(FlipperFormat* flipper_format);
232
241bool flipper_format_seek(FlipperFormat* flipper_format, int32_t offset, FlipperFormatOffset anchor);
242
250bool flipper_format_seek_to_end(FlipperFormat* flipper_format);
251
260bool flipper_format_key_exist(FlipperFormat* flipper_format, const char* key);
261
271 FlipperFormat* flipper_format,
272 FuriString* filetype,
273 uint32_t* version);
274
284 FlipperFormat* flipper_format,
285 FuriString* filetype,
286 const uint32_t version);
287
297 FlipperFormat* flipper_format,
298 const char* filetype,
299 const uint32_t version);
300
310 FlipperFormat* flipper_format,
311 const char* key,
312 uint32_t* count);
313
322bool flipper_format_read_string(FlipperFormat* flipper_format, const char* key, FuriString* data);
323
332bool flipper_format_write_string(FlipperFormat* flipper_format, const char* key, FuriString* data);
333
343 FlipperFormat* flipper_format,
344 const char* key,
345 const char* data);
346
357 FlipperFormat* flipper_format,
358 const char* key,
359 uint64_t* data,
360 const uint16_t data_size);
361
372 FlipperFormat* flipper_format,
373 const char* key,
374 const uint64_t* data,
375 const uint16_t data_size);
376
387 FlipperFormat* flipper_format,
388 const char* key,
389 uint32_t* data,
390 const uint16_t data_size);
391
402 FlipperFormat* flipper_format,
403 const char* key,
404 const uint32_t* data,
405 const uint16_t data_size);
406
417 FlipperFormat* flipper_format,
418 const char* key,
419 int32_t* data,
420 const uint16_t data_size);
421
432 FlipperFormat* flipper_format,
433 const char* key,
434 const int32_t* data,
435 const uint16_t data_size);
436
447 FlipperFormat* flipper_format,
448 const char* key,
449 bool* data,
450 const uint16_t data_size);
451
462 FlipperFormat* flipper_format,
463 const char* key,
464 const bool* data,
465 const uint16_t data_size);
466
477 FlipperFormat* flipper_format,
478 const char* key,
479 float* data,
480 const uint16_t data_size);
481
492 FlipperFormat* flipper_format,
493 const char* key,
494 const float* data,
495 const uint16_t data_size);
496
507 FlipperFormat* flipper_format,
508 const char* key,
509 uint8_t* data,
510 const uint16_t data_size);
511
522 FlipperFormat* flipper_format,
523 const char* key,
524 const uint8_t* data,
525 const uint16_t data_size);
526
534bool flipper_format_write_comment(FlipperFormat* flipper_format, FuriString* data);
535
543bool flipper_format_write_comment_cstr(FlipperFormat* flipper_format, const char* data);
544
552
561bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key);
562
572bool flipper_format_update_string(FlipperFormat* flipper_format, const char* key, FuriString* data);
573
584 FlipperFormat* flipper_format,
585 const char* key,
586 const char* data);
587
599 FlipperFormat* flipper_format,
600 const char* key,
601 const uint32_t* data,
602 const uint16_t data_size);
603
615 FlipperFormat* flipper_format,
616 const char* key,
617 const int32_t* data,
618 const uint16_t data_size);
619
631 FlipperFormat* flipper_format,
632 const char* key,
633 const bool* data,
634 const uint16_t data_size);
635
647 FlipperFormat* flipper_format,
648 const char* key,
649 const float* data,
650 const uint16_t data_size);
651
663 FlipperFormat* flipper_format,
664 const char* key,
665 const uint8_t* data,
666 const uint16_t data_size);
667
679 FlipperFormat* flipper_format,
680 const char* key,
681 FuriString* data);
682
694 FlipperFormat* flipper_format,
695 const char* key,
696 const char* data);
697
710 FlipperFormat* flipper_format,
711 const char* key,
712 const uint32_t* data,
713 const uint16_t data_size);
714
727 FlipperFormat* flipper_format,
728 const char* key,
729 const int32_t* data,
730 const uint16_t data_size);
731
744 FlipperFormat* flipper_format,
745 const char* key,
746 const bool* data,
747 const uint16_t data_size);
748
761 FlipperFormat* flipper_format,
762 const char* key,
763 const float* data,
764 const uint16_t data_size);
765
778 FlipperFormat* flipper_format,
779 const char* key,
780 const uint8_t* data,
781 const uint16_t data_size);
782
783#ifdef __cplusplus
784}
785#endif
bool flipper_format_get_value_count(FlipperFormat *flipper_format, const char *key, uint32_t *count)
Get the count of values by key.
Definition flipper_format.c:188
bool flipper_format_write_hex(FlipperFormat *flipper_format, const char *key, const uint8_t *data, const uint16_t data_size)
Write key and array of hex-formatted bytes.
Definition flipper_format.c:396
bool flipper_format_read_string(FlipperFormat *flipper_format, const char *key, FuriString *data)
Read a string by key.
Definition flipper_format.c:197
bool flipper_format_read_int32(FlipperFormat *flipper_format, const char *key, int32_t *data, const uint16_t data_size)
Read array of int32 by key.
Definition flipper_format.c:292
bool flipper_format_update_string_cstr(FlipperFormat *flipper_format, const char *key, const char *data)
Updates the value of the first matching key to a string value.
Definition flipper_format.c:453
bool flipper_format_buffered_file_open_always(FlipperFormat *flipper_format, const char *path)
Open file.
Definition flipper_format.c:99
bool flipper_format_rewind(FlipperFormat *flipper_format)
Rewind the RW pointer.
Definition flipper_format.c:130
bool flipper_format_file_close(FlipperFormat *flipper_format)
Closes the file, use only if FlipperFormat allocated as a file.
Definition flipper_format.c:110
FlipperFormat * flipper_format_file_alloc(Storage *storage)
Allocate FlipperFormat as file.
Definition flipper_format.c:38
bool flipper_format_write_string_cstr(FlipperFormat *flipper_format, const char *key, const char *data)
Write key and string.
Definition flipper_format.c:215
bool flipper_format_update_int32(FlipperFormat *flipper_format, const char *key, const int32_t *data, const uint16_t data_size)
Updates the value of the first matching key to a int32 array value.
Definition flipper_format.c:486
bool flipper_format_write_uint32(FlipperFormat *flipper_format, const char *key, const uint32_t *data, const uint16_t data_size)
Write key and array of uint32.
Definition flipper_format.c:276
bool flipper_format_file_open_new(FlipperFormat *flipper_format, const char *path)
Open file.
Definition flipper_format.c:105
bool flipper_format_write_comment(FlipperFormat *flipper_format, FuriString *data)
Write comment.
Definition flipper_format.c:412
bool flipper_format_insert_or_update_uint32(FlipperFormat *flipper_format, const char *key, const uint32_t *data, const uint16_t data_size)
Updates the value of the first matching key to a uint32 array value, or adds the key and value if the...
Definition flipper_format.c:582
void flipper_format_set_strict_mode(FlipperFormat *flipper_format, bool strict_mode)
Set FlipperFormat mode.
Definition flipper_format.c:126
bool flipper_format_update_string(FlipperFormat *flipper_format, const char *key, FuriString *data)
Updates the value of the first matching key to a string value.
Definition flipper_format.c:440
bool flipper_format_write_comment_cstr(FlipperFormat *flipper_format, const char *data)
Write comment.
Definition flipper_format.c:417
bool flipper_format_seek(FlipperFormat *flipper_format, int32_t offset, FlipperFormatOffset anchor)
Set the RW pointer position to an arbitrary value.
Definition flipper_format.c:140
bool flipper_format_update_float(FlipperFormat *flipper_format, const char *key, const float *data, const uint16_t data_size)
Updates the value of the first matching key to a float array value.
Definition flipper_format.c:518
bool flipper_format_update_hex(FlipperFormat *flipper_format, const char *key, const uint8_t *data, const uint16_t data_size)
Updates the value of the first matching key to an array of hex-formatted bytes.
Definition flipper_format.c:534
bool flipper_format_buffered_file_open_existing(FlipperFormat *flipper_format, const char *path)
Open existing file, buffered mode.
Definition flipper_format.c:57
bool flipper_format_read_hex(FlipperFormat *flipper_format, const char *key, uint8_t *data, const uint16_t data_size)
Read array of hex-formatted bytes by key.
Definition flipper_format.c:382
void flipper_format_free(FlipperFormat *flipper_format)
Free FlipperFormat.
Definition flipper_format.c:120
bool flipper_format_key_exist(FlipperFormat *flipper_format, const char *key)
Check if the key exists.
Definition flipper_format.c:151
FlipperFormat * flipper_format_buffered_file_alloc(Storage *storage)
Allocate FlipperFormat as file, buffered mode.
Definition flipper_format.c:45
bool flipper_format_insert_or_update_int32(FlipperFormat *flipper_format, const char *key, const int32_t *data, const uint16_t data_size)
Updates the value of the first matching key to a int32 array value, or adds the key and value if the ...
Definition flipper_format.c:599
bool flipper_format_write_string(FlipperFormat *flipper_format, const char *key, FuriString *data)
Write key and string.
Definition flipper_format.c:203
bool flipper_format_insert_or_update_hex(FlipperFormat *flipper_format, const char *key, const uint8_t *data, const uint16_t data_size)
Updates the value of the first matching key to an array of hex-formatted bytes, or adds the key and v...
Definition flipper_format.c:650
bool flipper_format_insert_or_update_bool(FlipperFormat *flipper_format, const char *key, const bool *data, const uint16_t data_size)
Updates the value of the first matching key to a bool array value, or adds the key and value if the k...
Definition flipper_format.c:616
bool flipper_format_insert_or_update_string_cstr(FlipperFormat *flipper_format, const char *key, const char *data)
Updates the value of the first matching key to a string value, or adds the key and value if the key d...
Definition flipper_format.c:566
bool flipper_format_write_float(FlipperFormat *flipper_format, const char *key, const float *data, const uint16_t data_size)
Write key and array of float.
Definition flipper_format.c:366
bool flipper_format_file_open_existing(FlipperFormat *flipper_format, const char *path)
Open existing file.
Definition flipper_format.c:52
FlipperFormat * flipper_format_string_alloc(void)
Allocate FlipperFormat as string.
Definition flipper_format.c:31
bool flipper_format_read_float(FlipperFormat *flipper_format, const char *key, float *data, const uint16_t data_size)
Read array of float by key.
Definition flipper_format.c:352
bool flipper_format_buffered_file_close(FlipperFormat *flipper_format)
Closes the file, use only if FlipperFormat allocated as a buffered file.
Definition flipper_format.c:115
bool flipper_format_seek_to_end(FlipperFormat *flipper_format)
Move the RW pointer at the end.
Definition flipper_format.c:146
bool flipper_format_write_bool(FlipperFormat *flipper_format, const char *key, const bool *data, const uint16_t data_size)
Write key and array of bool.
Definition flipper_format.c:336
bool flipper_format_update_bool(FlipperFormat *flipper_format, const char *key, const bool *data, const uint16_t data_size)
Updates the value of the first matching key to a bool array value.
Definition flipper_format.c:502
bool flipper_format_file_open_always(FlipperFormat *flipper_format, const char *path)
Open file.
Definition flipper_format.c:94
bool flipper_format_write_header(FlipperFormat *flipper_format, FuriString *filetype, const uint32_t version)
Write the header (file type and version).
Definition flipper_format.c:169
bool flipper_format_read_uint32(FlipperFormat *flipper_format, const char *key, uint32_t *data, const uint16_t data_size)
Read array of uint32 by key.
Definition flipper_format.c:261
bool flipper_format_write_header_cstr(FlipperFormat *flipper_format, const char *filetype, const uint32_t version)
Write the header (file type and version).
Definition flipper_format.c:178
bool flipper_format_read_hex_uint64(FlipperFormat *flipper_format, const char *key, uint64_t *data, const uint16_t data_size)
Read array of uint64 in hex format by key.
Definition flipper_format.c:230
bool flipper_format_insert_or_update_string(FlipperFormat *flipper_format, const char *key, FuriString *data)
Updates the value of the first matching key to a string value, or adds the key and value if the key d...
Definition flipper_format.c:550
bool flipper_format_file_open_append(FlipperFormat *flipper_format, const char *path)
Open existing file for writing and add values to the end of file.
Definition flipper_format.c:63
bool flipper_format_write_int32(FlipperFormat *flipper_format, const char *key, const int32_t *data, const uint16_t data_size)
Write key and array of int32.
Definition flipper_format.c:306
bool flipper_format_read_header(FlipperFormat *flipper_format, FuriString *filetype, uint32_t *version)
Read the header (file type and version).
Definition flipper_format.c:160
bool flipper_format_write_empty_line(FlipperFormat *flipper_format)
Write empty line (Improves readability for human based parsing)
Definition flipper_format.c:422
size_t flipper_format_tell(FlipperFormat *flipper_format)
Get the RW pointer position.
Definition flipper_format.c:135
bool flipper_format_update_uint32(FlipperFormat *flipper_format, const char *key, const uint32_t *data, const uint16_t data_size)
Updates the value of the first matching key to a uint32 array value.
Definition flipper_format.c:469
bool flipper_format_delete_key(FlipperFormat *flipper_format, const char *key)
Removes the first matching key and its value.
Definition flipper_format.c:427
bool flipper_format_insert_or_update_float(FlipperFormat *flipper_format, const char *key, const float *data, const uint16_t data_size)
Updates the value of the first matching key to a float array value, or adds the key and value if the ...
Definition flipper_format.c:633
bool flipper_format_read_bool(FlipperFormat *flipper_format, const char *key, bool *data, const uint16_t data_size)
Read array of bool by key.
Definition flipper_format.c:322
bool flipper_format_write_hex_uint64(FlipperFormat *flipper_format, const char *key, const uint64_t *data, const uint16_t data_size)
Write key and array of uint64 in hex format.
Definition flipper_format.c:245
APIs for working with storages, directories and files.
Definition flipper_format.c:17
Definition string.c:4
Definition storage_i.h:23