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

Function pv_parse_sdp_session_name

sdp_ops.c:1486–1559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1484
1485
1486int pv_parse_sdp_session_name(pv_spec_p sp, const str *_in)
1487{
1488 str in = *_in, tok;
1489 int escape = 0, i;
1490 enum sdp_pv_name nm = SDP_PV_NAME_P3_LINE;
1491 struct sdp_pv_param *param;
1492
1493 if (!sp)
1494 return -1;
1495
1496 LM_DBG("parse sdp name: '%.*s'\n", in.len, in.s);
1497 trim(&in);
1498 if (!in.s || in.len == 0)
1499 goto done;
1500
1501 if (in.s[0] == PV_MARKER) {
1502 LM_ERR("no support for dynamic names in $sdp.line\n");
1503 return -1;
1504 } else if (in.s[0] == '@') {
1505 // TODO: impl custom SDP holders (perhaps using a map)
1506 return -1;
1507 }
1508
1509 param = pkg_malloc(sizeof *param);
1510 if (!param) {
1511 LM_ERR("oom\n");
1512 return -1;
1513 }
1514 memset(param, 0, sizeof *param);
1515
1516 tok.s = in.s;
1517 for (i = 0; i < in.len; i++) {
1518 if (escape && (in.s[i] == '\\' || in.s[i] == '/')) {
1519 memmove(&in.s[i-1], &in.s[i], in.len - i);
1520 in.len--;
1521 i--;
1522 escape = 0;
1523 continue;
1524 }
1525
1526 if (in.s[i] == '\\') {
1527 escape = 1;
1528 continue;
1529 }
1530 escape = 0;
1531
1532 if (in.s[i] == '/' && nm <= SDP_PV_NAME_P4_TOKEN) {
1533 tok.len = i - (tok.s - in.s);
1534 // save tok
1535 switch (nm) {
1536 case SDP_PV_NAME_P1_NAME:
1537 case SDP_PV_NAME_P2_STREAM:
1538 case SDP_PV_NAME_P3_LINE:
1539 param->match_line.prefix = tok;
1540 tok.s = in.s + i + 1;
1541 nm++;
1542 break;
1543 case SDP_PV_NAME_P4_TOKEN:

Callers

nothing calls this directly

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected