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

Function cclen

modules/enum/enum.c:51–105  ·  view source on GitHub ↗

* Input: E.164 number w/o leading + * * Output: number of digits in the country code * 0 on invalid number * * convention: * 3 digits is the default length of a country code. * country codes 1 and 7 are a single digit. * the following country codes are two digits: 20, 27, 30-34, 36, 39, * 40, 41, 43-49, 51-58, 60-66, 81, 82, 84, 86, 90-95, 98. */

Source from the content-addressed store, hash-verified

49 * 40, 41, 43-49, 51-58, 60-66, 81, 82, 84, 86, 90-95, 98.
50 */
51static int cclen(const char *number)
52{
53 char d1,d2;
54
55 if (!number || (strlen(number) < 3))
56 return(0);
57
58 d1 = number[0];
59 d2 = number[1];
60
61 if (!isdigit((int)d2))
62 return(0);
63
64 switch(d1) {
65 case '1':
66 case '7':
67 return(1);
68 case '2':
69 if ((d2 == '0') || (d2 == '7'))
70 return(2);
71 break;
72 case '3':
73 if ((d2 >= '0') && (d2 <= '4'))
74 return(2);
75 if ((d2 == '6') || (d2 == '9'))
76 return(2);
77 break;
78 case '4':
79 if (d2 != '2')
80 return(2);
81 break;
82 case '5':
83 if (d2 != '9')
84 return(2);
85 break;
86 case '6':
87 if (d2 <= '6')
88 return(2);
89 break;
90 case '8':
91 if ((d2 == '1') || (d2 == '2') || (d2 == '4') || (d2 == '6'))
92 return(2);
93 break;
94 case '9':
95 if (d2 <= '5')
96 return(2);
97 if (d2 == '8')
98 return(2);
99 break;
100 default:
101 return(0);
102 }
103
104 return(3);
105}
106
107
108

Callers 1

i_enum_queryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected