#include "version.h"
#include "PalmType.h"
#include "p_util.h"
#include "p_tcpip.h"

#if defined CALL_SIP || defined CALL_MGCP

 /*
 UCHAR p_toupper(UCHAR iChar)
{
	if (iChar >= 'a' && iChar <= 'z')
		return (UCHAR)(iChar - 0x20);
	else
		return iChar;
}


 BOOLEAN p_memcmp_nocase_c2x(PXCHAR pDst, PCCHAR pSrc, UCHAR iLen)
{
	DCHAR i;
	
	for (i = 0; i < iLen; i ++)
	{
		if (p_toupper(pDst[i]) != p_toupper(pSrc[i]))
			return FALSE;
	}
	return TRUE;
}

 BOOLEAN p_memcmp_nocase_x2x(PXCHAR pDst, PXCHAR pSrc, UCHAR iLen)
{
	DCHAR i;
	
	for (i = 0; i < iLen; i ++)
	{
		if (p_toupper(pDst[i]) != p_toupper(pSrc[i]))
			return FALSE;
	}
	return TRUE;
}


 BOOLEAN p_strcmp_nocase_c2x(PXCHAR pDst, PCCHAR pSrc)
{
	DCHAR iDstLen, iSrcLen;

	iDstLen = p_strlen_x(pDst);
	iSrcLen = p_strlen_c(pSrc);
	if (iSrcLen == iDstLen)
	{
		return p_memcmp_nocase_c2x(pDst, pSrc, iSrcLen);
	}
	return FALSE;
}


 BOOLEAN p_strcmp_nocase_x2x(PXCHAR pDst, PXCHAR pSrc)
{
	DCHAR iDstLen, iSrcLen;

	iDstLen = p_strlen_x(pDst);
	iSrcLen = p_strlen_x(pSrc);
	if (iSrcLen == iDstLen)
	{
		return p_memcmp_nocase_x2x(pDst, pSrc, iSrcLen);
	}
	return FALSE;
}

  #define p_tolower(x)		((x) >= 'A' && (x) <= 'Z') ? ((x) + 0x20) : (x);

 void string_to_lower(PXCHAR pStr)
{
	PXCHAR_D pCur;
	DCHAR iVal;

	pCur = pStr;
	do
	{
		iVal = *pCur;
		*pCur ++ = p_tolower(iVal);
	} while (iVal);
}

 BOOLEAN strcmp_lower_c2x(PXCHAR pXStr, PCCHAR pCStr)
{
	DCHAR i, iVal;
	PXCHAR_D pDst;
	PCCHAR_D pSrc;
	XCHAR pBuf[MAX_CASE_COMPARE_SIZE+1];

	pDst = pBuf;
	pSrc = pCStr;

	for (i = 0; i < MAX_CASE_COMPARE_SIZE; i ++)
	{
		iVal = *pSrc ++;
		*pDst ++ = p_tolower(iVal);
		if (!iVal)	break;
	}
	return (p_strcmp_x2x(pXStr, pBuf)) ? FALSE : TRUE;
}

*/
UCHAR p_count_space(PXCHAR pString)
{
	DCHAR iLen;
	PXCHAR_D pLine;

	pLine = pString;
	iLen = 0;
	while (pLine[iLen] == ' ' || pLine[iLen] == '\t')
	{
		iLen ++;
	}
	return iLen;
}

UCHAR p_count_char(PXCHAR pString, UCHAR iChar)
{
	DCHAR iLen;
	PXCHAR_D pLine;

	pLine = pString;
	iLen = 0;
	while (pLine[iLen] == ' ' || pLine[iLen] == '\t' || pLine[iLen] == iChar)
	{
		iLen ++;
	}
	return iLen;
}

#endif
