comparison utils/sim-iccid-mkrange.c @ 25:9c9f6adbaedb

sim-iccid-mkrange utility added
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 15 Mar 2021 09:07:20 +0000
parents utils/sim-iccid-mkfull.c@372ecc4aa2c4
children
comparison
equal deleted inserted replaced
24:47a491a16de3 25:9c9f6adbaedb
1 /*
2 * This program is a special utility for generating lists of ICCIDs
3 * following the 18+1 convention. The first argument is the starting
4 * ICCID without Luhn (entered as shorthand, expanded to 18 digits),
5 * the second argument is the number of consecutive ICCIDs to generate.
6 * The output is a list of full 19-digit ICCIDs.
7 */
8
9 #include <sys/types.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 main(argc, argv)
14 char **argv;
15 {
16 u_char digits[19];
17 char asc[20];
18 unsigned total, n;
19 int rc;
20
21 if (argc != 3) {
22 fprintf(stderr, "usage: %s start-iccid num-cards\n", argv[0]);
23 exit(1);
24 }
25 rc = parse_decimal_shorthand(argv[1], digits, 18);
26 if (rc < 0)
27 exit(1); /* error msg already printed */
28 total = atoi(argv[2]);
29 for (n = 0; n < total; n++) {
30 digits[18] = compute_iccid_luhn(digits);
31 nibbles_to_ascii(digits, 19, asc);
32 puts(asc);
33 decimal_string_increment(digits, 18);
34 }
35 exit(0);
36 }