FreeCalypso > hg > themwi-nanp
annotate libnumutil/nanp_valid.c @ 7:dc1554b7dfb8
themwi-check-own compiles in the new model
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 13 Dec 2023 03:33:51 +0000 |
parents | 159dd90eeafe |
children |
rev | line source |
---|---|
0
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Utility functions for NANP number validation. |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdbool.h> |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <themwi/nanp/number_utils.h> |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 bool is_nanp_valid_prefix(const char *s) |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 { |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 /* validate NPA part */ |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 if (s[0] < '2') |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 return false; |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 if (s[1] == '1' && s[2] == '1') |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 return false; |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 /* validate exchange part */ |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (s[3] < '2') |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 return false; |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if (s[4] == '1' && s[5] == '1') |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 return false; |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 /* all checks passed */ |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 return true; |
159dd90eeafe
beginning, libnumutil compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |