FreeCalypso > hg > freecalypso-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
385:ce3b57b8920b | 386:bae0fd7285dd |
---|---|
6 #include <strings.h> | 6 #include <strings.h> |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 char *infname; | 9 char *infname; |
10 FILE *inf; | 10 FILE *inf; |
11 int ascii_ext_mode, global_hexdump_mode; | 11 int ascii_ext_mode, global_hexdump_mode, keep_raw_pdu; |
12 | 12 |
13 char input_line[1024]; | 13 char input_line[1024]; |
14 u_char pdu[176], first_octet; | 14 u_char pdu[176], first_octet; |
15 unsigned pdu_length, pdu_ptr; | 15 unsigned pdu_length, pdu_ptr; |
16 int dcs_distilled; | 16 int dcs_distilled; |
387 char **argv; | 387 char **argv; |
388 { | 388 { |
389 int c; | 389 int c; |
390 extern int optind; | 390 extern int optind; |
391 | 391 |
392 while ((c = getopt(argc, argv, "ehu")) != EOF) | 392 while ((c = getopt(argc, argv, "ehpu")) != EOF) |
393 switch (c) { | 393 switch (c) { |
394 case 'e': | 394 case 'e': |
395 ascii_ext_mode = 1; | 395 ascii_ext_mode = 1; |
396 continue; | 396 continue; |
397 case 'h': | 397 case 'h': |
398 global_hexdump_mode = 1; | 398 global_hexdump_mode = 1; |
399 continue; | 399 continue; |
400 case 'p': | |
401 keep_raw_pdu = 1; | |
402 continue; | |
400 case 'u': | 403 case 'u': |
401 ascii_ext_mode = 2; | 404 ascii_ext_mode = 2; |
402 continue; | 405 continue; |
403 default: | 406 default: |
404 fprintf(stderr, "%s: invalid option\n", argv[0]); | 407 fprintf(stderr, "%s: invalid option\n", argv[0]); |
446 if (cc <= 0) { | 449 if (cc <= 0) { |
447 puts(input_line); | 450 puts(input_line); |
448 continue; | 451 continue; |
449 } | 452 } |
450 pdu_length = cc; | 453 pdu_length = cc; |
451 cc = process_pdu(); | 454 if (keep_raw_pdu) |
452 if (cc < 0) { | 455 printf("%s\n\n", input_line); |
453 /* decode error, dump the raw PDU */ | 456 process_pdu(); |
454 printf("\n%s\n", input_line); | |
455 } | |
456 putchar('\n'); | 457 putchar('\n'); |
457 swallow_empty_line(); | 458 swallow_empty_line(); |
458 } | 459 } |
459 exit(0); | 460 exit(0); |
460 } | 461 } |