tbm-mcu/include/shell.h

37 lines
936 B
C
Raw Normal View History

2017-02-27 14:48:38 +00:00
#pragma once
#include <macros.h>
2017-07-24 17:57:13 +02:00
struct console;
2017-02-27 14:48:38 +00:00
struct cmd {
const char *cmd;
const char *desc;
2017-07-27 11:54:31 +02:00
int (* exec)(struct console *con, size_t argc, const char **argv);
};
struct shell {
char line[128];
struct cmd *cmds;
const char *prompt;
2017-07-24 17:57:13 +02:00
struct console *con;
unsigned flags;
2017-02-27 14:48:38 +00:00
};
#define SHELL_SHOW_EXIT_CODE BIT(0)
size_t count_args(const char *line);
char **parse_args(const char *line, size_t *argc);
2017-07-27 11:54:31 +02:00
int cmd_exec(struct cmd *cmds, struct console *con, size_t argc,
2017-07-27 11:41:20 +02:00
const char **argv);
2017-07-27 11:54:31 +02:00
int cmd_parse(struct cmd *cmds, struct console *con, const char *line);
2017-03-23 15:20:00 +00:00
int shell_init(struct shell *shell, struct cmd *cmds,
struct console *con, const char *prompt, unsigned flags);
int shell_parse(struct shell *shell);
2017-07-27 11:54:31 +02:00
int do_flash_cmd(struct console *con, size_t argc, const char **argv);
int do_ftl_cmd(struct console *con, size_t argc, const char **argv);
int do_mufs_cmd(struct console *con, size_t argc, const char **argv);