FreeCalypso > hg > fc-sim-tools
annotate libutil/decimal_incr.c @ 90:3afa61d98961
fc-uicc-tool: savebin ported over from fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 11 Apr 2021 04:32:26 +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 } |