comparison libutil/alpha_decode.c @ 8:34bbb0585cab

libutil: import from previous fc-pcsc-tools version
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 05:42:37 +0000
parents
children
comparison
equal deleted inserted replaced
7:b25d4dfe5798 8:34bbb0585cab
1 /*
2 * This module contains functions for decoding and displaying alpha fields
3 * that exist in various SIM files.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8
9 static void
10 print_alpha_field_hex(data, nbytes, outf)
11 u_char *data;
12 unsigned nbytes;
13 FILE *outf;
14 {
15 u_char *dp, *endp;
16
17 fputs("HEX ", outf);
18 dp = data;
19 endp = data + nbytes;
20 while (dp < endp)
21 fprintf(outf, "%02X", *dp++);
22 }
23
24 void
25 print_alpha_field(data, nbytes, outf)
26 u_char *data;
27 unsigned nbytes;
28 FILE *outf;
29 {
30 if (!nbytes) {
31 fputs("\"\"", outf);
32 return;
33 }
34 if (data[0] & 0x80)
35 print_alpha_field_hex(data, nbytes, outf);
36 else
37 print_gsm7_string_to_file(data, nbytes, outf);
38 }