changeset 49:bbc2821288aa

fc-simtool sst-dump: much more compact output
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 03:32:37 +0000
parents 9a21f4353158
children dc8a2e6fa03e
files simtool/sstdump.c
diffstat 1 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/sstdump.c	Sat Feb 13 03:09:44 2021 +0000
+++ b/simtool/sstdump.c	Sat Feb 13 03:32:37 2021 +0000
@@ -12,7 +12,7 @@
 cmd_sst_dump()
 {
 	int rc;
-	unsigned byte, pos, code, nserv;
+	unsigned byte, pos, code, nserv, linelen;
 
 	rc = select_op(DF_GSM);
 	if (rc < 0)
@@ -40,16 +40,28 @@
 	rc = readbin_op(0, curfile_total_size);
 	if (rc < 0)
 		return(rc);
-	nserv = 1;
-	for (byte = 0; byte < curfile_total_size; byte++) {
-		for (pos = 0; pos < 8; pos += 2) {
+	linelen = 0;
+	for (byte = 0, nserv = 1; byte < curfile_total_size; byte++) {
+		for (pos = 0; pos < 8; pos += 2, nserv++) {
 			code = (sim_resp_data[byte] >> pos) & 3;
-			if (code == 3)
-				printf("#%u: activated\n", nserv);
-			else if (code == 1)
-				printf("#%u: allocated\n", nserv);
-			nserv++;
+			if (!(code & 1))
+				continue;
+			if (linelen > 73) {
+				putchar('\n');
+				linelen = 0;
+			}
+			if (linelen) {
+				putchar(' ');
+				linelen++;
+			}
+			linelen += printf("%u", nserv);
+			if (!(code & 2)) {
+				putchar('^');
+				linelen++;
+			}
 		}
 	}
+	if (linelen)
+		putchar('\n');
 	return(0);
 }