/*
**
*/

#include "../include/includes.h"

u_char *
ByteRev(u_char *ptr, size_t size,int flag)
{
	int len = size;
    /*
    if(flag)
    { //internation msisdn,as: 8675557127049
	  *ptr++; 
	  len --;
    }
*/
	while (len--) {
		*ptr = (*ptr >> 4) | (*ptr << 4); 
		ptr ++;
	}
	return ptr;
}

void
Strrev(char *sp)
{
	char     ch;
	ch = sp[0];
	sp[0] = sp[1];
	sp[1] = ch;
}

void
ByteReverse(BYTE *pbuf, BYTE *p, size_t size)
{
	
	int         i;
	char        *sp=NULL, tmpbuf[3];
	
	sp = (char *) malloc(4*size + 1);
	bzero(p, size);
	
	for (i=0; i<2*size; i+=2) {
		sprintf(tmpbuf, "%02x", *(pbuf++));
		tmpbuf[2]=0;
		Strrev(tmpbuf);
		strncpy(sp+i, tmpbuf, 2);	
	}
	AsciiToBcd(pbuf, sp, 4*size);
	memcpy(p, pbuf, 2*size);
	free(sp);
}
