From 1f70902da5bc43d7604925bad0c97ac3788a85bb Mon Sep 17 00:00:00 2001 From: Peter Marschall Date: Sun, 20 May 2012 18:05:16 +0200 Subject: [PATCH] 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 --- src/tools/opensc-explorer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tools/opensc-explorer.c b/src/tools/opensc-explorer.c index 61dffc65..60687739 100644 --- a/src/tools/opensc-explorer.c +++ b/src/tools/opensc-explorer.c @@ -76,6 +76,7 @@ static const char *option_help[] = { /* 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_find(int argc, char **argv); static int do_cd(int argc, char **argv); @@ -111,6 +112,9 @@ struct command { }; static struct command cmds[] = { + { do_echo, + "echo", "[ ..]", + "display arguments" }, { do_ls, "ls", "", "list all files in the current DF" }, @@ -381,6 +385,17 @@ static void print_file(const sc_file_t *file) 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) { u8 buf[256], *cur = buf;