| 274 | |
| 275 | |
| 276 | int pv_parse_sdp_name(pv_spec_p sp, const str *_in) |
| 277 | { |
| 278 | // TODO -- add support for custom SDP holders |
| 279 | str in = *_in, tok; |
| 280 | int escape = 0, i; |
| 281 | enum sdp_pv_name nm = SDP_PV_NAME_P3_LINE; |
| 282 | struct sdp_pv_param *param; |
| 283 | char *p, *lim = in.s + in.len; |
| 284 | |
| 285 | if (!sp) |
| 286 | return -1; |
| 287 | |
| 288 | LM_DBG("parse sdp name: '%.*s'\n", in.len, in.s); |
| 289 | trim(&in); |
| 290 | if (!in.s || in.len == 0) |
| 291 | goto done; |
| 292 | |
| 293 | if (in.s[0] == PV_MARKER) { |
| 294 | LM_ERR("no support for dynamic names in $sdp.line\n"); |
| 295 | return -1; |
| 296 | } else if (in.s[0] == '@') { |
| 297 | // TODO: impl custom SDP holders (perhaps using a map) |
| 298 | return -1; |
| 299 | } |
| 300 | |
| 301 | param = pkg_malloc(sizeof *param); |
| 302 | if (!param) { |
| 303 | LM_ERR("oom\n"); |
| 304 | return -1; |
| 305 | } |
| 306 | memset(param, 0, sizeof *param); |
| 307 | |
| 308 | tok.s = in.s; |
| 309 | for (i = 0; i < in.len; i++) { |
| 310 | struct sdp_pv_idx idx = {0}; |
| 311 | |
| 312 | if (escape && (in.s[i] == '\\' || in.s[i] == '/')) { |
| 313 | memmove(&in.s[i-1], &in.s[i], in.len - i); |
| 314 | in.len--; |
| 315 | i--; |
| 316 | escape = 0; |
| 317 | continue; |
| 318 | } |
| 319 | |
| 320 | if (in.s[i] == '\\') { |
| 321 | escape = 1; |
| 322 | continue; |
| 323 | } |
| 324 | escape = 0; |
| 325 | |
| 326 | if (in.s[i] == '[') { |
| 327 | p = parse_sdp_pv_index(in.s + i + 1, in.len - i - 1, &idx); |
| 328 | if (!p) { |
| 329 | LM_ERR("error while parsing index in $sdp name: '%.*s'\n", in.len, in.s); |
| 330 | return -1; |
| 331 | } |
| 332 | |
| 333 | if (p < lim && *p != '/') { |
nothing calls this directly
no test coverage detected