FreeCalypso > hg > fc-pcsc-tools
comparison simtool/sstlist.c @ 60:090704d1ddc1
simtool: C module implementing sst command renamed
from sstdump.c to sstlist.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Feb 2021 01:45:05 +0000 |
parents | simtool/sstdump.c@c56e63a8725d |
children | 9c16cf1a79af |
comparison
equal
deleted
inserted
replaced
59:c56e63a8725d | 60:090704d1ddc1 |
---|---|
1 /* | |
2 * This module implements the sst command, listing the SIM Service Table | |
3 * in a human-readable, yet very compact form: just a list of activated | |
4 * (or allocated but not activated, specially marked) service numbers. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include <stdio.h> | |
9 #include "simresp.h" | |
10 #include "curfile.h" | |
11 #include "file_id.h" | |
12 | |
13 cmd_sst() | |
14 { | |
15 int rc; | |
16 unsigned byte, pos, code, nserv, linelen; | |
17 | |
18 rc = select_op(DF_GSM); | |
19 if (rc < 0) | |
20 return(rc); | |
21 rc = select_op(EF_SST); | |
22 if (rc < 0) | |
23 return(rc); | |
24 rc = parse_ef_select_response(); | |
25 if (rc < 0) | |
26 return(rc); | |
27 if (curfile_structure != 0x00) { | |
28 fprintf(stderr, "error: EF_SST is not transparent\n"); | |
29 return(-1); | |
30 } | |
31 if (curfile_total_size < 2) { | |
32 fprintf(stderr, | |
33 "error: EF_SST is shorter than spec minimum of 2 bytes\n"); | |
34 return(-1); | |
35 } | |
36 if (curfile_total_size > 256) { | |
37 fprintf(stderr, | |
38 "error: EF_SST is longer than our 256 byte limit\n"); | |
39 return(-1); | |
40 } | |
41 rc = readbin_op(0, curfile_total_size); | |
42 if (rc < 0) | |
43 return(rc); | |
44 linelen = 0; | |
45 for (byte = 0, nserv = 1; byte < curfile_total_size; byte++) { | |
46 for (pos = 0; pos < 8; pos += 2, nserv++) { | |
47 code = (sim_resp_data[byte] >> pos) & 3; | |
48 if (!(code & 1)) | |
49 continue; | |
50 if (linelen > 73) { | |
51 putchar('\n'); | |
52 linelen = 0; | |
53 } | |
54 if (linelen) { | |
55 putchar(' '); | |
56 linelen++; | |
57 } | |
58 linelen += printf("%u", nserv); | |
59 if (!(code & 2)) { | |
60 putchar('^'); | |
61 linelen++; | |
62 } | |
63 } | |
64 } | |
65 if (linelen) | |
66 putchar('\n'); | |
67 return(0); | |
68 } |