| 4379 | |
| 4380 | |
| 4381 | static int msg_branch_flag_set(struct sip_msg* msg, pv_param_t *param, int op, |
| 4382 | pv_value_t *val) |
| 4383 | { |
| 4384 | int size; |
| 4385 | int idx; |
| 4386 | int idxf; |
| 4387 | |
| 4388 | if(param==NULL) { |
| 4389 | LM_ERR("bad parameters\n"); |
| 4390 | return -1; |
| 4391 | } |
| 4392 | |
| 4393 | if (val==NULL || (val->flags&(PV_VAL_NULL|PV_VAL_NONE))!=0 || |
| 4394 | (val->flags&PV_TYPE_INT)==0 ) { |
| 4395 | LM_ERR("input for $branch.flag() found not to be an integer\n"); |
| 4396 | return -1; |
| 4397 | } |
| 4398 | |
| 4399 | /* get the index */ |
| 4400 | if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) { |
| 4401 | LM_ERR("invalid index\n"); |
| 4402 | return -1; |
| 4403 | } |
| 4404 | |
| 4405 | if(idxf==PV_IDX_ALL) { |
| 4406 | LM_ERR("SCRIPT BUG - * not allowed in branch flag assignment\n"); |
| 4407 | return -1; |
| 4408 | } |
| 4409 | |
| 4410 | size = get_dset_size() + 1; |
| 4411 | |
| 4412 | /* if no idx, work with the last branch */ |
| 4413 | if (idxf==0 && idx==0) |
| 4414 | idx = size - 1; |
| 4415 | |
| 4416 | if (idx<0) { |
| 4417 | idx = size + idx; |
| 4418 | } |
| 4419 | |
| 4420 | if (idx<0 || idx>=size) { |
| 4421 | LM_DBG("inexisting branch flag assignment [%d/%d]\n", size, idx); |
| 4422 | return -1; |
| 4423 | } |
| 4424 | |
| 4425 | if (val->ri==0) |
| 4426 | resetbflag (msg, idx, param->pvn.u.isname.name.n); |
| 4427 | else |
| 4428 | setbflag( msg, idx, param->pvn.u.isname.name.n); |
| 4429 | |
| 4430 | return 0; |
| 4431 | } |
| 4432 | |
| 4433 | |
| 4434 | static int msg_branch_flag_get(struct sip_msg *msg, pv_param_t *param, |
nothing calls this directly
no test coverage detected