rem: memcpy(at, gw_uri_val.s->s, at_char - gw_uri_val.s->s); at = at + (at_char - gw_uri_val.s->s); memcpy(at, _m->parsed_uri.user.s, _m->parsed_uri.user.len); at = at + _m->parsed_uri.user.len;
add: memcpy(at, gw_uri_val.s->s, strip_char - gw_uri_val.s->s); sscanf(strip_char+1,"%d",&strip); at = at + (strip_char - gw_uri_val.s->s); memcpy(at, _m->parsed_uri.user.s+strip, _m->parsed_uri.user.len-strip); at = at + _m->parsed_uri.user.len-strip;
context: int next_gw(struct sip_msg* _m, char* _s1, char* _s2){    int_str gw_uri_val, ruri_user_val, val;    struct action act;    int rval;    struct usr_avp *gw_uri_avp, *ruri_user_avp;    str new_ruri;    char *at, *at_char;    gw_uri_avp = search_first_avp(gw_uri_avp_name_str,				  gw_uri_name, &gw_uri_val);    if (!gw_uri_avp) return -1;    if (route_type == REQUEST_ROUTE) {	/* Create new Request-URI taking URI user from current Request-URI	   and other parts of from gw_uri AVP. */	if (parse_sip_msg_uri(_m) < 0) {	    LOG(L_ERR, "next_gw(): Parsing of R-URI failed.\n");	    return -1;	}	new_ruri.len = gw_uri_val.s->len + _m->parsed_uri.user.len + 1;	new_ruri.s = pkg_malloc(new_ruri.len);	if (!new_ruri.s) {	    LOG(L_ERR, "next_gw(): No memory for new R-URI.\n");	    return -1;	}	at_char = memchr(gw_uri_val.s->s, '@', gw_uri_val.s->len);	if (!at_char) {	    pkg_free(new_ruri.s);	    LOG(L_ERR, "next_gw(): No @ in gateway URI.\n");	    return -1;	}	at = new_ruri.s;	memcpy(at, gw_uri_val.s->s, at_char - gw_uri_val.s->s);	at = at + (at_char - gw_uri_val.s->s);	memcpy(at, _m->parsed_uri.user.s, _m->parsed_uri.user.len);	at = at + _m->parsed_uri.user.len;	memcpy(at, at_char, gw_uri_val.s->len - (at_char - gw_uri_val.s->s));	at = at + gw_uri_val.s->len - (at_char - gw_uri_val.s->s);	*at = '\0';	/* Save Request-URI user for use in FAILURE_ROUTE */	val.s = &(_m->parsed_uri.user);	add_avp(ruri_user_avp_name_str|AVP_VAL_STR, ruri_user_name, val);	DBG("load_gws(): DEBUG: Added ruri_user_avp <%.*s>\n",	    val.s->len, val.s->s);	/* Rewrite Request URI */	act.type = SET_URI_T;	act.p1_type = STRING_ST;	act.p1.string = new_ruri.s;	rval = do_action(&act, _m);	pkg_free(new_ruri.s);	destroy_avp(gw_uri_avp);	if (rval != 1) {	    LOG(L_ERR, "next_gw(): ERROR: do_action failed with return "		"value <%d>\n", rval);	    return -1;	}	return 1;    } else if (route_type == FAILURE_ROUTE) {	/* Create new Request-URI taking URI user from ruri_user AVP	   and other parts of from gateway URI AVP. */	ruri_user_avp = search_first_avp(ruri_user_avp_name_str,					 ruri_user_name, &ruri_user_val);	if (!ruri_user_avp) {	    LOG(L_ERR, "next_gw(): No ruri_user AVP\n");	    return -1;	}	new_ruri.len = gw_uri_val.s->len + ruri_user_val.s->len + 1;	new_ruri.s = pkg_malloc(new_ruri.len);	if (!new_ruri.s) {	    LOG(L_ERR, "next_gw(): No memory for new R-URI.\n");	    return -1;	}	at_char = memchr(gw_uri_val.s->s, '@', gw_uri_val.s->len);	if (!at_char) {	    pkg_free(new_ruri.s);	    LOG(L_ERR, "next_gw(): No @ in gateway URI.\n");	    return -1;	}	at = new_ruri.s;	memcpy(at, gw_uri_val.s->s, at_char - gw_uri_val.s->s);	at = at + (at_char - gw_uri_val.s->s);	memcpy(at, ruri_user_val.s->s, ruri_user_val.s->len);	at = at + ruri_user_val.s->len;	memcpy(at, at_char, gw_uri_val.s->len - (at_char - gw_uri_val.s->s));	at = at + gw_uri_val.s->len - (at_char - gw_uri_val.s->s);	*at = '\0';	act.type = APPEND_BRANCH_T;	act.p1_type = STRING_ST;	act.p1.string = new_ruri.s;	act.p2_type = NUMBER_ST;	act.p2.number = 0;	rval = do_action(&act, _m);	pkg_free(new_ruri.s);	destroy_avp(gw_uri_avp);	if (rval != 1) {	    LOG(L_ERR, "next_gw(): ERROR: do_action failed with return "		"value <%d>\n", rval);	    return -1;	}	return 1;    }    /* unsupported route type */    return -1;}