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

Function tr_parse_nameaddr

transformations.c:3536–3615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3534}
3535
3536int tr_parse_nameaddr(str* in, trans_t *t)
3537{
3538 char *p;
3539 str name;
3540 tr_param_t *tp = NULL;
3541
3542
3543 if(in==NULL || t==NULL)
3544 return -1;
3545
3546 p = in->s;
3547parse_name:
3548 name.s = p;
3549
3550 /* find next token */
3551 while(is_in_str(p, in) && *p!=TR_PARAM_MARKER && *p!=TR_RBRACKET && *p!=TR_CLASS_MARKER) p++;
3552 if(*p=='\0')
3553 {
3554 LM_ERR("invalid transformation: %.*s\n",
3555 in->len, in->s);
3556 goto error;
3557 }
3558 name.len = p - name.s;
3559 trim(&name);
3560 if (*p == TR_CLASS_MARKER) {
3561 if (t->params) {
3562 LM_ERR("transformation [%.*s] already has an index!\n",
3563 in->len, in->s);
3564 goto error;
3565 }
3566 /* we either have a pvar, or an index */
3567 if (tr_parse_nparam(name.s, &name, &tp) == NULL) {
3568 LM_ERR("invalid index: %.*s\n", name.len, name.s);
3569 goto error;
3570 }
3571 t->params = tp;
3572 tp = 0;
3573 p++;
3574 goto parse_name;
3575 }
3576
3577 if(name.len==3 && strncasecmp(name.s, "uri", 3)==0)
3578 {
3579 t->subtype = TR_NA_URI;
3580 return 0;
3581 } else if(name.len==3 && strncasecmp(name.s, "len", 3)==0)
3582 {
3583 t->subtype = TR_NA_LEN;
3584 return 0;
3585 } else if(name.len==4 && strncasecmp(name.s, "name", 4)==0) {
3586 t->subtype = TR_NA_NAME;
3587 return 0;
3588 } else if(name.len==5 && strncasecmp(name.s, "param", 5)==0) {
3589 t->subtype = TR_NA_PARAM;
3590 if(*p!=TR_PARAM_MARKER)
3591 {
3592 LM_ERR("invalid value transformation: %.*s\n",
3593 in->len, in->s);

Callers

nothing calls this directly

Calls 3

trimFunction · 0.85
tr_parse_nparamFunction · 0.85
tr_parse_sparamFunction · 0.85

Tested by

no test coverage detected