FreeCalypso > hg > fc-sim-tools
annotate libutil/alpha_decode.c @ 63:f4eb486aab40
doc/Admin-write-commands: fix verify-hex command name
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 Mar 2021 23:29:31 +0000 |
parents | 34bbb0585cab |
children |
rev | line source |
---|---|
8
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains functions for decoding and displaying alpha fields |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * that exist in various SIM files. |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 static void |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 print_alpha_field_hex(data, nbytes, outf) |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 u_char *data; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 unsigned nbytes; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 FILE *outf; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 u_char *dp, *endp; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 fputs("HEX ", outf); |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 dp = data; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 endp = data + nbytes; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 while (dp < endp) |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 fprintf(outf, "%02X", *dp++); |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 void |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 print_alpha_field(data, nbytes, outf) |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 u_char *data; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 unsigned nbytes; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 FILE *outf; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 if (!nbytes) { |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 fputs("\"\"", outf); |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return; |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (data[0] & 0x80) |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 print_alpha_field_hex(data, nbytes, outf); |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 else |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 print_gsm7_string_to_file(data, nbytes, outf); |
34bbb0585cab
libutil: import from previous fc-pcsc-tools version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |