changeset 160:19b96c52348f

fc-uicc-tool: readef command ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Feb 2021 04:15:59 +0000
parents a5e2b6e3bdf7
children d3128f3e1bde
files uicc/dispatch.c uicc/readcmd.c
diffstat 2 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/uicc/dispatch.c	Sun Feb 07 04:07:24 2021 +0000
+++ b/uicc/dispatch.c	Sun Feb 07 04:15:59 2021 +0000
@@ -21,6 +21,7 @@
 extern int cmd_pb_update_imm();
 extern int cmd_pb_update_imm_hex();
 extern int cmd_readbin();
+extern int cmd_readef();
 extern int cmd_readrec();
 extern int cmd_select();
 extern int cmd_select_aid();
@@ -55,6 +56,7 @@
 	{"pb-update-imm-hex", 4, 4, cmd_pb_update_imm_hex},
 	{"quit", 0, 0, good_exit},
 	{"readbin", 2, 2, cmd_readbin},
+	{"readef", 1, 1, cmd_readef},
 	{"readrec", 1, 2, cmd_readrec},
 	{"select", 1, 1, cmd_select},
 	{"select-aid", 1, 1, cmd_select_aid},
--- a/uicc/readcmd.c	Sun Feb 07 04:07:24 2021 +0000
+++ b/uicc/readcmd.c	Sun Feb 07 04:15:59 2021 +0000
@@ -61,3 +61,38 @@
 	display_sim_resp_in_hex();
 	return(0);
 }
+
+cmd_readef(argc, argv)
+	char **argv;
+{
+	int file_id, rc;
+	unsigned file_len, readlen;
+
+	if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) &&
+	    isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4])
+		file_id = strtoul(argv[1], 0, 16);
+	else
+		file_id = find_symbolic_file_name(argv[1]);
+	if (file_id < 0) {
+		fprintf(stderr,
+"error: file ID argument is not a hex value or a recognized symbolic name\n");
+		return(-1);
+	}
+	rc = select_op(file_id);
+	if (rc < 0)
+		return(rc);
+	rc = select_resp_get_transparent(&file_len);
+	if (rc < 0)
+		return(rc);
+	printf("Transparent EF of %u byte(s)\n", file_len);
+	if (!file_len)
+		return(0);
+	readlen = file_len;
+	if (readlen > 256)
+		readlen = 256;
+	rc = readbin_op(0, readlen);
+	if (rc < 0)
+		return(rc);
+	display_sim_resp_in_hex();
+	return(0);
+}