FreeCalypso > hg > fc-pcsc-tools
comparison libutil/alpha_decode.c @ 157:f064dbcc5f41
libutil split from libcommon
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 26 Feb 2021 20:19:58 +0000 |
parents | libcommon/alpha_decode.c@d4dc86195382 |
children |
comparison
equal
deleted
inserted
replaced
156:5f1f3f6fd865 | 157:f064dbcc5f41 |
---|---|
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 } |