changeset 122:f18704e91393

fc-simtool: pb-dump-rec command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Jan 2021 05:12:10 +0000
parents 87b34a244901
children b391204d3cd5
files simtool/dispatch.c simtool/pbdump.c
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Thu Jan 28 05:04:16 2021 +0000
+++ b/simtool/dispatch.c	Thu Jan 28 05:12:10 2021 +0000
@@ -19,6 +19,7 @@
 extern int cmd_iccid();
 extern int cmd_imsi();
 extern int cmd_pb_dump();
+extern int cmd_pb_dump_rec();
 extern int cmd_pb_erase();
 extern int cmd_pb_erase_one();
 extern int cmd_pb_erase_range();
@@ -68,6 +69,7 @@
 	{"iccid", 0, 0, cmd_iccid},
 	{"imsi", 0, 0, cmd_imsi},
 	{"pb-dump", 1, 2, cmd_pb_dump},
+	{"pb-dump-rec", 2, 3, cmd_pb_dump_rec},
 	{"pb-erase", 1, 1, cmd_pb_erase},
 	{"pb-erase-one", 2, 2, cmd_pb_erase_one},
 	{"pb-erase-range", 3, 3, cmd_pb_erase_range},
--- a/simtool/pbdump.c	Thu Jan 28 05:04:16 2021 +0000
+++ b/simtool/pbdump.c	Thu Jan 28 05:12:10 2021 +0000
@@ -140,3 +140,43 @@
 		fclose(outf);
 	return(0);
 }
+
+cmd_pb_dump_rec(argc, argv)
+	char **argv;
+{
+	int rc;
+	unsigned recno, startrec, endrec;
+
+	rc = phonebook_op_common(argv[1]);
+	if (rc < 0)
+		return(rc);
+	startrec = strtoul(argv[2], 0, 0);
+	if (startrec < 1 || startrec > curfile_record_count) {
+		fprintf(stderr,
+			"error: specified starting record number is invalid\n");
+		return(-1);
+	}
+	if (argv[3]) {
+		endrec = strtoul(argv[3], 0, 0);
+		if (endrec < 1 || endrec > curfile_record_count) {
+			fprintf(stderr,
+			"error: specified final record number is invalid\n");
+			return(-1);
+		}
+		if (startrec > endrec) {
+			fprintf(stderr,
+				"error: reverse record range specified\n");
+			return(-1);
+		}
+	} else
+		endrec = startrec;
+	for (recno = startrec; recno <= endrec; recno++) {
+		rc = readrec_op(recno, 0x04, curfile_record_len);
+		if (rc < 0)
+			return(rc);
+		if (check_all_blank())
+			continue;
+		dump_record(recno, stdout);
+	}
+	return(0);
+}