| 5438 | |
| 5439 | |
| 5440 | int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags) |
| 5441 | { |
| 5442 | pv_value_t tv; |
| 5443 | if(ip==NULL || idx==NULL || flags==NULL) |
| 5444 | return -1; |
| 5445 | |
| 5446 | *idx = 0; |
| 5447 | *flags = ip->pvi.type; |
| 5448 | |
| 5449 | if(ip->pvi.type == 0) |
| 5450 | return 0; |
| 5451 | |
| 5452 | if(ip->pvi.type == PV_IDX_ALL || ip->pvi.type == PV_IDX_APPEND) { |
| 5453 | return 0; |
| 5454 | } |
| 5455 | |
| 5456 | if(ip->pvi.type == PV_IDX_INT) |
| 5457 | { |
| 5458 | *idx = ip->pvi.u.ival; |
| 5459 | return 0; |
| 5460 | } |
| 5461 | |
| 5462 | /* pvar */ |
| 5463 | if(pv_get_spec_value(msg, (const pv_spec_p)ip->pvi.u.dval, &tv)!=0) |
| 5464 | { |
| 5465 | LM_ERR("cannot get index value\n"); |
| 5466 | return -1; |
| 5467 | } |
| 5468 | if(!(tv.flags & PV_VAL_INT)) |
| 5469 | { |
| 5470 | LM_ERR("invalid index value\n"); |
| 5471 | return -1; |
| 5472 | } |
| 5473 | *idx = tv.ri; |
| 5474 | return 0; |
| 5475 | } |
| 5476 | |
| 5477 | /* function to set pv value */ |
| 5478 | int pv_set_value(struct sip_msg* msg, pv_spec_p sp, |
no test coverage detected