Parse NAPTR regexp field of the form !pattern!replacement! and return its * components in pattern and replacement parameters. Regexp field starts at * address first and is len characters long. */
| 126 | * address first and is len characters long. |
| 127 | */ |
| 128 | static inline int parse_naptr_regexp(char* first, int len, str* pattern, |
| 129 | str* replacement) |
| 130 | { |
| 131 | char *second, *third; |
| 132 | |
| 133 | if (len > 0) { |
| 134 | if (*first == '!') { |
| 135 | second = (char *)memchr((void *)(first + 1), '!', len - 1); |
| 136 | if (second) { |
| 137 | len = len - (second - first + 1); |
| 138 | if (len > 0) { |
| 139 | third = memchr(second + 1, '!', len); |
| 140 | if (third) { |
| 141 | pattern->len = second - first - 1; |
| 142 | pattern->s = first + 1; |
| 143 | replacement->len = third - second - 1; |
| 144 | replacement->s = second + 1; |
| 145 | return 1; |
| 146 | } else { |
| 147 | LM_ERR("Third ! missing from regexp\n"); |
| 148 | return -1; |
| 149 | } |
| 150 | } else { |
| 151 | LM_ERR("Third ! missing from regexp\n"); |
| 152 | return -2; |
| 153 | } |
| 154 | } else { |
| 155 | LM_ERR("Second ! missing from regexp\n"); |
| 156 | return -3; |
| 157 | } |
| 158 | } else { |
| 159 | LM_ERR("First ! missing from regexp\n"); |
| 160 | return -4; |
| 161 | } |
| 162 | } else { |
| 163 | LM_ERR("Regexp missing\n"); |
| 164 | return -5; |
| 165 | } |
| 166 | } |
| 167 | /* Checks if NAPTR record has flag u and its services field |
| 168 | * e2u+[service:]sip or |
| 169 | * e2u+service[+service[+service[+...]]] |
no outgoing calls
no test coverage detected