changeset 84:0c19ec7af526

fc-uicc-tool update-rec: support prev mode like fc-simtool
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Apr 2021 02:46:49 +0000
parents 3055d5c9e7a3
children c179deb9bb39
files uicc/writecmd.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/uicc/writecmd.c	Sun Apr 11 02:38:31 2021 +0000
+++ b/uicc/writecmd.c	Sun Apr 11 02:46:49 2021 +0000
@@ -45,7 +45,7 @@
 cmd_update_rec(argc, argv)
 	char **argv;
 {
-	unsigned recno;
+	unsigned recno, mode;
 	u_char data[255];
 	int rc;
 
@@ -53,11 +53,17 @@
 		fprintf(stderr, "error: no record-based file selected\n");
 		return(-1);
 	}
-	recno = strtoul(argv[1], 0, 0);
-	if (recno < 1 || recno > 255) {
-		fprintf(stderr,
+	if (!strcmp(argv[1], "prev")) {
+		recno = 0;
+		mode = 0x03;
+	} else {
+		recno = strtoul(argv[1], 0, 0);
+		if (recno < 1 || recno > 255) {
+			fprintf(stderr,
 			"error: record number argument is out of range\n");
-		return(-1);
+			return(-1);
+		}
+		mode = 0x04;
 	}
 	rc = read_hex_data_file(argv[2], data, 255);
 	if (rc < 0)
@@ -66,5 +72,5 @@
 		fprintf(stderr, "error: hex data length != EF record length\n");
 		return(-1);
 	}
-	return update_rec_op(recno, 0x04, data, last_sel_file_record_len);
+	return update_rec_op(recno, mode, data, last_sel_file_record_len);
 }