changeset 113:32acef9d20ff

fc-simtool plmnsel-dump: support output redirection
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 07:17:59 +0000
parents 440a4582d2a5
children 2c07684a3980
files simtool/dispatch.c simtool/plmnsel.c
diffstat 2 files changed, 3 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Fri Feb 19 07:09:21 2021 +0000
+++ b/simtool/dispatch.c	Fri Feb 19 07:17:59 2021 +0000
@@ -142,7 +142,7 @@
 	{"pb-update", 2, 2, 0, cmd_pb_update},
 	{"pb-update-imm", 3, 4, 0, cmd_pb_update_imm},
 	{"pb-update-imm-hex", 4, 4, 0, cmd_pb_update_imm_hex},
-	{"plmnsel-dump", 0, 1, 0, cmd_plmnsel_dump},
+	{"plmnsel-dump", 0, 0, 1, cmd_plmnsel_dump},
 	{"plmnsel-erase", 1, 2, 0, cmd_plmnsel_erase},
 	{"plmnsel-erase-all", 0, 0, 0, cmd_plmnsel_erase_all},
 	{"plmnsel-write", 2, 2, 0, cmd_plmnsel_write},
--- a/simtool/plmnsel.c	Fri Feb 19 07:09:21 2021 +0000
+++ b/simtool/plmnsel.c	Fri Feb 19 07:17:59 2021 +0000
@@ -47,14 +47,14 @@
 	return(0);
 }
 
-cmd_plmnsel_dump(argc, argv)
+cmd_plmnsel_dump(argc, argv, outf)
 	char **argv;
+	FILE *outf;
 {
 	int rc, gap_flag;
 	u_char *dp, *endp;
 	char ascbuf[8];
 	unsigned idx, linelen;
-	FILE *outf;
 
 	rc = select_ef_plmnsel();
 	if (rc < 0)
@@ -62,14 +62,6 @@
 	rc = readbin_op(0, curfile_total_size);
 	if (rc < 0)
 		return(rc);
-	if (argv[1]) {
-		outf = fopen(argv[1], "w");
-		if (!outf) {
-			perror(argv[1]);
-			return(-1);
-		}
-	} else
-		outf = stdout;
 	dp = sim_resp_data;
 	endp = sim_resp_data + sim_resp_data_len;
 	gap_flag = 0;
@@ -99,8 +91,6 @@
 	}
 	if (linelen)
 		putc('\n', outf);
-	if (argv[1])
-		fclose(outf);
 	return(0);
 }