rem: DBG("---%d--<%d><%d>--\n|%.*s|\n",i,len_array[i],buf_len,buf_len,buf);
add: DBG("---%d--<%d><%d>--\n|%.*s|\n", i, len_array[i], buf_len, (int)buf_len, buf);
context: int send_as_sms(struct sms_msg *sms_messg, struct modem *mdm){	static char   buf[MAX_SMS_LENGTH];	unsigned int  buf_len;	unsigned char len_array_1[256], len_array_2[256], *len_array;	unsigned int  nr_chunks_1,  nr_chunks_2, nr_chunks;	unsigned int  use_nice;	str  text;	char *p, *q;	int  ret_code;	int  i;	text.s   = sms_messg->text.s;	text.len = sms_messg->text.len;	nr_chunks_1 = split_text( &text, len_array_1, 0);	nr_chunks_2 = split_text( &text, len_array_2, 1);	if (nr_chunks_1==nr_chunks_2) {		len_array = len_array_2;		nr_chunks = nr_chunks_2;		use_nice = 1;	} else {		len_array = len_array_1;		nr_chunks = nr_chunks_1;		use_nice = 0;	}	sms_messg->ref = 1;	for(i=0,p=text.s ; i<nr_chunks&&i<max_sms_parts ; p+=len_array[i++]) {		if (use_nice) {			q = buf;			if (nr_chunks>1 && i)  {				append_str(q,SMS_EDGE_PART,SMS_EDGE_PART_LEN);				*(q-2)=nr_chunks+'0';				*(q-4)=i+1+'0';			}			append_str(q,p,len_array[i]);			if (nr_chunks>1 && !i)  {				append_str(q,SMS_EDGE_PART,SMS_EDGE_PART_LEN);				*(q-2)=nr_chunks+'0';				*(q-4)=i+1+'0';			}			buf_len = q-buf;		} else {			q = buf;			append_str(q,p,len_array[i]);			buf_len = len_array[i];		}		if (i+1==max_sms_parts && i+1<nr_chunks) {			/* simply override the end of the last allowed part */			buf_len += SMS_TRUNCATED_LEN+SMS_FOOTER_LEN;			if (buf_len>MAX_SMS_LENGTH) buf_len = MAX_SMS_LENGTH;			q = buf + (buf_len-SMS_TRUNCATED_LEN-SMS_FOOTER_LEN);			append_str(q,SMS_TRUNCATED,SMS_TRUNCATED_LEN);			append_str(q,SMS_FOOTER,SMS_FOOTER_LEN);			p += buf_len-SMS_TRUNCATED_LEN-SMS_FOOTER_LEN-SMS_EDGE_PART_LEN;			send_error(sms_messg, ERR_TRUNCATE_TEXT, ERR_TRUNCATE_TEXT_LEN,				p, text.len-(p-text.s)-SMS_FOOTER_LEN);		}		DBG("---%d--<%d><%d>--\n|%.*s|\n",i,len_array[i],buf_len,buf_len,buf);		sms_messg->text.s   = buf;		sms_messg->text.len = buf_len;		if ( (ret_code=putsms(sms_messg,mdm))<0)			goto error;		if (use_sms_report)			add_sms_into_report_queue(ret_code,sms_messg,				p-use_nice*(nr_chunks>1)*SMS_EDGE_PART_LEN,len_array[i]);	}	sms_messg->ref--;	/* put back the pointer to the beginning of the messsage*/	sms_messg->text.s = text.s;	sms_messg->text.len = text.len;	/* remove the sms if nobody points to it */	if (!sms_messg->ref){		shm_free(sms_messg);	}	return 1;error:	if (!(--(sms_messg->ref)))		shm_free(sms_messg);	if (ret_code==-1)		/* bad number */		send_error(sms_messg, sms_messg->to.s, sms_messg->to.len,			ERR_NUMBER_TEXT, ERR_NUMBER_TEXT_LEN);	else if (ret_code==-2)		/* bad modem */		send_error(sms_messg, ERR_MODEM_TEXT, ERR_MODEM_TEXT_LEN,			text.s+SMS_HDR_BF_ADDR_LEN+sms_messg->from.len+SMS_HDR_AF_ADDR_LEN,			text.len-SMS_FOOTER_LEN-SMS_HDR_BF_ADDR_LEN-sms_messg->from.len-			SMS_HDR_AF_ADDR_LEN );	return -1;}