Files
svc.ems/plat/public/ut/function.c
2024-09-27 15:39:34 +08:00

88 lines
1.6 KiB
C

/* public function c file */
/* written by Liu Zhiguo 2002-03-26 */
/* version 1.0 */
/* -------------------------------- */
#include "./include/includes.h"
#include "./include/public.h"
#include "./include/pub_debug.h"
# ifndef S_SPLINT_S
/*@ignore@*/
/* ++++++++++++++++++++++++++++++++++++++ */
/* transfer ascii code to bcd code */
/* ++++++++++++++++++++++++++++++++++++++ */
/*
void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len)
{
int i;
char ch;
char flag=0;
if (ascii_buf == NULL)
{
for (i=0;i<len/2;i++)
bcd_buf[i] = 0;
bcd_buf[len/2] = '\0';
return;
}
if (len & 1)
{
bcd_buf[0] = 0;
flag = 1;
}
for (i=0; i<len; i++)
{
ch = ascii_buf[i];
if (ch>='a')
ch -= 'a' - 10;
else if (ch>='A')
ch -= 'A' - 10;
else
ch -= '0';
if (flag)
{
if (i & 1)
*bcd_buf = ch << 4;
else
*(bcd_buf++) |= ch & 0x0f;
}
else
{
if (i & 1)
*(bcd_buf++) |= ch & 0x0f;
else
*bcd_buf = ch << 4;
}
}
}
*/
/* ++++++++++++++++++++++++++++++++++++++ */
/* transfer bcd code to ascii code */
/* ++++++++++++++++++++++++++++++++++++++ */
/*
void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len)
{
int i;
char ch;
if (bcd_buf == NULL)
{
for (i=0;i<len;i++)
ascii_buf[i] = '0';
ascii_buf[len] = '\0';
return;
}
for (i=0; i<len; i++)
{
if (i & 1) ch = *(bcd_buf++) & 0x0f;
else ch = *bcd_buf >> 4;
ascii_buf[i] = ch + ((ch > 9)? 'A'-10 : '0');
}
ascii_buf[i] = '\0';
}
*/
/*@end@*/
#endif