apdu_log.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <flipper_format/flipper_format.h>
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <stddef.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef enum {
  10. APDULogModeOpenExisting,
  11. APDULogModeOpenAlways,
  12. } APDULogMode;
  13. typedef struct APDULog APDULog;
  14. /** Check if the file list exists
  15. *
  16. * @param path - list path
  17. *
  18. * @return true if list exists, false otherwise
  19. */
  20. bool apdu_log_check_presence(const char* path);
  21. /** Open or create list
  22. * Depending on mode, list will be opened or created.
  23. *
  24. * @param path - Path of the file that contain the list
  25. * @param mode - ListKeysMode value
  26. *
  27. * @return Returns APDULog list instance
  28. */
  29. APDULog* apdu_log_alloc(const char* path, APDULogMode mode);
  30. /** Close list
  31. *
  32. * @param instance - APDULog list instance
  33. */
  34. void apdu_log_free(APDULog* instance);
  35. /** Get total number of lines in list
  36. *
  37. * @param instance - APDULog list instance
  38. *
  39. * @return Returns total number of lines in list
  40. */
  41. size_t apdu_log_get_total_lines(APDULog* instance);
  42. /** Rewind list
  43. *
  44. * @param instance - APDULog list instance
  45. *
  46. * @return Returns true if rewind was successful, false otherwise
  47. */
  48. bool apdu_log_rewind(APDULog* instance);
  49. bool apdu_log_get_next_log_str(APDULog* instance, FuriString* log);
  50. #ifdef __cplusplus
  51. }
  52. #endif