view libnumutil/nanp_valid.c @ 4:b280d93e8bc1

themwi-dump-numdb: old source as starting point
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 13 Dec 2023 02:18:07 +0000
parents 159dd90eeafe
children
line wrap: on
line source

/*
 * 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;
}