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

📄 mmisimtoolkit.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* INFO DISPLAY */
    T_MFW_WIN       * info_win_data   = ((T_MFW_HDR *)win)->data;
    T_sim_toolkit   * info_data       = (T_sim_toolkit *)info_win_data->user;

    TRACE_FUNCTION("sat_info_cb");

    if (win EQ NULL)
        return;

        /*
        * Who has initiated the information screen
    */
    switch (identifier)
    {
    case SAT_SEND_SMS:
    case SAT_SEND_SS:
    case SAT_CALL_RESULT:
        if ((info_win_data EQ NULL) || (info_data EQ NULL))
            return;
        sat_destroy_TEXT_ASCIIZ((char*)info_data->editor_data.TextString); /* displayed text */
		//editor_destroy(info_data->info_win);
        
        break;
    default:
        TRACE_EVENT("sat_info_cb(): unexp. event");
        break;
    }
}


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

 $Function:  sat_set_setup_menu_win

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

 $Returns:    none.

 $Arguments:

*******************************************************************************/
void sat_set_setup_menu_win(T_MFW_HND win)
{
  TRACE_FUNCTION("sat_set_setup_menu_win");

    g_sim_toolkit_data->sat_setup_menu_win = win;
}


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

 $Function:  sat_get_setup_menu_win

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

 $Returns:    none.

 $Arguments:

*******************************************************************************/
T_MFW_HND sat_get_setup_menu_win(void)
{
  TRACE_EVENT("sat_get_setup_menu_win");
    return g_sim_toolkit_data->sat_setup_menu_win;
}


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

 $Function:  sat_set_call_setup_win

 $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:

*******************************************************************************/
/*zy 2003-04-16 checkin 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_gsm

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

 $Returns:    none.

 $Arguments:

*******************************************************************************/
/*JVJE
void sat_ucode_to_gsm (char * gsm_string, cp_wstring_t UCS2_string)
{
    U16 i;

    for (i = 0; i < UCS2_string->length; i++)
        gsm_string[i] = g_ascii_gsm_table[(U8)(UCS2_string->chars[i])];
}
JVJE*/

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

 $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_EVENT("sat_ucode_to_asci");

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

void sat_ucode_no_to_ascii0 (char * ascii_string, char * UCS2_chars, U16 length)
{

  //char buf[40];  //zhaowm   

    U16 i=0;
  TRACE_EVENT("sat_ucode_to_asci");
  
    ascii_string[0] = 0x80;
    //for (i = 0; i < length; i++)
    for (i = 1; i < length+1; i++)
    
      {
        //ascii_string[i] = UCS2_chars[i];
        ascii_string[i] = UCS2_chars[i-1];       
       // sprintf(buf," i=%u,%x",i, ascii_string[i]);//
		//TRACE_EVENT(buf);//
       }
    ascii_string[i] = 0x00;
    ascii_string[i+1] = 0x00;
    /*
    sprintf(buf," i=%u,%x",i, ascii_string[i]);//
	TRACE_EVENT(buf);//
	sprintf(buf," i+1=%u,%x",i, ascii_string[i+1]);//
	TRACE_EVENT(buf);//
	*/
	
;
}   //no convert, zhaowm
/*******************************************************************************

 $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] = {
        064, 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_ascii_to_gsm");
    for (i = 0; i < length; i++)
        ascii_string[i] = g_gsm_ascii_table[(gsm_string[i] & (U8)0x7F)];
    ascii_string[i] = '\0';
}
void sat_gsm_to_ascii0 (char * ascii_string, char * gsm_string, U16 length)   //zhaowm,2002.0618 
{
 // char buf[30];  //zhaowm   

    U16 i;
  TRACE_EVENT("sat_gsm_to_ascii0 ");
  //for (i = 1; i < length; i++)
  for (i = 0; i < length; i++)

       {
        //ascii_string[i] = gsm_string[i+1] ;
        ascii_string[i] = gsm_string[i] ;       
    	//sprintf(buf," i=%u,%x",i, ascii_string[i]);//
		//TRACE_EVENT(buf);//
       }  
 
    ascii_string[i] = 0x00;
    ascii_string[i+1] = 0x00;
    



}//no convert  and remove 0x80(in the first)  


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

 $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;

    TRACE_FUNCTION("sat_TEXT_to_ASCIIZ");

    switch (txt->code)
    {
    case MFW_DCS_7bits:
  TRACE_EVENT("sat_TEXT_to_ASCIIZ() 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:
          //sat_gsm_to_ascii (destination, (char *)txt + txt->text, (UBYTE)txt->len);
          sat_gsm_to_ascii0 (destination, (char *)txt + txt->text, (UBYTE)txt->len);//zhaowm
  break;
    case MFW_DCS_UCS2:
       //sat_ucode_to_ascii (destination, (wchar_t *)((char *)txt + txt->text), txt->len);
        sat_ucode_no_to_ascii0 (destination, (char *)txt + txt->text, (UBYTE)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:

*******************************************************************************/
#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;

    /* 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+2);

   // *(U16 *) res = size; /* store allocated size in first 2 bytes (for deallocation purposes) */
    *(U16 *) res = size+2; /* 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 */

    /* con

⌨️ 快捷键说明

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