2022-07-26 18:30:49 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <storage/storage.h>
|
|
|
|
#include <lib/flipper_format/flipper_format.h>
|
|
|
|
#include <lib/toolbox/stream/file_stream.h>
|
|
|
|
#include <lib/toolbox/stream/buffered_file_stream.h>
|
|
|
|
|
2023-07-10 11:03:41 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
typedef enum {
|
|
|
|
MfClassicDictTypeUser,
|
2022-12-27 12:14:03 +03:00
|
|
|
MfClassicDictTypeSystem,
|
2022-09-22 20:35:28 +03:00
|
|
|
MfClassicDictTypeUnitTest,
|
2022-07-26 18:30:49 +03:00
|
|
|
} MfClassicDictType;
|
|
|
|
|
|
|
|
typedef struct MfClassicDict MfClassicDict;
|
|
|
|
|
|
|
|
bool mf_classic_dict_check_presence(MfClassicDictType dict_type);
|
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Allocate MfClassicDict instance
|
|
|
|
*
|
|
|
|
* @param[in] dict_type The dictionary type
|
|
|
|
*
|
|
|
|
* @return MfClassicDict instance
|
|
|
|
*/
|
2022-07-26 18:30:49 +03:00
|
|
|
MfClassicDict* mf_classic_dict_alloc(MfClassicDictType dict_type);
|
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Free MfClassicDict instance
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
*/
|
2022-07-26 18:30:49 +03:00
|
|
|
void mf_classic_dict_free(MfClassicDict* dict);
|
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Get total keys count
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
*
|
|
|
|
* @return total keys count
|
|
|
|
*/
|
2022-07-26 18:30:49 +03:00
|
|
|
uint32_t mf_classic_dict_get_total_keys(MfClassicDict* dict);
|
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Rewind to the beginning
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2022-09-19 19:43:53 +03:00
|
|
|
bool mf_classic_dict_rewind(MfClassicDict* dict);
|
|
|
|
|
|
|
|
bool mf_classic_dict_is_key_present(MfClassicDict* dict, uint8_t* key);
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
bool mf_classic_dict_is_key_present_str(MfClassicDict* dict, FuriString* key);
|
2022-09-19 19:43:53 +03:00
|
|
|
|
2022-07-26 18:30:49 +03:00
|
|
|
bool mf_classic_dict_get_next_key(MfClassicDict* dict, uint64_t* key);
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
bool mf_classic_dict_get_next_key_str(MfClassicDict* dict, FuriString* key);
|
2022-09-19 19:43:53 +03:00
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Get key at target offset as uint64_t
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
* @param[out] key Pointer to the uint64_t key
|
|
|
|
* @param[in] target Target offset from current position
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2022-09-19 19:43:53 +03:00
|
|
|
bool mf_classic_dict_get_key_at_index(MfClassicDict* dict, uint64_t* key, uint32_t target);
|
|
|
|
|
2022-10-05 21:27:13 +03:00
|
|
|
/** Get key at target offset as FuriString*
|
2022-09-22 20:35:28 +03:00
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
* @param[out] key Found key destination buffer
|
|
|
|
* @param[in] target Target offset from current position
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2022-10-05 18:15:23 +03:00
|
|
|
bool mf_classic_dict_get_key_at_index_str(MfClassicDict* dict, FuriString* key, uint32_t target);
|
2022-07-26 18:30:49 +03:00
|
|
|
|
|
|
|
bool mf_classic_dict_add_key(MfClassicDict* dict, uint8_t* key);
|
2022-09-19 19:43:53 +03:00
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Add string representation of the key
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
* @param[in] key String representation of the key
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2022-10-05 18:15:23 +03:00
|
|
|
bool mf_classic_dict_add_key_str(MfClassicDict* dict, FuriString* key);
|
2022-09-19 19:43:53 +03:00
|
|
|
|
|
|
|
bool mf_classic_dict_find_index(MfClassicDict* dict, uint8_t* key, uint32_t* target);
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
bool mf_classic_dict_find_index_str(MfClassicDict* dict, FuriString* key, uint32_t* target);
|
2022-09-19 19:43:53 +03:00
|
|
|
|
2022-09-22 20:35:28 +03:00
|
|
|
/** Delete key at target offset
|
|
|
|
*
|
|
|
|
* @param dict MfClassicDict instance
|
|
|
|
* @param[in] target Target offset from current position
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
2022-09-19 19:43:53 +03:00
|
|
|
bool mf_classic_dict_delete_index(MfClassicDict* dict, uint32_t target);
|
2023-07-10 11:03:41 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|