comparison libutil/nanp_valid.c @ 2:b1c364729a93

libutil: add NANP number validation function
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 25 Jun 2022 18:58:00 -0800
parents
children 81958b35f74d
comparison
equal deleted inserted replaced
1:dbc0a8677b69 2:b1c364729a93
1 /*
2 * Utility functions for NANP number validation.
3 */
4
5 is_nanp_valid_prefix(s)
6 char *s;
7 {
8 /* validate NPA part */
9 if (s[0] < '2')
10 return(0);
11 if (s[1] == '1' && s[2] == '1')
12 return(0);
13 if (s[1] == '9')
14 return(0);
15 /* validate exchange part */
16 if (s[3] < '2')
17 return(0);
18 if (s[4] == '1' && s[5] == '1')
19 return(0);
20 /* all checks passed */
21 return(1);
22 }