comparison offline/sim-iccid-mkfull.c @ 163:4cd2023f56a6

sim-iccid-mkfull utility created, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Feb 2021 21:32:41 +0000
parents
children
comparison
equal deleted inserted replaced
162:274bfd8bccd0 163:4cd2023f56a6
1 /*
2 * This program is a special utility for constructing ICCIDs
3 * following the 18+1 convention. The argument is an 18-digit ICCID
4 * base, usually entered in shorthand, and the output is the full
5 * 19-digit ICCID.
6 */
7
8 #include <sys/types.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 main(argc, argv)
13 char **argv;
14 {
15 u_char digits[19];
16 char asc[20];
17 int rc;
18
19 if (argc != 2) {
20 fprintf(stderr, "usage: %s shorthand-iccid\n", argv[0]);
21 exit(1);
22 }
23 rc = parse_decimal_shorthand(argv[1], digits, 18);
24 if (rc < 0)
25 exit(1); /* error msg already printed */
26 digits[18] = compute_iccid_luhn(digits);
27 nibbles_to_ascii(digits, 19, asc);
28 puts(asc);
29 exit(0);
30 }