comparison utils/sim-iccid-mkfull.c @ 17:372ecc4aa2c4

off-line utils ported over
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 07:48:55 +0000
parents
children
comparison
equal deleted inserted replaced
16:53f8a1146a56 17:372ecc4aa2c4
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 }