| 276 | #define DP_MAX_ATTRS_LEN 256 |
| 277 | static char dp_attrs_buf[DP_MAX_ATTRS_LEN+1]; |
| 278 | int translate(struct sip_msg *msg, str input, str * output, dpl_id_p idp, str * attrs) { |
| 279 | |
| 280 | dpl_node_p rulep, rrulep; |
| 281 | int string_res = -1, regexp_res = -1, bucket; |
| 282 | |
| 283 | if(!input.s || !input.len) { |
| 284 | LM_ERR("invalid input string\n"); |
| 285 | return -1; |
| 286 | } |
| 287 | |
| 288 | bucket = core_case_hash(&input, NULL, DP_INDEX_HASH_SIZE); |
| 289 | |
| 290 | /* try to match the input in the corresponding string bucket */ |
| 291 | for (rulep = idp->rule_hash[bucket].first_rule; rulep; rulep=rulep->next) { |
| 292 | |
| 293 | LM_DBG("Equal operator testing\n"); |
| 294 | |
| 295 | if(rulep->match_exp.len != input.len) |
| 296 | continue; |
| 297 | |
| 298 | LM_DBG("Comparing (input %.*s) with (rule %.*s) [%d] and timerec %.*s\n", |
| 299 | input.len, input.s, rulep->match_exp.len, rulep->match_exp.s, |
| 300 | rulep->match_flags, rulep->timerec.len, rulep->timerec.s); |
| 301 | |
| 302 | // Check for Time Period if Set |
| 303 | if(rulep->parsed_timerec) { |
| 304 | LM_DBG("Timerec exists for rule checking: %.*s\n", rulep->timerec.len, rulep->timerec.s); |
| 305 | // Doesn't matches time period continue with next rule |
| 306 | if(tmrec_expr_check(rulep->parsed_timerec) < 0) { |
| 307 | LM_DBG("Time rule doesn't match: skip next!\n"); |
| 308 | continue; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if (rulep->match_flags & DP_CASE_INSENSITIVE) { |
| 313 | string_res = strncasecmp(rulep->match_exp.s,input.s,input.len); |
| 314 | } else { |
| 315 | string_res = strncmp(rulep->match_exp.s,input.s,input.len); |
| 316 | } |
| 317 | |
| 318 | if (string_res == 0) { |
| 319 | break; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /* try to match the input in the regexp bucket */ |
| 324 | for (rrulep = idp->rule_hash[DP_INDEX_HASH_SIZE].first_rule; rrulep; rrulep=rrulep->next) { |
| 325 | |
| 326 | // Check for Time Period if Set |
| 327 | if(rrulep->parsed_timerec) { |
| 328 | LM_DBG("Timerec exists for rule checking: %.*s\n", rrulep->timerec.len, rrulep->timerec.s); |
| 329 | // Doesn't matches time period continue with next rule |
| 330 | if(tmrec_expr_check(rrulep->parsed_timerec) < 0) { |
| 331 | LM_DBG("Time rule doesn't match: skip next!\n"); |
| 332 | continue; |
| 333 | } |
| 334 | } |
| 335 |
no test coverage detected