changeset 110:2aa92dfcb4b5

fc-simtool iccid, imsi, spn: support output redirection
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 06:59:56 +0000
parents 8a27f45bc1e6
children 869488ef86b6
files simtool/dispatch.c simtool/hlread.c
diffstat 2 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Fri Feb 19 06:53:14 2021 +0000
+++ b/simtool/dispatch.c	Fri Feb 19 06:59:56 2021 +0000
@@ -126,8 +126,8 @@
 	{"grcard2-set-puk2", 1, 1, 0, cmd_grcard2_set_puk},
 	{"grcard2-set-super", 1, 1, 0, cmd_grcard2_set_super},
 	{"grcard2-set-super-hex", 1, 1, 0, cmd_grcard2_set_super_hex},
-	{"iccid", 0, 0, 0, cmd_iccid},
-	{"imsi", 0, 0, 0, cmd_imsi},
+	{"iccid", 0, 0, 1, cmd_iccid},
+	{"imsi", 0, 0, 1, cmd_imsi},
 	{"lnd-dump", 0, 1, 0, cmd_lnd_dump},
 	{"lnd-erase", 0, 0, 0, cmd_lnd_erase},
 	{"lnd-restore", 1, 1, 0, cmd_lnd_restore},
@@ -166,7 +166,7 @@
 	{"smsp-restore", 1, 1, 0, cmd_smsp_restore},
 	{"smsp-set", 2, 6, 0, cmd_smsp_set},
 	{"smsp-set-tag", 3, 7, 0, cmd_smsp_set_tag},
-	{"spn", 0, 0, 0, cmd_spn},
+	{"spn", 0, 0, 1, cmd_spn},
 	{"sst", 0, 0, 0, cmd_sst},
 	{"telecom-sum", 0, 0, 0, cmd_telecom_sum},
 	{"uicc-dir", 0, 0, 1, cmd_uicc_dir},
--- a/simtool/hlread.c	Fri Feb 19 06:53:14 2021 +0000
+++ b/simtool/hlread.c	Fri Feb 19 06:59:56 2021 +0000
@@ -8,7 +8,9 @@
 #include "curfile.h"
 #include "file_id.h"
 
-cmd_iccid()
+cmd_iccid(argc, argv, outf)
+	char **argv;
+	FILE *outf;
 {
 	int rc;
 	char buf[21], *cp;
@@ -33,11 +35,13 @@
 	for (cp = buf + 20; (cp > buf + 1) && (cp[-1] == 'F'); cp--)
 		;
 	*cp = '\0';
-	printf("%s\n", buf);
+	fprintf(outf, "%s\n", buf);
 	return(0);
 }
 
-cmd_imsi()
+cmd_imsi(argc, argv, outf)
+	char **argv;
+	FILE *outf;
 {
 	int rc;
 	char buf[17];
@@ -60,11 +64,14 @@
 		return(rc);
 	decode_reversed_nibbles(sim_resp_data + 1, 8, buf);
 	buf[16] = '\0';
-	printf("%s parity=%c len=%u\n", buf + 1, buf[0], sim_resp_data[0]);
+	fprintf(outf, "%s parity=%c len=%u\n", buf + 1, buf[0],
+		sim_resp_data[0]);
 	return(0);
 }
 
-cmd_spn()
+cmd_spn(argc, argv, outf)
+	char **argv;
+	FILE *outf;
 {
 	int rc;
 	unsigned textlen;
@@ -85,13 +92,13 @@
 	rc = readbin_op(0, 17);
 	if (rc < 0)
 		return(rc);
-	printf("Display condition: %02X\n", sim_resp_data[0]);
-	printf("SPN: ");
+	fprintf(outf, "Display condition: %02X\n", sim_resp_data[0]);
+	fputs("SPN: ", outf);
 	rc = validate_alpha_field(sim_resp_data + 1, 16, &textlen);
 	if (rc >= 0)
-		print_alpha_field(sim_resp_data, textlen, stdout);
+		print_alpha_field(sim_resp_data, textlen, outf);
 	else
-		printf("malformed alpha field");
-	putchar('\n');
+		fputs("malformed alpha field", outf);
+	putc('\n', outf);
 	return(0);
 }