MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / _is_e164

Function _is_e164

ut.h:655–679  ·  view source on GitHub ↗

@max_digits should be just 15, but there are exceptions to this rule! */

Source from the content-addressed store, hash-verified

653
654/* @max_digits should be just 15, but there are exceptions to this rule! */
655static inline int _is_e164(const str* _user, int require_plus, int max_digits)
656{
657 char *d, *start, *end;
658
659 if (_user->len < 1)
660 return -1;
661
662 if (_user->s[0] == '+') {
663 start = _user->s + 1;
664 } else {
665 if (require_plus)
666 return -1;
667 start = _user->s;
668 }
669
670 end = _user->s + _user->len;
671 if (end - start < 2 || end - start > max_digits)
672 return -1;
673
674 for (d = start; d < end; d++)
675 if (!_isdigit(*d))
676 return -1;
677
678 return 1;
679}
680#define is_e164(_user) _is_e164(_user, 1, 15)
681
682/*

Callers 2

check_passport_phonenumFunction · 0.85
test_utFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_utFunction · 0.68