FreeCalypso > hg > fc-sim-tools
annotate libutil/decimal_incr.c @ 53:fbedb67d234f
serial: fix parity for inverse coding convention
Important note: it is my (Mother Mychaela's) understanding that
SIM cards with inverse coding convention are extremely rare,
and I have never seen such a card. Therefore, our support for
the inverse coding convention will likely remain forever untested.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Mar 2021 20:46:09 +0000 |
parents | 9c9f6adbaedb |
children |
rev | line source |
---|---|
25
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements a function for incrementing decimal strings, |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * to be used in producing ranges of ICCID and IMSI numbers. |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 void |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 decimal_string_increment(str, ndigits) |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 u_char *str; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 unsigned ndigits; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 u_char *p; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 for (p = str + ndigits; p > str; ) { |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 --p; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 (*p)++; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (*p < 10) |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 return; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 *p = 0; |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |