rem: DBG(" copied size: orig:%d, new: %d, rest: %d\n", s_offset, offset, len-s_offset );
add: DBG("build_res_from_sip_res: copied size: orig:%d, new: %d, rest: %d" " msg=\n%s\n", s_offset, offset, len-s_offset, new_buf);
context: char * build_res_buf_from_sip_res( struct sip_msg* msg,				unsigned int *returned_len){	unsigned int new_len, via_len;	char* new_buf;	unsigned offset, s_offset, via_offset;#ifdef SCRATCH	char* orig;#endif	char* buf;	unsigned int len;#ifdef SCRATCH	orig=msg->orig;#endif	buf=msg->buf;	len=msg->len;	new_buf=0;	/* we must remove the first via */#ifdef PRESERVE_ZT	via_len=msg->via1->bsize;	via_offset=msg->via1->hdr.s-buf;	DBG("via len: %d, initial via offset: %d\n", via_len, via_offset);	if (msg->via1->next){		/* add hdr size*/		via_offset+=msg->via1->hdr.len+1;	    DBG(" adjusted via len: %d, initial offset: %d\n",				via_len, via_offset);	}else{		/* add hdr size ("Via:")*/		via_len+=msg->via1->hdr.len+1;	}#else	if (msg->via1->next) {		via_len=msg->via1->bsize;		via_offset=msg->h_via1->body.s-buf;	} else {		via_len=msg->h_via1->len;		via_offset=msg->h_via1->name.s-buf;	}#endif	/* remove the first via*/	if (del_lump( &(msg->repl_add_rm), via_offset, via_len, HDR_VIA)==0){		LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first"					"via\n");		goto error;	}	new_len=len+lumps_len(msg->repl_add_rm);	DBG(" old size: %d, new size: %d\n", len, new_len);	new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging 											 (\0 to print it )*/	if (new_buf==0){		LOG(L_ERR, "ERROR: build_res_buf_from_sip_res: out of mem\n");		goto error;	}	new_buf[new_len]=0; /* debug: print the message */	offset=s_offset=0;	process_lumps(msg->repl_add_rm, new_buf, &offset, #ifdef SCRATCH		orig, #else		buf,#endif		&s_offset);	/* copy the rest of the message */	memcpy(new_buf+offset,#ifdef SCRATCH		orig+s_offset, #else		buf+s_offset, #endif		len-s_offset);	 /* send it! */	DBG(" copied size: orig:%d, new: %d, rest: %d\n",			s_offset, offset,			len-s_offset );	*returned_len=new_len;	return new_buf;error:	*returned_len=0;	return 0;}