rem: if ( ((!msg->to&&parse_headers(msg,HDR_TO,0)==-1) || !msg->to ) ||
add: if ( (!msg->to&&((parse_headers(msg,HDR_TO,0)==-1) || !msg->to)) ||
context: int push_on_network(struct sip_msg *msg, int net){	str    body;	struct sip_uri  uri;	struct sms_msg  *sms_messg;	struct to_body  *from;	char   *p;	int    len;	int    mime;	/* get the message's body	 * anyhow we have to call this function, so let's do it at the beginning	 * to force the parsing of all the headers - like this we avoid separat	 * calls of parse_headers function for FROM, CONTENT_LENGTH, TO hdrs  */	body.s = get_body( msg );	if (body.s==0) {		LOG(L_ERR,"ERROR:sms_push_on_net: cannot extract body from msg!\n");		goto error;	}	/* content-length (if present) must be already parsed */	if (!msg->content_length) {		LOG(L_ERR,"ERROR:sms_push_on_net: no Content-Length header found!\n");		goto error;	}	body.len = get_content_length( msg );	/* parse the content-type header */	if ( (mime=parse_content_type_hdr(msg))<1 ) {		LOG(L_ERR,"ERROR:sms_push_on_net:cannot parse Content-Type header\n");		goto error;	}	/* check the content-type value */	if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN	&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {		LOG(L_ERR,"ERROR:sms_push_on_net: invalid content-type for a "			"message request! type found=%d\n",mime);		goto error;	}	/* we try to get the user name (phone number) first from the RURI 	   (in our case means from new_uri or from first_line.u.request.uri);	   if it's missing there (like in requests generated by MSN MESSENGER),	   we go for "to" header	*/	DBG("DEBUG:sms_push_on_net: tring to get user from new_uri\n");	if ( !msg->new_uri.s||parse_uri( msg->new_uri.s,msg->new_uri.len,&uri)	|| !uri.user.len )	{		DBG("DEBUG:sms_push_on_net: tring to get user from R_uri\n");		if ( parse_uri( msg->first_line.u.request.uri.s,		msg->first_line.u.request.uri.len ,&uri)||!uri.user.len )		{			DBG("DEBUG:sms_push_on_net: tring to get user from To\n");			if ( ((!msg->to&&parse_headers(msg,HDR_TO,0)==-1) || !msg->to ) ||			parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1			|| !uri.user.len)			{				LOG(L_ERR,"ERROR:sms_push_on_net: unable to extract user"					" name from RURI and To header!\n");				goto error;			}		}	}	/* check the uri.user format = '+(inter code)(number)' */	if (uri.user.len<2 || uri.user.s[0]!='+' || uri.user.s[1]<'1'	|| uri.user.s[1]>'9') {		LOG(L_ERR,"ERROR:sms_push_on_net: user tel number [%.*s] does not"			"respect international format\n",uri.user.len,uri.user.s);		goto error;	}	/* parsing from header */	if ( parse_from_header( msg )==-1 ) {		LOG(L_ERR,"ERROR:sms_push_on_net: cannot get FROM header\n");		goto error;	}	from = (struct to_body*)msg->from->parsed;#if 0	/* adds contact header into reply */	if (add_contact(msg,&(uri.user))==-1) {		LOG(L_ERR,"ERROR:sms_push_on_net:can't build contact for reply\n");		goto error;	}#endif	/*-------------BUILD AND FILL THE SMS_MSG STRUCTURE --------------------*/	/* computes the amount of memory needed */	len = SMS_HDR_BF_ADDR_LEN + from->uri.len		+ SMS_HDR_AF_ADDR_LEN + body.len + SMS_FOOTER_LEN /*text to send*/		+ from->uri.len /* from */		+ uri.user.len-1 /* to user (wihout '+') */		+ sizeof(struct sms_msg) ; /* the sms_msg structure */	/* allocs a new sms_msg structure in shared memory */	sms_messg = (struct sms_msg*)shm_malloc(len);	if (!sms_messg) {		LOG(L_ERR,"ERROR:sms_push_on_net: cannot get shm memory!\n");		goto error;	}	p = (char*)sms_messg + sizeof(struct sms_msg);	/* copy "from" into sms struct */	sms_messg->from.len = from->uri.len;	sms_messg->from.s = p;	append_str(p,from->uri.s,from->uri.len);	/* copy "to.user" - we have to strip out the '+' */	sms_messg->to.len = uri.user.len-1;	sms_messg->to.s = p;	append_str(p,uri.user.s+1,sms_messg->to.len);	/* copy (and compossing) sms body */	sms_messg->text.len = SMS_HDR_BF_ADDR_LEN + sms_messg->from.len		+ SMS_HDR_AF_ADDR_LEN + body.len+SMS_FOOTER_LEN;	sms_messg->text.s = p;	append_str(p, SMS_HDR_BF_ADDR, SMS_HDR_BF_ADDR_LEN);	append_str(p, sms_messg->from.s, sms_messg->from.len);	append_str(p, SMS_HDR_AF_ADDR, SMS_HDR_AF_ADDR_LEN);	append_str(p, body.s, body.len);	append_str(p, SMS_FOOTER, SMS_FOOTER_LEN);	if (*queued_msgs>MAX_QUEUED_MESSAGES)		goto error;	(*queued_msgs)++;	if (write(net_pipes_in[net], &sms_messg, sizeof(sms_messg))!=	sizeof(sms_messg) )	{		LOG(L_ERR,"ERROR:sms_push_on_net: error when writting for net %d "			"to pipe [%d] : %s\n",net,net_pipes_in[net],strerror(errno) );		shm_free(sms_messg);		(*queued_msgs)--;		goto error;	}	return 1; error:	return -1;}