cli_shared_methods.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <cli/cli.h>
  3. #include <cli/cli_ansi.h>
  4. #include "../types/plugin_state.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /**
  9. * @brief Checks whether user is authenticated and entered correct PIN.
  10. * If user is not authenticated it prompts user to enter correct PIN to authenticate.
  11. * @param plugin_state application state
  12. * @param cli pointer to the firmware CLI subsystem
  13. * @return \c true if user is already authenticated or successfully authenticated; \c false otherwise
  14. */
  15. bool totp_cli_ensure_authenticated(const PluginState* plugin_state, Cli* cli);
  16. /**
  17. * @brief Forces application to be instantly closed
  18. * @param event_queue main app queue
  19. */
  20. void totp_cli_force_close_app(void* ctx);
  21. /**
  22. * @brief Reads line of characters from console
  23. * @param cli pointer to the firmware CLI subsystem
  24. * @param out_str pointer to an output string to put read line to
  25. * @param mask_user_input whether to mask input characters in console or not
  26. * @return \c true if line successfully read and confirmed; \c false otherwise
  27. */
  28. bool totp_cli_read_line(Cli* cli, FuriString* out_str, bool mask_user_input);
  29. /**
  30. * @brief Extracts \c uint8_t value and trims arguments string
  31. * @param args arguments string
  32. * @param[out] value parsed value
  33. * @return \c true if value successfully read and parsed as \c uint8_t ; \c false otherwise
  34. */
  35. bool args_read_uint8_and_trim(FuriString* args, uint8_t* value);
  36. /**
  37. * @brief Free \c FuriString instance in a secure manner by clearing it first
  38. * @param str instance to free
  39. */
  40. void furi_string_secure_free(FuriString* str);
  41. /**
  42. * @brief Prints information about unknown argument
  43. * @param arg
  44. */
  45. void totp_cli_printf_unknown_argument(const FuriString* arg);
  46. /**
  47. * @brief Prints information about missed required argument
  48. * @param arg
  49. */
  50. void totp_cli_printf_missed_argument_value(char* arg);
  51. #ifdef __cplusplus
  52. }
  53. #endif