⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmisimtoolkit.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 5 页
字号:

 $Description:   set the window associated with the call setup command

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void sat_set_call_setup_win(T_MFW_HND win)
{
  TRACE_FUNCTION("sat_set_call_setup_win");
    g_sim_toolkit_data->sat_call_setup_win = win;
}


/*******************************************************************************

 $Function:  sat_get_call_setup_win

 $Description:    get the window associated with the call setup command

 $Returns:    none.

 $Arguments:

*******************************************************************************/
/* Marcus: Issue 1057: 21/01/2003: Made public */
T_MFW_HND sat_get_call_setup_win(void)
{
  TRACE_FUNCTION("sat_get_call_setup_win");
    return g_sim_toolkit_data->sat_call_setup_win;
}

/*******************************************************************************

 $Function:  g_ascii_gsm_table

 $Description:  convert a string coded in ASCIIZ into GSM alphabet

 $Returns:    none.

 $Arguments:

*******************************************************************************/
    static const char g_ascii_gsm_table[256] = {
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //000-007
       0x20,0x20,  10,0x20,0x20,  13,0x20,0x20, //008-015
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //016-023
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //024-031
         32,  33,  34,  35,   2,  37,  38,  39, //032-039
         40,  41,  42,  43,  44,  45,  46,  47, //040-047
         48,  49,  50,  51,  52,  53,  54,  55, //048-055
         56,  57,  58,  59,  60,  61,  62,  63, //056-063
          0,  65,  66,  67,  68,  69,  70,  71, //064-071
         72,  73,  74,  75,  76,  77,  78,  79, //072-079
         80,  81,  82,  83,  84,  85,  86,  87, //080-087
         88,  89,  90,0x20,0x20,0x20,0x20,0x20, //088-095
       0x20,  97,  98,  99, 100, 101, 102, 103, //096-103
        104, 105, 106, 107, 108, 109, 110, 111, //104-111
        112, 113, 114, 115, 116, 117, 118, 119, //112-119
        120, 121, 122,0x20,0x20,0x20,0x20,0x20, //120-127
          9, 126,   5,0x20, 123, 127,  15,0x20, //128-135
       0x20,0x20,   4,0x20,0x20,   7,  91,  14, //136-143
         31,  29,  28,0x20, 124,   8,0x20,   6, //144-151
       0x20,  92,  94,0x20,   1,   3,0x20,0x20, //152-159
       0x20,0x20,0x20,0x20, 125,  93,0x20,0x20, //160-167
         96,  17,0x20,0x20,0x20,  64,0x20,0x20, //168-175
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //176-183
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //184-191
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //192-199
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //200-207
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //208-215
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //216-223
       0x20,  30,  19,  22,  24,0x20,0x20,0x20, //224-231
         18,  25,  21,0x20,0x20,0x20,0x20,  20, //232-239
         26,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //240-247
       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, //248-255
    };

void sat_ascii_to_gsm (char * gsm_string, char * ascii_string, U16 length)
{
    U16 i;
  TRACE_FUNCTION("sat_ascii_to_gsm");

    for (i = 0; i < length; i++)
        gsm_string[i] = g_ascii_gsm_table[ascii_string[i]];
}

/*******************************************************************************

 $Function:  sat_ascii_to_ucode

 $Description:  convert a string coded in ASCIIZ into UCS2 alphabet

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void sat_ascii_to_ucode (wchar_t * UCS2_chars, char * ascii_string, U16 length)
{
    U16 i;
  TRACE_FUNCTION("sat_ascii_to_ucode");
    for (i = 0; i < length; i++)
        UCS2_chars[i] = (wchar_t)ascii_string[i];
}

/*******************************************************************************

 $Function:  sat_ucode_to_ascii

 $Description:   convert a string coded in UCS2 into ASCII alphabet

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void sat_ucode_to_ascii (char * ascii_string, wchar_t * UCS2_chars, U16 length)
{
    U16 i;
  TRACE_FUNCTION("sat_ucode_to_asci");

    for (i = 0; i < length; i++)
        ascii_string[i] = (char)UCS2_chars[i];
    ascii_string[i] = '\0';
}
/*******************************************************************************

 $Function:  g_gsm_ascii_table

 $Description:    convert a string coded in GSM alphabet into an ASCIIZ string

 $Returns:    none.

 $Arguments:

*******************************************************************************/

    static const char g_gsm_ascii_table[128] = {
         64, 156,  36, 157, 138, 130, 151, 141,
        149, 128,  10,0x20 , 32,  13, 143, 134,
       0x20, 169, 232, 226, 239, 234, 227,0x20,
        228, 233, 240,0x20, 146, 145, 225, 144,
         32,  33,  34,  35,0x20,  37,  38,  39,
         40,  41,  42,  43,  44,  45,  46,  47,
         48,  49,  50,  51,  52,  53,  54,  55,
         56,  57,  58,  59,  60,  61,  62,  63,
        173,  65,  66,  67,  68,  69,  70,  71,
         72,  73,  74,  75,  76,  77,  78,  79,
         80,  81,  82,  83,  84,  85,  86,  87,
         88,  89,  90, 142, 153, 165, 154,0x20,
        168,  97,  98,  99, 100, 101, 102, 103,
        104, 105, 106, 107, 108, 109, 110, 111,
        112, 113, 114, 115, 116, 117, 118, 119,
        120, 121, 122, 132, 148, 164, 129, 133
    };

void sat_gsm_to_ascii (char * ascii_string, char * gsm_string, U16 length)
{
    U16 i;
  TRACE_FUNCTION("sat_gsm_to_ascii");
    for (i = 0; i < length; i++)
        ascii_string[i] = g_gsm_ascii_table[(gsm_string[i] & (U8)0x7F)];
    ascii_string[i] = '\0';
}


/*******************************************************************************

 $Function:  sat_TEXT_to_ASCIIZ

 $Description:   This routine converts a MFW SAT text descriptor into a
         conventional ASCIIZ string
 $Returns:    none.

 $Arguments:

*******************************************************************************/
void sat_TEXT_to_ASCIIZ (char * destination, T_SAT_TXT * txt)
{
    UBYTE * temp_buffer;
    UBYTE len;
    char* txt_start;

    TRACE_FUNCTION("sat_TEXT_to_ASCIIZ");

    TRACE_EVENT_P1("T_SAT_TXT txt->code=%x", txt->code);

    switch (txt->code)
    {
    case MFW_DCS_7bits:
  temp_buffer = (UBYTE *)ALLOC_MEMORY(((txt->len*8)/7)+1);
  len = utl_cvt7To8 ((UBYTE *)txt + txt->text, txt->len, temp_buffer);
  sat_gsm_to_ascii (destination, (char *)temp_buffer, len);
  FREE_MEMORY ((U8 *)temp_buffer, ((txt->len*8)/7)+1);
  break;
    case MFW_DCS_8bits:
     /* SPR#1700 - DS - Modified to handle 0x80 style unicode */
    txt_start = (char*)txt + txt->text;
    if ((*txt_start == 0x80) && (txt->len & 1))
    {
    	TRACE_EVENT("0x80 style unicode");
        memset(destination,0,txt->len+2);
        memcpy(destination,txt_start+1,txt->len-1);
        txt->code = MFW_DCS_UCS2;
    }
    else
    {
        sat_gsm_to_ascii (destination, (char *)txt + txt->text, (UBYTE)txt->len);
    }
  break;
    case MFW_DCS_UCS2:
        sat_ucode_to_ascii (destination, (wchar_t *)((char *)txt + txt->text), txt->len);
  break;
    default:
      sat_gsm_to_ascii (destination, (char *)txt + txt->text, (UBYTE)txt->len); /* SH - got txt->code=244, so need generic response to this*/
    TRACE_EVENT("sat_TEXT_to_ASCIIZ() unexp. DCS");
    }
}



/*******************************************************************************

 $Function:  sat_create_TEXT_ASCIIZ

 $Description:   This routine creates out of an MFW SAT text descriptor an
        dynamically allocated ASCIIZ string pointer

 $Returns:    none.

 $Arguments:

				MC, Note: text returned by this function has no Unicode tag at beginning
 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
/*MC, SPR 940/2 uncommented function back in, and then rewrote it :)*/
void sat_TEXT_to_UCODE (char*  destination, int size, T_SAT_TXT * txt)
{
	
    UBYTE * temp_buffer;
    UBYTE len;
    char debug[50];


	TRACE_EVENT("sat_TEXT_to_UCODE()");

    switch (txt->code) /*DCS of Text*/
    {
    case MFW_DCS_7bits:
	temp_buffer = (UBYTE *)ALLOC_MEMORY(((txt->len*8)/7)+1); 
			/*convert from 7 to 8 bit*/
	len = utl_cvt7To8 ((UBYTE *)txt + txt->text, txt->len, temp_buffer, 0);
       
        /*MC, convert from 8 bit to UCS2*/
        SmsRead_convertSMSmsg((char*)temp_buffer, MFW_DCS_8bits, (((txt->len*8)/7)+1), (char*)destination, MFW_DCS_UCS2, /*txt->len*2*/size, FALSE);
	FREE_MEMORY ((U8 *)temp_buffer, ((txt->len*8)/7)+1);
	break;
    case MFW_DCS_8bits:/*DCS tends to come out as 8 bit whatever it is*/ 
    if (*((UBYTE*)txt+txt->text) !=0x80)/*MC, if ASCII, convert to Unicode*/
    {	
#ifdef SAT_TEXT_TRACING
    	//string_GSM_to_UCS2((UBYTE)txt->len, (UBYTE *)txt + txt->text, (USHORT)(txt->len), destination);
    	sprintf(debug, "Length of MENU HEADER:%d", txt->len);
    	TRACE_EVENT(debug);
#endif
		/*MC, convert from 8 bit to UCS2*/
        SmsRead_convertSMSmsg((char *)txt +txt->text, MFW_DCS_8bits, txt->len, (char*)destination, MFW_DCS_UCS2, /*txt->len*2*/size, FALSE);
    }
    else 
    {	
		/*MC, unicode string, convert to our display format*/
    	destination[0] =0x80;/*SPR 1728, add unicode tag*/
    	destination[1] = 0x7f;

    	memcpy(&destination[2], (UBYTE*)txt+txt->text+1, txt->len-1);

    }
	break;
    case MFW_DCS_UCS2:/*MC, unicode string, convert to our display format*/
	{	destination[0] =0x80;/*SPR 1728, add unicode tag*/
    	destination[1] = 0x7f;

    	memcpy(&destination[2], (UBYTE*)txt+txt->text+1, txt->len-1);

    }//memcpy(destination, (char *)txt + txt->text+1, txt->len-1);

	break;
    default:
	TRACE_EVENT("sat_TEXT_to_UCODE() unexp. DCS");
    }
    /*MC, SPR 1086 Commented out traces here, as long buffers cause a crash*/
    {int i;

    	for (i=0; i <size && i<20; i++)
    	{	if (destination[i] == 0)
    			debug[i] ='0';
    		else
    			debug[i] = destination[i];
    	}
    	TRACE_EVENT(debug);
    }
}
/*JVJE*/

