FreeCalypso > hg > themwi-nanp
diff libnumutil/nanp_valid.c @ 0:159dd90eeafe
beginning, libnumutil compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 12 Dec 2023 23:52:50 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libnumutil/nanp_valid.c Tue Dec 12 23:52:50 2023 +0000 @@ -0,0 +1,23 @@ +/* + * Utility functions for NANP number validation. + */ + +#include <stdbool.h> + +#include <themwi/nanp/number_utils.h> + +bool is_nanp_valid_prefix(const char *s) +{ + /* validate NPA part */ + if (s[0] < '2') + return false; + if (s[1] == '1' && s[2] == '1') + return false; + /* validate exchange part */ + if (s[3] < '2') + return false; + if (s[4] == '1' && s[5] == '1') + return false; + /* all checks passed */ + return true; +}