annotate libutil/nanp_valid.c @ 147:94b5831c017f

sip-manual-out code: split bye_in.c from uas.c
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 08 Oct 2022 23:01:32 -0800
parents b1c364729a93
children 81958b35f74d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Utility functions for NANP number validation.
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 is_nanp_valid_prefix(s)
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 char *s;
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 {
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 /* validate NPA part */
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 if (s[0] < '2')
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 return(0);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 if (s[1] == '1' && s[2] == '1')
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 return(0);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 if (s[1] == '9')
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 return(0);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /* validate exchange part */
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (s[3] < '2')
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 return(0);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (s[4] == '1' && s[5] == '1')
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return(0);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 /* all checks passed */
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return(1);
b1c364729a93 libutil: add NANP number validation function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }