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

📄 phb_se.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 5 页
字号:
            kal_uint8 specified_decoded_str_len;
            kal_uint16 ch;
            kal_uint16 base_ptr;
            kal_uint8 count;
            kal_uint8 result[PHB_ALPHA_ID_DEPTH];

            kal_mem_cpy(&temp_name, &phb_entry->alpha_id, sizeof(l4_name_struct));

            ++offset;
            specified_decoded_str_len = phb_entry->alpha_id.name[offset++];
            base_ptr = phb_entry->alpha_id.name[offset++] << 7;

            for (count = 0; offset < phb_entry->alpha_id.name_length;)
            {
                ch = phb_entry->alpha_id.name[offset++];

                /* Exceeds capacity, truncate */
                if ((count + 1) >= PHB_ALPHA_ID_DEPTH)
                {
                    break;
                }

                /* All bytes are docoed */
                if ((count + 1) >= (specified_decoded_str_len * 2))
                {
                    break;
                }

                if (ch < 0x80)
                {
                    result[count++] = 0x0;
                    result[count++] = (kal_uint8) ch;
                }
                else
                {
                    ch &= 0x7F;
                    ch += base_ptr;

                    result[count++] = phb_more_significant_char(ch);
                    result[count++] = phb_less_significant_char(ch);
                }
            }
            kal_mem_cpy(&phb_entry->alpha_id.name, result, PHB_ALPHA_ID_DEPTH);
            phb_entry->alpha_id.name_dcs = PHB_UCS2;
            phb_entry->alpha_id.name_length = count;
        }
        else if (phb_entry->alpha_id.name_dcs == PHB_UCS2_82)
        {
            kal_uint8 offset = 0;
            kal_uint8 specified_decoded_str_len;
            kal_uint16 ch;
            kal_uint16 base_ptr;
            kal_uint8 count;
            kal_uint8 result[PHB_ALPHA_ID_DEPTH];

            kal_mem_cpy(&temp_name, &phb_entry->alpha_id, sizeof(l4_name_struct));

            ++offset;
            specified_decoded_str_len = phb_entry->alpha_id.name[offset++];
            base_ptr = phb_entry->alpha_id.name[offset++] << 8;
            base_ptr |= phb_entry->alpha_id.name[offset++];

            for (count = 0; offset < phb_entry->alpha_id.name_length;)
            {
                ch = phb_entry->alpha_id.name[offset++];

                /* Exceeds capacity, truncate */
                if ((count + 1) >= PHB_ALPHA_ID_DEPTH)
                {
                    break;
                }

                /* All bytes are docoed */
                if ((count + 1) >= (specified_decoded_str_len * 2))
                {
                    break;
                }

                if (ch < 0x80)
                {
                    result[count++] = 0x0;
                    result[count++] = (kal_uint8) ch;
                }
                else
                {
                    ch &= 0x7F;
                    ch += base_ptr;

                    result[count++] = phb_more_significant_char(ch);
                    result[count++] = phb_less_significant_char(ch);
                }
            }
            kal_mem_cpy(&phb_entry->alpha_id.name, result, PHB_ALPHA_ID_DEPTH);
            phb_entry->alpha_id.name_dcs = PHB_UCS2;
            phb_entry->alpha_id.name_length = count;
        }
    #endif /* __PHB_0x81_SUPPORT__ */ 
        index = phb_name_num_index_append(
                    name_num_index,
                    (alpha_id_type*) & phb_entry->alpha_id,
                    phb_entry->storage,
                    record_index,
                    signature,
                    tel_num,
                    ext_index);
        if (fake_name == KAL_TRUE)
        {
            kal_mem_set(phb_entry->alpha_id.name, 0, 30);
            phb_entry->alpha_id.name_length = 0;
        }
    #ifdef __PHB_0x81_SUPPORT__     /* MTK 2004-04-20 Wisoln, support maximum length of 0x81 UCS2 */
        if (temp_name.name_dcs == PHB_UCS2_81 || temp_name.name_dcs == PHB_UCS2_82)
        {
            kal_mem_cpy(&phb_entry->alpha_id, &temp_name, sizeof(l4_name_struct));
        }
    #endif /* __PHB_0x81_SUPPORT__ */ 
        return index;
    }

    return (kal_uint16) PHB_INVALID_VALUE;
}   /* end of phb_se_append */


/*****************************************************************************
 * FUNCTION
 *  phb_se_update
 * DESCRIPTION
 *  Build index of certain type
 * PARAMETERS
 *  type                [IN]        
 *  ext_index           [IN]        
 *  phb_entry           [?]         
 *  old_index           [IN]        
 *  old_ext_index       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
kal_uint16 phb_se_update(
            phb_type_enum type,
            kal_uint8 ext_index,
            phb_entry_struct *phb_entry,
            kal_uint16 old_index,
            kal_uint8 *old_ext_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SE_UPDATE);

#ifdef __PHB_SORT_ENABLE__
    if ((type == PHB_PHONEBOOK) || (type == PHB_FDN) || (type == PHB_BDN))
#else 
    if ((type == PHB_FDN) || (type == PHB_BDN))
#endif 
    {
        kal_bool fake_name = KAL_FALSE;
        kal_uint8 signature;
        kal_uint8 tel_num;
        kal_uint16 index;
        name_num_index_type *name_num_index;

    #ifdef __PHB_0x81_SUPPORT__     /* MTK 2004-04-20 Wisoln, support maximum length of 0x81 UCS2 */
        l4_name_struct temp_name;

        temp_name.name_dcs = 0;
    #endif /* __PHB_0x81_SUPPORT__ */ 

        phb_se_get_index_values(type, &phb_entry->tel_number, &signature, &tel_num, &name_num_index);

        /* amanda add, put number in name for sorting */
        if (phb_entry->alpha_id.name_length == 0)
        {
            kal_uint8 fake_name_bcd[15];
            kal_uint8 *temp_ptr;

            fake_name = KAL_TRUE;
            kal_mem_cpy(fake_name_bcd, &phb_entry->tel_number.addr_bcd[1], 10);
            fake_name_bcd[10] = 0xff;
            temp_ptr = phb_entry->alpha_id.name;
            phb_entry->alpha_id.name_length = 0;
            if (phb_entry->tel_number.addr_bcd[0] & 0x10)
            {
                *(temp_ptr++) = '+';
                phb_entry->alpha_id.name_length++;
            }
            phb_entry->alpha_id.name_length += convert_to_digit(fake_name_bcd, temp_ptr);
            phb_entry->alpha_id.name_dcs = PHB_ASCII;
        }
        /* Convert 0x81 to 0x80 in L4 for sorting. */
    #ifdef __PHB_0x81_SUPPORT__     /* MTK 2004-04-20 Wisoln, support maximum length of 0x81 UCS2 */
        else if (phb_entry->alpha_id.name_dcs == PHB_UCS2_81)
        {
            kal_uint8 offset = 0;
            kal_uint8 specified_decoded_str_len;
            kal_uint16 ch;
            kal_uint16 base_ptr;
            kal_uint8 count;
            kal_uint8 result[PHB_ALPHA_ID_DEPTH];

            kal_mem_cpy(&temp_name, &phb_entry->alpha_id, sizeof(l4_name_struct));

            ++offset;
            specified_decoded_str_len = phb_entry->alpha_id.name[offset++];
            base_ptr = phb_entry->alpha_id.name[offset++] << 7;

            for (count = 0; offset < phb_entry->alpha_id.name_length;)
            {
                ch = phb_entry->alpha_id.name[offset++];

                /* Exceeds capacity, truncate */
                if ((count + 1) >= PHB_ALPHA_ID_DEPTH)
                {
                    break;
                }

                /* All bytes are docoed */
                if ((count + 1) >= (specified_decoded_str_len * 2))
                {
                    break;
                }

                if (ch < 0x80)
                {
                    result[count++] = 0x0;
                    result[count++] = (kal_uint8) ch;
                }
                else
                {
                    ch &= 0x7F;
                    ch += base_ptr;

                    result[count++] = phb_more_significant_char(ch);
                    result[count++] = phb_less_significant_char(ch);
                }
            }
            kal_mem_cpy(&phb_entry->alpha_id.name, result, PHB_ALPHA_ID_DEPTH);
            phb_entry->alpha_id.name_dcs = PHB_UCS2;
            phb_entry->alpha_id.name_length = count;
        }
        else if (phb_entry->alpha_id.name_dcs == PHB_UCS2_82)
        {
            kal_uint8 offset = 0;
            kal_uint8 specified_decoded_str_len;
            kal_uint16 ch;
            kal_uint16 base_ptr;
            kal_uint8 count;
            kal_uint8 result[PHB_ALPHA_ID_DEPTH];

            kal_mem_cpy(&temp_name, &phb_entry->alpha_id, sizeof(l4_name_struct));

            ++offset;
            specified_decoded_str_len = phb_entry->alpha_id.name[offset++];
            base_ptr = phb_entry->alpha_id.name[offset++] << 8;
            base_ptr |= phb_entry->alpha_id.name[offset++];

            for (count = 0; offset < phb_entry->alpha_id.name_length;)
            {
                ch = phb_entry->alpha_id.name[offset++];

                /* Exceeds capacity, truncate */
                if ((count + 1) >= PHB_ALPHA_ID_DEPTH)
                {
                    break;
                }

                /* All bytes are docoed */
                if ((count + 1) >= (specified_decoded_str_len * 2))
                {
                    break;
                }

                if (ch < 0x80)
                {
                    result[count++] = 0x0;
                    result[count++] = (kal_uint8) ch;
                }
                else
                {
                    ch &= 0x7F;
                    ch += base_ptr;

                    result[count++] = phb_more_significant_char(ch);
                    result[count++] = phb_less_significant_char(ch);
                }
            }
            kal_mem_cpy(&phb_entry->alpha_id.name, result, PHB_ALPHA_ID_DEPTH);
            phb_entry->alpha_id.name_dcs = PHB_UCS2;
            phb_entry->alpha_id.name_length = count;
        }
    #endif /* __PHB_0x81_SUPPORT__ */ 

        index = phb_name_num_index_update(
                    name_num_index,
                    old_index,
                    (alpha_id_type*) & phb_entry->alpha_id,
                    signature,
                    tel_num,
                    ext_index,
                    old_ext_index);
        if (fake_name == KAL_TRUE)
        {
            kal_mem_set(phb_entry->alpha_id.name, 0, 30);
            phb_entry->alpha_id.name_length = 0;
        }
    #ifdef __PHB_0x81_SUPPORT__     /* MTK 2004-04-20 Wisoln, support maximum length of 0x81 UCS2 */
        if (temp_name.name_dcs == PHB_UCS2_81 || temp_name.name_dcs == PHB_UCS2_82)
        {
            kal_mem_cpy(&phb_entry->alpha_id, &temp_name, sizeof(l4_name_struct));
        }
    #endif /* __PHB_0x81_SUPPORT__ */ 
        return index;
    }
    return (kal_uint16) PHB_INVALID_VALUE;
}   /* end of phb_se_update */


/*****************************************************************************
 * FUNCTION
 *  phb_se_delete
 * DESCRIPTION
 *  Build index of certain type
 * PARAMETERS
 *  type            [IN]        
 *  old_index       [IN]        
 *  ext_index       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void phb_se_delete(phb_type_enum type, kal_uint16 old_index, kal_uint8 *ext_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    name_num_index_type *name_num_index = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SE_DELETE);

#ifdef __PHB_SORT_ENABLE__
    if (type == PHB_PHONEBOOK)
    {
        name_num_index = &phb_ptr->indices.phb_index;
    }
    else if (type == PHB_FDN)
#else /* __PHB_SORT_ENABLE__ */ 
    if (type == PHB_FDN)
#endif /* __PHB_SORT_ENABLE__ */ 
        name_num_index = &phb_ptr->indices.fdn_index;
    else if (type == PHB_BDN)
    {
        name_num_index = &phb_ptr->indices.bdn_index;
    }

    if (name_num_index != NULL)
    {
        phb_name_num_index_delete(name_num_index, old_index, ext_index);

⌨️ 快捷键说明

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