changeset 133:ede661d78730

fc-uicc-tool: command shell features match fc-simtool
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 22:30:54 +0000
parents d991944aa5f3
children 13dea9b95afc
files uicc/dispatch.c uicc/hlread.c uicc/script.c
diffstat 3 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/uicc/dispatch.c	Sat Feb 20 22:23:03 2021 +0000
+++ b/uicc/dispatch.c	Sat Feb 20 22:30:54 2021 +0000
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 
 extern int cmd_apdu();
+extern int cmd_cd();
 extern int cmd_change_pin();
 extern int cmd_dir();
 extern int cmd_disable_pin();
@@ -44,13 +45,14 @@
 } cmdtab[] = {
 	{"apdu", 1, 1, 0, cmd_apdu},
 	{"atr", 0, 0, 0, retrieve_atr},
+	{"cd", 1, 1, 0, cmd_cd},
 	{"change-pin", 3, 3, 0, cmd_change_pin},
 	{"dir", 0, 0, 1, cmd_dir},
 	{"disable-pin", 2, 2, 0, cmd_disable_pin},
 	{"enable-pin", 2, 2, 0, cmd_enable_pin},
 	{"exec", 1, 1, 0, cmd_exec},
 	{"exit", 0, 0, 0, good_exit},
-	{"iccid", 0, 0, 0, cmd_iccid},
+	{"iccid", 0, 0, 1, cmd_iccid},
 	{"pin-attempt-cnt", 1, 1, 0, cmd_pin_attempt_cnt},
 	{"puk-attempt-cnt", 1, 1, 0, cmd_puk_attempt_cnt},
 	{"quit", 0, 0, 0, good_exit},
@@ -116,6 +118,8 @@
 		return(0);
 	if (is_script)
 		printf("Script command: %s\n", cp);
+	if (*cp == '!')
+		return system(cp + 1);
 	argv[0] = cp;
 	while (*cp && !isspace(*cp))
 		cp++;
--- a/uicc/hlread.c	Sat Feb 20 22:23:03 2021 +0000
+++ b/uicc/hlread.c	Sat Feb 20 22:30:54 2021 +0000
@@ -7,7 +7,9 @@
 #include "simresp.h"
 #include "file_id.h"
 
-cmd_iccid()
+cmd_iccid(argc, argv, outf)
+	char **argv;
+	FILE *outf;
 {
 	int rc;
 	unsigned len;
@@ -33,6 +35,6 @@
 	for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--)
 		;
 	*cp = '\0';
-	printf("%s\n", buf);
+	fprintf(outf, "%s\n", buf);
 	return(0);
 }
--- a/uicc/script.c	Sat Feb 20 22:23:03 2021 +0000
+++ b/uicc/script.c	Sat Feb 20 22:30:54 2021 +0000
@@ -7,6 +7,8 @@
 #include <string.h>
 #include <strings.h>
 
+extern FILE *open_script_input_file();
+
 cmd_exec(argc, argv)
 	char **argv;
 {
@@ -14,7 +16,7 @@
 	char linebuf[512], *cp;
 	int lineno, retval = 0;
 
-	f = fopen(argv[1], "r");
+	f = open_script_input_file(argv[1]);
 	if (!f) {
 		perror(argv[1]);
 		return(-1);