FreeCalypso > hg > fc-sim-tools
annotate libutil/decimal_incr.c @ 70:ce3752d3d3b4
doc/SIM-in-Calypso-phone: update for fc-host-tools-r15 release
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 Mar 2021 19:44:31 +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 } |