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

Function tr_eval_csv

transformations.c:1487–1608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1485static csv_record* _tr_csv_list = NULL;
1486
1487int tr_eval_csv(struct sip_msg *msg, tr_param_t *tp,int subtype,
1488 pv_value_t *val)
1489{
1490 csv_record *cit=NULL;
1491 int n,i,list_size=0;
1492 pv_value_t v;
1493
1494 if (!val)
1495 return -1;
1496
1497 if (val->flags & PV_VAL_NULL)
1498 return 0;
1499
1500 if (!(val->flags&PV_VAL_STR) || val->rs.len<=0)
1501 goto error;
1502
1503 if(_tr_csv_str.len==0 || _tr_csv_str.len!=val->rs.len ||
1504 strncmp(_tr_csv_str.s, val->rs.s, val->rs.len)!=0)
1505 {
1506 if(val->rs.len>_tr_csv_str.len)
1507 {
1508 if(_tr_csv_str.s) pkg_free(_tr_csv_str.s);
1509 _tr_csv_str.s = (char*)pkg_malloc((val->rs.len+1));
1510 if(_tr_csv_str.s==NULL)
1511 {
1512 LM_ERR("no more private memory\n");
1513 memset(&_tr_csv_str, 0, sizeof(str));
1514 if(_tr_csv_list != NULL)
1515 {
1516 free_csv_record(_tr_csv_list);
1517 _tr_csv_list = NULL;
1518 }
1519 goto error;
1520 }
1521 }
1522 _tr_csv_str.len = val->rs.len;
1523 memcpy(_tr_csv_str.s, val->rs.s, val->rs.len);
1524 _tr_csv_str.s[_tr_csv_str.len] = '\0';
1525
1526 /* reset old values */
1527 if(_tr_csv_list != NULL)
1528 {
1529 free_csv_record(_tr_csv_list);
1530 _tr_csv_list = NULL;
1531 }
1532
1533 /* parse csv */
1534 _tr_csv_list = _parse_csv_record(&_tr_csv_str, CSV_RFC_4180);
1535 if (!_tr_csv_list)
1536 goto error;
1537 }
1538
1539 if (_tr_csv_list == NULL)
1540 goto error;
1541
1542 switch(subtype)
1543 {
1544 case TR_CSV_COUNT:

Callers

nothing calls this directly

Calls 3

free_csv_recordFunction · 0.85
int2strFunction · 0.85
pv_get_spec_valueFunction · 0.85

Tested by

no test coverage detected