annotate decode/pcm-sms-decode.c @ 33:a91fb88a57b2 default tip

add INSTALL document
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Jun 2024 20:29:17 +0000
parents aae078d9eaa6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <ctype.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdio.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <stdlib.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <string.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <strings.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <unistd.h>
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 extern int ascii_ext_mode, global_hexdump_mode;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 extern u_char pdu[176];
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern unsigned pdu_length;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static char *infname;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 static FILE *inf;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static unsigned start_recno;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static char *msgtype[4] = {"received", "received unread", "sent",
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 "stored unsent"};
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 static
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 process_cmdline(argc, argv)
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char **argv;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int c;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern int optind;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 while ((c = getopt(argc, argv, "ehsu")) != EOF)
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 switch (c) {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 case 'e':
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 ascii_ext_mode = 1;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 continue;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 case 'h':
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 global_hexdump_mode = 1;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 continue;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 case 's':
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 start_recno = 1;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 continue;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 case 'u':
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 ascii_ext_mode = 2;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 continue;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 default:
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(stderr, "%s: invalid option\n", argv[0]);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 exit(1);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (argc != optind + 1) {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 fprintf(stderr, "usage: %s [options] pcm-sms-binfile\n",
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 argv[0]);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 exit(1);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 infname = argv[optind];
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 main(argc, argv)
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 char **argv;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 u_char record[176];
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 unsigned recno;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 process_cmdline(argc, argv);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 inf = fopen(infname, "r");
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (!inf) {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 perror(infname);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 exit(1);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 pdu_length = 176;
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 for (recno = start_recno; fread(record, sizeof record, 1, inf);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 recno++) {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (record[0] & 1) {
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 printf("Record #%u is %s message:\n", recno,
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 msgtype[(record[0] >> 1) & 3]);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 bcopy(record + 1, pdu, 175);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 process_pdu(0, 1);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 putchar('\n');
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 } else
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 printf("Record #%u is empty\n\n", recno);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 exit(0);
aae078d9eaa6 immigrate sms-pdu-decode and pcm-sms-decode here
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }