📄 atbcommon.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name:
$Project code:
$Module:
$File: ATBCommon.c
$Revision:
$Author: SH - Condat(UK)
$Date:
********************************************************************************
Description: ATB Common functions and definitions.
********************************************************************************
$History: ATBCommon.c
$End
*******************************************************************************/
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_tim.h"
#include "mfw_phb.h"
#include "mfw_sms.h"
#include "mfw_ss.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_lng.h"
#include "mfw_sat.h"
#include "mfw_kbd.h"
#include "mfw_nm.h"
#include "mfw_cm.h"
#include "ATBCommon.h"
/*******************************************************************************
$Function: ATB_mem_Alloc
$Description: ATB memory allocation function.
$Returns: Address if successful, null if not.
$Arguments: Size of memory to be allocated.
*******************************************************************************/
UBYTE* ATB_mem_Alloc(USHORT size)
{
return (UBYTE *)mfwAlloc(size);
}
/*******************************************************************************
$Function: ATB_mem_Free
$Description: Frees memory allocated by the ATB
$Returns: None.
$Arguments: address - Pointer to memory to free
size - Size of the allocated block
*******************************************************************************/
void ATB_mem_Free(UBYTE* address, USHORT size)
{
mfwFree(address,size);
return;
}
/*******************************************************************************
$Function: ATB_char_Ascii
$Description: Returns the ascii of the provided unicode character
$Returns: An ascii character
$Arguments: character - The unicode character
*******************************************************************************/
char ATB_char_Ascii(USHORT character)
{
return (char)((character & UNICODE_ASCII)>>8);
}
/*******************************************************************************
$Function: ATB_char_Unicode
$Description: Returns the unicode of the provided ascii character
$Returns: A unicode character
$Arguments: character - The ascii character
*******************************************************************************/
USHORT ATB_char_Unicode(char character)
{
return (USHORT)(character<<8);
}
/*******************************************************************************
$Function: ATB_char_IsAscii
$Description: Returns TRUE if the unicode character provided is ascii
$Returns: TRUE or FALSE
$Arguments: character - The unicode character
*******************************************************************************/
BOOL ATB_char_IsAscii(USHORT character)
{
BOOL result = FALSE;
if (character & UNICODE_NONASCII) // Make sure character is ASCII
{
result = FALSE;
}
else
{
result = TRUE;
}
return result;
}
/*******************************************************************************
$Function: ATB_char_IsAlphabetic
$Description: Return TRUE if unicode character is part of latin alphabet
$Returns: TRUE or FALSE
$Arguments: character - The unicode character
*******************************************************************************/
BOOL ATB_char_IsAlphabetic(USHORT character)
{
BOOL result = FALSE;
UBYTE asciiChar;
if (ATB_char_IsAscii(character)) // Make sure character is ASCII
{
asciiChar = ATB_char_Ascii(character);
if ( (asciiChar >='A') && (asciiChar <='Z') )
result = TRUE;
else if ( (asciiChar >='a') && (asciiChar <='z') )
result = TRUE;
}
return result;
}
/*******************************************************************************
$Function: ATB_char_IsNumierc
$Description: Return TRUE if unicode character is a digit, 0-9
$Returns: TRUE or FALSE
$Arguments: character - The unicode character
*******************************************************************************/
BOOL ATB_char_IsNumeric(USHORT character)
{
BOOL result = FALSE;
UBYTE asciiChar;
if (ATB_char_IsAscii(character)) // Make sure character is ASCII
{
asciiChar = ATB_char_Ascii(character);
if ( (asciiChar >='0') && (asciiChar <='9') )
result = TRUE;
}
return result;
}
/*******************************************************************************
$Function: ATB_char_IsVisible
$Description: Return TRUE if unicode character is visible, i.e. not ascii <32
$Returns: TRUE or FALSE
$Arguments: character - The unicode character
*******************************************************************************/
BOOL ATB_char_IsVisible(USHORT character)
{
BOOL result = TRUE;
UBYTE asciiChar;
if (ATB_char_IsAscii(character)) // Make sure character is ASCII
{
asciiChar = ATB_char_Ascii(character);
if (asciiChar < ' ')
result = FALSE;
}
return result;
}
/*******************************************************************************
$Function: ATB_string_Size
$Description: Return the size in bytes of a character in the string
$Returns: No. of bytes per character
$Arguments: text - The text string
*******************************************************************************/
UBYTE ATB_string_Size(T_ATB_TEXT *text)
{
UBYTE size;
switch(text->dcs)
{
case ATB_DCS_UNICODE:
size = 2;
break;
default:
size = 1;
break;
}
return size;
}
/*******************************************************************************
$Function: ATB_string_SetChar
$Description: Set a character in the string to a value. Use this function rather than
accessing text data directly; it allows transparent ASCII and Unicode
handling.
$Returns: None
$Arguments: text - The text string
textIndex - The position of the character to set
character - The unicode character to set it to
*******************************************************************************/
void ATB_string_SetChar(T_ATB_TEXT *text, USHORT textIndex, USHORT character)
{
USHORT *unicode;
if (text->dcs==ATB_DCS_UNICODE)
{
unicode = (USHORT *)text->data;
unicode[textIndex] = character;
}
else
text->data[textIndex] = ATB_char_Ascii(character);
return;
}
/*******************************************************************************
$Function: ATB_string_GetChar
$Description: Gets the value of a character in the string. Use this function rather than
accessing text data directly; it allows transparent ASCII and Unicode
handling.
$Returns: The unicode character at the required position
$Arguments: text - The text string
textIndex - The position of the character to get
*******************************************************************************/
USHORT ATB_string_GetChar(T_ATB_TEXT *text, USHORT textIndex)
{
USHORT *unicode;
USHORT character;
if (text->dcs==ATB_DCS_UNICODE)
{
unicode = (USHORT *)text->data;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -