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

Function tr_parse_uri

transformations.c:3281–3364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3279}
3280
3281int tr_parse_uri(str* in, trans_t *t)
3282{
3283 char *p;
3284 str name;
3285 tr_param_t *tp = NULL;
3286
3287 if(in==NULL || in->s==NULL || t==NULL)
3288 return -1;
3289 p = in->s;
3290 name.s = in->s;
3291
3292 /* find next token */
3293 while(*p && *p!=TR_PARAM_MARKER && *p!=TR_RBRACKET) p++;
3294 if(*p=='\0')
3295 {
3296 LM_ERR("invalid transformation: %.*s\n", in->len, in->s);
3297 goto error;
3298 }
3299 name.len = p - name.s;
3300 trim(&name);
3301
3302 if(name.len==4 && strncasecmp(name.s, "user", 4)==0)
3303 {
3304 t->subtype = TR_URI_USER;
3305 return 0;
3306 } else if((name.len==4 && strncasecmp(name.s, "host", 4)==0)
3307 || (name.len==6 && strncasecmp(name.s, "domain", 6)==0)) {
3308 t->subtype = TR_URI_HOST;
3309 return 0;
3310 } else if(name.len==6 && strncasecmp(name.s, "passwd", 6)==0) {
3311 t->subtype = TR_URI_PASSWD;
3312 return 0;
3313 } else if(name.len==4 && strncasecmp(name.s, "port", 4)==0) {
3314 t->subtype = TR_URI_PORT;
3315 return 0;
3316 } else if(name.len==6 && strncasecmp(name.s, "params", 6)==0) {
3317 t->subtype = TR_URI_PARAMS;
3318 return 0;
3319 } else if(name.len==5 && strncasecmp(name.s, "param", 5)==0) {
3320 t->subtype = TR_URI_PARAM;
3321 if(*p!=TR_PARAM_MARKER)
3322 {
3323 LM_ERR("invalid param transformation: %.*s\n", in->len, in->s);
3324 goto error;
3325 }
3326 p++;
3327 if (tr_parse_sparam(p, in, &tp, 0) == NULL)
3328 goto error;
3329 t->params = tp;
3330 return 0;
3331 } else if(name.len==9 && strncasecmp(name.s, "transport", 9)==0) {
3332 t->subtype = TR_URI_TRANSPORT;
3333 return 0;
3334 } else if(name.len==7 && strncasecmp(name.s, "headers", 7)==0) {
3335 t->subtype = TR_URI_HEADERS;
3336 return 0;
3337 } else if(name.len==3 && strncasecmp(name.s, "ttl", 3)==0) {
3338 t->subtype = TR_URI_TTL;

Callers

nothing calls this directly

Calls 2

trimFunction · 0.85
tr_parse_sparamFunction · 0.85

Tested by

no test coverage detected