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

Function subst_uri_f

modules/textops/textops.c:513–546  ·  view source on GitHub ↗

sed-perl style re: s/regular expression/replacement/flags, like * subst but works on the message uri */

Source from the content-addressed store, hash-verified

511/* sed-perl style re: s/regular expression/replacement/flags, like
512 * subst but works on the message uri */
513static int subst_uri_f(struct sip_msg* msg, struct subst_expr *se)
514{
515 char* tmp;
516 int len;
517 char c;
518 str* result;
519
520 if (msg->new_uri.s){
521 len=msg->new_uri.len;
522 tmp=msg->new_uri.s;
523 }else{
524 tmp=msg->first_line.u.request.uri.s;
525 len =msg->first_line.u.request.uri.len;
526 };
527 /* ugly hack: 0 s[len], and restore it afterward
528 * (our re functions require 0 term strings), we can do this
529 * because we always alloc len+1 (new_uri) and for first_line, the
530 * message will always be > uri.len */
531 c=tmp[len];
532 tmp[len]=0;
533 result=subst_str(tmp, msg, se, 0); /* pkg malloc'ed result */
534 tmp[len]=c;
535 if (result){
536 LM_DBG("%s match - old uri= [%.*s], new uri= [%.*s]\n",
537 exports.name, len, tmp,
538 (result->len)?result->len:0,(result->s)?result->s:"");
539 if (msg->new_uri.s) pkg_free(msg->new_uri.s);
540 msg->new_uri=*result;
541 msg->parsed_uri_ok=0; /* reset "use cached parsed uri" flag */
542 pkg_free(result); /* free str* pointer */
543 return 1; /* success */
544 }
545 return -1; /* false, no subst. made */
546}
547
548
549

Callers

nothing calls this directly

Calls 1

subst_strFunction · 0.85

Tested by

no test coverage detected