opensc-explorer: add 'echo' command
Add 'echo' command that simply displays its arguments. With the recently committed script interpreter feature and this echo command, nice litte scripts can be written, like e.g. $ cat opengpg-userinfo #!/usr/bin/opensc-explorer cd 0065 echo Name: cat 005B echo Language: cat 5F2D echo Gender: cat 5F35 quit
This commit is contained in:
parent
f8f02dbd65
commit
1f70902da5
|
@ -76,6 +76,7 @@ static const char *option_help[] = {
|
||||||
|
|
||||||
|
|
||||||
/* declare functions called by user commands */
|
/* declare functions called by user commands */
|
||||||
|
static int do_echo(int argc, char **argv);
|
||||||
static int do_ls(int argc, char **argv);
|
static int do_ls(int argc, char **argv);
|
||||||
static int do_find(int argc, char **argv);
|
static int do_find(int argc, char **argv);
|
||||||
static int do_cd(int argc, char **argv);
|
static int do_cd(int argc, char **argv);
|
||||||
|
@ -111,6 +112,9 @@ struct command {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct command cmds[] = {
|
static struct command cmds[] = {
|
||||||
|
{ do_echo,
|
||||||
|
"echo", "[<string> ..]",
|
||||||
|
"display arguments" },
|
||||||
{ do_ls,
|
{ do_ls,
|
||||||
"ls", "",
|
"ls", "",
|
||||||
"list all files in the current DF" },
|
"list all files in the current DF" },
|
||||||
|
@ -381,6 +385,17 @@ static void print_file(const sc_file_t *file)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_echo(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
printf("%s%s", argv[i], (i < argc) ? " " : "");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int do_ls(int argc, char **argv)
|
static int do_ls(int argc, char **argv)
|
||||||
{
|
{
|
||||||
u8 buf[256], *cur = buf;
|
u8 buf[256], *cur = buf;
|
||||||
|
|
Loading…
Reference in New Issue