FreeCalypso > hg > freecalypso-tools
comparison uptools/sms-pdu-decode/pcm-sms-decode.c @ 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 | 31e219088cd6 |
children | 411d1cc14326 |
comparison
equal
deleted
inserted
replaced
806:843850c526b7 | 807:3a80bfa87496 |
---|---|
10 extern u_char pdu[176]; | 10 extern u_char pdu[176]; |
11 extern unsigned pdu_length; | 11 extern unsigned pdu_length; |
12 | 12 |
13 static char *infname; | 13 static char *infname; |
14 static FILE *inf; | 14 static FILE *inf; |
15 static unsigned start_recno; | |
15 | 16 |
16 static char *msgtype[4] = {"received", "received unread", "sent", | 17 static char *msgtype[4] = {"received", "received unread", "sent", |
17 "stored unsent"}; | 18 "stored unsent"}; |
18 | 19 |
19 static | 20 static |
21 char **argv; | 22 char **argv; |
22 { | 23 { |
23 int c; | 24 int c; |
24 extern int optind; | 25 extern int optind; |
25 | 26 |
26 while ((c = getopt(argc, argv, "ehu")) != EOF) | 27 while ((c = getopt(argc, argv, "ehsu")) != EOF) |
27 switch (c) { | 28 switch (c) { |
28 case 'e': | 29 case 'e': |
29 ascii_ext_mode = 1; | 30 ascii_ext_mode = 1; |
30 continue; | 31 continue; |
31 case 'h': | 32 case 'h': |
32 global_hexdump_mode = 1; | 33 global_hexdump_mode = 1; |
34 continue; | |
35 case 's': | |
36 start_recno = 1; | |
33 continue; | 37 continue; |
34 case 'u': | 38 case 'u': |
35 ascii_ext_mode = 2; | 39 ascii_ext_mode = 2; |
36 continue; | 40 continue; |
37 default: | 41 default: |
57 if (!inf) { | 61 if (!inf) { |
58 perror(infname); | 62 perror(infname); |
59 exit(1); | 63 exit(1); |
60 } | 64 } |
61 pdu_length = 176; | 65 pdu_length = 176; |
62 for (recno = 0; fread(record, sizeof record, 1, inf); recno++) { | 66 for (recno = start_recno; fread(record, sizeof record, 1, inf); |
67 recno++) { | |
63 if (record[0] & 1) { | 68 if (record[0] & 1) { |
64 printf("Record #%u is %s message:\n", recno, | 69 printf("Record #%u is %s message:\n", recno, |
65 msgtype[(record[0] >> 1) & 3]); | 70 msgtype[(record[0] >> 1) & 3]); |
66 bcopy(record + 1, pdu, 175); | 71 bcopy(record + 1, pdu, 175); |
67 process_pdu(0); | 72 process_pdu(0); |