changeset 807:3a80bfa87496

pcm-sms-decode: add -s option for 1-based record numbering
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 25 Mar 2021 05:56:06 +0000
parents 843850c526b7
children ac527de89a0d
files uptools/sms-pdu-decode/pcm-sms-decode.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/uptools/sms-pdu-decode/pcm-sms-decode.c	Thu Mar 25 05:35:07 2021 +0000
+++ b/uptools/sms-pdu-decode/pcm-sms-decode.c	Thu Mar 25 05:56:06 2021 +0000
@@ -12,6 +12,7 @@
 
 static char *infname;
 static FILE *inf;
+static unsigned start_recno;
 
 static char *msgtype[4] = {"received", "received unread", "sent",
 			   "stored unsent"};
@@ -23,7 +24,7 @@
 	int c;
 	extern int optind;
 
-	while ((c = getopt(argc, argv, "ehu")) != EOF)
+	while ((c = getopt(argc, argv, "ehsu")) != EOF)
 		switch (c) {
 		case 'e':
 			ascii_ext_mode = 1;
@@ -31,6 +32,9 @@
 		case 'h':
 			global_hexdump_mode = 1;
 			continue;
+		case 's':
+			start_recno = 1;
+			continue;
 		case 'u':
 			ascii_ext_mode = 2;
 			continue;
@@ -59,7 +63,8 @@
 		exit(1);
 	}
 	pdu_length = 176;
-	for (recno = 0; fread(record, sizeof record, 1, inf); recno++) {
+	for (recno = start_recno; fread(record, sizeof record, 1, inf);
+	     recno++) {
 		if (record[0] & 1) {
 			printf("Record #%u is %s message:\n", recno,
 				msgtype[(record[0] >> 1) & 3]);