@max_digits should be just 15, but there are exceptions to this rule! */
| 653 | |
| 654 | /* @max_digits should be just 15, but there are exceptions to this rule! */ |
| 655 | static 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 | /* |
no outgoing calls