diff uptools/sms-pdu-decode/sms-pdu-decode.c @ 386:bae0fd7285dd

sms-pdu-decode: added -p option to keep the raw PDUs in the output
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 09 Mar 2018 22:15:43 +0000
parents 7f8f446db97e
children 542c6d733772
line wrap: on
line diff
--- a/uptools/sms-pdu-decode/sms-pdu-decode.c	Fri Mar 09 20:43:53 2018 +0000
+++ b/uptools/sms-pdu-decode/sms-pdu-decode.c	Fri Mar 09 22:15:43 2018 +0000
@@ -8,7 +8,7 @@
 
 char *infname;
 FILE *inf;
-int ascii_ext_mode, global_hexdump_mode;
+int ascii_ext_mode, global_hexdump_mode, keep_raw_pdu;
 
 char input_line[1024];
 u_char pdu[176], first_octet;
@@ -389,7 +389,7 @@
 	int c;
 	extern int optind;
 
-	while ((c = getopt(argc, argv, "ehu")) != EOF)
+	while ((c = getopt(argc, argv, "ehpu")) != EOF)
 		switch (c) {
 		case 'e':
 			ascii_ext_mode = 1;
@@ -397,6 +397,9 @@
 		case 'h':
 			global_hexdump_mode = 1;
 			continue;
+		case 'p':
+			keep_raw_pdu = 1;
+			continue;
 		case 'u':
 			ascii_ext_mode = 2;
 			continue;
@@ -448,11 +451,9 @@
 			continue;
 		}
 		pdu_length = cc;
-		cc = process_pdu();
-		if (cc < 0) {
-			/* decode error, dump the raw PDU */
-			printf("\n%s\n", input_line);
-		}
+		if (keep_raw_pdu)
+			printf("%s\n\n", input_line);
+		process_pdu();
 		putchar('\n');
 		swallow_empty_line();
 	}