summaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/cmd.c b/cmd.c
index aa8beff..42a184d 100644
--- a/cmd.c
+++ b/cmd.c
@@ -23,8 +23,7 @@ enum args_type {
A_OPTIONAL = 16
};
-typedef int (*fptr)(int, const struct command *, const struct param *,
- int, char **);
+typedef int (*fptr)(int, const struct command *, int, char **);
struct command {
char alias;
@@ -100,8 +99,7 @@ syntax_error:
}
static int
-cmd_boot(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+cmd_boot(int fd, const struct command *cmd, int argc, char **args)
{
int err;
uint8_t bank;
@@ -115,8 +113,7 @@ cmd_boot(int fd, const struct command *cmd, const struct param *param,
}
static int
-cmd_read(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+cmd_read(int fd, const struct command *cmd, int argc, char **args)
{
int err = 0;
uint8_t buf[MAX_PACKET_SIZE];
@@ -135,7 +132,7 @@ cmd_read(int fd, const struct command *cmd, const struct param *param,
return err;
}
- if (param->human_readable) {
+ if (param.human_readable) {
hexdump(address, length, buf);
} else if (pathname) {
FILE *fp;
@@ -154,8 +151,7 @@ cmd_read(int fd, const struct command *cmd, const struct param *param,
}
static int
-cmd_write(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+cmd_write(int fd, const struct command *cmd, int argc, char **args)
{
int err;
char line[512];
@@ -172,7 +168,7 @@ cmd_write(int fd, const struct command *cmd, const struct param *param,
if (err < 0)
return -1;
- if (param->human_readable) {
+ if (param.human_readable) {
do {
// TODO: Handle fgets error
fgets(line, LEN(line), stdin);
@@ -220,14 +216,13 @@ cmd_write(int fd, const struct command *cmd, const struct param *param,
}
static int
-cmd_echo(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+cmd_echo(int fd, const struct command *cmd, int argc, char **args)
{
int err;
char line[512];
char buf[MAX_PACKET_SIZE];
- if (!param->human_readable) {
+ if (!param.human_readable) {
fputs("Echo is a interactive command only", stderr);
return -1;
}
@@ -271,15 +266,13 @@ cmd_echo(int fd, const struct command *cmd, const struct param *param,
}
static int
-repl_io_write(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+repl_io_write(int fd, const struct command *cmd, int argc, char **args)
{
return 0;
}
static int
-repl_io_read(int fd, const struct command *cmd, const struct param *param,
- int argc, char **args)
+repl_io_read(int fd, const struct command *cmd, int argc, char **args)
{
return 0;
}
@@ -356,7 +349,7 @@ const struct command cmd_table[] = {
};
int
-run_line(int fd, struct param *param, char *line, const char *sep)
+run_line(int fd, char *line, const char *sep)
{
int err;
int argc = 1;
@@ -385,7 +378,7 @@ run_line(int fd, struct param *param, char *line, const char *sep)
}
if ((p = cmd_table[cmdi].fptr)
- && (err = p(fd, &cmd_table[cmdi], param, argc - 1, &args[1]))) {
+ && (err = p(fd, &cmd_table[cmdi], argc - 1, &args[1]))) {
print_error(err);
return err;
}
@@ -395,7 +388,7 @@ run_line(int fd, struct param *param, char *line, const char *sep)
// TODO: Handle signals (CTRL-C)
void
-repl(int fd, struct param *param)
+repl(int fd)
{
int quit = 0;
@@ -411,7 +404,7 @@ repl(int fd, struct param *param)
break;
add_history(line);
- quit = run_line(fd, param, line, " ");
+ quit = run_line(fd, line, " ");
free(line);
#else
size_t len = 0;
@@ -425,7 +418,7 @@ repl(int fd, struct param *param)
if (line[len - 1] == '\n')
line[len - 1] = '\0';
- quit = run_line(fd, param, line, " ");
+ quit = run_line(fd, line, " ");
#endif
}
}