cli.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* cli.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef CLI_H_
  17. #define CLI_H_
  18. #include <stdint.h>
  19. #include "string-extras.h"
  20. #ifndef VOID_FPT
  21. #define VOID_FPT
  22. typedef void(*void_fpt)(void);
  23. #endif
  24. typedef char (*cli_rx_fpt)(void);
  25. typedef void (*cli_tx_fpt)(char);
  26. #define CLI_BUFFER_BS 20
  27. #define CMDLIST_ENTRY_SIZE 16
  28. typedef struct {
  29. uint16_t option_flags;
  30. void *options[];
  31. } cmdoption_t;
  32. #define CLI_OPTION_DESC 0x01
  33. #define CLI_OPTION_MANP 0x02
  34. typedef struct {
  35. const char* cmd_name; /* string containing the function name */
  36. const char* cmd_param_str; /* param descriptor string */
  37. void_fpt cmd_function; /* function pointer */
  38. const cmdoption_t* options;
  39. } cmdlist_entry_t;
  40. extern cli_rx_fpt cli_rx;
  41. extern cli_tx_fpt cli_tx;
  42. extern uint8_t cli_echo;
  43. void cli_putc(char c);
  44. uint16_t cli_getc(void);
  45. uint16_t cli_getc_cecho(void);
  46. uint8_t cli_getsn(char* s, uint32_t n);
  47. void cli_putstr(const char* s);
  48. void cli_hexdump(const void* data, uint32_t length);
  49. void cli_hexdump_rev(const void* data, uint32_t length);
  50. void cli_hexdump2(const void* data, uint32_t length);
  51. void cli_hexdump_block(const void* data, uint32_t length, uint8_t indent, uint8_t width);
  52. void cli_hexdump_byte(uint8_t byte);
  53. void echo_ctrl(char* s);
  54. int8_t cmd_interface(const cmdlist_entry_t* cmd_desc);
  55. #endif /*CLI_H_*/