/*******************************************************************************

 $Function:  sat_create_TEXT_ASCIIZ  

 $Description:	 This routine creates out of an MFW SAT text descriptor an 
				dynamically allocated ASCIIZ string pointer

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
#define SAT_LEN_SIZE (U16)sizeof(U16)         /* used to hold the allocation size */
#define SAT_TERMINATOR_SIZE (U16)sizeof(U16)  /* used to hold terminating '\0' in U8 and U16 */

char * sat_create_TEXT_ASCIIZ (T_SAT_TXT * txt)
{  
	
    char * res;
    U16 size;
	UBYTE first_char= *((UBYTE*)txt+txt->text);/*SPR 1728*/
    TRACE_EVENT("sat_create_TEXT_ASCIIZ ()");
#ifdef  NO_ASCIIZ
	TRACE_EVENT_P2("DCS:%d  first_char:%d", txt->code, first_char);
	/*SPR 1728, if unicode string format it for display*/
      if ( first_char==0x80 ||txt->code==MFW_DCS_UCS2)
    {	return (char*)sat_create_TEXT_UCODE (txt);}
#endif
      
    /* allocate sufficient space for the converted string */
    if (txt->code == MFW_DCS_7bits)
	size = SAT_LEN_SIZE + ((txt->len*8)/7)*sizeof(char) + SAT_TERMINATOR_SIZE;
    else
	size = SAT_LEN_SIZE + txt->len*sizeof(char) + SAT_TERMINATOR_SIZE;
    res = (char *)ALLOC_MEMORY (size); 
    *(U16 *) res = size; /* store allocated size in first 2 bytes (for deallocation purposes) */
    res += SAT_LEN_SIZE,  /* set the pointer to the string, not to the alloc size */

    /* convert the string */
    sat_TEXT_to_ASCIIZ (res, txt);
  

    return res;
}

/*******************************************************************************

 $Function:  sat_create_TEXT_UCODE  

 $Description:	 This routine creates out of an MFW SAT text descriptor an
				 dynamically allocated UCS2 string pointer

 $Returns:		none.

 $Arguments:	
 
*******************************************************************************/
/*JVJE*/
/*MC, SPR 940/2 uncommneted and then re-written function, pointers to wide chars now are pointers to chars*/
char* sat_create_TEXT_UCODE (T_SAT_TXT * txt)
{
    char * res;
    U16 size;

    TRACE_EVENT("sat_create_TEXT_UCODE()");
    
    if (txt->code == MFW_DCS_7bits)					/*MC SPR 1086, add 2 extra chars in case UCS2 tag is to be added later*/ 
        size = SAT_LEN_SIZE + sizeof(char) + ((txt->len*8)/7) * /*sizeof(wchar_t)*/2+SAT_TERMINATOR_SIZE*2;
    else											/*MC SPR 1086, add 2 extra chars in case UCS2 tag is to be added later*/ 
        size = SAT_LEN_SIZE + sizeof(char) + txt->len * /*sizeof(wchar_t)*/2+SAT_TERMINATOR_SIZE*2;
    res = (char *)ALLOC_MEMORY (size); 
    *(U16 *)res = size; 
    res = ((char *)res + SAT_LEN_SIZE); 

    sat_TEXT_to_UCODE (res,size,  txt);

    return res;
}


/*****************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -