2017-02-27 14:48:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-07-27 12:15:24 +02:00
|
|
|
#include <macros.h>
|
|
|
|
|
2017-07-24 17:57:13 +02:00
|
|
|
struct console;
|
|
|
|
|
2017-02-27 14:48:38 +00:00
|
|
|
struct cmd {
|
2017-07-20 16:51:05 +02:00
|
|
|
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);
|
2017-07-20 16:51:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct shell {
|
|
|
|
char line[128];
|
|
|
|
struct cmd *cmds;
|
|
|
|
const char *prompt;
|
2017-07-24 17:57:13 +02:00
|
|
|
struct console *con;
|
2017-07-27 12:15:24 +02:00
|
|
|
unsigned flags;
|
2017-02-27 14:48:38 +00:00
|
|
|
};
|
|
|
|
|
2017-07-27 12:15:24 +02:00
|
|
|
#define SHELL_SHOW_EXIT_CODE BIT(0)
|
|
|
|
|
2017-07-20 16:51:05 +02:00
|
|
|
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
|
|
|
|
2017-07-20 16:51:05 +02:00
|
|
|
int shell_init(struct shell *shell, struct cmd *cmds,
|
2017-07-27 12:15:24 +02:00
|
|
|
struct console *con, const char *prompt, unsigned flags);
|
2017-07-20 16:51:05 +02:00
|
|
|
int shell_parse(struct shell *shell);
|
2017-07-20 17:46:23 +02:00
|
|
|
|
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);
|