[Feature][task-view-998]merge P56U10 version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: Id05b15148bef69d7b4642d18cc40564e5ef0c9a0
diff --git a/ap/app/busybox/src/init/halt.c b/ap/app/busybox/src/init/halt.c
index 7974adb..b7d439b 100644
--- a/ap/app/busybox/src/init/halt.c
+++ b/ap/app/busybox/src/init/halt.c
@@ -94,6 +94,81 @@
#define write_wtmp() ((void)0)
#endif
+/* Started by AICoder, pid:eecb340c7fw298714a9d0b3210b0288be1203207 */
+static void get_app_name_by_pid(int pid, char *app_name, int app_name_len)
+{
+ char file_comm[256];
+ FILE *pfile;
+ size_t len;
+
+ memset(file_comm, 0, sizeof(file_comm));
+ snprintf(file_comm, sizeof(file_comm), "/proc/%d/comm", pid);
+
+ pfile = fopen(file_comm, "r");
+ if (pfile)
+ {
+ memset(app_name, 0, app_name_len);
+ fgets(app_name, app_name_len, pfile);
+ app_name[app_name_len-1] = '\0';
+ app_name[strlen(app_name) - 1] = '\0'; //last byte is \n
+ fclose(pfile);
+ }
+}
+
+static int get_ppid(int pid) {
+ char path[256];
+ snprintf(path, sizeof(path), "/proc/%d/stat", pid);
+
+ FILE *fp = fopen(path, "r");
+ if (fp == NULL) {
+ perror("fopen");
+ return -1;
+ }
+
+ int ppid = -1;
+ // 通过解析第4列(ppid)来获取父进程ID
+ fscanf(fp, "%*d %*s %*c %d", &ppid);
+ fclose(fp);
+ return ppid;
+}
+
+static int get_reboot_caller(char *applet_name)
+{
+ int pid = get_ppid(getpid());
+ char app_name[32];
+ int app_name_len = sizeof(app_name);
+ char cmd_str[256];
+ int try_cnt = 0;
+
+ while(1)
+ {
+ if (try_cnt > 5) {
+ strcpy(app_name, "unkown");
+ break;
+ }
+ try_cnt++;
+ if (pid == 1) {
+ get_app_name_by_pid(pid, app_name, app_name_len);
+ break; //init
+ }
+ get_app_name_by_pid(pid, app_name, app_name_len);
+ if ((strcmp(app_name, "sh") == 0) || (strcmp(app_name, "bash") == 0)) {
+ //printf("shell %s continue %d\n", app_name, strlen(app_name));
+ pid = get_ppid(pid); //sh continue
+ } else {
+ //printf("not sh break %s %d\n", app_name, strlen(app_name));
+ break; //not sh
+ }
+ }
+
+ memset(cmd_str, 0, sizeof(cmd_str));
+ snprintf(cmd_str, sizeof(cmd_str), "nv set ap_reset_app=%s_%d; nv save", app_name, pid);
+ system(cmd_str);
+ printf("call %s by %s(%d)\n", applet_name, app_name, pid);
+
+ return 0;
+}
+/* Ended by AICoder, pid:eecb340c7fw298714a9d0b3210b0288be1203207 */
int halt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int halt_main(int argc UNUSED_PARAM, char **argv)
@@ -111,6 +186,10 @@
/* Figure out which applet we're running */
for (which = 0; "hpr"[which] != applet_name[0]; which++)
continue;
+#if ENABLE_INSTALL_TO_RECOVERY
+#else
+ get_reboot_caller(applet_name); //add by zxic, print parent proccess name and pid
+#endif
/* Parse and handle arguments */
opt_complementary = "d+"; /* -d N */
diff --git a/ap/app/fs_check/mtd.c b/ap/app/fs_check/mtd.c
index c610bf0..4b0322d 100755
--- a/ap/app/fs_check/mtd.c
+++ b/ap/app/fs_check/mtd.c
@@ -423,6 +423,7 @@
sc_debug_info_record(MODULE_ID_AP_FS_CHECK, "fs_check file: %s permission loss \n",NV_FS_RW_BACKUP_SYMBOL_PATH);
return -1;//²é¿´backup_flagÎļþÊÇ·ñ¿É¶Áд
}
+#ifndef USE_CAP_SUPPORT
if(access(NV_FS_RW_AP_NV_MAIN_PATH, W_OK | R_OK) < 0)
{
printf("fs_check file: %s permission loss \n",NV_FS_RW_AP_NV_MAIN_PATH);
@@ -435,6 +436,7 @@
sc_debug_info_record(MODULE_ID_AP_FS_CHECK, "fs_check file: %s permission loss \n",NV_FS_RW_AP_NV_BACKUP_PATH);
return -1;//²é¿´apϱ¸·ÝnvÎļþÊÇ·ñ¿É¶Áд
}
+#endif
return 0;
}
diff --git a/ap/app/hostapd-2.10/hostapd/libwpa_client.a b/ap/app/hostapd-2.10/hostapd/libwpa_client.a
index 2ba2b63..f3bcbc6 100755
--- a/ap/app/hostapd-2.10/hostapd/libwpa_client.a
+++ b/ap/app/hostapd-2.10/hostapd/libwpa_client.a
Binary files differ
diff --git a/ap/app/include/audio_res_ctrl.h b/ap/app/include/audio_res_ctrl.h
index fc3a5ed..6b08b41 100755
--- a/ap/app/include/audio_res_ctrl.h
+++ b/ap/app/include/audio_res_ctrl.h
@@ -44,10 +44,8 @@
REL_AUDIO_IND, //ÇëÇóijҵÎñÄ£¿éÊÍ·ÅaudioµÄ½á¹ûÓ¦´ð£¬Èôʧ°Ü£¬¶ÏÑÔ£»»»ÑÔÖ®£¬±ØÐë³É¹¦
IDLE_AUDIO_INFO, //Ö÷¿ØÍ¨ÖªËùÓÐÉêÇë¹ýAUDIO×ÊÔ´µÄÒµÎñÄ£¿é£¬¸æÖªµ±Ç°¿ÕÏУ¬ÒÔ½â¾öÒµÎñÄ£¿é´¦ÓÚ¹ÒÆð̬»ò֮ǰ±»Ç¿ÐÐÊͷŵÄÒµÎñÄ£¿é£¬ÈçMP3ÒôÀÖ²¥·ÅµÈ£»
EXIT_AUDIO_IND, //֪ͨÖ÷¿Ø£¬ÒµÎñÄ£¿éÍ˳öÒôƵ×ÊÔ´¾ºÕù
-//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
- EXIT_AUDIO_REQ,
- EXIT_AUDIO_RSP,
-//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
+ EXIT_AUDIO_REQ, //ÇëÇóÒµÎñÄ£¿éÍ˳öÒôƵ×ÊÔ´¾ºÕù
+ EXIT_AUDIO_RSP, //ÏìÓ¦ÒµÎñÄ£¿éÍ˳öÒôƵ×ÊÔ´¾ºÕù
};
diff --git a/ap/app/wpa_supplicant-2.10/wpa_supplicant/libwpa_client.a b/ap/app/wpa_supplicant-2.10/wpa_supplicant/libwpa_client.a
index 46e8abd..d09b84b 100755
--- a/ap/app/wpa_supplicant-2.10/wpa_supplicant/libwpa_client.a
+++ b/ap/app/wpa_supplicant-2.10/wpa_supplicant/libwpa_client.a
Binary files differ
diff --git a/ap/app/zte_comm/nvserver/nvserver.c b/ap/app/zte_comm/nvserver/nvserver.c
index 101a499..fe5ba99 100755
--- a/ap/app/zte_comm/nvserver/nvserver.c
+++ b/ap/app/zte_comm/nvserver/nvserver.c
@@ -1,4 +1,19 @@
+/*******************************************************************************
+* °æÈ¨ËùÓÐ (C)2016, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ: nvserver.c
+* Îļþ±êʶ: nvserver.c
+* ÄÚÈÝÕªÒª: nvºǫ́ӦÓÃʵÏÖÎļþ
+*
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* ------------------------------------------------------------------------------
+* 2016/06/13 V1.0 Create ÁõÑÇÄÏ ´´½¨
+*
+*******************************************************************************/
+/*******************************************************************************
+* Í·Îļþ *
+*******************************************************************************/
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
@@ -10,281 +25,1242 @@
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/msg.h>
+
#include "nvserver.h"
#include "nv_typedef.h"
#include <message.h>
+
#ifdef FOTA_AB
#include "pub_flags.h"
#include "flags_api.h"
#endif
+
#ifdef __cplusplus
-extern"C"{
+extern "C" {
#endif
-static void nvConfig();static void nvInit();static int nvDirInit();static void
-analyMsg(T_NV_MSG_INFO*msgrecv,T_NV_MSG_RESULT*msgsnd);static bool checkNvFs(
-char*file);static bool isCfgConfiged(char*configFile);static bool isNvConfiged(
-char*configFile);static uint getSum(const char*s,int len);static int
-loadFactroyParam(T_NV_NODE*list);static int restoreNvFs(char*dstFile,char*
-srcFile);static int loadNvFs(char*file);static int addConfigFile(char*nvFile,
-char*configFile);static int saveNvFs(char*nvName,char*nvFile);static int nvset(
-char*file,const char*key,const char*value,int saveFlag);static int nvget(char*
-file,char*key,char*value);static int nvunset(char*file,char*key);static int
-nvclear(char*file);static int nvreset(char*file);static int nvcommit(char*file);
-T_NV_NODE*nv_list;int nvserver_main(int argc,char*argv[]){int msgId=
-(0xe7a+2066-0x168c);T_NV_MSG_INFO rcvBuf;T_NV_MSG_RESULT sndBuf;struct msqid_ds
-msgInfo;prctl(PR_SET_NAME,"\x6e\x76\x73\x65\x72\x76\x65\x72",(0x721+7163-0x231c)
-,(0x77a+1071-0xba9),(0x22b+6826-0x1cd5));memset(&rcvBuf,(0x12dd+715-0x15a8),
-sizeof(rcvBuf));memset(&sndBuf,(0xa8a+3067-0x1685),sizeof(sndBuf));memset(&
-msgInfo,(0xdcf+2206-0x166d),sizeof(msgInfo));msgId=msgget(MODULE_ID_NV,IPC_CREAT
-|(0xae7+5318-0x1e2d));if(-(0x1755+3387-0x248f)==msgId){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x6d\x73\x67\x67\x65\x74\x20\x6d\x73\x67\x49\x64\x20\x66\x61\x69\x6c\x2c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,errno);return-(0x151f+3866-0x2438);}if(-(0x694+8073-0x261c)!=msgctl(msgId,
-IPC_STAT,&msgInfo)){msgInfo.msg_qbytes=262144;if(-(0x6e0+5543-0x1c86)==msgctl(
-msgId,IPC_SET,&msgInfo))printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x6d\x73\x67\x63\x74\x6c\x20\x6d\x73\x67\x49\x64\x20\x66\x61\x69\x6c\x2c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,errno);}if(nvDirInit()!=(0x1916+2322-0x2228)){printf(
-"\x6e\x76\x44\x69\x72\x49\x6e\x69\x74\x20\x66\x61\x69\x6c\x65\x21" "\n");return-
-(0x6d7+7153-0x22c7);}nvConfig();nvInit();while((0x45f+958-0x81c)){if(-
-(0x301+3995-0x129b)==msgrcv(msgId,&rcvBuf,sizeof(T_NV_MSG_INFO)-sizeof(long),
-MSG_TYPE_NV,(0xc26+3801-0x1aff))){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6d\x73\x67\x72\x63\x76\x20\x66\x61\x69\x6c\x2c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x21" "\n"
-,errno);continue;}analyMsg(&rcvBuf,&sndBuf);if(-(0x6c0+5642-0x1cc9)==msgsnd(
-msgId,&sndBuf,sizeof(T_NV_MSG_RESULT)-sizeof(long),(0x57f+3769-0x1438))){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6d\x73\x67\x73\x6e\x64\x20\x66\x61\x69\x6c\x2c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x21" "\n"
-,errno);continue;}}return((0x10c9+920-0x1461));}static void configdir(char*dir){
-DIR*dp;int ret;struct dirent*entry;struct stat statbuf;if((dp=opendir(dir))==
-NULL){fprintf(stderr,
-"\x63\x61\x6e\x6e\x6f\x74\x20\x6f\x70\x65\x6e\x20\x64\x69\x72\x65\x63\x74\x6f\x72\x79\x3a\x20\x25\x73" "\n"
-,dir);return;}chdir(dir);while((entry=readdir(dp))!=NULL){ret=lstat(entry->
-d_name,&statbuf);if(ret<(0x93f+3551-0x171e)){fprintf(stderr,
-"\x6c\x73\x74\x61\x74\x20\x65\x72\x72\x6f\x72\x3a\x20\x25\x73" "\n",strerror(
-errno));chdir("\x2e\x2e");closedir(dp);return;}if(!S_ISDIR(statbuf.st_mode)){if(
-strcmp("\x2e",entry->d_name)==(0x82d+7150-0x241b)||strcmp("\x2e\x2e",entry->
-d_name)==(0xae0+824-0xe18))continue;if(!isNvConfiged(entry->d_name)){if(
-addConfigFile(entry->d_name,NULL)!=RESULT_SUCCESS)printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x63\x6f\x6e\x66\x69\x67\x20\x25\x73\x20\x65\x72\x72\x6f\x72\x21" "\n"
-,entry->d_name);}}}chdir("\x2e\x2e");closedir(dp);}static void nvConfig(){char*
-val=NULL;FILE*fp=NULL;char buf[NV_MAX_CONFIG_LEN]={(0x510+4322-0x15f2)};fp=fopen
-(NV_CONFIG_FILE,"\x72\x6f");if(!fp){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x6f\x70\x65\x6e\x20\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x21" "\n"
-,NV_CONFIG_FILE,errno);return;}while(fgets(buf,NV_MAX_CONFIG_LEN,fp)){if(buf[
-(0x84f+7727-0x267e)]=='\n'||buf[(0xf2a+4513-0x20cb)]==
-((char)(0x601+4850-0x18d0)))continue;val=strchr(buf,((char)(0xf85+3266-0x1c0a)))
-;if(!val){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x6f\x72\x6d\x61\x74\x20\x65\x72\x72\x6f\x72\x3a\x20\x73\x74\x72\x20\x3d\x20\x25\x73\x21" "\n"
-,NV_CONFIG_FILE,buf);continue;}buf[strlen(buf)-(0xb39+4270-0x1be6)]='\0';*val++=
-'\0';if(!isCfgConfiged(buf)){if(addConfigFile(val,buf)!=RESULT_SUCCESS)printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x63\x6f\x6e\x66\x69\x67\x20\x25\x73\x20\x65\x72\x72\x6f\x72\x21" "\n"
-,buf);}}fclose(fp);configdir(NV_FS_MAIN_PATH);}static int nvDirInit(){if(access(
-NV_FS_PATH,F_OK)!=(0x1ca9+1419-0x2234)){if(mkdir(NV_FS_PATH,(0x29d+142-0x13e))!=
-(0x1e29+652-0x20b5)){printf(
-"\x6e\x65\x72\x76\x65\x72\x20\x6d\x6b\x64\x69\x72\x20\x25\x73\x20\x66\x61\x6c\x69\x2c\x65\x72\x72\x6e\x6f\x3d\x25\x64" "\n"
-,NV_FS_PATH,errno);return-(0x194d+264-0x1a54);}if(mkdir(NV_FS_MAIN_PATH,
-(0x249a+1070-0x26db))!=(0x14f+2741-0xc04)){printf(
-"\x6e\x65\x72\x76\x65\x72\x20\x6d\x6b\x64\x69\x72\x20\x25\x73\x20\x66\x61\x6c\x69\x2c\x65\x72\x72\x6e\x6f\x3d\x25\x64" "\n"
-,NV_FS_MAIN_PATH,errno);return-(0xd8f+5331-0x2261);}if(mkdir(NV_FS_BACKUP_PATH,
-(0x1c92+1041-0x1eb6))!=(0x122c+168-0x12d4)){printf(
-"\x6e\x65\x72\x76\x65\x72\x20\x6d\x6b\x64\x69\x72\x20\x25\x73\x20\x66\x61\x6c\x69\x2c\x65\x72\x72\x6e\x6f\x3d\x25\x64" "\n"
-,NV_FS_BACKUP_PATH,errno);return-(0xa12+30-0xa2f);}}else{if(access(
-NV_FS_MAIN_PATH,F_OK)!=(0x14e8+1394-0x1a5a)){if(mkdir(NV_FS_MAIN_PATH,
-(0x1ff7+2203-0x26a5))!=(0x23eb+788-0x26ff)){printf(
-"\x6e\x65\x72\x76\x65\x72\x20\x6d\x6b\x64\x69\x72\x20\x25\x73\x20\x66\x61\x6c\x69\x2c\x65\x72\x72\x6e\x6f\x3d\x25\x64" "\n"
-,NV_FS_MAIN_PATH,errno);return-(0xc98+1801-0x13a0);}}if(access(NV_FS_BACKUP_PATH
-,F_OK)!=(0x3b7+6332-0x1c73)){if(mkdir(NV_FS_BACKUP_PATH,(0xd77+6373-0x246f))!=
-(0x1557+2974-0x20f5)){printf(
-"\x6e\x65\x72\x76\x65\x72\x20\x6d\x6b\x64\x69\x72\x20\x25\x73\x20\x66\x61\x6c\x69\x2c\x65\x72\x72\x6e\x6f\x3d\x25\x64" "\n"
-,NV_FS_BACKUP_PATH,errno);return-(0x73b+7107-0x22fd);}}}return
-(0x10c+5360-0x15fc);}static void nvInit(){T_NV_NODE*list=NULL;char nvMainFile[
-NV_PATH_LEN]={(0x471+321-0x5b2)};char nvBackupFile[NV_PATH_LEN]={
-(0xdbb+722-0x108d)};
+
+/*******************************************************************************
+* ³£Á¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ºê¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* Êý¾ÝÀàÐͶ¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¾Ö²¿º¯ÊýÉùÃ÷ *
+*******************************************************************************/
+static void nvConfig();
+static void nvInit();
+static int nvDirInit();
+static void analyMsg(T_NV_MSG_INFO *msgrecv, T_NV_MSG_RESULT *msgsnd);
+static bool checkNvFs(char *file);
+static bool isCfgConfiged(char *configFile);
+static bool isNvConfiged(char *configFile);
+static uint getSum(const char *s, int len);
+static int loadFactroyParam(T_NV_NODE *list);
+static int restoreNvFs(char *dstFile, char *srcFile);
+static int loadNvFs(char *file);
+static int addConfigFile(char *nvFile, char *configFile);
+static int saveNvFs(char *nvName, char *nvFile);
+static int nvset(char *file, const char *key, const char *value, int saveFlag);
+static int nvget(char *file, char *key, char *value);
+static int nvunset(char *file, char *key);
+static int nvclear(char *file);
+static int nvreset(char *file);
+static int nvcommit(char *file);
+
+/*******************************************************************************
+* ¾Ö²¿¾²Ì¬±äÁ¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Ö±äÁ¿¶¨Òå *
+*******************************************************************************/
+T_NV_NODE *nv_list;
+
+/*******************************************************************************
+* ¾Ö²¿º¯ÊýʵÏÖ *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Öº¯ÊýʵÏÖ *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: main
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+int nvserver_main(int argc, char *argv[])
+{
+ int msgId = 0;
+ T_NV_MSG_INFO rcvBuf;
+ T_NV_MSG_RESULT sndBuf;
+ struct msqid_ds msgInfo;
+
+ prctl(PR_SET_NAME, "nvserver", 0, 0, 0);
+
+ memset( &rcvBuf, 0, sizeof(rcvBuf));
+ memset( &sndBuf, 0, sizeof(sndBuf));
+ memset( &msgInfo, 0, sizeof(msgInfo));
+
+ msgId = msgget(MODULE_ID_NV, IPC_CREAT | 0600);
+ if(-1 == msgId)
+ {
+ printf("nvserver error: msgget msgId fail, errno = %d\n", errno);
+ return -1;
+ }
+
+ if(-1 != msgctl(msgId, IPC_STAT, &msgInfo))
+ {
+ msgInfo.msg_qbytes = 262144; // 256k
+ if(-1 == msgctl(msgId, IPC_SET, &msgInfo))
+ printf("nvserver error: msgctl msgId fail, errno = %d\n", errno);
+ }
+
+ if(nvDirInit() != 0)
+ {
+ printf("nvDirInit faile!\n");
+ return -1;
+ }
+
+ nvConfig();
+
+ nvInit();
+
+ // ÏûÏ¢½»»¥
+ while(1)
+ {
+ if(-1 == msgrcv(msgId, &rcvBuf, sizeof(T_NV_MSG_INFO) - sizeof(long), MSG_TYPE_NV, 0))
+ {
+ printf("nvserver error: nvserver msgrcv fail, errno = %d!\n", errno);
+ continue;
+ }
+
+ analyMsg(&rcvBuf, &sndBuf);
+
+ if(-1 == msgsnd(msgId, &sndBuf, sizeof(T_NV_MSG_RESULT) - sizeof(long), 0))
+ {
+ printf("nvserver error: nvserver msgsnd fail, errno = %d!\n", errno);
+ continue;
+ }
+ }
+
+ return (0);
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: configdir
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) dir
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static void configdir(char *dir)
+{
+ DIR *dp;
+ int ret;
+
+ struct dirent *entry;
+ struct stat statbuf;
+ if((dp = opendir(dir)) == NULL)
+ {
+ fprintf(stderr,"cannot open directory: %s\n", dir);
+ return;
+ }
+
+ chdir(dir);
+ while((entry = readdir(dp)) != NULL)
+ {
+ ret = lstat(entry->d_name,&statbuf);
+ if (ret < 0)
+ {
+ fprintf(stderr,"lstat error: %s\n", strerror(errno));
+ chdir("..");
+ closedir(dp);
+ return;
+ }
+ if(!S_ISDIR(statbuf.st_mode))
+ {
+
+ if(strcmp(".",entry->d_name) == 0 ||strcmp("..",entry->d_name) == 0)
+ continue;
+
+ if(!isNvConfiged(entry->d_name))
+ {
+ if(addConfigFile(entry->d_name, NULL) != RESULT_SUCCESS)
+ printf("nvserver error:config %s error!\n", entry->d_name);
+ }
+ }
+ }
+ chdir("..");
+ closedir(dp);
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvConfig
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static void nvConfig()
+{
+ char *val = NULL;
+ FILE *fp = NULL;
+ char buf[NV_MAX_CONFIG_LEN] = {0};
+
+ fp = fopen(NV_CONFIG_FILE, "ro");
+ if(!fp)
+ {
+ printf("nvserver error:open %s file fail errno = %d!\n", NV_CONFIG_FILE, errno);
+ return;
+ }
+
+ while (fgets(buf, NV_MAX_CONFIG_LEN, fp))
+ {
+ if (buf[0] == '\n' || buf[0] == '#')
+ continue;
+
+ val = strchr(buf, '=');
+ if (!val)
+ {
+ printf("nvserver error:%s file format error: str = %s!\n", NV_CONFIG_FILE, buf);
+ continue;
+ }
+
+ // buf=nvconfig val=nvfile
+ buf[strlen(buf) - 1] = '\0';
+ *val++ = '\0';
+
+ if(!isCfgConfiged(buf))
+ {
+ if(addConfigFile(val, buf) != RESULT_SUCCESS)
+ printf("nvserver error:config %s error!\n", buf);
+ }
+ }
+
+ fclose(fp);
+
+ configdir(NV_FS_MAIN_PATH);
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvDirInit
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int nvDirInit()
+{
+ if(access(NV_FS_PATH, F_OK) != 0)
+ {
+ if(mkdir(NV_FS_PATH, 0755) != 0)
+ {
+ printf("nerver mkdir %s fali,errno=%d\n", NV_FS_PATH, errno);
+ return -1;
+ }
+
+ if(mkdir(NV_FS_MAIN_PATH, 0755) != 0)
+ {
+ printf("nerver mkdir %s fali,errno=%d\n", NV_FS_MAIN_PATH, errno);
+ return -1;
+ }
+
+ if(mkdir(NV_FS_BACKUP_PATH, 0755) != 0)
+ {
+ printf("nerver mkdir %s fali,errno=%d\n", NV_FS_BACKUP_PATH, errno);
+ return -1;
+ }
+ }
+ else
+ {
+ if(access(NV_FS_MAIN_PATH, F_OK) != 0)
+ {
+ if(mkdir(NV_FS_MAIN_PATH, 0755) != 0)
+ {
+ printf("nerver mkdir %s fali,errno=%d\n", NV_FS_MAIN_PATH, errno);
+ return -1;
+ }
+ }
+
+ if(access(NV_FS_BACKUP_PATH, F_OK) != 0)
+ {
+ if(mkdir(NV_FS_BACKUP_PATH, 0755) != 0)
+ {
+ printf("nerver mkdir %s fali,errno=%d\n", NV_FS_BACKUP_PATH, errno);
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvInit
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static void nvInit()
+{
+ T_NV_NODE *list = NULL;
+ char nvMainFile[NV_PATH_LEN] = {0};
+ char nvBackupFile[NV_PATH_LEN] = {0};
#ifdef FOTA_AB
-T_FLAGS_INFO flags_info={(0xc88+3690-0x1af2)};int ret=(0x2+587-0x24d);
+ T_FLAGS_INFO flags_info = {0};
+ int ret = 0;
#endif
-for(list=nv_list;list;list=list->next){snprintf(nvMainFile,NV_PATH_LEN,
-"\x25\x73\x2f\x25\x73",NV_FS_MAIN_PATH,list->nvFile);snprintf(nvBackupFile,
-NV_PATH_LEN,"\x25\x73\x2f\x25\x73",NV_FS_BACKUP_PATH,list->nvFile);if(checkNvFs(
-nvMainFile)){if(!checkNvFs(nvBackupFile))restoreNvFs(nvBackupFile,nvMainFile);}
-else if(checkNvFs(nvBackupFile)){restoreNvFs(nvMainFile,nvBackupFile);}else{
-loadFactroyParam(list);nvcommit(list->nvFile);continue;}loadNvFs(list->nvFile);
-if(!strcmp(list->nvFile,NV_CFG)&&get_update_status()==(0x89+9653-0x263c)){
-reloadFactroyParam(list);delete_not_needed(list);nvcommit(list->nvFile);
+
+ for(list = nv_list; list; list = list->next)
+ {
+ snprintf(nvMainFile, NV_PATH_LEN, "%s/%s", NV_FS_MAIN_PATH, list->nvFile);
+ snprintf(nvBackupFile, NV_PATH_LEN, "%s/%s", NV_FS_BACKUP_PATH, list->nvFile);
+
+ if(checkNvFs(nvMainFile))
+ {
+ if(!checkNvFs(nvBackupFile))
+ restoreNvFs(nvBackupFile, nvMainFile);
+ }
+ else if(checkNvFs(nvBackupFile))
+ {
+ restoreNvFs(nvMainFile, nvBackupFile);
+ }
+ else
+ {
+ loadFactroyParam(list);
+ nvcommit(list->nvFile);
+ continue;
+ }
+
+ loadNvFs(list->nvFile);
+ if(!strcmp(list->nvFile, NV_CFG) && get_update_status() == 2 ){
+ reloadFactroyParam(list);
+ delete_not_needed(list);
+ nvcommit(list->nvFile);
#ifdef FOTA_AB
-ret=flags_get(&flags_info);flags_info.boot_fota_flag.fota_status=
-(0xfc6+4638-0x21e4);ret=flags_set(&flags_info);
+ ret = flags_get(&flags_info);
+ flags_info.boot_fota_flag.fota_status = 0;
+ ret = flags_set(&flags_info);
#endif
-}}}uint hash(const char*s){uint hash=(0x537+6036-0x1ccb);while(*s){hash=
-NV_HASH_MUL*hash+*s++;}return hash;}static int loadFactroyParam(T_NV_NODE*list){
-char*val=NULL;FILE*fp=NULL;T_NV_CONFIG*config=NULL;char buf[NV_MAX_ITEM_LEN]={
-(0x1d8+9324-0x2644)};for(config=list->fileList;config;config=config->next){fp=
-fopen(config->configFile,"\x72\x6f");if(!fp){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x6f\x70\x65\x6e\x20\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x21" "\n"
-,config->configFile,errno);return RESULT_FILE_OPEN_FAIL;}while(fgets(buf,
-NV_MAX_ITEM_LEN,fp)){if(buf[(0x1277+4187-0x22d2)]=='\n'||buf[(0x6ff+8141-0x26cc)
-]==((char)(0xd0a+3970-0x1c69)))continue;val=strchr(buf,
-((char)(0x1486+1381-0x19ae)));if(!val){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x6f\x72\x6d\x61\x74\x20\x65\x72\x72\x6f\x72\x3a\x73\x74\x72\x69\x6e\x67\x20\x3d\x20\x25\x73" "\n"
-,config->configFile,buf);continue;}if(buf[strlen(buf)-(0x75c+239-0x84a)]=='\n')
-buf[strlen(buf)-(0x104+6728-0x1b4b)]='\0';*val++='\0';nvset(list->nvFile,buf,val
-,(0x134a+1615-0x1998));}printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6c\x6f\x61\x64\x46\x61\x63\x74\x72\x6f\x79\x50\x61\x72\x61\x6d\x20\x25\x73\x21" "\n"
-,config->configFile);fclose(fp);}return RESULT_SUCCESS;}static bool checkNvFs(
-char*file){int len=(0xb72+5012-0x1f06);int cnt=(0x354+6751-0x1db3);FILE*fp=NULL;
-char*buf=NULL;struct stat statbuff={(0xdb8+3546-0x1b92)};if(stat(file,&statbuff)
-<(0x244+1296-0x754))return false;len=statbuff.st_size;if(len<NV_CHECK_SIZE)
-return false;fp=fopen(file,"\x72\x6f");if(!fp)return false;buf=(char*)malloc(len
-);if(!buf){fclose(fp);return false;}cnt=(0x2075+1098-0x24bf);while(cnt<len){cnt=
-cnt+fread(buf+cnt,(0xc34+187-0xcee),len-cnt,fp);if(ferror(fp)){clearerr(fp);free
-(buf);fclose(fp);return false;}}if(len!=cnt){free(buf);fclose(fp);return false;}
-if(getSum(buf,len-NV_CHECK_SIZE)+NV_FILE_FLAG!=*(uint*)(buf+len-NV_CHECK_SIZE)){
-free(buf);fclose(fp);return false;}free(buf);fclose(fp);return true;}static int
-copyfile(const char*from,const char*to){int fd_to;int fd_from;char buf[
-(0x12b8+6770-0x1d2a)];ssize_t nread;int ret=-(0x480+3392-0x11bf);fd_from=open(
-from,O_RDONLY);if(fd_from<(0x70+5260-0x14fc))return-(0x15ec+4222-0x2668);fd_to=
-open(to,O_RDWR|O_CREAT|O_TRUNC|O_SYNC,(0xb21+4555-0x1b4c));if(fd_to<
-(0x795+6002-0x1f07)){ret=-(0x1562+3795-0x2432);goto out_error;}while(
-(0x434+8843-0x26be)){char*out_ptr;ssize_t nwritten;nread=read(fd_from,buf,sizeof
-(buf));if(nread==(0x6d5+8193-0x26d6)){break;}else{if(nread<(0x7bb+3192-0x1433)){
-if(errno==EINTR||errno==EAGAIN){continue;}else{ret=-(0x1588+717-0x1851);goto
-out_error;}}}out_ptr=buf;do{nwritten=write(fd_to,out_ptr,nread);if(nwritten>
-(0x9aa+1698-0x104c)){nread-=nwritten;out_ptr+=nwritten;}else{if(nwritten<
-(0xe7d+77-0xeca)){if(errno==EINTR||errno==EAGAIN){continue;}else{ret=-
-(0xc34+1310-0x114d);goto out_error;}}}}while(nread>(0x726+5923-0x1e49));}ret=
-fsync(fd_to);if(ret<(0x48f+5872-0x1b7f)){printf(
-"\x53\x79\x6e\x63\x20\x46\x61\x69\x6c\x65\x64\x3a\x25\x73\x2c\x20\x66\x69\x6c\x65\x20\x70\x61\x74\x68\x3a\x25\x73"
-,strerror(errno),to);goto out_error;}if(close(fd_to)<(0x1306+2532-0x1cea)){fd_to
-=-(0x10e4+4316-0x21bf);ret=-(0x2df+1211-0x794);goto out_error;}close(fd_from);
-return(0x1cd4+1409-0x2255);out_error:printf(
-"\x63\x6f\x70\x79\x66\x69\x6c\x65\x20\x25\x73\x20\x74\x6f\x20\x25\x73\x20\x65\x72\x72\x6f\x72\x3a\x25\x64" "\n"
-,from,to,ret);close(fd_from);if(fd_to>=(0xc25+185-0xcde))close(fd_to);return ret
-;}static int restoreNvFs(char*dstFile,char*srcFile){if(copyfile(srcFile,dstFile)
-!=(0xf14+2971-0x1aaf))return RESULT_FAIL;return RESULT_SUCCESS;}static int
-loadNvFs(char*file){int len=(0x2dc+4597-0x14d1);int cnt=(0x2d4+9022-0x2612);FILE
-*fp=NULL;char*buf=NULL;char*name=NULL;char*value=NULL;char*eq=NULL;struct stat
-statbuff={(0xbf6+3098-0x1810)};char nvFile[NV_PATH_LEN]={(0x1971+3000-0x2529)};
-sprintf(nvFile,"\x25\x73\x2f\x25\x73",NV_FS_MAIN_PATH,file);if(stat(nvFile,&
-statbuff)<(0x762+4454-0x18c8))return RESULT_FAIL;len=statbuff.st_size;if(
-NV_CHECK_SIZE>len)return RESULT_FAIL;fp=fopen(nvFile,"\x72\x6f");if(!fp)return
-RESULT_FILE_OPEN_FAIL;len=len-NV_CHECK_SIZE;buf=(char*)malloc(len+
-(0x1ba2+1756-0x227d));if(!buf){fclose(fp);return RESULT_MALLOC_FAIL;}memset(buf,
-(0xc11+5775-0x22a0),len+(0xf89+3474-0x1d1a));cnt=(0xa33+4352-0x1b33);while(cnt<
-len){cnt=cnt+fread(buf+cnt,(0x1477+4008-0x241e),len-cnt,fp);if(ferror(fp)){
-clearerr(fp);fclose(fp);free(buf);return RESULT_FILE_READ_FAIL;}}if(cnt!=len){
-fclose(fp);free(buf);return RESULT_FILE_READ_FAIL;}buf[len]='\0';name=buf;while(
-*name){if(!(eq=strchr(name,((char)(0x2277+449-0x23fb))))){break;}*eq='\0';value=
-eq+(0x1898+637-0x1b14);nvset(file,name,value,(0x14cc+904-0x1853));*eq=
-((char)(0x323+4632-0x14fe));name=value+strlen(value)+(0x383+4424-0x14ca);}free(
-buf);fclose(fp);return RESULT_SUCCESS;}static void analyMsg(T_NV_MSG_INFO*
-msgrecv,T_NV_MSG_RESULT*msgsnd){switch(msgrecv->nvType){case MSG_GET:msgsnd->
-result=nvget(msgrecv->file,msgrecv->key,msgsnd->value);break;case MSG_SET:msgsnd
-->result=nvset(msgrecv->file,msgrecv->key,msgrecv->value,msgrecv->saveflag);
-break;case MSG_UNSET:msgsnd->result=nvunset(msgrecv->file,msgrecv->key);break;
-case MSG_CLEAR:msgsnd->result=nvclear(msgrecv->file);break;case MSG_RESET:msgsnd
-->result=nvreset(msgrecv->file);break;case MSG_SHOW:msgsnd->result=saveNvFs(
-msgrecv->file,NV_FS_SHOW);;break;case MSG_COMMIT:msgsnd->result=nvcommit(msgrecv
-->file);break;default:break;}msgsnd->msgType=msgrecv->pid;msgsnd->msgIndex=
-msgrecv->msgIndex;}static int addConfigFile(char*nvFile,char*configFile){
-T_NV_NODE*list=NULL;T_NV_NODE*newList=NULL;T_NV_CONFIG*newConfig=NULL;if(!nvFile
-){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x70\x61\x72\x61\x6d\x20\x69\x6c\x6c\x65\x67\x61\x6c\x21" "\n"
-);return RESULT_INVAL;}if(configFile){newConfig=(T_NV_CONFIG*)malloc(sizeof(
-T_NV_CONFIG));if(!newConfig)return RESULT_MALLOC_FAIL;strncpy(newConfig->
-configFile,configFile,NV_PATH_LEN-(0x3d9+364-0x544));newConfig->configFile[
-NV_PATH_LEN-(0x17d1+2559-0x21cf)]='\0';newConfig->next=NULL;}for(list=nv_list;
-list;list=list->next){if(strcmp(list->nvFile,nvFile)==(0x1e00+1484-0x23cc))break
-;}if(!list){newList=(T_NV_NODE*)malloc(sizeof(T_NV_NODE));if(!newList){if(
-newConfig)free(newConfig);return RESULT_MALLOC_FAIL;}newList->next=NULL;strncpy(
-newList->nvFile,nvFile,NV_PATH_LEN-(0x324+1980-0xadf));newList->nvFile[
-NV_PATH_LEN-(0x955+3249-0x1605)]='\0';memset(newList->nvTable,
-(0xc52+4853-0x1f47),NV_HASH_LEN*(0x73a+6839-0x21ed));newList->fileList=newConfig
-;if(!nv_list)nv_list=newList;else{newList->next=nv_list->next;nv_list->next=
-newList;}}else if(!list->fileList)list->fileList=newConfig;else{if(newConfig==
-NULL)return RESULT_FAIL;newConfig->next=list->fileList->next;list->fileList->
-next=newConfig;}return RESULT_SUCCESS;}static bool isCfgConfiged(char*configFile
-){T_NV_NODE*list=NULL;T_NV_CONFIG*config=NULL;for(list=nv_list;list;list=list->
-next){for(config=list->fileList;config;config=config->next){if(!strcmp(config->
-configFile,configFile))return true;}}return false;}static bool isNvConfiged(char
-*nvFile){T_NV_NODE*list=NULL;for(list=nv_list;list;list=list->next){if(!strcmp(
-list->nvFile,nvFile))return true;}return false;}static uint getSum(const char*s,
-int len){uint sum=(0x1ddf+172-0x1e8b);char*data=(char*)s;while(len-- >
-(0x549+1618-0xb9b)){sum+=(*data++);}return sum;}static int saveNvFs(char*nvName,
-char*nvFile){int i=(0x826+6755-0x2289);int sum=(0x752+3072-0x1352);int bufSize=
-(0x153+1357-0x6a0);int itemSize=(0x1b65+2062-0x2373);int ret=(0x93d+3433-0x16a6)
-;int fp=(0x454+794-0x76e);char*buf=NULL;T_NV_NODE*list=NULL;T_NV_ITEM*item=NULL;
-for(list=nv_list;list;list=list->next){if(strcmp(list->nvFile,nvName))continue;
-fp=open(nvFile,O_SYNC|O_RDWR|O_CREAT|O_TRUNC,(0x43c+8005-0x21e1));if(fp==-
-(0xa35+228-0xb18)){printf(
-"\x6f\x70\x65\x6e\x20\x25\x73\x20\x66\x61\x69\x6c\x2c\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,nvFile,errno);return RESULT_FILE_OPEN_FAIL;}buf=(char*)malloc(NV_BLOCK_SIZE);if
-(!buf){close(fp);return RESULT_MALLOC_FAIL;}for(i=(0xf16+2821-0x1a1b);i<
-NV_HASH_LEN;i++){for(item=list->nvTable[i];item;item=item->next){if(strcmp(
-nvFile,NV_FS_SHOW)&&!item->saveFlag)continue;itemSize=strlen(item->key)+strlen(
-item->value)+(0x13b4+2864-0x1ee2);if(bufSize+itemSize>NV_BLOCK_SIZE){if(write(fp
-,buf,bufSize)<(0x284+1627-0x8df)){printf(
-"\x65\x72\x72\x6f\x72\x20\x25\x73\x20\x25\x64\x3a\x20\x77\x72\x69\x74\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,__FILE__,__LINE__,errno);close(fp);free(buf);return RESULT_FILE_WRITE_FAIL;}sum
-+=getSum(buf,bufSize);bufSize=(0x17b2+3190-0x2428);}sprintf(buf+bufSize,
-"\x25\x73\x3d\x25\x73",item->key,item->value);bufSize+=itemSize;}}if(bufSize!=
-(0x983+5619-0x1f76)){if(write(fp,buf,bufSize)<(0x3c2+4379-0x14dd)){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x77\x72\x69\x74\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,errno);close(fp);free(buf);return RESULT_FILE_WRITE_FAIL;}sum+=getSum(buf,
-bufSize);}sum+=NV_FILE_FLAG;if(write(fp,&sum,NV_CHECK_SIZE)<(0x181b+3703-0x2692)
-){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x20\x77\x72\x69\x74\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64" "\n"
-,errno);close(fp);free(buf);return RESULT_FILE_WRITE_FAIL;}ret=fsync(fp);free(
-buf);close(fp);if(ret<(0x1837+246-0x192d)){printf(
-"\x53\x79\x6e\x63\x20\x46\x61\x69\x6c\x65\x64\x3a\x25\x73\x2c\x20\x66\x69\x6c\x65\x20\x70\x61\x74\x68\x3a\x25\x73"
-,strerror(errno),nvFile);return ret;}return RESULT_SUCCESS;}return
-RESULT_NO_FILE;}static int nvget(char*file,char*key,char*value){int index=
-(0x1d3+4764-0x146f);T_NV_NODE*list=NULL;T_NV_ITEM*item=NULL;for(list=nv_list;
-list;list=list->next){if(strcmp(list->nvFile,file))continue;index=hash(key)%
-NV_HASH_LEN;for(item=list->nvTable[index];item;item=item->next){if(strcmp(item->
-key,key))continue;strncpy(value,item->value,NV_MAX_VAL_LEN-(0xd5a+4074-0x1d43));
-value[NV_MAX_VAL_LEN-(0x9b3+2600-0x13da)]='\0';return RESULT_SUCCESS;}}return
-RESULT_NO_ITEM;}static int nvset(char*file,const char*key,const char*value,int
-saveFlag){int index=(0xd0c+552-0xf34);int ret=(0x8a5+3844-0x17a9);int
-key_buf_len=(0x10ea+785-0x13fb);int value_buf_len=(0x465+6781-0x1ee2);T_NV_NODE*
-list=NULL;T_NV_ITEM*item=NULL;T_NV_ITEM*newItem=NULL;if(NULL==key||NULL==value)
-return RESULT_FAIL;key_buf_len=strlen(key)+(0x4c8+3774-0x1385);value_buf_len=
-strlen(value)+(0xd44+3765-0x1bf8);for(list=nv_list;list;list=list->next){if(
-strcmp(list->nvFile,file))continue;index=hash(key)%NV_HASH_LEN;for(item=list->
-nvTable[index];item;item=item->next){if(strcmp(item->key,key))continue;if(
-saveFlag)item->saveFlag=saveFlag;if(!strcmp(item->value,value))return
-RESULT_SUCCESS;free(item->value);item->value=(char*)malloc(value_buf_len);if(!
-item->value)return RESULT_MALLOC_FAIL;strncpy(item->value,value,value_buf_len-
-(0x293+6898-0x1d84));item->value[value_buf_len-(0xdfb+2094-0x1628)]='\0';return
-RESULT_SUCCESS;}newItem=(T_NV_ITEM*)malloc(sizeof(T_NV_ITEM));if(!newItem)return
- RESULT_MALLOC_FAIL;newItem->key=(char*)malloc(key_buf_len);if(!newItem->key){
-free(newItem);return RESULT_MALLOC_FAIL;}newItem->value=(char*)malloc(
-value_buf_len);if(!newItem->value){free(newItem->key);free(newItem);return
-RESULT_MALLOC_FAIL;}strncpy(newItem->key,key,key_buf_len-(0x68f+1599-0xccd));
-newItem->key[key_buf_len-(0x237+1412-0x7ba)]='\0';strncpy(newItem->value,value,
-value_buf_len-(0x10b8+4596-0x22ab));newItem->value[value_buf_len-
-(0x13a4+4644-0x25c7)]='\0';newItem->next=NULL;newItem->saveFlag=saveFlag;newItem
-->update_flag=(0xca1+6650-0x269b);if(!list->nvTable[index])list->nvTable[index]=
-newItem;else{newItem->next=list->nvTable[index]->next;list->nvTable[index]->next
-=newItem;}return RESULT_SUCCESS;}ret=addConfigFile(file,NULL);if(ret==
-RESULT_SUCCESS)return nvset(file,key,value,saveFlag);else return ret;}static int
- nvunset(char*file,char*key){int index=(0x16f7+1158-0x1b7d);T_NV_NODE*list=NULL;
-T_NV_ITEM*item=NULL;T_NV_ITEM*prev=NULL;for(list=nv_list;list;list=list->next){
-if(strcmp(list->nvFile,file))continue;index=hash(key)%NV_HASH_LEN;for(item=list
-->nvTable[index];item;prev=item,item=item->next){if(strcmp(item->key,key))
-continue;if(!prev)list->nvTable[index]=item->next;else prev->next=item->next;
-free(item->key);free(item->value);free(item);return RESULT_SUCCESS;}}return
-RESULT_NO_ITEM;}static int nvreset(char*file){int ret=(0x7c0+7258-0x241a);
-T_NV_NODE*list=NULL;for(list=nv_list;list;list=list->next){if(strcmp(list->
-nvFile,file))continue;ret=nvclear(file);if(ret!=RESULT_SUCCESS)return ret;if(
-loadFactroyParam(list)!=RESULT_SUCCESS)return RESULT_FAIL;return nvcommit(file);
-}return RESULT_NO_FILE;}static int nvclear(char*file){int i=(0xdd0+17-0xde1);
-T_NV_NODE*list=NULL;T_NV_ITEM*cur=NULL;T_NV_ITEM*item=NULL;for(list=nv_list;list
-;list=list->next){if(strcmp(list->nvFile,file))continue;for(i=(0x104+605-0x361);
-i<NV_HASH_LEN;i++){for(item=list->nvTable[i];item;){cur=item;item=item->next;
-free(cur->key);free(cur->value);free(cur);}list->nvTable[i]=NULL;}return
-RESULT_SUCCESS;}return RESULT_NO_FILE;}static int nvcommit(char*file){int ret=
-(0x115c+3316-0x1e50);char nvMainFile[NV_PATH_LEN]={(0x21f+8420-0x2303)};char
-nvBackupFile[NV_PATH_LEN]={(0xdf0+4084-0x1de4)};sprintf(nvMainFile,
-"\x25\x73\x2f\x25\x73",NV_FS_MAIN_PATH,file);sprintf(nvBackupFile,
-"\x25\x73\x2f\x25\x73",NV_FS_BACKUP_PATH,file);ret=saveNvFs(file,nvMainFile);if(
-ret!=RESULT_SUCCESS)return ret;return restoreNvFs(nvBackupFile,nvMainFile);}
+ }
+ }
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: hash
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: hash value
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+uint hash(const char *s)
+{
+ uint hash = 0;
+
+ while (*s)
+ {
+ hash = NV_HASH_MUL * hash + *s++;
+ }
+
+ return hash;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: loadFactroyParam
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) list
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: 0±íʾ³É¹¦ -1±íʾʧ°Ü
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int loadFactroyParam(T_NV_NODE *list)
+{
+ char *val = NULL;
+ FILE *fp = NULL;
+ T_NV_CONFIG *config = NULL;
+ char buf[NV_MAX_ITEM_LEN] = {0};
+
+ for(config = list->fileList; config; config = config->next)
+ {
+ fp = fopen(config->configFile, "ro");
+ if(!fp)
+ {
+ printf("nvserver error:open %s file fail errno = %d!\n", config->configFile, errno);
+ return RESULT_FILE_OPEN_FAIL;
+ }
+
+ while (fgets(buf, NV_MAX_ITEM_LEN, fp))
+ {
+ if (buf[0] == '\n' || buf[0] == '#')
+ continue;
+
+ val = strchr(buf, '=');
+ if (!val)
+ {
+ printf("nvserver error:%s file format error:string = %s\n", config->configFile, buf);
+ continue;
+ }
+
+ /*strip line break,the last line may not have a line break*/
+ if (buf[strlen(buf) - 1] == '\n')
+ buf[strlen(buf) - 1] = '\0';
+
+ *val++ = '\0';
+
+ nvset(list->nvFile, buf, val, 1);
+ }
+ printf("nvserver loadFactroyParam %s!\n", config->configFile);
+ fclose(fp);
+ }
+
+ return RESULT_SUCCESS;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: checkNvFs
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) void
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: bool
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static bool checkNvFs(char *file)
+{
+ int len = 0;
+ int cnt = 0;
+ FILE * fp = NULL;
+ char * buf = NULL;
+ struct stat statbuff = {0};
+
+ if(stat(file, &statbuff) < 0)
+ return false;
+
+ len = statbuff.st_size;
+ if(len < NV_CHECK_SIZE)
+ return false;
+
+ fp = fopen(file, "ro");
+ if (!fp)
+ return false;
+
+ buf = (char *)malloc(len);
+ if(!buf)
+ {
+ fclose(fp);
+ return false;
+ }
+
+ cnt = 0;
+ while (cnt < len)
+ {
+ cnt = cnt + fread(buf + cnt, 1, len - cnt, fp);
+ if (ferror(fp))
+ {
+ clearerr(fp);
+ free(buf);
+ fclose(fp);
+ return false;
+ }
+ }
+ if (len != cnt)
+ {
+ free(buf);
+ fclose(fp);
+ return false;
+ }
+
+ if(getSum(buf, len - NV_CHECK_SIZE) + NV_FILE_FLAG != *(uint *)(buf + len - NV_CHECK_SIZE))
+ {
+ free(buf);
+ fclose(fp);
+ return false;
+ }
+
+ free(buf);
+ fclose(fp);
+
+ return true;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: copyfile
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) to:Ä¿±êÎļþ
+* (´«Èë²ÎÊý) from:Ô´Îļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦,¸ºÖµÊ§°Ü
+* ÆäËü˵Ã÷:
+*******************************************************************************/
+static int copyfile(const char *from, const char *to)
+{
+ int fd_to;
+ int fd_from;
+ char buf[4096];
+ ssize_t nread;
+ int ret = -1;
+
+ fd_from = open(from, O_RDONLY);
+ if (fd_from < 0)
+ return -2;
+
+ fd_to = open(to, O_RDWR | O_CREAT | O_TRUNC | O_SYNC, 0640);
+ if (fd_to < 0) {
+ ret = -3;
+ goto out_error;
+ }
+
+ while (1)
+ {
+ char *out_ptr;
+ ssize_t nwritten;
+
+ nread = read(fd_from, buf, sizeof(buf));
+ if (nread == 0)
+ {
+ break; /* read file done*/
+ }
+ else
+ {
+ if (nread < 0 )
+ {
+ if (errno == EINTR || errno == EAGAIN)
+ {
+ continue;
+ }
+ else
+ {
+ ret = -4;
+ goto out_error;
+ }
+ }
+ }
+
+ out_ptr = buf;
+ do
+ {
+ nwritten = write(fd_to, out_ptr, nread);
+ if (nwritten > 0)
+ {
+ nread -= nwritten;
+ out_ptr += nwritten;
+ }
+ else
+ {
+ if (nwritten < 0)
+ {
+ if (errno == EINTR || errno == EAGAIN)
+ {
+ continue;
+ }
+ else
+ {
+ ret = -5;
+ goto out_error;
+ }
+ }
+ }
+ } while (nread > 0);
+ }
+
+ ret = fsync(fd_to);
+ if (ret < 0) {
+ printf("Sync Failed:%s, file path:%s", strerror(errno), to);
+ goto out_error;
+ }
+
+ if (close(fd_to) < 0)
+ {
+ fd_to = -1;
+ ret = -6;
+ goto out_error;
+ }
+ close(fd_from);
+
+ /* Success! */
+ return 0;
+
+out_error:
+ printf("copyfile %s to %s error:%d\n", from, to, ret);
+ close(fd_from);
+ if (fd_to >= 0)
+ close(fd_to);
+
+ return ret;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: restoreNvFs
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) dstFile:Ä¿±êÎļþ
+* (´«Èë²ÎÊý) srcFile:Ô´Îļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int restoreNvFs(char *dstFile, char *srcFile)
+{
+ if (copyfile(srcFile, dstFile) != 0)
+ return RESULT_FAIL;
+
+ return RESULT_SUCCESS;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: loadNvFs
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int loadNvFs(char *file)
+{
+ int len = 0;
+ int cnt = 0;
+ FILE *fp = NULL;
+ char *buf = NULL;
+ char *name = NULL;
+ char *value = NULL;
+ char *eq = NULL;
+
+ struct stat statbuff = {0};
+ char nvFile[NV_PATH_LEN] = {0};
+
+ sprintf(nvFile, "%s/%s", NV_FS_MAIN_PATH, file);
+
+ if(stat(nvFile, &statbuff) < 0)
+ return RESULT_FAIL;
+
+ len = statbuff.st_size;
+ if(NV_CHECK_SIZE > len)
+ return RESULT_FAIL;
+
+ fp = fopen(nvFile, "ro");
+ if (!fp)
+ return RESULT_FILE_OPEN_FAIL;
+
+ len = len - NV_CHECK_SIZE;
+ buf = (char *)malloc(len + 1);
+ if(!buf)
+ {
+ fclose(fp);
+ return RESULT_MALLOC_FAIL;
+ }
+ memset(buf, 0, len + 1);
+
+ cnt = 0;
+ while (cnt < len)
+ {
+ cnt = cnt + fread(buf + cnt, 1, len - cnt, fp);
+ if (ferror(fp))
+ {
+ clearerr(fp);
+ fclose(fp);
+ free(buf);
+ return RESULT_FILE_READ_FAIL;
+ }
+ }
+ if (cnt != len)
+ {
+ fclose(fp);
+ free(buf);
+ return RESULT_FILE_READ_FAIL;
+ }
+
+ buf[len] = '\0'; /* fix warning for coverity */
+ name = buf;
+ while(*name)
+ {
+ if (!(eq = strchr(name, '=')))
+ {
+ break;
+ }
+ *eq = '\0';
+ value = eq + 1;
+
+ nvset(file, name, value, 1);
+
+ *eq = '=';
+ name = value + strlen(value) + 1;
+ }
+
+ free(buf);
+ fclose(fp);
+
+ return RESULT_SUCCESS;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: analyMsg
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) msgrecv:½ÓÊÕÏûÏ¢
+* (´«³ö²ÎÊý) msgsnd:·¢ËÍÏûÏ¢
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static void analyMsg(T_NV_MSG_INFO *msgrecv, T_NV_MSG_RESULT *msgsnd)
+{
+ switch(msgrecv->nvType)
+ {
+ case MSG_GET:
+ msgsnd->result = nvget(msgrecv->file, msgrecv->key, msgsnd->value);
+ break;
+ case MSG_SET:
+ msgsnd->result = nvset(msgrecv->file, msgrecv->key, msgrecv->value, msgrecv->saveflag);
+ break;
+ case MSG_UNSET:
+ msgsnd->result = nvunset(msgrecv->file, msgrecv->key);
+ break;
+ case MSG_CLEAR:
+ msgsnd->result = nvclear(msgrecv->file);
+ break;
+ case MSG_RESET:
+ msgsnd->result = nvreset(msgrecv->file);
+ break;
+ case MSG_SHOW:
+ msgsnd->result = saveNvFs(msgrecv->file, NV_FS_SHOW);;
+ break;
+ case MSG_COMMIT:
+ msgsnd->result = nvcommit(msgrecv->file);
+ break;
+ default:
+ break;
+ }
+
+ msgsnd->msgType = msgrecv->pid;
+ msgsnd->msgIndex = msgrecv->msgIndex;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: addConfigFile
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) nvFile:nvÎļþ
+* (´«Èë²ÎÊý) configFile:ÅäÖÃÎļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int addConfigFile(char *nvFile, char *configFile)
+{
+ T_NV_NODE *list = NULL;
+ T_NV_NODE *newList = NULL;
+ T_NV_CONFIG *newConfig = NULL;
+
+ if(!nvFile)
+ {
+ printf("nvserver error: param illegal!\n");
+ return RESULT_INVAL;
+ }
+
+ if(configFile)// nv has no config file
+ {
+ newConfig = (T_NV_CONFIG * )malloc(sizeof(T_NV_CONFIG));
+ if(!newConfig)
+ return RESULT_MALLOC_FAIL;
+
+ strncpy(newConfig->configFile, configFile, NV_PATH_LEN - 1);
+ newConfig->configFile[NV_PATH_LEN - 1] = '\0';
+ newConfig->next = NULL;
+ }
+
+ for(list = nv_list; list; list =list->next)
+ {
+ if(strcmp(list->nvFile, nvFile) == 0)
+ break;
+ }
+
+ if(!list) //can't fine the nv
+ {
+ newList = (T_NV_NODE *)malloc(sizeof(T_NV_NODE));
+ if(!newList)
+ {
+ if(newConfig)
+ free(newConfig);
+ return RESULT_MALLOC_FAIL;
+ }
+
+ newList->next = NULL;
+ strncpy(newList->nvFile, nvFile, NV_PATH_LEN - 1);
+ newList->nvFile[NV_PATH_LEN - 1] = '\0';
+ memset(newList->nvTable, 0, NV_HASH_LEN * 4);
+
+ newList->fileList = newConfig;
+
+ if(!nv_list)
+ nv_list = newList;
+ else
+ {
+ newList->next = nv_list->next;
+ nv_list->next = newList;
+ }
+ }
+ else if(!list->fileList) //can't fine the filelist
+ list->fileList = newConfig;
+ else //can't fine the file
+ {
+ if(newConfig == NULL)
+ return RESULT_FAIL;
+ newConfig->next = list->fileList->next;
+ list->fileList->next = newConfig;
+ }
+
+ return RESULT_SUCCESS;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: isConfiged
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) configFile:ÅäÖÃÎļþÃû
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static bool isCfgConfiged(char *configFile)
+{
+ T_NV_NODE *list = NULL;
+ T_NV_CONFIG *config = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ for(config = list->fileList; config; config = config->next)
+ {
+ if(!strcmp(config->configFile, configFile))
+ return true;
+ }
+ }
+ return false;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: isNvConfiged
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) configFile:ÅäÖÃÎļþÃû
+* ·µ »Ø Öµ: void
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static bool isNvConfiged(char *nvFile)
+{
+ T_NV_NODE *list = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(!strcmp(list->nvFile, nvFile))
+ return true;
+ }
+ return false;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: getSum
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) s:×Ö·û´®»º³å
+* ·µ »Ø Öµ: sumÊýÖµ
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static uint getSum(const char *s, int len)
+{
+ uint sum = 0;
+ char *data = (char*)s;
+
+ while (len-- > 0)
+ {
+ sum += (*data++);
+ }
+
+ return sum;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: saveNvFs
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) nvName:nvÎļþÃû
+* (´«Èë²ÎÊý) nvFile:nv±£´æÎļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int saveNvFs(char *nvName, char *nvFile)
+{
+ int i = 0;
+ int sum = 0;
+ int bufSize = 0;
+ int itemSize = 0;
+ int ret = 0;
+ int fp = 0;
+ char *buf = NULL;
+ T_NV_NODE * list = NULL;
+ T_NV_ITEM * item = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, nvName))
+ continue;
+
+ fp= open(nvFile, O_SYNC | O_RDWR | O_CREAT | O_TRUNC, 0640);
+ if(fp == -1)
+ {
+ printf("open %s fail,errno = %d\n", nvFile, errno);
+ return RESULT_FILE_OPEN_FAIL;
+ }
+
+ buf = (char *)malloc(NV_BLOCK_SIZE);
+ if(!buf)
+ {
+ close(fp);
+ return RESULT_MALLOC_FAIL;
+ }
+
+ for(i = 0; i < NV_HASH_LEN; i ++)
+ {
+ for(item = list->nvTable[i]; item; item = item->next)
+ {
+ if(strcmp(nvFile, NV_FS_SHOW) && !item->saveFlag)
+ continue;
+
+ itemSize = strlen(item->key) + strlen(item->value) + 2;
+ if(bufSize + itemSize > NV_BLOCK_SIZE)
+ {
+ if(write(fp, buf, bufSize) < 0)
+ {
+ printf("error %s %d: write fail errno = %d\n", __FILE__, __LINE__, errno);
+ close(fp);
+ free(buf);
+ return RESULT_FILE_WRITE_FAIL;
+ }
+ sum += getSum(buf, bufSize);
+ bufSize = 0;
+ }
+
+ sprintf(buf + bufSize, "%s=%s", item->key, item->value);
+ bufSize += itemSize;
+ }
+ }
+
+ // last block
+ if(bufSize != 0)
+ {
+ if(write(fp, buf, bufSize) < 0)
+ {
+ printf("nvserver error: write fail errno = %d\n", errno);
+ close(fp);
+ free(buf);
+ return RESULT_FILE_WRITE_FAIL;
+ }
+ sum += getSum(buf, bufSize);
+ }
+ sum += NV_FILE_FLAG;
+
+ // write sum
+ if(write(fp, &sum, NV_CHECK_SIZE) < 0)
+ {
+ printf("nvserver error: write fail errno = %d\n", errno);
+ close(fp);
+ free(buf);
+ return RESULT_FILE_WRITE_FAIL;
+ }
+
+ ret = fsync(fp);
+
+ free(buf);
+ close(fp);
+
+ if (ret < 0) {
+ printf("Sync Failed:%s, file path:%s", strerror(errno), nvFile);
+ return ret;
+ }
+
+ return RESULT_SUCCESS;
+ }
+
+ return RESULT_NO_FILE;
+}
+
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvget
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* (´«Èë²ÎÊý) key:nvÏîÃû
+* (´«³ö²ÎÊý) value:nvÖµ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int nvget(char *file, char *key, char *value)
+{
+ int index = 0;
+ T_NV_NODE *list = NULL;
+ T_NV_ITEM *item = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, file))
+ continue;
+
+ index = hash(key) % NV_HASH_LEN;
+ for(item = list->nvTable[index]; item; item = item->next)
+ {
+ if(strcmp(item->key, key))
+ continue;
+
+ strncpy(value, item->value, NV_MAX_VAL_LEN - 1);
+ value[NV_MAX_VAL_LEN - 1] = '\0';
+ return RESULT_SUCCESS;
+ }
+ }
+
+ return RESULT_NO_ITEM;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvset
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* (´«Èë²ÎÊý) key:nvÏîÃû
+* (´«Èë²ÎÊý) value:nvÖµ
+* (´«Èë²ÎÊý) saveFlag:±£´æ±êÖ¾
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int nvset(char *file, const char *key, const char *value, int saveFlag)
+{
+ int index = 0;
+ int ret = 0;
+ int key_buf_len = 0;
+ int value_buf_len = 0;
+ T_NV_NODE *list = NULL;
+ T_NV_ITEM *item = NULL;
+ T_NV_ITEM *newItem = NULL;
+
+ if (NULL == key || NULL == value)
+ return RESULT_FAIL;
+
+ key_buf_len = strlen(key) + 1;
+ value_buf_len = strlen(value) + 1;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, file))
+ continue;
+
+ index = hash(key) % NV_HASH_LEN;
+ for(item = list->nvTable[index]; item; item = item->next)
+ {
+ // change item
+ if(strcmp(item->key, key))
+ continue;
+
+ if(saveFlag)
+ item->saveFlag = saveFlag;
+
+ if(!strcmp(item->value, value))
+ return RESULT_SUCCESS;
+
+ free(item->value);
+ item->value = (char *)malloc(value_buf_len);
+ if(!item->value)
+ return RESULT_MALLOC_FAIL;
+
+ strncpy(item->value, value, value_buf_len - 1);
+ item->value[value_buf_len - 1] = '\0';
+
+ return RESULT_SUCCESS;
+ }
+
+ // add item
+ newItem = (T_NV_ITEM *)malloc(sizeof(T_NV_ITEM ));
+ if(!newItem)
+ return RESULT_MALLOC_FAIL;
+
+ newItem->key = (char *)malloc(key_buf_len);
+ if(!newItem->key)
+ {
+ free(newItem);
+ return RESULT_MALLOC_FAIL;
+ }
+
+ newItem->value = (char *)malloc(value_buf_len);
+ if(!newItem->value)
+ {
+ free(newItem->key);
+ free(newItem);
+ return RESULT_MALLOC_FAIL;
+ }
+
+ strncpy(newItem->key, key, key_buf_len - 1);
+ newItem->key[key_buf_len - 1] = '\0';
+ strncpy(newItem->value, value, value_buf_len - 1);
+ newItem->value[value_buf_len - 1] = '\0';
+
+ newItem->next = NULL;
+ newItem->saveFlag = saveFlag;
+ newItem->update_flag=0;// 0: not update , 1: updated
+
+ if(!list->nvTable[index])
+ list->nvTable[index] = newItem;
+ else
+ {
+ newItem->next = list->nvTable[index]->next;
+ list->nvTable[index]->next = newItem;
+ }
+
+ return RESULT_SUCCESS;
+ }
+
+ // add nv
+ ret = addConfigFile(file, NULL);
+ if(ret == RESULT_SUCCESS)
+ return nvset(file, key, value, saveFlag);
+ else
+ return ret;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvunset
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* (´«Èë²ÎÊý) key:nvÏîÃû
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int nvunset(char * file, char *key)
+{
+ int index = 0;
+ T_NV_NODE *list = NULL;
+ T_NV_ITEM *item = NULL;
+ T_NV_ITEM *prev = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, file))
+ continue;
+
+ index = hash(key) % NV_HASH_LEN;
+ for(item = list->nvTable[index]; item; prev = item, item = item->next)
+ {
+ if(strcmp(item->key, key))
+ continue;
+
+ if(!prev)
+ list->nvTable[index] = item->next;
+ else
+ prev->next = item->next;
+
+ free(item->key);
+ free(item->value);
+ free(item);
+
+ return RESULT_SUCCESS;
+ }
+ }
+
+ return RESULT_NO_ITEM;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvreset
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: ɾ³ýnvÎļþ
+*******************************************************************************/
+static int nvreset(char *file)
+{
+ int ret = 0;
+ T_NV_NODE *list = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, file))
+ continue;
+
+ ret = nvclear(file);
+ if(ret != RESULT_SUCCESS)
+ return ret;
+
+ if(loadFactroyParam(list) != RESULT_SUCCESS)
+ return RESULT_FAIL;
+
+ return nvcommit(file);
+ }
+
+ return RESULT_NO_FILE;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvclear
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* ·µ »Ø Öµ: 0±íʾ³É¹¦
+* ÆäËü˵Ã÷: ²Á³ýÄÚ´ænv
+*******************************************************************************/
+static int nvclear(char *file)
+{
+ int i = 0;
+ T_NV_NODE *list = NULL;
+ T_NV_ITEM *cur = NULL;
+ T_NV_ITEM *item = NULL;
+
+ for(list = nv_list; list; list = list->next)
+ {
+ if(strcmp(list->nvFile, file))
+ continue;
+
+ for(i = 0; i < NV_HASH_LEN; i ++)
+ {
+ for(item = list->nvTable[i]; item; )
+ {
+ cur = item;
+ item = item->next;
+
+ free(cur->key);
+ free(cur->value);
+ free(cur);
+ }
+ list->nvTable[i] = NULL;
+ }
+
+ return RESULT_SUCCESS;
+ }
+
+ return RESULT_NO_FILE;
+}
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: nvcommit
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) file:nvÎļþ
+* ·µ »Ø Öµ: RESULT_SUCCESS±íʾ³É¹¦
+* ÆäËü˵Ã÷: void
+*******************************************************************************/
+static int nvcommit(char *file)
+{
+ int ret = 0;
+ char nvMainFile[NV_PATH_LEN] = {0};
+ char nvBackupFile[NV_PATH_LEN] = {0};
+
+ sprintf(nvMainFile, "%s/%s", NV_FS_MAIN_PATH, file);
+ sprintf(nvBackupFile, "%s/%s", NV_FS_BACKUP_PATH, file);
+
+ ret = saveNvFs(file, nvMainFile);
+ if(ret != RESULT_SUCCESS)
+ return ret;
+
+ return restoreNvFs(nvBackupFile, nvMainFile);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/ap/app/zte_comm/nvserver/nvupdate.c b/ap/app/zte_comm/nvserver/nvupdate.c
index 3028294..c2335a9 100755
--- a/ap/app/zte_comm/nvserver/nvupdate.c
+++ b/ap/app/zte_comm/nvserver/nvupdate.c
@@ -1,4 +1,19 @@
+/*******************************************************************************
+* °æÈ¨ËùÓÐ (C)2016, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ: nvserver.c
+* Îļþ±êʶ: nvserver.c
+* ÄÚÈÝÕªÒª: nvºǫ́ӦÓÃʵÏÖÎļþ
+*
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* ------------------------------------------------------------------------------
+* 2016/06/13 V1.0 Create ÁõÑÇÄÏ ´´½¨
+*
+*******************************************************************************/
+/*******************************************************************************
+* Í·Îļþ *
+*******************************************************************************/
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
@@ -10,115 +25,322 @@
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/msg.h>
+
#include "nvserver.h"
#include "nv_typedef.h"
#include <message.h>
#include <fota_common.h>
+
#ifdef FOTA_AB
#include "pub_flags.h"
#include "flags_api.h"
#endif
+
#ifdef __cplusplus
-extern"C"{
+extern "C" {
#endif
-extern T_NV_NODE*nv_list;
+
+/*******************************************************************************
+* ³£Á¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ºê¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* Êý¾ÝÀàÐͶ¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¾Ö²¿º¯ÊýÉùÃ÷ *
+*******************************************************************************/
+
+/*******************************************************************************
+* ¾Ö²¿¾²Ì¬±äÁ¿¶¨Òå *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Ö±äÁ¿¶¨Òå *
+*******************************************************************************/
+extern T_NV_NODE *nv_list;
+
+/*******************************************************************************
+* ¾Ö²¿º¯ÊýʵÏÖ *
+*******************************************************************************/
+
+/*******************************************************************************
+* È«¾Öº¯ÊýʵÏÖ *
+*******************************************************************************/
+//#define FOTA_UPDATE_STATUS_FILE "/cache/zte_fota/update_status"
#ifdef FOTA_AB
-int get_update_status(void){T_FLAGS_INFO flags_info={(0x11+8127-0x1fd0)};
-unsigned int status=(0x3ff+7834-0x2299);int ret=(0x47+9018-0x2381);ret=flags_get
-(&flags_info);status=flags_info.boot_fota_flag.fota_status;if(status==
-(0x4ed+645-0x771))return(0x18a3+3150-0x24ef);else return(0x11cb+3530-0x1f95);}
+int get_update_status (void)
+{
+ T_FLAGS_INFO flags_info = {0};
+ unsigned int status = 0;
+ int ret = 0;
+ ret = flags_get(&flags_info);
+ status = flags_info.boot_fota_flag.fota_status;
+
+ if (status == 1)
+ return 2;
+ else
+ return 0;
+}
#else
-int get_update_status(void){int update_status;FILE*fd=(0x864+4715-0x1acf);int
-ret;char*filename=NULL;if(access(FOTA_UPDATE_STATUS_FILE_OLD,R_OK)==
-(0x11bc+3480-0x1f54)){filename=FOTA_UPDATE_STATUS_FILE_OLD;}else{filename=
-FOTA_UPDATE_STATUS_FILE;}printf(
-"get_update_status, read_update_status from %s\n",filename);fd=fopen(filename,
-"\x72\x62\x2b");if(fd==NULL){printf(
-"\x5b\x6e\x76\x73\x65\x72\x76\x65\x72\x5d\x75\x70\x64\x61\x74\x65\x5f\x73\x74\x61\x74\x75\x73\x20\x6f\x70\x65\x6e\x20\x20\x65\x72\x72\x6f\x72\x3a\x25\x73" "\n"
-,strerror(errno));goto error0;}ret=fscanf(fd,"\x25\x64",(int*)&update_status);if
-(ret<(0x12cb+1191-0x1772)){printf(
-"\x67\x65\x74\x20\x69\x6e\x66\x6f\x20\x66\x72\x6f\x6d\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72\x3a\x25\x73" "\n"
-,strerror(errno));fclose(fd);goto error0;}printf(
-"\x75\x70\x64\x61\x74\x65\x5f\x73\x74\x61\x74\x75\x73\x3d\x25\x64" "\n",
-update_status);fclose(fd);return update_status;error0:return-(0x197a+676-0x1c1d)
-;}
+int get_update_status (void)
+{
+ int update_status;
+ FILE *fd = 0;
+ int ret;
+ char* filename = NULL;
+
+ if(access(FOTA_UPDATE_STATUS_FILE_OLD, R_OK) == 0){
+ filename = FOTA_UPDATE_STATUS_FILE_OLD;
+ }else{
+ filename = FOTA_UPDATE_STATUS_FILE;
+ }
+
+ printf("get_update_status, read_update_status from %s\n", filename);
+ fd = fopen (filename, "rb+");
+ if (fd == NULL) {
+ printf ("[nvserver]update_status open error:%s\n", strerror (errno));
+ goto error0;
+ }
+
+ ret = fscanf (fd, "%d", (int *) &update_status);
+ if (ret < 0) {
+ printf ("get info from file error:%s\n", strerror (errno));
+ fclose (fd);
+ goto error0;
+ }
+ printf ("update_status=%d\n", update_status);
+ fclose (fd);
+
+ return update_status;
+
+error0:
+ return -1;
+}
#endif
-int nvupdate(char*nv_file,char*config_file,const char*key,const char*value,int
-saveFlag){int index=(0x1b99+1285-0x209e);int key_buf_len=(0x1b8b+634-0x1e05);int
- value_buf_len=(0xc03+275-0xd16);T_NV_NODE*list=NULL;T_NV_ITEM*item=NULL;
-T_NV_ITEM*newItem=NULL;if(NULL==key||NULL==value)return RESULT_FAIL;printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6e\x76\x75\x70\x64\x61\x74\x65\x20\x6e\x76\x5f\x66\x69\x6c\x65\x3a\x25\x73\x20\x6b\x65\x79\x3a\x25\x73\x20\x76\x61\x6c\x75\x65\x3a\x25\x73" "\n"
-,nv_file,key,value);key_buf_len=strlen(key)+(0x1c1+5757-0x183d);value_buf_len=
-strlen(value)+(0x1de0+1134-0x224d);for(list=nv_list;list;list=list->next){if(
-strcmp(list->nvFile,nv_file))continue;index=hash(key)%NV_HASH_LEN;for(item=list
-->nvTable[index];item;item=item->next){if(strcmp(item->key,key))continue;if(
-saveFlag)item->saveFlag=saveFlag;if(!strcmp(item->value,value)){item->
-update_flag=(0xb8c+5734-0x21f1);printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6e\x76\x75\x70\x64\x61\x74\x65\x20\x73\x61\x6d\x65\x73\x6b\x69\x70\x3a\x69\x74\x65\x6d\x2d\x3e\x6b\x65\x79\x3a\x25\x73\x20\x69\x74\x65\x6d\x2d\x3e\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x63\x6f\x6e\x66\x69\x67\x5f\x66\x69\x6c\x65\x3a\x25\x73" "\n"
-,item->key,item->value,value,config_file);return RESULT_SUCCESS;}if(strstr(
-config_file,"\x75\x73\x65\x72")){if((0x586+4751-0x1814)==item->update_flag){
-printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6e\x76\x75\x70\x64\x61\x74\x65\x20\x73\x65\x63\x6f\x6e\x64\x20\x63\x68\x61\x6e\x67\x65\x3a\x69\x74\x65\x6d\x2d\x3e\x6b\x65\x79\x3a\x25\x73\x20\x69\x74\x65\x6d\x2d\x3e\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x63\x6f\x6e\x66\x69\x67\x5f\x66\x69\x6c\x65\x3a\x25\x73" "\n"
-,item->key,item->value,value,config_file);}else{item->update_flag=
-(0x411+4388-0x1534);printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6e\x76\x75\x70\x64\x61\x74\x65\x20\x75\x73\x65\x72\x73\x6b\x69\x70\x3a\x69\x74\x65\x6d\x2d\x3e\x6b\x65\x79\x3a\x25\x73\x20\x69\x74\x65\x6d\x2d\x3e\x76\x61\x6c\x75\x65\x31\x3a\x25\x73\x20\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x63\x6f\x6e\x66\x69\x67\x5f\x66\x69\x6c\x65\x3a\x25\x73" "\n"
-,item->key,item->value,value,config_file);return RESULT_SUCCESS;}}printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x6b\x65\x79\x3d\x25\x73\x20\x63\x68\x61\x6e\x67\x65\x20\x76\x61\x6c\x75\x65\x3a\x25\x73\x20\x74\x6f\x20\x76\x61\x6c\x75\x65\x3d\x25\x73\x20" "\n"
-,item->key,item->value,value);free(item->value);item->value=(char*)malloc(
-value_buf_len);if(!item->value)return RESULT_MALLOC_FAIL;strncpy(item->value,
-value,value_buf_len-(0x334+7692-0x213f));item->value[value_buf_len-
-(0x59f+4826-0x1878)]='\0';item->update_flag=(0x9e7+6105-0x21bf);return
-RESULT_SUCCESS;}newItem=(T_NV_ITEM*)malloc(sizeof(T_NV_ITEM));if(!newItem){
-printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x52\x45\x53\x55\x4c\x54\x5f\x4d\x41\x4c\x4c\x4f\x43\x5f\x46\x41\x49\x4c\x31\x20" "\n"
-);return RESULT_MALLOC_FAIL;}newItem->key=(char*)malloc(strlen(key)+
-(0x150f+2636-0x1f5a));if(!newItem->key){free(newItem);printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x52\x45\x53\x55\x4c\x54\x5f\x4d\x41\x4c\x4c\x4f\x43\x5f\x46\x41\x49\x4c\x32" "\n"
-);return RESULT_MALLOC_FAIL;}newItem->value=(char*)malloc(value_buf_len);if(!
-newItem->value){free(newItem->key);free(newItem);printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x52\x45\x53\x55\x4c\x54\x5f\x4d\x41\x4c\x4c\x4f\x43\x5f\x46\x41\x49\x4c\x33\x20" "\n"
-);return RESULT_MALLOC_FAIL;}strncpy(newItem->key,key,key_buf_len-
-(0x1daf+705-0x206f));newItem->key[key_buf_len-(0x4c2+109-0x52e)]='\0';strncpy(
-newItem->value,value,value_buf_len-(0x306+5736-0x196d));newItem->value[
-value_buf_len-(0xddd+299-0xf07)]='\0';newItem->next=NULL;newItem->saveFlag=
-saveFlag;newItem->update_flag=(0x1e82+595-0x20d4);printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x61\x64\x64\x20\x6b\x65\x79\x3d\x25\x73\x2c\x20\x76\x61\x6c\x75\x65\x3d\x25\x73\x20" "\n"
-,newItem->key,newItem->value);if(!list->nvTable[index])list->nvTable[index]=
-newItem;else{newItem->next=list->nvTable[index]->next;list->nvTable[index]->next
-=newItem;}return RESULT_SUCCESS;}return RESULT_FAIL;}int reloadFactroyParam(
-T_NV_NODE*list){char*val=NULL;FILE*fp=NULL;T_NV_CONFIG*config=NULL;char buf[
-NV_MAX_ITEM_LEN]={(0x11eb+2510-0x1bb9)};printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x72\x65\x6c\x6f\x61\x64\x46\x61\x63\x74\x72\x6f\x79\x50\x61\x72\x61\x6d\x20\x6e\x76\x46\x69\x6c\x65\x3a\x25\x73" "\n"
-,list->nvFile);for(config=list->fileList;config;config=config->next){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x72\x65\x6c\x6f\x61\x64\x46\x61\x63\x74\x72\x6f\x79\x50\x61\x72\x61\x6d\x20\x63\x6f\x6e\x66\x69\x67\x46\x69\x6c\x65\x20\x73\x74\x61\x72\x74\x3a\x25\x73\x21" "\n"
-,config->configFile);fp=fopen(config->configFile,"\x72\x6f");if(!fp){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x6f\x70\x65\x6e\x20\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x61\x69\x6c\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x21" "\n"
-,config->configFile,errno);return RESULT_FILE_OPEN_FAIL;}while(fgets(buf,
-NV_MAX_ITEM_LEN,fp)){if(buf[(0x7c7+1130-0xc31)]=='\n'||buf[(0x1580+3707-0x23fb)]
-==((char)(0x8b2+730-0xb69)))continue;val=strchr(buf,((char)(0xa1f+5807-0x2091)))
-;if(!val){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x65\x72\x72\x6f\x72\x3a\x25\x73\x20\x66\x69\x6c\x65\x20\x66\x6f\x72\x6d\x61\x74\x20\x65\x72\x72\x6f\x72\x3a\x73\x74\x72\x69\x6e\x67\x20\x3d\x20\x25\x73" "\n"
-,config->configFile,buf);continue;}buf[strlen(buf)-(0x10a0+5373-0x259c)]='\0';*
-val++='\0';nvupdate(list->nvFile,config->configFile,buf,val,(0x2210+1063-0x2636)
-);}printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x72\x65\x6c\x6f\x61\x64\x46\x61\x63\x74\x72\x6f\x79\x50\x61\x72\x61\x6d\x20\x63\x6f\x6e\x66\x69\x67\x46\x69\x6c\x65\x20\x65\x6e\x64\x3a\x25\x73\x21" "\n"
-,config->configFile);fclose(fp);}return RESULT_SUCCESS;}void dump_list(T_NV_ITEM
-*list){if(list==NULL){printf(
-"\x6c\x69\x73\x74\x20\x69\x73\x20\x6e\x75\x6c\x6c" "\n");return;}T_NV_ITEM*p=
-list->next;while(p!=NULL){printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x64\x75\x6d\x70\x20\x6b\x65\x79\x3d\x25\x73\x2c\x20\x76\x61\x6c\x75\x65\x3d\x25\x73\x2c\x20\x70\x3d\x30\x78\x25\x78" "\n"
-,p->key,p->value,((unsigned int)p));p=p->next;}}int delete_not_needed(T_NV_NODE*
-list){int index=(0xc20+2485-0x15d5);T_NV_ITEM*item=NULL;T_NV_ITEM head={
-(0x15ec+919-0x1983)};T_NV_ITEM*prev=&head;printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x64\x65\x6c\x65\x74\x65\x5f\x6e\x6f\x74\x5f\x6e\x65\x65\x64\x65\x64\x20\x65\x6e\x74\x65\x72\x20\x2a\x2a\x2a" "\n"
-);for(index=(0x11c6+4121-0x21df);index<NV_HASH_LEN;index++){head.next=list->
-nvTable[index];prev=&head;for(item=prev->next;item;){if((0xb56+5861-0x223a)==
-item->update_flag){prev=item;item=item->next;}else{printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x64\x65\x6c\x65\x74\x65\x20\x6b\x65\x79\x3d\x25\x73\x2c\x20\x76\x61\x6c\x75\x65\x3d\x25\x73\x20" "\n"
-,item->key,item->value);prev->next=item->next;free(item->key);free(item->value);
-free(item);item=prev->next;}}list->nvTable[index]=head.next;}printf(
-"\x6e\x76\x73\x65\x72\x76\x65\x72\x20\x64\x65\x6c\x65\x74\x65\x5f\x6e\x6f\x74\x5f\x6e\x65\x65\x64\x65\x64\x20\x65\x6e\x64\x20\x2a\x2a\x2a" "\n"
-);return RESULT_SUCCESS;}
+
+int nvupdate (char *nv_file, char *config_file, const char *key, const char *value, int saveFlag)
+{
+ int index = 0;
+ int key_buf_len = 0;
+ int value_buf_len = 0;
+ T_NV_NODE *list = NULL;
+ T_NV_ITEM *item = NULL;
+ T_NV_ITEM *newItem = NULL;
+
+ if (NULL == key || NULL == value)
+ return RESULT_FAIL;
+
+ printf("nvserver nvupdate nv_file:%s key:%s value:%s\n", nv_file, key, value);
+
+ key_buf_len = strlen(key) + 1;
+ value_buf_len = strlen(value) + 1;
+
+ for (list = nv_list; list; list = list->next) {
+ if (strcmp (list->nvFile, nv_file))
+ continue;
+
+ index = hash (key) % NV_HASH_LEN;
+ for (item = list->nvTable[index]; item; item = item->next) {
+ // change item
+ if (strcmp (item->key, key))
+ continue;
+
+ if (saveFlag)
+ item->saveFlag = saveFlag;
+ //if value is the same , or the key is in default_parameter_user , though the value change ,but do not update it
+ //just update it if the key is in default_parameter_sys
+ if (!strcmp (item->value, value))
+ {
+ /* value equal when sys or user */
+ item->update_flag = 1; // indicate the value is updated , or it is the newest
+ printf("nvserver nvupdate sameskip:item->key:%s item->value:%s value:%s config_file:%s\n", item->key,
+ item->value, value, config_file);
+ return RESULT_SUCCESS;
+ }
+ if (strstr(config_file, "user"))
+ {
+ if (1 == item->update_flag)
+ {
+ /* second time:key in sys_user or user_user */
+ printf("nvserver nvupdate second change:item->key:%s item->value:%s value:%s config_file:%s\n", item->key,
+ item->value, value, config_file);
+ }
+ else
+ {
+ item->update_flag = 1;
+ printf("nvserver nvupdate userskip:item->key:%s item->value1:%s value:%s config_file:%s\n", item->key,
+ item->value, value, config_file);
+ return RESULT_SUCCESS;
+ }
+ }
+
+ printf ("nvserver key=%s change value:%s to value=%s \n", item->key, item->value, value);
+ free (item->value);
+ item->value = (char *) malloc (value_buf_len);
+ if (!item->value)
+ return RESULT_MALLOC_FAIL;
+
+ strncpy (item->value, value, value_buf_len - 1);
+ item->value[value_buf_len - 1] = '\0';
+
+ item->update_flag = 1; // indicate the value is updated , or it is the newest
+ return RESULT_SUCCESS;
+ }
+
+ // add item
+ newItem = (T_NV_ITEM *) malloc (sizeof (T_NV_ITEM));
+ if (!newItem) {
+ printf ("nvserver RESULT_MALLOC_FAIL1 \n");
+ return RESULT_MALLOC_FAIL;
+ }
+ newItem->key = (char *) malloc (strlen (key) + 1);
+ if (!newItem->key) {
+ free (newItem);
+ printf ("nvserver RESULT_MALLOC_FAIL2\n");
+
+ return RESULT_MALLOC_FAIL;
+ }
+
+ newItem->value = (char *) malloc (value_buf_len);
+ if (!newItem->value) {
+ free (newItem->key);
+ free (newItem);
+ printf ("nvserver RESULT_MALLOC_FAIL3 \n");
+ return RESULT_MALLOC_FAIL;
+ }
+
+ strncpy (newItem->key, key, key_buf_len - 1);
+ newItem->key[key_buf_len - 1] = '\0';
+
+ strncpy (newItem->value, value, value_buf_len - 1);
+ newItem->value[value_buf_len - 1] = '\0';
+
+ newItem->next = NULL;
+ newItem->saveFlag = saveFlag;
+ newItem->update_flag = 1; // indicate the value is updated , or it is the newest
+ printf ("nvserver add key=%s, value=%s \n", newItem->key, newItem->value);
+
+
+ if (!list->nvTable[index])
+ list->nvTable[index] = newItem;
+ else {
+ newItem->next = list->nvTable[index]->next;
+ list->nvTable[index]->next = newItem;
+ }
+
+ return RESULT_SUCCESS;
+ }
+
+ return RESULT_FAIL;
+}
+
+int reloadFactroyParam (T_NV_NODE *list)
+{
+ char *val = NULL;
+ FILE *fp = NULL;
+ T_NV_CONFIG *config = NULL;
+ char buf[NV_MAX_ITEM_LEN] = {0};
+
+ printf("nvserver reloadFactroyParam nvFile:%s\n", list->nvFile);
+
+ for (config = list->fileList; config; config = config->next) {
+ printf ("nvserver reloadFactroyParam configFile start:%s!\n", config->configFile);
+ fp = fopen (config->configFile, "ro");
+ if (!fp) {
+ printf ("nvserver error:open %s file fail errno = %d!\n", config->configFile, errno);
+ return RESULT_FILE_OPEN_FAIL;
+ }
+
+ while (fgets (buf, NV_MAX_ITEM_LEN, fp)) {
+ if (buf[0] == '\n' || buf[0] == '#')
+ continue;
+
+ val = strchr (buf, '=');
+ if (!val) {
+ printf ("nvserver error:%s file format error:string = %s\n", config->configFile, buf);
+ continue;
+ }
+
+ buf[strlen (buf) - 1] = '\0';
+ *val++ = '\0';
+
+ nvupdate (list->nvFile, config->configFile, buf, val, 1);
+ }
+ printf ("nvserver reloadFactroyParam configFile end:%s!\n", config->configFile);
+ fclose (fp);
+ }
+
+ return RESULT_SUCCESS;
+}
+
+void dump_list(T_NV_ITEM *list)
+{
+ if(list == NULL){
+ printf("list is null\n");
+ return;
+ }
+
+ T_NV_ITEM *p = list->next;
+
+ while(p!= NULL){
+ printf ("nvserver dump key=%s, value=%s, p=0x%x\n", p->key, p->value, ((unsigned int)p));
+ p=p->next;
+ }
+}
+
+int delete_not_needed (T_NV_NODE *list)
+{
+ int index = 0;
+ T_NV_ITEM *item = NULL;
+ T_NV_ITEM head = {0};
+ T_NV_ITEM *prev = &head;
+
+ printf ("nvserver delete_not_needed enter ***\n");
+
+ for (index = 0; index < NV_HASH_LEN; index ++) {
+ head.next = list->nvTable[index];
+ prev = &head;
+// printf ("nvserver index=%d begin *****\n", index);
+// dump_list(&head);
+ for (item = prev->next; item;) {
+
+// printf("nvserver1 delete key=%s, value=%s \n", item->key, item->value);
+
+ if (1 == item->update_flag) {
+ prev = item;
+ item = item->next;
+ }
+ else
+ {
+ printf ("nvserver delete key=%s, value=%s \n", item->key, item->value);
+ prev->next = item->next;
+ free (item->key);
+ free (item->value);
+ free (item);
+ item = prev->next;
+
+ }
+ }
+ list->nvTable[index] = head.next;
+// dump_list(&head);
+// printf ("nvserver index=%d end *****\n", index);
+
+ }
+
+ printf ("nvserver delete_not_needed end ***\n");
+
+ return RESULT_SUCCESS;
+}
+
+
+
+
#ifdef __cplusplus
}
#endif
diff --git a/ap/app/zte_comm/phonebook/src/pb_db.c b/ap/app/zte_comm/phonebook/src/pb_db.c
index 7e3ac3f..ea0eb1d 100755
--- a/ap/app/zte_comm/phonebook/src/pb_db.c
+++ b/ap/app/zte_comm/phonebook/src/pb_db.c
@@ -1,327 +1,804 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : Atserver-PB
+* ÎÄ ¼þ Ãû : pb_db.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : Pb Êý¾Ý¿â²Ù×÷½Ó¿Úº¯ÊýʵÏÖ
+* ×÷ Õß : syx
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-05-16
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ :
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
#include "pb_com.h"
-T_zPb_DbResult atPb_CreatDb(){T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[
-ZPB_MAX_BYTES_DB]={(0x17bf+3885-0x26ec)};UINT32 count=(0x677+5507-0x1bfa);result
-=atPb_ExecDbSql(ZPB_CREATE_PBM_TABLE,NULL,NULL);if(ZPB_DB_OK!=result){slog(
-PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x72\x65\x61\x74\x65\x20\x70\x62\x6d\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(
-ZPB_CREATE_PBM_SIM_CAPABILITY_TABLE,NULL,NULL);if(ZPB_DB_OK!=result){slog(
-PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x72\x65\x61\x74\x65\x20\x70\x62\x6d\x5f\x73\x69\x6d\x5f\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(
-ZPB_CREATE_PBM_DEVICE_CAPABILITY_TABLE,NULL,NULL);if(ZPB_DB_OK!=result){slog(
-PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x72\x65\x61\x74\x65\x20\x70\x62\x6d\x5f\x64\x65\x76\x69\x63\x65\x5f\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}snprintf(sql,sizeof(sql),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);result=atPb_ExecDbSql(sql,NULL,NULL);if(
-ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x72\x65\x61\x74\x65\x20\x70\x62\x6d\x5f\x64\x65\x76\x69\x63\x65\x5f\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}memset(sql,(0x7c5+1762-0xea7),sizeof(sql));snprintf(sql,
-sizeof(sql)-(0x29f+1571-0x8c1),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73"
-,ZPB_DB_SIM_CAPABILITY_TABLE);(VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&
-count);if((0x373+2622-0xdb1)<count){memset(sql,(0x4d8+6944-0x1ff8),sizeof(sql));
-snprintf(sql,sizeof(sql)-(0x674+7098-0x222d),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x53\x69\x6d\x5f\x74\x79\x70\x65\x3e\x3d\x30"
-,ZPB_DB_SIM_CAPABILITY_TABLE);result=atPb_ExecDbSql(sql,NULL,NULL);if(ZPB_DB_OK
-!=result){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x65\x74\x53\x69\x6d\x43\x61\x70\x61\x63\x69\x74\x79\x54\x61\x62\x6c\x65\x3a\x66\x61\x69\x6c\x21" "\n"
-);return result;}}return ZPB_DB_OK;}T_zPb_DbResult atPb_DropDb(){T_zPb_DbResult
-result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0x1015+4461-0x2182)};result=
-atPb_ExecDbSql(ZTE_DROP_PBM_SQL,NULL,NULL);if(ZPB_DB_OK!=result){slog(PB_PRINT,
-SLOG_ERR,
-"\x61\x74\x50\x62\x5f\x44\x72\x6f\x70\x44\x62\x3a\x64\x65\x6c\x20\x70\x62\x6d\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(ZTE_DROP_PBM_DEVICE_SQL,NULL,NULL)
-;if(ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_ERR,
-"\x61\x74\x50\x62\x5f\x44\x72\x6f\x70\x44\x62\x3a\x64\x65\x6c\x20\x70\x62\x6d\x5f\x64\x65\x76\x69\x63\x65\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(ZTE_DROP_PBM_SIM_SQL,NULL,NULL);if
-(ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_ERR,
-"\x61\x74\x50\x62\x5f\x44\x72\x6f\x70\x44\x62\x3a\x64\x65\x6c\x20\x70\x62\x6d\x5f\x73\x69\x6d\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(ZTE_DROP_PBM_SIM_CAPABILITY_SQL,
-NULL,NULL);if(ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_ERR,
-"\x61\x74\x50\x62\x5f\x44\x72\x6f\x70\x44\x62\x3a\x64\x65\x6c\x20\x70\x62\x6d\x5f\x73\x69\x6d\x5f\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}result=atPb_ExecDbSql(ZTE_DROP_PBM_DEVICE_CAPABILITY_SQL
-,NULL,NULL);if(ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_ERR,
-"\x61\x74\x50\x62\x5f\x44\x72\x6f\x70\x44\x62\x3a\x64\x65\x6c\x20\x70\x62\x6d\x5f\x64\x65\x76\x69\x63\x65\x5f\x63\x61\x70\x61\x62\x69\x6c\x69\x74\x79\x20\x74\x61\x62\x6c\x65\x20\x72\x65\x73\x75\x6c\x74\x20\x69\x73\x20\x25\x64" "\n"
-,result);return result;}return ZPB_DB_OK;}T_zPb_DbResult atPb_DbOpen(sqlite3**
-pDb){sqlite3*pTmpDb=NULL;if(NULL==pDb){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x69\x6e\x76\x61\x6c\x69\x64\x65\x20\x69\x6e\x70\x75\x74\x73\x2e"
-);return ZPB_DB_ERROR_INVALIDPTR;}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x73\x71\x6c\x69\x74\x65\x33\x5f\x6f\x70\x65\x6e\x20\x63\x61\x6c\x6c"
-);
-#if (0x2197+446-0x2355)
-if(!fopen(ZPB_DB_PATH,"\x72")){file=fopen(ZPB_DB_PATH,"\x77");if(!file){printf(
-"\x75\x6e\x61\x62\x6c\x65\x20\x74\x6f\x20\x6f\x70\x65\x6e\x20\x20\x66\x69\x6c\x65\x20\x65\x74\x63\x5f\x72\x77\x2f\x70\x62\x6d\x2e\x64\x62" "\n"
-);}else{printf(
-"\x20\x6f\x70\x65\x6e\x20\x20\x66\x69\x6c\x65\x20\x65\x74\x63\x5f\x72\x77\x2f\x70\x62\x6d\x2e\x64\x62\x20\x66\x69\x6c\x65\x3d\x25\x64" "\n"
-,file);fclose(file);}}
-#endif
-if(sqlite3_open(ZPB_DB_PATH,&pTmpDb)){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x61\x6e\x20\x6e\x6f\x74\x20\x6f\x70\x65\x6e\x20\x64\x62\x2c\x73\x71\x6c\x69\x74\x65\x33\x5f\x65\x72\x72\x6d\x73\x67\x3a\x25\x73\x2e"
-,sqlite3_errmsg(pTmpDb));(VOID)sqlite3_close(pTmpDb);return
-ZPB_DB_ERROR_NOTOPENDB;}*pDb=pTmpDb;return ZPB_DB_OK;}T_zPb_DbResult
-atPb_DbClose(sqlite3*pDb){if(NULL==pDb){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x69\x6e\x76\x61\x6c\x69\x64\x65\x20\x69\x6e\x70\x75\x74\x73\x2e"
-);return ZPB_DB_ERROR_INVALIDPTR;}if(sqlite3_close(pDb)){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x61\x6e\x20\x6e\x6f\x74\x20\x63\x6c\x6f\x73\x65\x20\x64\x62"
-);return ZPB_DB_ERROR;}
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+T_zPb_DbResult atPb_CreatDb()
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ UINT32 count = 0;
+
+ result = atPb_ExecDbSql(ZPB_CREATE_PBM_TABLE,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:create pbm table result is %d\n", result);
+ return result;
+ }
+ /*create pbm_sim_capability table*/
+ result = atPb_ExecDbSql(ZPB_CREATE_PBM_SIM_CAPABILITY_TABLE,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:create pbm_sim_capability table result is %d\n", result);
+ return result;
+ }
+ /*create pbm_device_capability table*/
+ result = atPb_ExecDbSql(ZPB_CREATE_PBM_DEVICE_CAPABILITY_TABLE,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:create pbm_device_capability table result is %d\n", result);
+ return result;
+ }
+ /*ɾ³ýpbm±íÖÐλÖÃΪsim¿¨µÄµç»°±¾¼Ç¼*/
+ snprintf(sql,sizeof(sql),"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:create pbm_device_capability table result is %d\n", result);
+ return result;
+ }
+
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s",ZPB_DB_SIM_CAPABILITY_TABLE);
+ (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
+ if(0 < count)
+ {
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Sim_type>=0",ZPB_DB_SIM_CAPABILITY_TABLE);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_SetSimCapacityTable:fail!\n");
+ return result;
+ }
+ }
+ return ZPB_DB_OK;
+}
+
+T_zPb_DbResult atPb_DropDb()
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+
+ result = atPb_ExecDbSql(ZTE_DROP_PBM_SQL,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"atPb_DropDb:del pbm table result is %d\n", result);
+ return result;
+ }
+
+ result = atPb_ExecDbSql(ZTE_DROP_PBM_DEVICE_SQL,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"atPb_DropDb:del pbm_device table result is %d\n", result);
+ return result;
+ }
+
+ result = atPb_ExecDbSql(ZTE_DROP_PBM_SIM_SQL,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"atPb_DropDb:del pbm_sim table result is %d\n", result);
+ return result;
+ }
+
+ result = atPb_ExecDbSql(ZTE_DROP_PBM_SIM_CAPABILITY_SQL,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"atPb_DropDb:del pbm_sim_capability table result is %d\n", result);
+ return result;
+ }
+
+ result = atPb_ExecDbSql(ZTE_DROP_PBM_DEVICE_CAPABILITY_SQL,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_ERR,"atPb_DropDb:del pbm_device_capability table result is %d\n", result);
+ return result;
+ }
+
+ return ZPB_DB_OK;
+}
+
+T_zPb_DbResult atPb_DbOpen(sqlite3**pDb)
+{
+ sqlite3* pTmpDb = NULL;
+
+ if(NULL == pDb)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:invalide inputs.");/*lint !e26*/
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:sqlite3_open call");/*lint !e26*/
+
+#if 0
+ if(!fopen(ZPB_DB_PATH, "r"))
+ {
+ file = fopen(ZPB_DB_PATH, "w");
+ if(!file)
+ {
+ printf("unable to open file etc_rw/pbm.db\n");/*lint !e26*/
+
+ }
+ else
+ {
+ printf(" open file etc_rw/pbm.db file=%d\n", file);
+ fclose(file);
+ }
+ }
+ #endif
+ if(sqlite3_open(ZPB_DB_PATH, &pTmpDb))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:can not open db,sqlite3_errmsg:%s.",sqlite3_errmsg(pTmpDb));
+ (VOID) sqlite3_close(pTmpDb);
+ return ZPB_DB_ERROR_NOTOPENDB;
+ }
+ *pDb = pTmpDb;
+ return ZPB_DB_OK;
+}
+T_zPb_DbResult atPb_DbClose (sqlite3*pDb)
+{
+ if (NULL == pDb)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:invalide inputs.");/*lint !e26*/
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ if(sqlite3_close(pDb))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:can not close db");/*lint !e26*/
+ return ZPB_DB_ERROR;
+ }
#ifdef WEBS_SECURITY
-if(access(ZPB_TMP_PATH,F_OK)==(0x7ed+181-0x8a2)){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x74\x6d\x70\x20\x64\x62\x20\x73\x74\x61\x79");if(
-remove(ZPB_TMP_PATH)!=(0xb37+5205-0x1f8c)){slog(PB_PRINT,SLOG_ERR,
-"\x72\x65\x6d\x6f\x76\x65\x20\x5a\x50\x42\x5f\x54\x4d\x50\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}}if(rename(ZPB_SEC_PATH,ZPB_TMP_PATH)!=(0x1030+5248-0x24b0)){slog(PB_PRINT,
-SLOG_ERR,
-"\x72\x65\x6e\x61\x6d\x65\x20\x5a\x50\x42\x5f\x53\x45\x43\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}{char rnum_buf[(0x1565+3485-0x22ea)]={(0xd7b+4880-0x208b)};char cmd[
-(0x14f3+1868-0x1bbf)]={(0xe43+2558-0x1841)};sc_cfg_get(
-"\x72\x6e\x75\x6d\x5f\x61\x74",rnum_buf,sizeof(rnum_buf));snprintf(cmd,sizeof(
-cmd),
-"\x2f\x62\x69\x6e\x2f\x6f\x70\x65\x6e\x73\x73\x6c\x20\x65\x6e\x63\x20\x2d\x65\x20\x2d\x61\x65\x73\x32\x35\x36\x20\x2d\x73\x61\x6c\x74\x20\x2d\x69\x6e\x20\x25\x73\x20\x2d\x6f\x75\x74\x20\x25\x73\x20\x2d\x70\x61\x73\x73\x20\x70\x61\x73\x73\x3a\x25\x73"
-,ZPB_DB_PATH,ZPB_SEC_PATH,rnum_buf);zxic_system(cmd);if(access(ZPB_SEC_PATH,F_OK
-)==(0x1637+944-0x19e7)){if(remove(ZPB_TMP_PATH)!=(0x9eb+4596-0x1bdf)){slog(
-PB_PRINT,SLOG_ERR,
-"\x72\x65\x6d\x6f\x76\x65\x20\x5a\x50\x42\x5f\x54\x4d\x50\x5f\x50\x41\x54\x48\x31\x20\x66\x61\x69\x6c"
-);}}}
+ if(access(ZPB_TMP_PATH, F_OK) == 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:tmp db stay");/*lint !e26*/
+ if(remove(ZPB_TMP_PATH) != 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"remove ZPB_TMP_PATH fail");
+ }
+ }
+ if(rename(ZPB_SEC_PATH, ZPB_TMP_PATH) != 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"rename ZPB_SEC_PATH fail");
+ }
+ {
+ char rnum_buf[24] = {0};
+ char cmd[128] = {0};
+
+ sc_cfg_get("rnum_at", rnum_buf, sizeof(rnum_buf));
+ snprintf(cmd, sizeof(cmd), "/bin/openssl enc -e -aes256 -salt -in %s -out %s -pass pass:%s", ZPB_DB_PATH, ZPB_SEC_PATH, rnum_buf);
+ zxic_system(cmd);
+ if(access(ZPB_SEC_PATH, F_OK) == 0)
+ {
+ if(remove(ZPB_TMP_PATH) != 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"remove ZPB_TMP_PATH1 fail");
+ }
+ }
+ }
#endif
-return ZPB_DB_OK;}static check_sql_cmd(const char*pSql){if(pSql!=NULL){if(strstr
-(pSql,"\x3b")||strstr(pSql,"\x2d\x2d")){return(0x149d+3953-0x240e);}return
-(0x28b+6211-0x1acd);}return(0x6b7+2456-0x104f);}T_zPb_DbResult atPb_ExecDbSql(
-const char*pSql,sqlite3_callback callback,VOID*pFvarg){sqlite3*pDb=NULL;CHAR
-dbErrMsg[(0x11eb+3354-0x1e85)]={(0x22b+5720-0x1883)};if(NULL==pSql){return
-ZPB_DB_ERROR_INVALIDPTR;}
+ return ZPB_DB_OK;
+}
+
+static check_sql_cmd(const char *pSql)
+{
+ if(pSql != NULL)
+ {
+ if(strstr(pSql, ";") || strstr(pSql, "--"))
+ {
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+T_zPb_DbResult atPb_ExecDbSql(const char *pSql, sqlite3_callback callback,VOID *pFvarg)
+{
+ sqlite3 *pDb = NULL;
+ CHAR dbErrMsg[128] = {0};
+ if(NULL == pSql)
+ {
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
#ifdef WEBS_SECURITY
-if(check_sql_cmd(pSql)==(0xa76+5764-0x20fa)){slog(PB_PRINT,SLOG_ERR,
-"\x21\x21\x61\x74\x50\x62\x5f\x45\x78\x65\x63\x44\x62\x53\x71\x6c\x3a\x78\x73\x73\x20\x25\x73" "\n"
-,pSql);return ZPB_DB_ERROR_INVALIDPTR;}
+ if(check_sql_cmd(pSql) == 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"!!atPb_ExecDbSql:xss %s\n",pSql);
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
#endif
-if(ZPB_DB_OK!=atPb_DbOpen(&pDb)){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x6f\x70\x65\x6e\x20\x70\x62\x6d\x2e\x64\x62\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return ZPB_DB_ERROR_NOTOPENDB;}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x45\x78\x65\x63\x44\x62\x53\x71\x6c\x3a\x25\x73" "\n"
-,pSql);if(sqlite3_exec(pDb,pSql,callback,pFvarg,NULL)){strncpy(dbErrMsg,
-sqlite3_errmsg(pDb),sizeof(dbErrMsg)-(0x3d8+123-0x452));slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x63\x61\x6e\x20\x6e\x6f\x74\x20\x65\x78\x65\x63\x20\x73\x71\x6c\x2c\x73\x71\x6c\x69\x74\x65\x33\x5f\x65\x72\x72\x6d\x73\x67\x3a\x25\x73\x2e"
-,dbErrMsg);(VOID)sqlite3_close(pDb);return ZPB_DB_ERROR;}(VOID)atPb_DbClose(pDb)
-;return ZPB_DB_OK;}SINT32 atPb_InitApIndexCb(VOID*fvarg,int line,char**zresult,
-char**lname){SINT32 index=(0x1ab8+2955-0x2643);if((0x698+5816-0x1d4f)>line){slog
-(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x49\x6e\x69\x74\x41\x70\x49\x6e\x64\x65\x78\x43\x62\x3a\x72\x65\x63\x6f\x72\x64\x20\x6e\x6f\x20\x64\x61\x74\x61\x2e" "\n"
-);return-(0xaec+2311-0x13f2);}index=atoi(zresult[(0xb28+6501-0x248d)]);if(index>
-ZPB_AP_MAX_RECORD){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x49\x6e\x69\x74\x41\x70\x49\x6e\x64\x65\x78\x43\x62\x3a\x69\x6e\x64\x65\x78\x20\x6f\x76\x65\x72\x66\x6c\x6f\x77\x2e" "\n"
-);return-(0x120f+3797-0x20e3);}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x49\x6e\x69\x74\x41\x70\x49\x6e\x64\x65\x78\x43\x62\x3a\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3d\x25\x64" "\n"
-,index);g_zPb_ApIndex[index]=PBM_SUCCESS;return(0x1207+2834-0x1d19);}
-T_zPb_DbResult atPb_InitApIndex(){CHAR sql[ZPB_MAX_BYTES_DB]={
-(0x2160+1016-0x2558)};SINT32 i=(0xec8+3074-0x1ac9);g_zPb_ApIndex[
-(0x7e0+2610-0x1212)]=ZPB_AP_MAX_RECORD;for(i=(0x4a0+2443-0xe2a);i<=g_zPb_ApIndex
-[(0x11a1+2820-0x1ca5)];i++){g_zPb_ApIndex[i]=PBM_ERROR_NOT_FOUND;}snprintf(sql,
-sizeof(sql),
-"\x73\x65\x6c\x65\x63\x74\x20\x50\x62\x6d\x5f\x69\x6e\x64\x65\x78\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP);return atPb_ExecDbSql(sql,atPb_InitApIndexCb,
-ZUFI_NULL);}INT zte_pbm_check_and_creat_dir(char*path){if(-(0xe16+5704-0x245d)==
-access(path,(0x5ac+8376-0x2664))){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x25\x73\x20\x64\x6f\x65\x73\x20\x6e\x6f\x74\x20\x65\x78\x69\x73\x74\x2c\x73\x6f\x63\x72\x65\x61\x74\x65\x20\x69\x74\x2e" "\n"
-,ZPB_DB_DIR);if(-(0x1c30+1852-0x236b)==mkdir(path,(0x656+3578-0x1251))){slog(
-PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x3a\x66\x61\x69\x6c\x65\x64\x20\x74\x6f\x20\x63\x72\x65\x61\x74\x65\x20\x64\x62\x20\x64\x69\x72\x2e" "\n"
-);return-(0xc46+633-0xebe);}}return(0xcca+563-0xefd);}UINT8
-zte_pbm_check_web_pbm_dir(VOID){
+ if(ZPB_DB_OK != atPb_DbOpen(&pDb))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:open pbm.db failed.");/*lint !e26*/
+ return ZPB_DB_ERROR_NOTOPENDB;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_ExecDbSql:%s\n",pSql);
+
+ if(sqlite3_exec(pDb,pSql,callback,pFvarg,NULL))
+ {
+ strncpy(dbErrMsg,sqlite3_errmsg(pDb),sizeof(dbErrMsg)-1);
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:can not exec sql,sqlite3_errmsg:%s.",dbErrMsg);
+ (VOID)sqlite3_close(pDb);
+ return ZPB_DB_ERROR;
+ }
+ (VOID)atPb_DbClose(pDb);
+ return ZPB_DB_OK;
+}
+
+SINT32 atPb_InitApIndexCb(VOID *fvarg,int line,char **zresult,char **lname)
+{
+ SINT32 index = 0;
+
+ if(1 > line)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_InitApIndexCb:record no data.\n");/*lint !e26*/
+ return -1;
+ }
+
+ index = atoi(zresult[0]);
+ if (index > ZPB_AP_MAX_RECORD) {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_InitApIndexCb:index overflow.\n");
+ return -1;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_InitApIndexCb:pbm_index=%d\n",index);
+ g_zPb_ApIndex[index] = PBM_SUCCESS;
+
+ return 0;
+}
+
+T_zPb_DbResult atPb_InitApIndex()
+{
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ SINT32 i = 1;
+
+ g_zPb_ApIndex[0] = ZPB_AP_MAX_RECORD;
+
+ for(i=1; i<=g_zPb_ApIndex[0]; i++)
+ {
+ g_zPb_ApIndex[i] = PBM_ERROR_NOT_FOUND;
+ }
+ snprintf(sql,sizeof(sql),"select Pbm_index from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_AP);
+ return atPb_ExecDbSql(sql,atPb_InitApIndexCb,ZUFI_NULL);
+}
+
+/*check whether the web pbm dir exist or not*/
+INT zte_pbm_check_and_creat_dir(char *path)
+{
+ if (-1==access(path,/*F_OK*/0))
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:%s does not exist,socreate it.\n",ZPB_DB_DIR);
+ if (-1 == mkdir(path, 0777))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb::failed to create db dir.\n");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+UINT8 zte_pbm_check_web_pbm_dir(VOID)
+{
#ifdef _MBB_OS_UCLINUX
-(VOID)zte_pbm_check_and_creat_dir(
-"\x2f\x6d\x6e\x74\x2f\x6a\x66\x66\x73\x32\x2f\x65\x74\x63\x5f\x72\x77");(VOID)
-zte_pbm_check_and_creat_dir(
-"\x2f\x6d\x6e\x74\x2f\x6a\x66\x66\x73\x32\x2f\x65\x74\x63\x5f\x72\x77\x2f\x63\x6f\x6e\x66\x69\x67"
-);
+ (VOID)zte_pbm_check_and_creat_dir("/mnt/jffs2/etc_rw");
+ (VOID)zte_pbm_check_and_creat_dir("/mnt/jffs2/etc_rw/config");
#else
-(VOID)zte_pbm_check_and_creat_dir("\x2f\x65\x74\x63\x5f\x72\x77");(VOID)
-zte_pbm_check_and_creat_dir(
-"\x2f\x65\x74\x63\x5f\x72\x77\x2f\x63\x6f\x6e\x66\x69\x67");
+(VOID)zte_pbm_check_and_creat_dir("/etc_rw");
+(VOID)zte_pbm_check_and_creat_dir("/etc_rw/config");
#endif
-return ZUFI_SUCC;}T_zPb_DbResult atPb_DelSimRecFromPbTable(SINT32 index){
-T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0x197f+3239-0x2626)
-};snprintf(sql,sizeof(sql),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64\x20\x61\x6e\x64\x20\x50\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM,index);result=atPb_ExecDbSql(sql,NULL,NULL);
-if(ZPB_DB_OK==result){g_zPb_SimIndex[index]=PBM_ERROR_NOT_FOUND;}return result;}
-T_zPb_DbResult atPb_LoadARecToPbmTable(T_zPb_WebContact*pbPara){T_zPb_DbResult
-result=ZPB_DB_ERROR;CHAR sql[ZPB_MAX_BYTES_DB]={(0x1627+4219-0x26a2)};if(NULL==
-pbPara){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x4c\x6f\x61\x64\x41\x52\x65\x63\x54\x6f\x50\x62\x6d\x54\x61\x62\x6c\x65\x3a\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74"
-);return ZPB_DB_ERROR_INVALIDPTR;}snprintf(sql,sizeof(sql),"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne) \
- values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",ZPB_DB_PBM_TABLE,pbPara->pbIndex,pbPara->pbLocation,pbPara->mobilNumber,pbPara
-->pbType,pbPara->name,pbPara->homeNumber,pbPara->officeNumber,pbPara->email,
-pbPara->sne);result=atPb_ExecDbSql(sql,NULL,NULL);if(ZPB_DB_OK==result){CHAR
-pbMax[(0x43f+803-0x730)]={(0x94b+5655-0x1f62)};sc_cfg_get(ZPB_NV_USIMINDEXMAX,
-pbMax,sizeof(pbMax));if((pbPara->pbIndex>=(0x598+2686-0x1015))&&(pbPara->pbIndex
-<=atoi(pbMax))){g_zPb_SimIndex[pbPara->pbIndex]=PBM_SUCCESS;}(VOID)sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_NEW_ERROR);}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x65\x78\x65\x63\x20\x74\x61\x62\x6c\x65\x20\x25\x73\x20\x72\x65\x73\x75\x6c\x74\x20\x25\x64" "\n"
-,ZPB_DB_PBM_TABLE,result);return result;}VOID atPb_SqlModifyOneRec(
-T_zPb_WebContact*pbmPara,char*sql,int len){printf(
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x71\x6c\x4d\x6f\x64\x69\x66\x79\x4f\x6e\x65\x52\x65\x63\x20\x65\x6e\x74\x65\x72"
-);if(ZPB_LOCATION_USIM==pbmPara->pbLocation){snprintf(sql,len,"update %s set Pbm_index=\'%d\',Location=\'%d\',Number=\'%s\',Type=\'%d\',Name=\'%s\',Anr=\'%s\', \
- Anr1=\'%s\',Email=\'%s\',Sne=\'%s\' where id=%d",ZPB_DB_PBM_TABLE,pbmPara->pbIndex,pbmPara->pbLocation,pbmPara->mobilNumber,
-pbmPara->pbType,pbmPara->name,pbmPara->homeNumber,pbmPara->officeNumber,pbmPara
-->email,pbmPara->sne,pbmPara->pbId);}else if(ZPB_LOCATION_AP==pbmPara->
-pbLocation){snprintf(sql,len,"update %s set Pbm_index=\'%d\',Location=\'%d\',Number=\'%s\',Type=\'%d\',Name=\'%s\',Anr=\'%s\', \
- Anr1=\'%s\',Email=\'%s\',Sne=\'%s\',Pbm_group=\'%s\' where id=%d",ZPB_DB_PBM_TABLE,pbmPara->pbIndex,pbmPara->pbLocation,pbmPara->mobilNumber,
-pbmPara->pbType,pbmPara->name,pbmPara->homeNumber,pbmPara->officeNumber,pbmPara
-->email,pbmPara->sne,pbmPara->group,pbmPara->pbId);}}T_zPb_DbResult
-atPb_DbGetParamCb(VOID*fvarg,int line,char**zresult,char**lname){T_zPb_Header
-para={(0x904+4519-0x1aab)};if((0x1479+2419-0x1deb)>line){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x62\x47\x65\x74\x50\x61\x72\x61\x6d\x43\x62\x3a\x72\x65\x63\x6f\x72\x64\x20\x6e\x6f\x20\x64\x61\x74\x61\x2e"
-);return ZPB_DB_ERROR;}para.pbIndex=atoi(zresult[(0x11cb+4266-0x2275)]);para.
-pbLocation=atoi(zresult[(0xddb+3424-0x1b3a)]);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x62\x47\x65\x74\x50\x61\x72\x61\x6d\x43\x62\x3a\x20\x69\x6e\x64\x65\x78\x3d\x25\x64\x2c\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,para.pbIndex,para.pbLocation);memcpy(fvarg,¶,sizeof(para));return ZPB_DB_OK
-;}T_zPb_DbResult atPb_GetIndexLocationById(T_zPb_Header*pbPara){CHAR sql[
-ZPB_MAX_BYTES_DB]={(0x2013+801-0x2334)};snprintf(sql,sizeof(sql)-
-(0x1944+3076-0x2547),
-"\x73\x65\x6c\x65\x63\x74\x20\x50\x62\x6d\x5f\x69\x6e\x64\x65\x78\x2c\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x69\x64\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,pbPara->pbId);memset(pbPara,(0x250+7824-0x20e0),sizeof(
-T_zPb_Header));return atPb_ExecDbSql(sql,atPb_DbGetParamCb,pbPara);}VOID
-atPb_SqlNewOneRec(T_zPb_WebContact*pbmPara,CHAR*sql,int len){if(
-ZPB_LOCATION_USIM==pbmPara->pbLocation){snprintf(sql,len,"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne)\
- values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",ZPB_DB_PBM_TABLE,pbmPara->pbIndex,pbmPara->pbLocation,pbmPara->mobilNumber,
-pbmPara->pbType,pbmPara->name,pbmPara->homeNumber,pbmPara->officeNumber,pbmPara
-->email,pbmPara->sne);}else if(ZPB_LOCATION_AP==pbmPara->pbLocation){snprintf(
-sql,len,"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne,Pbm_group)\
- values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",ZPB_DB_PBM_TABLE,pbmPara->pbIndex,pbmPara->pbLocation,pbmPara->mobilNumber,
-pbmPara->pbType,pbmPara->name,pbmPara->homeNumber,pbmPara->officeNumber,pbmPara
-->email,pbmPara->sne,pbmPara->group);}}T_zPb_DbResult
-atPb_WriteContactToPbmTable(T_zPb_WebContact*pPbRecord,BOOL pbNewFlag){
-T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0xc67+4861-0x1f64)}
-;if(NULL==pPbRecord){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x57\x72\x69\x74\x65\x43\x6f\x6e\x74\x61\x63\x74\x54\x6f\x50\x62\x6d\x54\x61\x62\x6c\x65\x3a\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74"
-);return ZPB_DB_ERROR_INVALIDPTR;}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x57\x72\x69\x74\x65\x43\x6f\x6e\x74\x61\x63\x74\x54\x6f\x50\x62\x6d\x54\x61\x62\x6c\x65\x3a\x69\x6e\x70\x75\x74\x20\x69\x6e\x64\x65\x78\x20\x69\x73\x20\x25\x64\x2c\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64" "\n"
-,pPbRecord->pbIndex,pPbRecord->pbLocation);if(TRUE==pbNewFlag){atPb_SqlNewOneRec
-(pPbRecord,sql,sizeof(sql));}else{atPb_SqlModifyOneRec(pPbRecord,sql,sizeof(sql)
-);}result=atPb_ExecDbSql(sql,NULL,NULL);if(ZPB_DB_OK==result){if(
-ZPB_LOCATION_USIM==pPbRecord->pbLocation){g_zPb_SimIndex[(pPbRecord->pbIndex)]=
-PBM_SUCCESS;}else if(ZPB_LOCATION_AP==pPbRecord->pbLocation){g_zPb_ApIndex[(
-pPbRecord->pbIndex)]=PBM_SUCCESS;}}return result;}SINT32 atPb_DbCountTableLineCb
-(VOID*fvarg,int line,char**zresult,char**lname){if((0x6a+9234-0x247b)>line){slog
-(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x72\x65\x63\x6f\x72\x64\x20\x6e\x6f\x20\x64\x61\x74\x61\x2e"
-);return-(0x1a19+334-0x1b66);}*(int*)fvarg=atoi(zresult[(0xf9d+2448-0x192d)]);
-return(0x14f2+2451-0x1e85);}T_zPb_DbResult atPb_SetSimCapacityTable(
-T_zPb_UsimCapacity pbPara){T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[
-ZPB_MAX_BYTES_DB]={(0x5f4+6581-0x1fa9)};UINT32 count=(0xbcb+6172-0x23e7);
-snprintf(sql,sizeof(sql)-(0x1a32+1835-0x215c),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73"
-,ZPB_DB_SIM_CAPABILITY_TABLE);(VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&
-count);if((0x83b+5003-0x1bc6)<count){memset(sql,(0x78+2703-0xb07),sizeof(sql));
-snprintf(sql,sizeof(sql)-(0xc87+846-0xfd4),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x53\x69\x6d\x5f\x74\x79\x70\x65\x3e\x3d\x30"
-,ZPB_DB_SIM_CAPABILITY_TABLE);result=atPb_ExecDbSql(sql,NULL,NULL);if(ZPB_DB_OK
-!=result){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x65\x74\x53\x69\x6d\x43\x61\x70\x61\x63\x69\x74\x79\x54\x61\x62\x6c\x65\x3a\x66\x61\x69\x6c\x21" "\n"
-);return result;}}memset(sql,(0x126a+213-0x133f),sizeof(sql));snprintf(sql,
-sizeof(sql)-(0x91f+1686-0xfb4),"insert into %s (Sim_type,Max_record_number,Used_record_number,Max_number_len,Max_name_len,Max_anr_len,Max_anr1_len, \
- Max_email_len,Max_sne_len) values(\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\')",ZPB_DB_SIM_CAPABILITY_TABLE,pbPara.simType,pbPara.maxRecordNum,pbPara.
-usedRecordNum,pbPara.maxNumberLen,pbPara.maxNameLen,pbPara.maxAnrLen,pbPara.
-maxAnr1Len,pbPara.maxEmailLen,pbPara.maxSneLen);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x65\x74\x53\x69\x6d\x43\x61\x70\x61\x63\x69\x74\x79\x54\x61\x62\x6c\x65\x3a\x6f\x6b\x21" "\n"
-);return atPb_ExecDbSql(sql,NULL,NULL);}T_zPb_DbResult atPb_SetApCapacityTable()
-{T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0xdf4+4783-0x20a3)
-};SINT32 count=(0x1e4d+1940-0x25e1);T_zPb_ApCapacity pbPara={
-(0x1c3b+1800-0x2343)};snprintf(sql,sizeof(sql)-(0x14c0+3297-0x21a0),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73"
-,ZPB_DB_DEVICE_CAPABILITY_TABLE);(VOID)atPb_ExecDbSql(sql,
-atPb_DbCountTableLineCb,&count);if((0x18df+221-0x19bc)<count){memset(sql,
-(0x1c+6659-0x1a1f),sizeof(sql));snprintf(sql,sizeof(sql)-(0x10e0+2762-0x1ba9),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73",
-ZPB_DB_DEVICE_CAPABILITY_TABLE);result=atPb_ExecDbSql(sql,NULL,NULL);if(
-ZPB_DB_OK!=result){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x65\x74\x41\x70\x43\x61\x70\x61\x63\x69\x74\x79\x54\x61\x62\x6c\x65\x3a\x66\x61\x69\x6c\x21" "\n"
-);return result;}}memset(sql,(0xa61+6377-0x234a),sizeof(sql));snprintf(sql,
-sizeof(sql)-(0x4ad+6230-0x1d02),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP);result=atPb_ExecDbSql(sql,
-atPb_DbCountTableLineCb,&count);if(ZPB_DB_OK==result){pbPara.usedRecordNum=count
-;pbPara.maxRecordNum=ZPB_AP_MAX_RECORD;}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x6d\x61\x78\x5f\x72\x65\x63\x5f\x6e\x75\x6d\x3d\x25\x64\x2c\x75\x73\x65\x64\x3d\x25\x64"
-,pbPara.maxRecordNum,pbPara.usedRecordNum);memset(sql,(0x1892+418-0x1a34),sizeof
-(sql));snprintf(sql,sizeof(sql)-(0x911+6386-0x2202),
-"\x69\x6e\x73\x65\x72\x74\x20\x69\x6e\x74\x6f\x20\x25\x73\x20\x28\x4d\x61\x78\x5f\x72\x65\x63\x6f\x72\x64\x5f\x6e\x75\x6d\x62\x65\x72\x2c\x55\x73\x65\x64\x5f\x72\x65\x63\x6f\x72\x64\x5f\x6e\x75\x6d\x62\x65\x72\x29\x20\x76\x61\x6c\x75\x65\x73\x28" "\'" "\x25\x64" "\'" "\x2c" "\'" "\x25\x64" "\'" "\x29"
-,ZPB_DB_DEVICE_CAPABILITY_TABLE,pbPara.maxRecordNum,pbPara.usedRecordNum);return
- atPb_ExecDbSql(sql,NULL,NULL);}T_zPb_DbResult atPb_DbGetIndexByGroupCb(VOID*
-fvarg,int line,char**zresult,char**lname){T_zPb_ApIndex*pbIndex=NULL;int i=
-(0x523+5894-0x1c29);if((0xc05+4139-0x1c2f)>line){return ZPB_DB_ERROR;}pbIndex=(
-T_zPb_ApIndex*)fvarg;i=pbIndex->count;slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x62\x47\x65\x74\x49\x6e\x64\x65\x78\x42\x79\x47\x72\x6f\x75\x70\x43\x62\x20\x65\x6e\x74\x65\x72\x2c\x69\x3d\x25\x64" "\n"
-,i);pbIndex->apIndex[i+(0x63f+7847-0x24e5)]=atoi(zresult[(0x5e5+4079-0x15d4)]);
-slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x67\x65\x74\x5f\x69\x6e\x64\x65\x78\x5f\x62\x79\x5f\x67\x72\x6f\x75\x70\x5f\x63\x62\x3a\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3d\x25\x64"
-,pbIndex->apIndex[i+(0x1624+1631-0x1c82)]);pbIndex->count=i+(0x23c+2043-0xa36);
-slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x67\x65\x74\x5f\x69\x6e\x64\x65\x78\x5f\x62\x79\x5f\x67\x72\x6f\x75\x70\x5f\x63\x62\x3a\x70\x62\x6d\x20\x63\x6f\x75\x6e\x74\x20\x69\x73\x20\x25\x64"
-,pbIndex->count);return ZPB_DB_OK;}T_zPb_DbResult atPb_DelRecFromPbmTableByGroup
-(T_zPb_ApIndex*index){T_zPb_DbResult result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]
-={(0x5f+1373-0x5bc)};SINT32 countByGroup=(0xebf+267-0xfca);CHAR pbGroup[
-ZPB_PARAM_SIZE20]={(0x837+1702-0xedd)};sc_cfg_get(ZPB_NV_GROUP,pbGroup,sizeof(
-pbGroup));snprintf(sql,sizeof(sql)-(0x1090+3204-0x1d13),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64\x20\x61\x6e\x64\x20\x28\x50\x62\x6d\x5f\x67\x72\x6f\x75\x70\x3d" "\"" "\x25\x73" "\"" "\x29"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP,pbGroup);(VOID)atPb_ExecDbSql(sql,
-atPb_DbCountTableLineCb,&countByGroup);memset(sql,(0x1d41+1412-0x22c5),sizeof(
-sql));snprintf(sql,sizeof(sql)-(0xbc5+84-0xc18),
-"\x73\x65\x6c\x65\x63\x74\x20\x50\x62\x6d\x5f\x69\x6e\x64\x65\x78\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64\x20\x61\x6e\x64\x20\x28\x50\x62\x6d\x5f\x67\x72\x6f\x75\x70\x3d" "\"" "\x25\x73" "\"" "\x29"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP,pbGroup);result=atPb_ExecDbSql(sql,
-atPb_DbGetIndexByGroupCb,index);if(countByGroup==index->count){memset(sql,
-(0x7e8+6380-0x20d4),sizeof(sql));snprintf(sql,sizeof(sql)-(0x189d+1369-0x1df5),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64\x20\x61\x6e\x64\x20\x28\x50\x62\x6d\x5f\x67\x72\x6f\x75\x70\x3d" "\"" "\x25\x73" "\"" "\x29"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP,pbGroup);if(ZPB_DB_OK==atPb_ExecDbSql(sql,NULL
-,NULL)){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);}slog(PB_PRINT,
-SLOG_DEBUG,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x65\x78\x65\x63\x20\x74\x61\x62\x6c\x65\x20\x25\x73\x20\x72\x65\x73\x75\x6c\x74\x20\x25\x64" "\n"
-,ZPB_DB_PBM_TABLE,result);}else{return ZPB_DB_ERROR;}(VOID)sc_cfg_set(
-ZPB_NV_GROUP,"");return result;}VOID atPb_GetLocationIndexForDel(T_zPb_DelInfo*
-recData,SINT32 delTime){T_zPb_Header pbHeader={(0x50d+1274-0xa07)};if(NULL==
-recData){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x47\x65\x74\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x49\x6e\x64\x65\x78\x46\x6f\x72\x44\x65\x6c\x2d\x2d\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74" "\n"
-);return;}pbHeader.pbId=recData->delId[delTime];if(ZPB_DB_OK!=
-atPb_GetIndexLocationById(&pbHeader)){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x66\x69\x6e\x64\x20\x69\x6e\x64\x65\x78\x20\x61\x6e\x64\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x66\x61\x69\x6c\x65\x64"
-);return;}recData->delIndex[delTime]=pbHeader.pbIndex;recData->delLocation=
-pbHeader.pbLocation;slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x64\x65\x6c\x20\x69\x6e\x64\x65\x78\x3d\x25\x64\x2c\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64\x2c\x64\x65\x6c\x5f\x70\x62\x6d\x5f\x74\x69\x6d\x65\x3d\x25\x64"
-,recData->delIndex[delTime],recData->delLocation,delTime);}T_zPb_DbResult
-atPb_DelARecFromPbmTable(T_zPb_DelInfo*pbPara,SINT32 delTime){T_zPb_DbResult
-result=ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0x1603+2123-0x1e4e)};if(NULL==
-pbPara){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74"
-);return ZPB_DB_ERROR_INVALIDPTR;}atPb_GetLocationIndexForDel(pbPara,delTime);
-slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x65\x6c\x41\x52\x65\x63\x46\x72\x6f\x6d\x50\x62\x6d\x54\x61\x62\x6c\x65\x20\x65\x6e\x74\x65\x72\x2c\x64\x65\x6c\x54\x69\x6d\x65\x3d\x25\x64\x2c\x69\x64\x3d\x25\x64" "\n"
-,delTime,pbPara->delId[delTime]);snprintf(sql,sizeof(sql)-(0xa9d+31-0xabb),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x69\x64\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,pbPara->delId[delTime]);result=atPb_ExecDbSql(sql,NULL,NULL);
-if(ZPB_DB_OK==result){if(ZPB_LOCATION_AP==pbPara->delLocation){g_zPb_ApIndex[(
-pbPara->delIndex[delTime])]=PBM_ERROR_NOT_FOUND;}else if(ZPB_LOCATION_USIM==
-pbPara->delLocation){g_zPb_SimIndex[(pbPara->delIndex[delTime])]=
-PBM_ERROR_NOT_FOUND;}}return result;}VOID atPb_ClearSimPbmIndexArray(VOID){
-SINT32 i=(0xff+4212-0x1172);for(i=(0x1127+5041-0x24d7);(i<=g_zPb_SimIndex[
-(0x1634+3491-0x23d7)])&&(i<(ZPB_SIM_MAX_RECORD+(0x16bc+555-0x18e6)));i++){
-g_zPb_SimIndex[i]=PBM_ERROR_NOT_FOUND;}}VOID atPb_ClearApPbmIndexArray(VOID){
-SINT32 i=(0x66b+2883-0x11ad);for(i=(0x155a+956-0x1915);(i<=g_zPb_ApIndex[
-(0x254+4705-0x14b5)])&&(i<(ZPB_AP_MAX_RECORD+(0x4ab+8038-0x2410)));i++){
-g_zPb_ApIndex[i]=PBM_ERROR_NOT_FOUND;}}T_zPb_DbResult
-atPb_DelAllRecsFromPbmTable(T_zPb_DelInfo*pbPara){T_zPb_DbResult result=
-ZPB_DB_OK;CHAR sql[ZPB_MAX_BYTES_DB]={(0x602+6240-0x1e62)};if(NULL==pbPara){slog
-(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x52\x65\x63\x73\x46\x72\x6f\x6d\x50\x62\x6d\x54\x61\x62\x6c\x65\x3a\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74" "\n"
-);return ZPB_DB_ERROR_INVALIDPTR;}snprintf(sql,sizeof(sql)-(0x41c+1190-0x8c1),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,pbPara->delLocation);result=atPb_ExecDbSql(sql,NULL,NULL);slog
-(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x52\x65\x63\x73\x46\x72\x6f\x6d\x50\x62\x6d\x54\x61\x62\x6c\x65\x3a\x65\x78\x65\x63\x20\x74\x61\x62\x6c\x65\x20\x25\x73\x20\x72\x65\x73\x75\x6c\x74\x20\x25\x64"
-,ZPB_DB_PBM_TABLE,result);if(ZPB_LOCATION_USIM==pbPara->delLocation){
-atPb_ClearSimPbmIndexArray();}else if(ZPB_LOCATION_AP==pbPara->delLocation){
-atPb_ClearApPbmIndexArray();}else if(ZPB_LOCATION_ALL==pbPara->delLocation){
-atPb_ClearSimPbmIndexArray();atPb_ClearApPbmIndexArray();}return result;}
+ return ZUFI_SUCC;
+}
+
+T_zPb_DbResult atPb_DelSimRecFromPbTable(SINT32 index)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+ snprintf(sql,sizeof(sql),"delete from %s where location=%d and Pbm_index=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM,index);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+
+ if(ZPB_DB_OK == result)
+ {
+ g_zPb_SimIndex[index] = PBM_ERROR_NOT_FOUND;
+ }
+ return result;
+}
+
+T_zPb_DbResult atPb_LoadARecToPbmTable(T_zPb_WebContact *pbPara)
+{
+ T_zPb_DbResult result = ZPB_DB_ERROR;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ if(NULL == pbPara)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_LoadARecToPbmTable:invalid input");/*lint !e26*/
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ snprintf(sql,sizeof(sql),"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne) \
+ values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",
+ ZPB_DB_PBM_TABLE,
+ pbPara->pbIndex,
+ pbPara->pbLocation,
+ pbPara->mobilNumber,
+ pbPara->pbType,
+ pbPara->name,
+ pbPara->homeNumber,
+ pbPara->officeNumber,
+ pbPara->email,
+ pbPara->sne);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ if(ZPB_DB_OK==result)
+ {
+ CHAR pbMax[50]={0};
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+ if((pbPara->pbIndex>=1)&&(pbPara->pbIndex <= atoi(pbMax)))/*Comment: Èç¹ûµç»°±¾ÔÚË÷ÒýÄÚ,ZhaoYong,2008/12/23 10:49 */
+ {
+ g_zPb_SimIndex[pbPara->pbIndex] = PBM_SUCCESS;
+ }
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:exec table %s result %d\n", ZPB_DB_PBM_TABLE,result);
+ return result;
+}
+
+VOID atPb_SqlModifyOneRec(T_zPb_WebContact *pbmPara,char *sql,int len)
+{
+ printf("pb:atPb_SqlModifyOneRec enter");/*lint !e26*/
+
+ if(ZPB_LOCATION_USIM == pbmPara->pbLocation)
+ {
+ snprintf(sql,len,"update %s set Pbm_index=\'%d\',Location=\'%d\',Number=\'%s\',Type=\'%d\',Name=\'%s\',Anr=\'%s\', \
+ Anr1=\'%s\',Email=\'%s\',Sne=\'%s\' where id=%d",
+ ZPB_DB_PBM_TABLE,
+ pbmPara->pbIndex,
+ pbmPara->pbLocation,
+ pbmPara->mobilNumber,
+ pbmPara->pbType,
+ pbmPara->name,
+ pbmPara->homeNumber,
+ pbmPara->officeNumber,
+ pbmPara->email,
+ pbmPara->sne,
+ pbmPara->pbId);
+ }
+ else if(ZPB_LOCATION_AP == pbmPara->pbLocation)
+ {
+ snprintf(sql,len,"update %s set Pbm_index=\'%d\',Location=\'%d\',Number=\'%s\',Type=\'%d\',Name=\'%s\',Anr=\'%s\', \
+ Anr1=\'%s\',Email=\'%s\',Sne=\'%s\',Pbm_group=\'%s\' where id=%d",
+ ZPB_DB_PBM_TABLE,
+ pbmPara->pbIndex,
+ pbmPara->pbLocation,
+ pbmPara->mobilNumber,
+ pbmPara->pbType,
+ pbmPara->name,
+ pbmPara->homeNumber,
+ pbmPara->officeNumber,
+ pbmPara->email,
+ pbmPara->sne,
+ pbmPara->group,
+ pbmPara->pbId);
+ }
+}
+
+T_zPb_DbResult atPb_DbGetParamCb(VOID *fvarg,int line,char **zresult,char **lname)
+{
+ T_zPb_Header para = {0};
+
+ if(1 > line)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_DbGetParamCb:record no data.");/*lint !e26*/
+ return ZPB_DB_ERROR;
+ }
+
+ para.pbIndex = atoi(zresult[0]);
+ para.pbLocation = atoi(zresult[1]);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_DbGetParamCb: index=%d,location=%d", para.pbIndex, para.pbLocation);
+ memcpy(fvarg,¶,sizeof(para));
+ return ZPB_DB_OK;
+}
+T_zPb_DbResult atPb_GetIndexLocationById(T_zPb_Header *pbPara)
+{
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+ snprintf(sql,sizeof(sql)-1,"select Pbm_index,Location from %s where id=%d",
+ ZPB_DB_PBM_TABLE,
+ pbPara->pbId);
+
+ memset(pbPara, 0,sizeof(T_zPb_Header));
+ return atPb_ExecDbSql(sql,atPb_DbGetParamCb, pbPara);
+}
+
+VOID atPb_SqlNewOneRec(T_zPb_WebContact *pbmPara,CHAR *sql,int len)
+{
+ if(ZPB_LOCATION_USIM == pbmPara->pbLocation)
+ {
+ snprintf(sql,len,"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne)\
+ values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",
+ ZPB_DB_PBM_TABLE,
+ pbmPara->pbIndex,
+ pbmPara->pbLocation,
+ pbmPara->mobilNumber,
+ pbmPara->pbType,
+ pbmPara->name,
+ pbmPara->homeNumber,
+ pbmPara->officeNumber,
+ pbmPara->email,
+ pbmPara->sne);
+
+ }
+ else if(ZPB_LOCATION_AP == pbmPara->pbLocation)
+ {
+ snprintf(sql,len,"insert into %s (Pbm_index,Location,Number,Type,Name,Anr,Anr1,Email,Sne,Pbm_group)\
+ values(\'%d\',\'%d\',\'%s\',\'%d\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\')",
+ ZPB_DB_PBM_TABLE,
+ pbmPara->pbIndex,
+ pbmPara->pbLocation,
+ pbmPara->mobilNumber,
+ pbmPara->pbType,
+ pbmPara->name,
+ pbmPara->homeNumber,
+ pbmPara->officeNumber,
+ pbmPara->email,
+ pbmPara->sne,
+ pbmPara->group);
+ }
+}
+
+
+T_zPb_DbResult atPb_WriteContactToPbmTable(T_zPb_WebContact *pPbRecord, BOOL pbNewFlag)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ //UINT8 ascName[ZPB_TEXT_SIZE_BYTES]={0};
+
+ if(NULL == pPbRecord)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_WriteContactToPbmTable:invalid input");/*lint !e26*/
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_WriteContactToPbmTable:input index is %d,location=%d\n",pPbRecord->pbIndex,pPbRecord->pbLocation);
+
+ //atPb_EncodeNameToAscii(pbRecord->name,ascName);
+ if(TRUE == pbNewFlag)
+ {
+ atPb_SqlNewOneRec(pPbRecord,sql,sizeof(sql));
+ }
+ else
+ {
+ atPb_SqlModifyOneRec(pPbRecord,sql,sizeof(sql));
+ }
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+
+ if(ZPB_DB_OK == result)
+ {
+ if(ZPB_LOCATION_USIM == pPbRecord->pbLocation)
+ {
+ g_zPb_SimIndex[(pPbRecord->pbIndex)] = PBM_SUCCESS;
+ }
+ else if(ZPB_LOCATION_AP == pPbRecord->pbLocation)
+ {
+ g_zPb_ApIndex[(pPbRecord->pbIndex)] = PBM_SUCCESS;
+ }
+ //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
+ }
+ return result;
+}
+
+
+
+SINT32 atPb_DbCountTableLineCb(VOID *fvarg,int line,char **zresult,char **lname)
+{
+ if(1 > line)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:record no data.");/*lint !e26*/
+ return -1;
+ }
+ *(int*)fvarg = atoi(zresult[0]);
+
+ return 0;
+}
+
+T_zPb_DbResult atPb_SetSimCapacityTable(T_zPb_UsimCapacity pbPara)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ UINT32 count = 0;
+
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s",ZPB_DB_SIM_CAPABILITY_TABLE);
+ (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
+ if(0 < count)
+ {
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Sim_type>=0",ZPB_DB_SIM_CAPABILITY_TABLE);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_SetSimCapacityTable:fail!\n");
+ return result;
+ }
+ }
+
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"insert into %s (Sim_type,Max_record_number,Used_record_number,Max_number_len,Max_name_len,Max_anr_len,Max_anr1_len, \
+ Max_email_len,Max_sne_len) values(\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\',\'%d\')",
+ ZPB_DB_SIM_CAPABILITY_TABLE,
+ pbPara.simType,
+ pbPara.maxRecordNum,
+ pbPara.usedRecordNum,
+ pbPara.maxNumberLen,
+ pbPara.maxNameLen,
+ pbPara.maxAnrLen,
+ pbPara.maxAnr1Len,
+ pbPara.maxEmailLen,
+ pbPara.maxSneLen);
+
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_SetSimCapacityTable:ok!\n");
+ return atPb_ExecDbSql(sql,NULL,NULL);
+}
+
+T_zPb_DbResult atPb_SetApCapacityTable()
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ SINT32 count = 0;
+ T_zPb_ApCapacity pbPara = {0};
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s",ZPB_DB_DEVICE_CAPABILITY_TABLE);
+ (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
+ if(0 < count)
+ {
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"delete from %s",ZPB_DB_DEVICE_CAPABILITY_TABLE);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ if(ZPB_DB_OK != result)
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_SetApCapacityTable:fail!\n");
+ return result;
+ }
+ }
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s where Location=%d",ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP);
+ result = atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
+ if(ZPB_DB_OK == result)
+ {
+ pbPara.usedRecordNum = count;
+ pbPara.maxRecordNum = ZPB_AP_MAX_RECORD;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:max_rec_num=%d,used=%d",pbPara.maxRecordNum,pbPara.usedRecordNum);
+
+ memset(sql, 0, sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"insert into %s (Max_record_number,Used_record_number) values(\'%d\',\'%d\')",
+ ZPB_DB_DEVICE_CAPABILITY_TABLE,
+ pbPara.maxRecordNum,
+ pbPara.usedRecordNum);
+ return atPb_ExecDbSql(sql,NULL,NULL);
+}
+
+T_zPb_DbResult atPb_DbGetIndexByGroupCb(VOID *fvarg,int line,char **zresult,char **lname)
+{
+ T_zPb_ApIndex *pbIndex = NULL;
+ int i = 0;
+
+ if(1 > line)
+ {
+ return ZPB_DB_ERROR;
+ }
+
+ pbIndex = (T_zPb_ApIndex*)fvarg;
+ i = pbIndex->count;
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_DbGetIndexByGroupCb enter,i=%d\n",i);
+
+ pbIndex->apIndex[i+1]= atoi(zresult[0]);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:get_index_by_group_cb:pbm_index=%d",pbIndex->apIndex[i+1]);
+
+ pbIndex->count = i + 1;
+ slog(PB_PRINT,SLOG_DEBUG,"pb:get_index_by_group_cb:pbm count is %d",pbIndex->count);
+ return ZPB_DB_OK;
+}
+
+T_zPb_DbResult atPb_DelRecFromPbmTableByGroup(T_zPb_ApIndex *index)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ SINT32 countByGroup = 0;
+ CHAR pbGroup[ZPB_PARAM_SIZE20] = {0};
+
+ sc_cfg_get(ZPB_NV_GROUP,pbGroup,sizeof(pbGroup));
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s where Location=%d and (Pbm_group=\"%s\")",
+ ZPB_DB_PBM_TABLE, ZPB_LOCATION_AP, pbGroup);
+ (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&countByGroup);
+
+ memset(sql,0,sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"select Pbm_index from %s where Location=%d and (Pbm_group=\"%s\")",ZPB_DB_PBM_TABLE,ZPB_LOCATION_AP,pbGroup);
+ result = atPb_ExecDbSql(sql,atPb_DbGetIndexByGroupCb, index); /*lint !e64*/
+
+ if(countByGroup == index->count)
+ {
+ memset(sql,0,sizeof(sql));
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d and (Pbm_group=\"%s\")",
+ ZPB_DB_PBM_TABLE,
+ ZPB_LOCATION_AP,
+ pbGroup);
+
+ if(ZPB_DB_OK == atPb_ExecDbSql(sql,NULL,NULL))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:exec table %s result %d\n", ZPB_DB_PBM_TABLE,result);
+ }
+ else
+ {
+ return ZPB_DB_ERROR;
+ }
+ /*write group nvconfig ""*/
+ (VOID)sc_cfg_set(ZPB_NV_GROUP, "");
+ return result;
+}
+
+VOID atPb_GetLocationIndexForDel(T_zPb_DelInfo *recData,SINT32 delTime)
+{
+ T_zPb_Header pbHeader = {0};
+
+ if(NULL == recData)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_GetLocationIndexForDel--invalid input\n");
+ return;
+ }
+
+ pbHeader.pbId = recData->delId[delTime];
+
+ if(ZPB_DB_OK != atPb_GetIndexLocationById(&pbHeader))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:find index and location failed");
+ return;
+ }
+ recData->delIndex[delTime] = pbHeader.pbIndex;
+ recData->delLocation = pbHeader.pbLocation;
+ slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:del index=%d,location=%d,del_pbm_time=%d",
+ recData->delIndex[delTime],recData->delLocation,delTime);
+}
+
+/* ¶ÌÐÅת´æ»òÐ޸쬏ÄΪÏÈ·¢atÃüÁÔÙ´æÊý¾Ý¿â£¬¹Ê´æ´¢³É¹¦¶øatÃüÁî·¢ËÍʧ°Üɾ³ý֮ǰ´æ´¢µÄ¶ÌÐÅÕâÖÖ³¡¾°²»´æÔÚ
+T_zPb_DbResult atPb_DelRecordFromDBWhenAddErr()
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+ sprintf(sql,"delete from %s where Pbm_index=%ld",ZPB_DB_PBM_TABLE,g_zPb_pbIndex);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+
+ if(ZPB_DB_OK == result)
+ {
+ g_zPb_SimIndex[g_zPb_pbIndex] = PBM_ERROR_NOT_FOUND;
+ }
+
+ printf("[PB] atPb_DelRecordFromDBWhenAddErr result=%d,g_zPb_pbIndex=%d\n", result,g_zPb_pbIndex);
+ g_zPb_pbIndex = 0;
+ return result;
+}*/
+
+
+T_zPb_DbResult atPb_DelARecFromPbmTable(T_zPb_DelInfo *pbPara, SINT32 delTime)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+ if(NULL == pbPara)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:pbm:invalid input");
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ atPb_GetLocationIndexForDel(pbPara, delTime);//del_pbm_time);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_DelARecFromPbmTable enter,delTime=%d,id=%d\n",delTime,pbPara->delId[delTime]);
+
+ snprintf(sql,sizeof(sql)-1,"delete from %s where id=%d",ZPB_DB_PBM_TABLE,pbPara->delId[delTime]);//del_pbm_time]);// ÔÝʱÏȶ¨Îª0
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+
+ if(ZPB_DB_OK == result)
+ {
+ if(ZPB_LOCATION_AP == pbPara->delLocation)
+ {
+ g_zPb_ApIndex[(pbPara->delIndex[delTime])] = PBM_ERROR_NOT_FOUND;
+ }
+ else if(ZPB_LOCATION_USIM == pbPara->delLocation)
+ {
+ g_zPb_SimIndex[(pbPara->delIndex[delTime])] = PBM_ERROR_NOT_FOUND;
+ }
+ }
+ return result;
+}
+VOID atPb_ClearSimPbmIndexArray(VOID)
+{
+ SINT32 i = 1;
+
+ for(i = 1; (i <= g_zPb_SimIndex[0]) && (i < (ZPB_SIM_MAX_RECORD+1)); i++)
+ {
+ g_zPb_SimIndex[i] = PBM_ERROR_NOT_FOUND;
+ }
+}
+
+VOID atPb_ClearApPbmIndexArray(VOID)
+{
+ SINT32 i = 1;
+
+ for(i = 1 ; (i <= g_zPb_ApIndex[0]) && (i < (ZPB_AP_MAX_RECORD+1)); i++)
+ {
+ g_zPb_ApIndex[i] = PBM_ERROR_NOT_FOUND;
+ }
+}
+
+T_zPb_DbResult atPb_DelAllRecsFromPbmTable(T_zPb_DelInfo *pbPara)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+
+ if(NULL == pbPara)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_DelAllRecsFromPbmTable:invalid input\n");/*lint !e26*/
+ return ZPB_DB_ERROR_INVALIDPTR;
+ }
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, pbPara->delLocation);
+ result = atPb_ExecDbSql(sql,NULL,NULL);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_DelAllRecsFromPbmTable:exec table %s result %d", ZPB_DB_PBM_TABLE,result);
+
+ if(ZPB_LOCATION_USIM == pbPara->delLocation)
+ {
+ atPb_ClearSimPbmIndexArray();
+ }
+ else if(ZPB_LOCATION_AP == pbPara->delLocation)
+ {
+ atPb_ClearApPbmIndexArray();
+ }
+ else if(ZPB_LOCATION_ALL == pbPara->delLocation)
+ {
+ atPb_ClearSimPbmIndexArray();
+ atPb_ClearApPbmIndexArray();
+ }
+ return result;
+}
+
+
diff --git a/ap/app/zte_comm/phonebook/src/pb_main.c b/ap/app/zte_comm/phonebook/src/pb_main.c
index 9442602..58a9dce 100755
--- a/ap/app/zte_comm/phonebook/src/pb_main.c
+++ b/ap/app/zte_comm/phonebook/src/pb_main.c
@@ -1,152 +1,494 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : pb
+* ÎÄ ¼þ Ãû : pb_main.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : PBÏûÏ¢Á÷³Ì¿ØÖÆ´¦Àí
+* ×÷ Õß :
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2017.3.13
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
#include <errno.h>
#include <sys/msg.h>
#include <semaphore.h>
+
#include "pb_com.h"
-typedef VOID(*pAtWeb_PbMsgProc)(UINT8*pDatabuf);typedef struct{UINT32 msg_id;
-VOID(*func_ptr)(UINT8*pDatabuf);BOOL need_block;}T_zPbHandleTable;VOID
-atWeb_AddOneContact(UINT8*pDatabuf);VOID atWeb_DelOneContact(UINT8*pDatabuf);
-VOID atWeb_DelMultiContact(UINT8*pDatabuf);VOID atWeb_DelAllContact(UINT8*
-pDatabuf);T_zPb_optRsp g_PbOptRsp={(0xc13+6886-0x26f9)};sem_t g_Pb_sem_id={
-(0x1aa5+97-0x1b06)};int g_zPb_MsqId=-(0xde9+4652-0x2014);int g_zPb_LocalMsqId=-
-(0x3e8+8013-0x2334);VOID atWeb_AddOneContact(UINT8*pDatabuf){T_zPb_WebContact*
-webPbContact=NULL;if(pDatabuf==NULL){printf(
-"\x5b\x70\x62\x5d\x2c\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x43\x6f\x6e\x74\x61\x63\x74\x20\x70\x61\x72\x61\x20\x69\x73\x20\x6e\x75\x6c\x6c" "\n"
-);return;}webPbContact=(T_zPb_WebContact*)pDatabuf;atWeb_AddOnePb(webPbContact,
-g_Pb_sem_id);}VOID atWeb_DelOneContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord=
-NULL;if(pDatabuf==NULL){printf(
-"\x5b\x70\x62\x5d\x2c\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4f\x6e\x65\x43\x6f\x6e\x74\x61\x63\x74\x20\x70\x61\x72\x61\x20\x69\x73\x20\x6e\x75\x6c\x6c" "\n"
-);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelOnepb(delRecord,
-g_Pb_sem_id);}VOID atWeb_DelMultiContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord
-=NULL;if(pDatabuf==NULL){printf(
-"\x5b\x70\x62\x5d\x2c\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4f\x6e\x65\x43\x6f\x6e\x74\x61\x63\x74\x20\x70\x61\x72\x61\x20\x69\x73\x20\x6e\x75\x6c\x6c" "\n"
-);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelMultPb(delRecord,
-g_Pb_sem_id);}VOID atWeb_DelAllContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord=
-NULL;if(pDatabuf==NULL){printf(
-"\x5b\x70\x62\x5d\x2c\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4f\x6e\x65\x43\x6f\x6e\x74\x61\x63\x74\x20\x70\x61\x72\x61\x20\x69\x73\x20\x6e\x75\x6c\x6c" "\n"
-);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelAllpb(delRecord,
-g_Pb_sem_id);}VOID zPb_RecvScpbrInd(UINT8*pDatabuf){T_zPb_AtScpbrTestRes*
-scpbsInd=NULL;if(pDatabuf==NULL){return;}scpbsInd=(T_zPb_AtScpbrTestRes*)
-pDatabuf;atPb_ScpbrTestRsp(scpbsInd);}VOID zPb_RecvScpbrReadInd(UINT8*pDatabuf){
-T_zPb_ScpbrSetRes*scpbsReadInd=NULL;if(pDatabuf==NULL){return;}scpbsReadInd=(
-T_zPb_ScpbrSetRes*)pDatabuf;atPb_ScpbrSetRsp(scpbsReadInd);}VOID zPb_RecvCpmsInd
-(UINT8*pDatabuf){T_zPb_AtCpbsReadRes*cpbsInd=NULL;if(pDatabuf==NULL){return;}
-cpbsInd=(T_zPb_AtCpbsReadRes*)pDatabuf;atPb_RecvCpbsReadRsp(cpbsInd);}VOID
-zPb_RecvZpbicInd(UINT8*pDatabuf){T_zAt_ZpbicRes*ptPara=ZUFI_NULL;if(pDatabuf==
-NULL){return;}ptPara=(T_zAt_ZpbicRes*)(pDatabuf);printf(
-"\x7a\x50\x62\x5f\x52\x65\x63\x76\x5a\x70\x62\x69\x63\x49\x6e\x64\x20\x70\x61\x72\x61\x2c\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2c\x20\x74\x79\x70\x65\x3a\x25\x64" "\n"
-,ptPara->result,ptPara->opertype);if(((0xd24+2346-0x164d)==ptPara->result)&&(
-(0x48b+6771-0x1efd)==ptPara->opertype)){CHAR needPb[(0x6ef+2128-0xf0d)]={
-(0x50a+4142-0x1538)};sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));if(
-(0x2d6+545-0x4f7)!=strcmp(needPb,"\x6e\x6f")){ipc_send_message(MODULE_ID_PB,
-MODULE_ID_AT_CTL,MSG_CMD_PBINIT_REQ,(0x608+7221-0x223d),NULL,
-(0x151d+1227-0x19e8));}}}VOID zPb_RecvZuslotInd(UINT8*pDatabuf){T_zAt_ZuslotRes*
-ptPara=ZUFI_NULL;if(pDatabuf==NULL){return;}ptPara=(T_zAt_ZuslotRes*)(pDatabuf);
-printf(
-"\x7a\x50\x62\x5f\x52\x65\x63\x76\x5a\x70\x62\x69\x63\x49\x6e\x64\x20\x70\x61\x72\x61\x2c\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2c\x20\x74\x79\x70\x65\x3a\x25\x64" "\n"
-,ptPara->slot,ptPara->slot_state);if(ptPara->slot_state==(0x141f+4389-0x2544)){
-CHAR needPb[(0x520+322-0x630)]={(0xabb+6947-0x25de)};sc_cfg_get(
-NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));if((0x4d4+5028-0x1878)!=strcmp(needPb,
-"\x6e\x6f")){atPb_CfgPbNvInit();atPb_DelAllRecsSimDb();}}}VOID zPb_RecvPbInitRst
-(UINT8*pDatabuf){int pbReadRet=-(0x120b+4522-0x23b4);memcpy(&g_PbOptRsp,pDatabuf
-,sizeof(T_zPb_optRsp));if(g_PbOptRsp.result==-(0x98a+28-0x9a5)){atPb_IintPbErr(
-NULL);return;}pbReadRet=atPb_SendScpbrSet_repeat(g_Pb_sem_id);printf(
-"\x7a\x50\x62\x5f\x52\x65\x63\x76\x50\x62\x49\x6e\x69\x74\x52\x73\x74\x20\x72\x65\x73\x75\x6c\x74\x3a\x25\x64" "\n"
-,pbReadRet);sc_cfg_set(ZPB_NV_INIT,ZPB_OPERATE_SUC);}void zPbLocalHandleWebMsg(
-MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x50\x62\x20\x72\x65\x63\x76\x20\x77\x65\x62\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_WRITE_PB:
-atWeb_AddOneContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_A_PB:
-atWeb_DelOneContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_MUTI_PB:
-atWeb_DelMultiContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_ALL_PB:
-atWeb_DelAllContact(ptMsgBuf->aucDataBuf);break;default:break;}}void
-zPbHandleWebMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x50\x62\x20\x72\x65\x63\x76\x20\x77\x65\x62\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_WRITE_PB:case
-MSG_CMD_DEL_A_PB:case MSG_CMD_DEL_MUTI_PB:case MSG_CMD_DEL_ALL_PB:
-ipc_send_message(MODULE_ID_PB,MODULE_ID_PB_LOCAL,ptMsgBuf->usMsgCmd,ptMsgBuf->
-usDataLen,(unsigned char*)ptMsgBuf->aucDataBuf,(0xae3+3648-0x1923));break;
-default:break;}}UINT8 zPbMsgCreat(VOID){g_zPb_MsqId=msgget(MODULE_ID_PB,
-IPC_CREAT|(0x4a4+8140-0x22f0));if(g_zPb_MsqId==-(0x1ced+284-0x1e08)){return
-ZUFI_FAIL;}g_zPb_LocalMsqId=msgget(MODULE_ID_PB_LOCAL,IPC_CREAT|
-(0xb03+2724-0x1427));if(g_zPb_LocalMsqId==-(0xe98+6222-0x26e5)){return ZUFI_FAIL
-;}sem_init(&g_Pb_sem_id,(0x40d+6402-0x1d0f),(0x569+2863-0x1098));return
-ZUFI_SUCC;}void detect_modem_state(void){CHAR state[(0x12dd+3914-0x21f5)]={
-(0x4d9+1720-0xb91)};sc_cfg_get(
-"\x6d\x6f\x64\x65\x6d\x5f\x6d\x61\x69\x6e\x5f\x73\x74\x61\x74\x65",state,sizeof(
-state));if((0x17f3+2474-0x219d)==strcmp(state,
-"\x6d\x6f\x64\x65\x6d\x5f\x73\x69\x6d\x5f\x75\x6e\x64\x65\x74\x65\x63\x74\x65\x64"
-)||(0xe0f+3886-0x1d3d)==strcmp(state,
-"\x6d\x6f\x64\x65\x6d\x5f\x73\x69\x6d\x5f\x64\x65\x73\x74\x72\x6f\x79")){
-sc_cfg_set("\x70\x62\x6d\x5f\x69\x6e\x69\x74\x5f\x66\x6c\x61\x67","\x30");}}void
- zPbLocalHandleAtctlMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x50\x62\x20\x6c\x6f\x63\x61\x6c\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_PBINIT_RSP:
-zPb_RecvPbInitRst(ptMsgBuf->aucDataBuf);break;default:break;}}VOID
-zPbHandleAtctlMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x50\x62\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n",
-ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_DELETE_PB_RSP:case
-MSG_CMD_ADD_MODIFY_PB_RSP:case MSG_CMD_READ_PB_RSP:{memcpy(&g_PbOptRsp,ptMsgBuf
-->aucDataBuf,sizeof(T_zPb_optRsp));sem_post(&g_Pb_sem_id);}break;case
-MSG_CMD_CPBS_IND:zPb_RecvCpmsInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_SCPBR_IND:zPb_RecvScpbrInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_SCPBR_READ_IND:zPb_RecvScpbrReadInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_ZPBIC_IND:zPb_RecvZpbicInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_ZUSLOT_IND:zPb_RecvZuslotInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_PBINIT_RSP:ipc_send_message(MODULE_ID_PB,MODULE_ID_PB_LOCAL,ptMsgBuf->
-usMsgCmd,ptMsgBuf->usDataLen,(unsigned char*)ptMsgBuf->aucDataBuf,
-(0x1b1c+2464-0x24bc));break;default:break;}}VOID zPbHandleResetToFactory(){CHAR
-clearPb[(0x21a0+988-0x254a)]={(0x111d+2882-0x1c5f)};sc_cfg_get(
-NV_CLEAR_PB_WHEN_RESTORE,clearPb,sizeof(clearPb));printf(
-"\x61\x74\x57\x65\x62\x5f\x52\x65\x73\x74\x6f\x72\x65\x46\x61\x63\x74\x6f\x72\x79\x53\x65\x74\x74\x69\x6e\x67\x20\x65\x6e\x74\x65\x72\x65\x64\x21\x20" "\n"
-);printf(
-"\x63\x6c\x65\x61\x72\x5f\x70\x62\x5f\x77\x68\x65\x6e\x5f\x72\x65\x73\x74\x6f\x72\x65\x3d\x25\x73\x20" "\n"
-,clearPb);if(strcmp(clearPb,"\x79\x65\x73")==(0x235+3478-0xfcb)){atPb_DropDb();}
-ipc_send_message(MODULE_ID_PB,MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_RSP,
-(0x103f+2866-0x1b71),NULL,(0x175a+885-0x1acf));}void zPbHandleMainCtrlMsg(
-MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x50\x62\x20\x72\x65\x63\x76\x20\x6d\x61\x69\x6e\x20\x63\x74\x72\x6c\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_RESET_NOTIFY:
-zPbHandleResetToFactory(ptMsgBuf->aucDataBuf);break;default:break;}}void
-pb_msg_thread_proc(void*arg){int iRet=(0x17ff+3491-0x25a2);MSG_BUF stMsg={
-(0x1105+5001-0x248e)};int msgSize=sizeof(MSG_BUF)-sizeof(SINT32);int queueId=*((
-int*)arg);prctl(PR_SET_NAME,"\x70\x62\x5f\x6c\x6f\x63\x61\x6c",
-(0xf7f+4472-0x20f7),(0x35b+6231-0x1bb2),(0x23a+9284-0x267e));while(
-(0xc4c+2934-0x17c1)){iRet=(0x1bdd+17-0x1bee);memset(&stMsg,(0xff9+649-0x1282),
-sizeof(MSG_BUF));iRet=msgrcv(queueId,&stMsg,msgSize,(0x7b+2412-0x9e7),
-(0x3b5+4689-0x1606));printf(
-"\x70\x62\x5f\x6d\x73\x67\x5f\x74\x68\x72\x65\x61\x64\x5f\x70\x72\x6f\x63\x3a\x25\x78\x2c\x25\x78\x20\x4d\x4f\x44\x55\x4c\x45\x5f\x49\x44\x5f\x41\x54\x5f\x43\x54\x4c\x3d\x25\x78" "\n"
-,stMsg.src_id,stMsg.usMsgCmd,MODULE_ID_AT_CTL);if(iRet>=(0x2041+658-0x22d3)){
-switch(stMsg.src_id){case MODULE_ID_WEB_CGI:{zPbHandleWebMsg(&stMsg);break;}case
- MODULE_ID_AT_CTL:{zPbHandleAtctlMsg(&stMsg);break;}case MODULE_ID_PB:{
-zPbLocalHandleWebMsg(&stMsg);zPbLocalHandleAtctlMsg(&stMsg);break;}case
-MODULE_ID_MAIN_CTRL:{zPbHandleMainCtrlMsg(&stMsg);break;}default:{break;}}}else{
-printf(
-"\x5b\x70\x62\x5d\x20\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x2c\x20\x65\x72\x72\x6d\x73\x67\x20\x3d\x20\x25\x73" "\n"
-,errno,strerror(errno));}}}int phonebook_main(int argc,char*argv[]){pthread_t
-recv_thread_tid=(0xc24+2678-0x169a);MSG_BUF msgBuf={(0x184+7485-0x1ec1)};CHAR
-needPb[(0xadc+4263-0x1b51)]={(0x1f6+3015-0xdbd)};prctl(PR_SET_NAME,
-"\x70\x62\x5f\x6d\x61\x69\x6e",(0xf75+359-0x10dc),(0xe42+4078-0x1e30),
-(0x9c4+1634-0x1026));loglevel_init();sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof
-(needPb));if((0x23ed+769-0x26ee)!=strcmp(needPb,"\x6e\x6f")){
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+//#define MODULE_ID_PB_LOCAL 0x2002
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef VOID (*pAtWeb_PbMsgProc)(UINT8 *pDatabuf);
+
+typedef struct
+{
+ UINT32 msg_id;
+ VOID (*func_ptr)(UINT8 *pDatabuf);
+ BOOL need_block;//ÊÇ·ñÐèÒª×èÈû£¬Èç¹û×èÈû£¬ÐèÒª½«ÏûϢתµ½ÄÚ²¿Ï̴߳¦Àí
+}T_zPbHandleTable;
+
+
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+VOID atWeb_AddOneContact(UINT8 *pDatabuf);
+VOID atWeb_DelOneContact(UINT8 *pDatabuf);
+VOID atWeb_DelMultiContact(UINT8 *pDatabuf);
+VOID atWeb_DelAllContact(UINT8 *pDatabuf);
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+T_zPb_optRsp g_PbOptRsp = {0};
+sem_t g_Pb_sem_id = {0};//ÓÃÓÚÄÚ²¿µÈ´ý
+int g_zPb_MsqId = -1;
+int g_zPb_LocalMsqId = -1;
+
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+
+// pDatabufΪpstMsg->aucDataBuf
+VOID atWeb_AddOneContact(UINT8 *pDatabuf)
+{
+ T_zPb_WebContact* webPbContact = NULL;
+
+ if(pDatabuf == NULL)
+ {
+ printf("[pb], atWeb_AddOneContact para is null\n");
+ return;
+ }
+ webPbContact = (T_zPb_WebContact*)pDatabuf;
+ atWeb_AddOnePb(webPbContact, g_Pb_sem_id);
+}
+
+VOID atWeb_DelOneContact(UINT8 *pDatabuf)
+{
+ T_zPb_DelInfo *delRecord = NULL;
+
+ if(pDatabuf == NULL)
+ {
+ printf("[pb], atWeb_DelOneContact para is null\n");
+ return;
+ }
+ delRecord = (T_zPb_DelInfo*)pDatabuf;
+ atWeb_DelOnepb(delRecord, g_Pb_sem_id);
+}
+
+VOID atWeb_DelMultiContact(UINT8 *pDatabuf)
+{
+ T_zPb_DelInfo *delRecord = NULL;
+
+ if(pDatabuf == NULL)
+ {
+ printf("[pb], atWeb_DelOneContact para is null\n");
+ return;
+ }
+ delRecord = (T_zPb_DelInfo*)pDatabuf;
+ atWeb_DelMultPb(delRecord, g_Pb_sem_id);
+}
+VOID atWeb_DelAllContact(UINT8 *pDatabuf)
+{
+ T_zPb_DelInfo *delRecord = NULL;
+
+ if(pDatabuf == NULL)
+ {
+ printf("[pb], atWeb_DelOneContact para is null\n");
+ return;
+ }
+ delRecord = (T_zPb_DelInfo*)pDatabuf;
+ atWeb_DelAllpb(delRecord, g_Pb_sem_id);
+}
+
+/*VOID zPb_RecvPbInitRst(UINT8 *pDatabuf)
+{
+ memcpy(&g_PbOptRsp, pDatabuf, sizeof(T_zPb_optRsp));
+
+ if(g_PbOptRsp.result == 1)
+ {
+ zPb_initAtOk();
+ }
+ else
+ {
+ zPb_initAtErr();
+ }
+}*/
+
+VOID zPb_RecvScpbrInd(UINT8 *pDatabuf)
+{
+ T_zPb_AtScpbrTestRes* scpbsInd= NULL;
+
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+
+ scpbsInd = (T_zPb_AtScpbrTestRes*)pDatabuf;
+ atPb_ScpbrTestRsp(scpbsInd);
+}
+
+VOID zPb_RecvScpbrReadInd(UINT8 *pDatabuf)
+{
+ T_zPb_ScpbrSetRes* scpbsReadInd= NULL;
+
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+
+ scpbsReadInd = (T_zPb_ScpbrSetRes*)pDatabuf;
+ atPb_ScpbrSetRsp(scpbsReadInd);
+}
+
+VOID zPb_RecvCpmsInd(UINT8 *pDatabuf)
+{
+ T_zPb_AtCpbsReadRes* cpbsInd = NULL;
+
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+
+ cpbsInd = (T_zPb_AtCpbsReadRes*)pDatabuf;
+ atPb_RecvCpbsReadRsp(cpbsInd);
+}
+
+VOID zPb_RecvZpbicInd(UINT8 *pDatabuf)
+{
+ T_zAt_ZpbicRes *ptPara = ZUFI_NULL;
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+ ptPara = (T_zAt_ZpbicRes*)(pDatabuf);
+ printf( "zPb_RecvZpbicInd para,result:%d, type:%d\n", ptPara->result, ptPara->opertype);
+ if((1 == ptPara->result) && (1 == ptPara->opertype))
+ {
+ //ÅжÏNV,added by wenqin 2016-5-18
+ CHAR needPb[50]={0};
+ sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));
+ if(0 != strcmp(needPb,"no"))
+ {
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_PBINIT_REQ, 0, NULL, 0);
+ }
+ }
+}
+
+VOID zPb_RecvZuslotInd(UINT8 *pDatabuf)
+{
+ T_zAt_ZuslotRes *ptPara = ZUFI_NULL;
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+ ptPara = (T_zAt_ZuslotRes*)(pDatabuf);
+ printf( "zPb_RecvZpbicInd para,result:%d, type:%d\n", ptPara->slot, ptPara->slot_state);
+ if(ptPara->slot_state == 0)
+ {
+ //ÅжÏNV,added by wenqin 2016-5-18
+ CHAR needPb[50]={0};
+ sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));
+ if(0 != strcmp(needPb,"no"))
+ {
+ atPb_CfgPbNvInit();
+ atPb_DelAllRecsSimDb();
+ }
+ }
+}
+
+VOID zPb_RecvPbInitRst(UINT8 *pDatabuf)
+{
+ int pbReadRet = -1;
+ memcpy(&g_PbOptRsp, pDatabuf, sizeof(T_zPb_optRsp));
+
+ if(g_PbOptRsp.result == -1)
+ {
+ atPb_IintPbErr(NULL);
+ return;
+ }
+ //Íê³ÉÃûƬ¼ÐÊý¾Ý¶ÁÈ¡
+ pbReadRet = atPb_SendScpbrSet_repeat(g_Pb_sem_id);
+ printf("zPb_RecvPbInitRst result:%d\n", pbReadRet);
+ sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
+}
+
+void zPbLocalHandleWebMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "Pb recv web msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_WRITE_PB:
+ atWeb_AddOneContact(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_DEL_A_PB:
+ atWeb_DelOneContact(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_DEL_MUTI_PB:
+ atWeb_DelMultiContact(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_DEL_ALL_PB:
+ atWeb_DelAllContact(ptMsgBuf->aucDataBuf);
+ break;
+ default:
+ break;
+
+ }
+}
+
+void zPbHandleWebMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "Pb recv web msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_WRITE_PB:
+ case MSG_CMD_DEL_A_PB:
+ case MSG_CMD_DEL_MUTI_PB:
+ case MSG_CMD_DEL_ALL_PB:
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_PB_LOCAL, ptMsgBuf->usMsgCmd, ptMsgBuf->usDataLen, (unsigned char *)ptMsgBuf->aucDataBuf, 0);
+ break;
+ default:
+ break;
+
+ }
+}
+
+UINT8 zPbMsgCreat(VOID)
+{
+ g_zPb_MsqId = msgget(MODULE_ID_PB, IPC_CREAT | 0600);
+ if(g_zPb_MsqId == -1)
+ {
+ return ZUFI_FAIL;
+ }
+ g_zPb_LocalMsqId = msgget(MODULE_ID_PB_LOCAL, IPC_CREAT | 0600);
+ if(g_zPb_LocalMsqId == -1)
+ {
+ return ZUFI_FAIL;
+ }
+ sem_init(&g_Pb_sem_id, 0 , 0);
+
+ return ZUFI_SUCC;
+}
+
+/*³õʼ»¯pbmµÄAP ²àµç»°±¾×¼±¸³É¹¦£¬·ñÔòÎÞ¿¨Ê±webuiתȦ£¬Ê±ÐòÉϲ»±£ÏÕ£¬ËùÒÔÔÚat_ctlÒ²ÔÚÉèÁËÒ»±é£¬×îºÃÓÃÏûÏ¢*/
+void detect_modem_state(void)
+{
+ CHAR state[50] = {0};
+
+ sc_cfg_get("modem_main_state", state, sizeof(state));
+ if(0 == strcmp(state, "modem_sim_undetected") || 0 == strcmp(state, "modem_sim_destroy"))
+ {
+ sc_cfg_set("pbm_init_flag","0");
+ }
+}
+
+void zPbLocalHandleAtctlMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "Pb local recv msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_PBINIT_RSP:
+ zPb_RecvPbInitRst(ptMsgBuf->aucDataBuf);
+ break;
+ default:
+ break;
+
+ }
+}
+
+VOID zPbHandleAtctlMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "Pb recv msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_DELETE_PB_RSP:
+ case MSG_CMD_ADD_MODIFY_PB_RSP:
+ case MSG_CMD_READ_PB_RSP:
+ {
+ memcpy(&g_PbOptRsp, ptMsgBuf->aucDataBuf, sizeof(T_zPb_optRsp));
+ sem_post(&g_Pb_sem_id);
+ }
+ break;
+ case MSG_CMD_CPBS_IND:
+ zPb_RecvCpmsInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_SCPBR_IND:
+ zPb_RecvScpbrInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_SCPBR_READ_IND:
+ zPb_RecvScpbrReadInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_ZPBIC_IND:
+ zPb_RecvZpbicInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_ZUSLOT_IND:
+ zPb_RecvZuslotInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_PBINIT_RSP:
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_PB_LOCAL, ptMsgBuf->usMsgCmd, ptMsgBuf->usDataLen, (unsigned char *)ptMsgBuf->aucDataBuf,0);
+ break;
+
+ default:
+ break;
+
+ }
+}
+
+VOID zPbHandleResetToFactory()
+{
+ CHAR clearPb[50] = {0};
+
+ sc_cfg_get(NV_CLEAR_PB_WHEN_RESTORE,clearPb,sizeof(clearPb));
+
+ printf("atWeb_RestoreFactorySetting entered! \n");
+ printf("clear_pb_when_restore=%s \n", clearPb);
+ if(strcmp(clearPb, "yes") == 0)
+ {
+ atPb_DropDb();
+ }
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL,0);
+}
+
+void zPbHandleMainCtrlMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "Pb recv main ctrl msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_RESET_NOTIFY:
+ zPbHandleResetToFactory(ptMsgBuf->aucDataBuf);
+ break;
+ default:
+ break;
+
+ }
+}
+
+
+void pb_msg_thread_proc(void* arg)
+{
+ int iRet = 0;
+ MSG_BUF stMsg = {0};
+ int msgSize = sizeof(MSG_BUF) - sizeof(SINT32);
+ int queueId = *((int*)arg);
+ prctl(PR_SET_NAME, "pb_local", 0, 0, 0);
+ while(1)
+ {
+ iRet = 0;
+ memset(&stMsg, 0x00, sizeof(MSG_BUF));
+ iRet = msgrcv(queueId, &stMsg, msgSize, 0, 0);
+printf("pb_msg_thread_proc:%x,%x MODULE_ID_AT_CTL=%x\n",stMsg.src_id,stMsg.usMsgCmd, MODULE_ID_AT_CTL);
+ if (iRet >= 0)
+ {
+ switch (stMsg.src_id)
+ {
+ case MODULE_ID_WEB_CGI:
+ {
+ zPbHandleWebMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_AT_CTL:
+ {
+ zPbHandleAtctlMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_PB://½ö±¾µØ¶ÓÁд¦Àíº¯Êý´¦Àí
+ {
+ zPbLocalHandleWebMsg(&stMsg);
+ zPbLocalHandleAtctlMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_MAIN_CTRL:
+ {
+ zPbHandleMainCtrlMsg(&stMsg);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ printf("[pb] errno = %d, errmsg = %s\n", errno,strerror(errno));
+ }
+ }
+}
+
+
+int phonebook_main(int argc, char* argv[])
+{
+ pthread_t recv_thread_tid = 0;
+ MSG_BUF msgBuf = {0};
+ CHAR needPb[50] = {0};
+ prctl(PR_SET_NAME, "pb_main", 0, 0, 0);
+
+ //¸ù¾ÝNV³õʼ»¯´òÓ¡¼¶±ð£¬²¢×¢²á¶¯Ì¬µ÷Õû´òÓ¡¼¶±ðÐźÅÁ¿
+ loglevel_init();
+
+ //ÅжÏNV,added by wenqin 2016-5-18
+ sc_cfg_get(NV_NEED_SUPPORT_PB, needPb, sizeof(needPb));
+ if(0 != strcmp(needPb, "no"))
+ {
#ifdef WEBS_SECURITY
-if(access(ZPB_DB_PATH,F_OK)!=(0x1146+681-0x13ef)){if(access(ZPB_TMP_PATH,F_OK)==
-(0x913+1803-0x101e)){if(remove(ZPB_SEC_PATH)!=(0x15ec+2408-0x1f54)){slog(
-PB_PRINT,SLOG_ERR,
-"\x72\x65\x6d\x6f\x76\x65\x20\x5a\x50\x42\x5f\x53\x45\x43\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}if(rename(ZPB_TMP_PATH,ZPB_SEC_PATH)!=(0x16f6+3785-0x25bf)){slog(PB_PRINT,
-SLOG_ERR,
-"\x72\x65\x6e\x61\x6d\x65\x20\x5a\x50\x42\x5f\x54\x4d\x50\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}}if(access(ZPB_SEC_PATH,F_OK)==(0x376+3721-0x11ff)){char rnum_buf[
-(0x12e3+3012-0x1e8f)]={(0x8cd+4648-0x1af5)};char cmd[(0xb36+3206-0x173c)]={
-(0x3d0+7585-0x2171)};sc_cfg_get("\x72\x6e\x75\x6d\x5f\x61\x74",rnum_buf,sizeof(
-rnum_buf));snprintf(cmd,sizeof(cmd),
-"\x2f\x62\x69\x6e\x2f\x6f\x70\x65\x6e\x73\x73\x6c\x20\x65\x6e\x63\x20\x2d\x64\x20\x2d\x61\x65\x73\x32\x35\x36\x20\x2d\x73\x61\x6c\x74\x20\x2d\x69\x6e\x20\x25\x73\x20\x2d\x6f\x75\x74\x20\x25\x73\x20\x2d\x70\x61\x73\x73\x20\x70\x61\x73\x73\x3a\x25\x73"
-,ZPB_SEC_PATH,ZPB_DB_PATH,rnum_buf);zxic_system(cmd);}}
+ if(access(ZPB_DB_PATH, F_OK) != 0)
+ {
+ if(access(ZPB_TMP_PATH, F_OK) == 0)
+ {
+ if(remove(ZPB_SEC_PATH) != 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"remove ZPB_SEC_PATH fail");
+ }
+ if(rename(ZPB_TMP_PATH, ZPB_SEC_PATH) != 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"rename ZPB_TMP_PATH fail");
+ }
+ }
+ if(access(ZPB_SEC_PATH, F_OK) == 0)
+ {
+ char rnum_buf[24] = {0};
+ char cmd[128] = {0};
+
+ sc_cfg_get("rnum_at", rnum_buf, sizeof(rnum_buf));
+ snprintf(cmd, sizeof(cmd), "/bin/openssl enc -d -aes256 -salt -in %s -out %s -pass pass:%s", ZPB_SEC_PATH, ZPB_DB_PATH, rnum_buf);
+ zxic_system(cmd);
+ }
+ }
#endif
-zPbMsgCreat();atPb_Init();}else{return-(0x50+284-0x16b);}printf(
-"\x50\x62\x20\x61\x70\x70\x20\x69\x6e\x69\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64\x2c\x20\x77\x69\x6c\x6c\x20\x74\x6f\x20\x72\x65\x63\x65\x69\x76\x65\x20\x6d\x73\x67\x2c\x20\x6d\x73\x67\x69\x64\x3a\x25\x64" "\n"
-,g_zPb_MsqId);if(pthread_create(&recv_thread_tid,NULL,pb_msg_thread_proc,(void*)
-(&g_zPb_LocalMsqId))==-(0x4b5+5588-0x1a88)){assert((0x22c+8869-0x24d1));}
-detect_modem_state();pb_msg_thread_proc(&g_zPb_MsqId);return(0x107a+1824-0x179a)
-;}
+ zPbMsgCreat();
+ atPb_Init();
+ }
+ else
+ {
+ return -1;
+ }
+
+ printf("Pb app init finished, will to receive msg, msgid:%d\n", g_zPb_MsqId);
+ //¸ÃÏß³ÌÓÃÓÚ´¦ÀíÄÚ²¿×èÈûµÄÏûÏ¢£¬¶ÔÓ¦ÏûÏ¢µÄsourceIdÊÇMODULE_ID_SMS
+ if(pthread_create(&recv_thread_tid, NULL, pb_msg_thread_proc, (void*)(&g_zPb_LocalMsqId)) == -1)
+ {
+ assert(0);
+ }
+
+ detect_modem_state();
+
+ //Ö÷Ïß³ÌÓÃÓÚ´¦ÀíÍⲿ½ÓÊÕÏûÏ¢£¬¶ÔÓ¦ÏûÏ¢µÄsourceId·ÇMODULE_ID_SMS
+ pb_msg_thread_proc(&g_zPb_MsqId);
+ return 0;
+}
+
diff --git a/ap/app/zte_comm/phonebook/src/pb_proc.c b/ap/app/zte_comm/phonebook/src/pb_proc.c
index 45e21df..f1ac525 100755
--- a/ap/app/zte_comm/phonebook/src/pb_proc.c
+++ b/ap/app/zte_comm/phonebook/src/pb_proc.c
@@ -1,552 +1,1460 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : Atserver
+* ÎÄ ¼þ Ãû : pb_proc.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : ATÃüÁî·¢Ëͺͽá¹û´¦ÀíÄ£¿éº¯Êý¶¨Òå
+* ×÷ Õß : syx
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-04-16
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ :
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ :
+* ÐÞ ¸Ä ÈË :
+* ÐÞ¸ÄÈÕÆÚ :
+* ÐÞ¸ÄÄÚÈÝ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
+//#include "port_com.h"
+//#include "at_main.h"
+//#include "at_proc.h"
#include <ctype.h>
#include <semaphore.h>
#include <limits.h>
#include "pb_com.h"
-#define ZPB_UCS2 (0x6d2+7518-0x242f)
-#define ZPB_UCS2_PREFIX (0x1803+1618-0x1dd5)
-#define ZPB_UCS2_PREFIX_LEN (0xca2+5315-0x2163)
-#define ZPB_NON_GSM (0x7f2+4457-0x193b)
-#define ZPB_GSM_CHARACTER_SET_SIZE (0x1e79+2035-0x25ec)
-#define ZPB_INIT_LOAD_RECORD_NUM (0x1b83+1510-0x2137)
-VOID atPb_CvtChCode(UINT16 basePointer,UINT8 srcData,UINT8*chMsb,UINT8*chLsb);
-BOOL atPb_CvtU82ToU80(const UINT8*srcData,UINT32 srcLen,UINT8*destData,UINT32
-destLen);BOOL atPb_CvtU81ToU80(const UINT8*srcData,UINT32 srcLen,UINT8*destData,
-UINT32 destLen);extern VOID atPb_ClearSimPbmIndexArray(VOID);extern sem_t
-g_Pb_sem_id;extern T_zPb_optRsp g_PbOptRsp;UINT32 g_zPb_DelIndex=
-(0x498+1087-0x8d7);SINT32 g_zPb_SimIndex[ZPB_SIM_MAX_RECORD+(0x1787+3536-0x2556)
-]={(0x173+4598-0x1369)};SINT32 g_zPb_ApIndex[ZPB_AP_MAX_RECORD+
-(0x127+4523-0x12d1)]={(0x11+1299-0x524)};T_zPb_DelStatusMultiOrAll
-g_zPb_DelStatusUsim={(0x4b4+7925-0x23a9)};const unsigned char G_ZPB_NEWUCS2TOGSM
-[ZPB_GSM_CHARACTER_SET_SIZE*(0xce0+5699-0x2321)]={ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,(0x1db3+185-0x1e62),ZPB_NON_GSM,ZPB_NON_GSM,
-(0x7a9+5222-0x1c02),ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,(0x3d1+1016-0x7a9),(0x600+4902-0x1905),(0x894+490-0xa5c),
-(0x10af+3233-0x1d2d),(0x55b+4049-0x152a),(0x805+3233-0x1481),(0xc0b+3338-0x18ef)
-,(0x1dd1+568-0x1fe2),(0x2b9+3675-0x10ec),(0x889+6872-0x2338),(0x720+7422-0x23f4)
-,(0xf6c+1881-0x169a),(0x78f+7564-0x24ef),(0x1108+5321-0x25a4),
-(0xb7b+1570-0x116f),(0x7f+6189-0x187d),(0x413+5910-0x1af9),(0x582+1759-0xc30),
-(0x830+5852-0x1eda),(0x1693+512-0x1860),(0x1a47+2145-0x2274),(0xb79+3302-0x182a)
-,(0x166c+1438-0x1bd4),(0x604+268-0x6d9),(0x1880+2544-0x2238),
-(0x1067+2075-0x1849),(0x1a45+3097-0x2624),(0x9f8+1506-0xf9f),(0xbc+1890-0x7e2),
-(0x11c4+5068-0x2553),(0xa51+1691-0x10ae),(0x21f+9271-0x2617),(0x546+4155-0x1581)
-,(0x11ab+3967-0x20e9),(0xcec+5865-0x2393),(0x6af+3467-0x13f7),
-(0x1152+3553-0x1eef),(0xc0d+6296-0x2460),(0xae3+3938-0x19ff),(0x24af+202-0x2532)
-,(0x1a26+2546-0x23d0),(0x421+2354-0xd0a),(0xdcb+2747-0x183c),(0x1f3+5841-0x1879)
-,(0xd04+2634-0x1702),(0x1167+4093-0x2117),(0x2a0+7564-0x1fde),(0xdd+3745-0xf2f),
-(0x14bc+761-0x1765),(0x46f+2158-0xc8c),(0x118d+435-0x12ee),(0x2d1+8743-0x24a5),
-(0x161c+2187-0x1e53),(0xca0+1627-0x12a6),(0x613+6250-0x1e27),(0x8cc+2094-0x10a3)
-,(0x5ac+5390-0x1a62),(0x1087+2218-0x18d8),(0x17b+6871-0x1bf8),
-(0x1367+1182-0x17aa),ZPB_NON_GSM,(0x4c7+3102-0x1088),ZPB_NON_GSM,
-(0x17bc+3457-0x252c),ZPB_NON_GSM,(0x886+2445-0x11b2),(0xe1+2247-0x946),
-(0x100d+2401-0x190b),(0xe67+3162-0x1a5d),(0x326+3119-0xef0),(0x75f+8085-0x268e),
-(0x3a9+6234-0x1b9c),(0xb7+6692-0x1a73),(0x11f+6265-0x192f),(0x449+5681-0x1a10),
-(0x3d7+6864-0x1e3c),(0xe07+738-0x107d),(0xb38+3688-0x1933),(0x7a4+4711-0x199d),
-(0xfba+3182-0x1bb9),(0x1684+3638-0x244a),(0xd9d+4093-0x1d29),
-(0x17ba+2784-0x2228),(0x28b+922-0x5b2),(0xb02+6345-0x2357),(0x9e5+670-0xc0e),
-(0x98b+3273-0x15de),(0x907+2245-0x1155),(0xd71+2691-0x177c),(0x334+5090-0x169d),
-(0x5e1+2809-0x1060),ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,(0x1180+1886-0x189e),ZPB_NON_GSM,
-(0x7b1+4203-0x181b),(0x16c3+2810-0x2199),(0x42a+7733-0x225c),ZPB_NON_GSM,
-(0x3d1+4382-0x1490),ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,ZPB_NON_GSM,
-(0x355+8559-0x2464),(0x26b+2650-0xc84),(0xacd+1544-0x1094),(0x922+3466-0x166b),
-(0xe2+7817-0x1f2a),(0x1a3c+971-0x1dac),(0x1f8+6409-0x1af3),(0x17aa+2435-0x2111),
-(0x65+3185-0xccd),(0x181b+1330-0x1d08),(0x1965+595-0x1b99),(0x504+1710-0xb6d),
-(0x5dd+8229-0x25bd),(0x1dc+7630-0x1f61),(0x6d1+995-0xa6b),(0xc13+2606-0x15f8),
-(0x136a+3362-0x2043),ZPB_NON_GSM,(0xe0f+4994-0x2134),(0xfec+4372-0x20b1),
-(0x232+8678-0x23c9),(0x16ad+1918-0x1ddc),(0x8b5+1181-0xd03),(0x3ab+3299-0x1032),
-ZPB_NON_GSM,(0x715+4256-0x17aa),(0x833+6752-0x223e),(0xaa7+805-0xd77),
-(0x19cb+2460-0x2312),(0x775+1463-0xcce),(0x1c20+1010-0x1fb9),ZPB_NON_GSM,
-(0x42b+8093-0x23aa),(0x1358+255-0x13d8),(0x476+4654-0x1643),(0x192c+3451-0x2646)
-,(0x321+942-0x66e),(0x7e0+125-0x7e2),(0x180a+3847-0x2702),(0x5b3+6033-0x1d27),
-(0x1472+148-0x14fd),(0x1a13+1411-0x1f92),(0x16fc+2696-0x217f),
-(0x2626+297-0x26ea),(0xceb+2837-0x179b),(0x5b+2239-0x913),(0x7f+3452-0xd92),
-(0xcf5+4927-0x1fcb),(0x1319+825-0x15e9),ZPB_NON_GSM,(0x8cb+3197-0x14cb),
-(0x1685+40-0x16a5),(0x19ac+3268-0x2601),(0x1647+775-0x18df),(0x21ea+996-0x255f),
-(0x1de7+1217-0x222c),ZPB_NON_GSM,(0x2427+149-0x24b0),(0x13b9+397-0x1540),
-(0x276+2589-0xc1e),(0x13e3+1330-0x18a0),(0xbd2+369-0xcc5),(0x1881+846-0x1b56),
-ZPB_NON_GSM,(0x7a8+2784-0x120f)};VOID atPb_Init(VOID){UINT32 pbCount=
-(0x864+5774-0x1ef2);g_zPb_SimIndex[(0x1281+384-0x1401)]=(0x2b3+8108-0x225f);
-sc_cfg_set(ZPB_NV_INIT,ZPB_LOADING);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_OPERATE_SUC);for(pbCount=(0x1d77+1261-0x2263);pbCount<=ZPB_SIM_MAX_RECORD;
-pbCount++){g_zPb_SimIndex[pbCount]=PBM_ERROR_NOT_FOUND;}if(ZPB_DB_OK!=
-atPb_CreatDb()){slog(PB_PRINT,SLOG_ERR,"pb:atPb_Init:create pbm table failed\n")
-;return;}if(ZPB_DB_OK!=atPb_InitApIndex()){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x49\x6e\x69\x74\x3a\x69\x6e\x69\x74\x20\x61\x70\x49\x6e\x64\x65\x78\x20\x66\x61\x69\x6c\x65\x64" "\n"
-);return;}(VOID)atPb_SetApCapacityTable();}VOID atPb_CfgPbNvInit(VOID){(VOID)
-sc_cfg_set(ZPB_NV_USIMINDEXMIN,"\x30");(VOID)sc_cfg_set(ZPB_NV_USIMINDEXMAX,
-"\x30");(VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x6e\x6f");}int
-atpb_CvtUcs2ToAlphaField(char*src,int srcLen,char*dest){int i=(0x1bf+2759-0xc86)
-;int min=32767;int max=(0x1969+2374-0x22af);int temp=(0xa34+6954-0x255e);int
-outOff=(0x16f8+1823-0x1e17);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x73\x72\x63\x4c\x65\x6e\x3d\x25\x64" "\n"
-,srcLen);if(srcLen<=(0x545+1987-0xd08)||src==NULL||dest==NULL){return-
-(0x8e0+1880-0x1037);}if(srcLen<=(0xb8c+2802-0x167c)){dest[(0xa03+1925-0x1188)]=
-(0x3c2+7567-0x20d1);memcpy(dest+(0x712+3864-0x1629),src,srcLen);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x75\x73\x65\x20\x38\x30\x20\x63\x6f\x64\x65\x2c\x20\x6c\x65\x6e\x20\x3d\x25\x64" "\n"
-,srcLen+(0xc97+5932-0x23c2));return srcLen+(0x1684+2846-0x21a1);}for(i=
-(0x870+315-0x9ab);i<srcLen;i+=(0xcc9+6302-0x2565)){if(src[i]!=
-(0x9a2+2288-0x1292)){temp=(int)(((src[i]<<(0x143+612-0x39f))&65280)|(src[i+
-(0x8f7+4721-0x1b67)]&(0x105b+755-0x124f)));
-#if (0x458+7459-0x217b)
-if(temp<(0xa08+1241-0xee1)){max=min+(0xcb8+1382-0x119c);break;}
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+#define ZPB_UCS2 1
+#define ZPB_UCS2_PREFIX 0x80
+#define ZPB_UCS2_PREFIX_LEN 2
+#define ZPB_NON_GSM 0x20
+#define ZPB_GSM_CHARACTER_SET_SIZE 0x80
+#define ZPB_INIT_LOAD_RECORD_NUM 50
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+VOID atPb_CvtChCode(UINT16 basePointer, UINT8 srcData, UINT8 *chMsb, UINT8 *chLsb);
+BOOL atPb_CvtU82ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen);
+BOOL atPb_CvtU81ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen);
+extern VOID atPb_ClearSimPbmIndexArray(VOID);
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+extern sem_t g_Pb_sem_id;
+extern T_zPb_optRsp g_PbOptRsp;
+//UINT32 g_zPb_pbIndex = 0;
+UINT32 g_zPb_DelIndex = 0;
+SINT32 g_zPb_SimIndex[ZPB_SIM_MAX_RECORD+1] = {0};
+SINT32 g_zPb_ApIndex[ZPB_AP_MAX_RECORD+1] = {0};
+T_zPb_DelStatusMultiOrAll g_zPb_DelStatusUsim = {0};
+const unsigned char G_ZPB_NEWUCS2TOGSM[ZPB_GSM_CHARACTER_SET_SIZE*2] =
+ { /*+0x0 +0x1 +0x2 +0x3 +0x4 +0x5 +0x6 +0x7*/
+ /*0x00*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x08*/ ZPB_NON_GSM, ZPB_NON_GSM, 0x0a, ZPB_NON_GSM, ZPB_NON_GSM, 0x0d, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x10*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x18*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x20*/ 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27,
+ /*0x28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ /*0x30*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ /*0x38*/ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ /*0x40*/ 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ /*0x48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ /*0x50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ /*0x58*/ 0x58, 0x59, 0x5a, 0x5b, ZPB_NON_GSM, 0x5d, ZPB_NON_GSM, 0x11,
+ /*0x60*/ ZPB_NON_GSM, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ /*0x68*/ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ /*0x70*/ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ /*0x78*/ 0x78, 0x79, 0x7a, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x80*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x88*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x90*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0x98*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0xa0*/ ZPB_NON_GSM, 0x40, ZPB_NON_GSM, 0x01, 0x24, 0x03, ZPB_NON_GSM, 0x5f,
+ /*0xa8*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0xb0*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM,
+ /*0xb8*/ ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, ZPB_NON_GSM, 0x60,
+ /*0xc0*/ 0x41, 0x41, 0x41, 0x41, 0x5b, 0x0e, 0x1c, 0x09,
+ /*0xc8*/ 0x45, 0x1f, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
+ /*0xd0*/ ZPB_NON_GSM, 0x5d, 0x4f, 0x4f, 0x4f, 0x4f, 0x5c, ZPB_NON_GSM,
+ /*0xd8*/ 0x0b, 0x55, 0x55, 0x55, 0x5e, 0x59, ZPB_NON_GSM, 0x1e,
+ /*0xe0*/ 0x7f, 0x61, 0x61, 0x61, 0x7b, 0x0f, 0x1d, 0x09,
+ /*0xe8*/ 0x04, 0x05, 0x65, 0x65, 0x07, 0x69, 0x69, 0x69,
+ /*0xf0*/ ZPB_NON_GSM, 0x7d, 0x08, 0x6f, 0x6f, 0x6f, 0x7c, ZPB_NON_GSM,
+ /*0xf8*/ 0x0c, 0x06, 0x75, 0x75, 0x7e, 0x79, ZPB_NON_GSM, 0x79
+ };
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+VOID atPb_Init(VOID)
+{
+ UINT32 pbCount = 0;
+
+ g_zPb_SimIndex[0] = 0;
+
+ sc_cfg_set(ZPB_NV_INIT,ZPB_LOADING);
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+
+ for(pbCount=1; pbCount<=ZPB_SIM_MAX_RECORD; pbCount++)
+ {
+ g_zPb_SimIndex[pbCount] = PBM_ERROR_NOT_FOUND;
+ }
+ if(ZPB_DB_OK != atPb_CreatDb())
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_Init:create pbm table failed\n");/*lint !e26*/
+ return;
+ }
+ if(ZPB_DB_OK != atPb_InitApIndex())
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:atPb_Init:init apIndex failed\n");
+ return;
+ }
+ (VOID)atPb_SetApCapacityTable();
+}
+
+VOID atPb_CfgPbNvInit(VOID)
+{
+ (VOID)sc_cfg_set(ZPB_NV_USIMINDEXMIN, "0");
+ (VOID)sc_cfg_set(ZPB_NV_USIMINDEXMAX, "0");
+ (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
+}
+ /**
+ * º¯Êý»áÓÅÏÈʹÓÃ81ºÍ82¸ñʽ±àÂ룬Èç¹û²»Âú×ã±àÂëÌõ¼þ£¬Ñ¡Ôñ80¸ñʽ±àÂë
+ *
+ * @param src Ô´UCS2×Ö½ÚÊý×é
+ * @param srcLen Ô´×Ö½ÚÊý×鳤¶È
+ * @param dest Ä¿±êÊý×é
+ * @return Ä¿±êÊý×鳤¶È
+ */
+int atpb_CvtUcs2ToAlphaField(char *src, int srcLen,char* dest)
+{
+ int i = 0;
+ int min = 0x7FFF;
+ int max = 0;
+ int temp = 0;
+ int outOff = 0;
+
+ printf("[PB] atpb_CvtUcs2ToAlphaField, srcLen=%d\n",srcLen);
+ if(srcLen <= 0 || src == NULL ||dest == NULL)
+ {
+ return -1;
+ }
+
+ if(srcLen <= 2)
+ {
+ dest[0]=0x80;
+ memcpy(dest+1, src, srcLen);
+ printf("[PB] atpb_CvtUcs2ToAlphaField, use 80 code, len =%d\n",srcLen+1);
+ return srcLen+1;
+ }
+
+ // µ±Ô´Êý×éµÄ³¤¶È´óÓÚ2ʱ²ÅÄÜʹÓÃ81»òÕß82¸ñʽ
+
+ // È¡µÃÔ´Êý×éµÄ×îСֵÓë×î´óÖµ
+ for (i = 0; i < srcLen; i += 2)
+ {
+ //ÿ¸ö×Ö·ûµÄµÚ1¸ö×Ö½Ú²»Îª0
+ if (src[i] != 0)
+ {
+ temp = (int) (((src[i] << 8) & 0xFF00) | (src[i+1] & 0xFF));
+ // ÒòΪÔÚ81¸ñʽÖлùÖ·×óÒÆ7λºó×î¸ßλҪ²¹0£¬ËùÒÔ8000µ½FFFF²»ÄÜʹÓÃ81
+#if 0 //kw 3
+ if (temp < 0)
+ {
+ max = min + 130;
+ break;
+ }
#endif
-if(min>temp){min=temp;}if(max<temp){max=temp;}}}printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x6d\x69\x6e\x3d\x25\x64\x2c\x20\x6d\x61\x78\x3d\x25\x64" "\n"
-,min,max);if((max-min)<(0xaa6+468-0xbf9)){if((unsigned char)(min&
-(0xe11+3451-0x1b0c))==(unsigned char)(max&(0x1bd4+248-0x1c4c))){dest[
-(0x108+5382-0x160d)]=(unsigned char)(srcLen/(0x1a9c+2005-0x226f));dest[
-(0x1186+4311-0x225d)]=(unsigned char)(0xec8+709-0x110c);min=(int)(min&32640);
-dest[(0xd6+7267-0x1d37)]=(unsigned char)((min>>(0x469+1672-0xaea))&
-(0x140d+752-0x15fe));outOff=(0x1fc5+1006-0x23b0);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x75\x73\x65\x20\x38\x31\x20\x63\x6f\x64\x65" "\n"
-);}else{dest[(0x2182+182-0x2237)]=(unsigned char)(srcLen/(0x17ab+1967-0x1f58));
-dest[(0x99b+5395-0x1eae)]=(unsigned char)(0x116a+4241-0x2179);dest[
-(0x182d+2200-0x20c3)]=(unsigned char)((min>>(0x10ab+5007-0x2432))&
-(0x9fd+1136-0xd6e));dest[(0xf58+2700-0x19e1)]=(unsigned char)(min&
-(0xc41+2730-0x15ec));outOff=(0xc6+2222-0x970);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x75\x73\x65\x20\x38\x32\x20\x63\x6f\x64\x65" "\n"
-);}for(i=(0x665+8131-0x2628);i<srcLen;i+=(0x19ec+3239-0x2691)){if(src[i]==
-(0xe61+5964-0x25ad)){dest[outOff]=(unsigned char)(src[i+(0x126+4917-0x145a)]&
-(0x1135+3166-0x1d14));}else{temp=(int)((((src[i]<<(0x1abf+1965-0x2264))&65280)|(
-src[i+(0x2e1+1142-0x756)]&(0x4d5+1041-0x7e7)))-min);dest[outOff]=(unsigned char)
-(temp|(0x142d+332-0x14f9));}outOff++;}printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x20\x6f\x75\x74\x4f\x66\x66\x3d\x25\x64\x2c\x64\x65\x73\x74\x5b\x25\x64\x5d\x3d\x25\x78" "\n"
-,outOff,outOff,dest[outOff]);return outOff;}dest[(0x58d+227-0x670)]=
-(0xb2f+3618-0x18d1);memcpy(dest+(0x16e6+80-0x1735),src,srcLen);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x70\x62\x5f\x43\x76\x74\x55\x63\x73\x32\x54\x6f\x41\x6c\x70\x68\x61\x46\x69\x65\x6c\x64\x2c\x20\x75\x73\x65\x20\x38\x30\x20\x63\x6f\x64\x65\x2c\x20\x6c\x65\x6e\x20\x3d\x25\x64" "\n"
-,srcLen+(0x1466+4370-0x2577));return srcLen+(0xc82+1817-0x139a);}int
-atPb_GetU80Code(const UINT8*srcCode,UINT32 srcCodeLen,UINT8*destCode,UINT32
-destCodeLen){assert(destCode!=NULL&&srcCode!=NULL);if(srcCodeLen==
-(0x100d+3756-0x1eb9)||destCodeLen==(0x345+3118-0xf73)||destCodeLen<srcCodeLen){
-return-(0xa2f+955-0xde9);}memset(destCode,(0xa55+3208-0x16dd),destCodeLen);
-destCode[(0x2d3+8272-0x2323)]=(0x21bf+830-0x247d);printf(
-"\x63\x68\x65\x6e\x6a\x69\x65\x20\x2d\x2d\x2d\x2d\x2d\x61\x74\x50\x62\x5f\x47\x65\x74\x55\x38\x30\x43\x6f\x64\x65\x2d\x2d\x2d\x2d\x2d\x73\x72\x63\x43\x6f\x64\x65\x5b\x30\x5d\x20\x3d\x20\x25\x64" "\n"
-,srcCode[(0x153+5462-0x16a9)]);switch(srcCode[(0x3d8+3908-0x131c)]){case
-(0x1949+1845-0x1ffe):{memcpy(destCode,srcCode,srcCodeLen);return srcCodeLen;}
-case(0x164d+2406-0x1f32):{atPb_CvtU81ToU80(srcCode+(0x4f1+3972-0x1474),
-srcCodeLen-(0xd73+4823-0x2049),destCode+(0x13a+3920-0x1089),destCodeLen-
-(0x2f8+152-0x38f));return srcCode[(0xb64+7043-0x26e6)]*(0x22a8+1062-0x26cc)+
-(0x1bd+6126-0x19aa);}case(0x1f4+5342-0x1650):{atPb_CvtU82ToU80(srcCode+
-(0x10c5+2108-0x1900),srcCodeLen-(0x3e2+7228-0x201d),destCode+(0x6d3+5377-0x1bd3)
-,destCodeLen-(0xa1f+3866-0x1938));return srcCode[(0x50d+6916-0x2010)]*
-(0x65d+7576-0x23f3)+(0xa4d+6253-0x22b9);}default:{return-(0x46b+6749-0x1ec7);}}}
-BOOL atPb_CvtU82ToU80(const UINT8*srcData,UINT32 srcLen,UINT8*destData,UINT32
-destLen){UINT8 chNum=(0xe85+385-0x1006);UINT16 basePointer=(0x6ad+1588-0xce1);
-UINT8 iCurChar=(0xbb9+483-0xd9c);UINT32 iCurSrc=(0x955+289-0xa76);chNum=(UINT32)
-srcData[(0xd58+3873-0x1c79)];basePointer=(UINT16)srcData[(0x75d+3054-0x134a)];
-basePointer=basePointer<<(0x1f1f+1631-0x2576);basePointer=basePointer+srcData[
-(0x165a+537-0x1871)];if(chNum*(0x102a+781-0x1335)>destLen){return FALSE;}for(
-iCurSrc=(0x442+3820-0x132b);iCurSrc<srcLen&&iCurChar<chNum;iCurSrc++,iCurChar++)
-{UINT8*curDest=destData+(0x1b7a+1871-0x22c7)*iCurChar;atPb_CvtChCode(basePointer
-,srcData[iCurSrc],curDest,curDest+(0x4d0+5-0x4d4));}return TRUE;}BOOL
-atPb_CvtU81ToU80(const UINT8*srcData,UINT32 srcLen,UINT8*destData,UINT32 destLen
-){UINT8 chNum=(0x752+7363-0x2415);UINT16 basePointer=(0x1866+1439-0x1e05);UINT8
-iCurChar=(0x125f+4956-0x25bb);UINT32 iCurSrc=(0xc28+5227-0x2093);chNum=srcData[
-(0x1e8a+1117-0x22e7)];basePointer=((UINT16)srcData[(0xbb8+1670-0x123d)])<<
-(0x15c3+3033-0x2195);if(chNum*(0xcc0+2325-0x15d3)>destLen){return FALSE;}for(
-iCurSrc=(0xb68+1830-0x128c);iCurSrc<srcLen&&iCurChar<chNum;iCurSrc++,iCurChar++)
-{UINT8*curDest=destData+(0x14d+8692-0x233f)*iCurChar;atPb_CvtChCode(basePointer,
-srcData[iCurSrc],curDest,curDest+(0x5cb+6315-0x1e75));}return TRUE;}VOID
-atPb_CvtChCode(UINT16 basePointer,UINT8 srcData,UINT8*chMsb,UINT8*chLsb){UINT16
-curChar=(0xd3d+4631-0x1f54);assert(chMsb!=NULL&&chLsb!=NULL);if((srcData&
-(0x180f+1147-0x1c0a))==(0xb8+1401-0x631)){curChar=srcData;}else{curChar=
-basePointer+(srcData&(0x314+83-0x2e8));}*chMsb=(UINT8)(curChar>>
-(0x1cfa+1512-0x22da));*chLsb=(UINT8)((curChar<<(0x2020+206-0x20e6))>>
-(0xcdf+5193-0x2120));return;}int atPb_String2Bytes(const char*pSrc,unsigned char
-*pDst,int nSrcLength){int i=(0xc49+6415-0x2558);if(pSrc==NULL||pDst==NULL||
-nSrcLength<(0x24ef+438-0x26a5)){return-(0x36c+6148-0x1b6f);}for(i=
-(0x13d2+4517-0x2577);i<nSrcLength;i+=(0x1cf1+2517-0x26c4)){if(*pSrc>=
-((char)(0x68f+4440-0x17b7))&&*pSrc<=((char)(0x162f+327-0x173d))){*pDst=(*pSrc-
-((char)(0x247+1395-0x78a)))<<(0xce1+506-0xed7);}else{*pDst=((toupper(*pSrc)-
-((char)(0x1580+1658-0x1bb9)))+(0x1af1+878-0x1e55))<<(0x614+7366-0x22d6);}pSrc++;
-if(*pSrc>=((char)(0x27c+1585-0x87d))&&*pSrc<=((char)(0xa5d+4488-0x1bac))){*pDst
-|=*pSrc-((char)(0x290+9203-0x2653));}else{*pDst|=(toupper(*pSrc)-
-((char)(0x994+1059-0xd76)))+(0x258+9105-0x25df);}pSrc++;pDst++;}return
-nSrcLength/(0x2190+277-0x22a3);}int atPb_Bytes2String(const unsigned char*pSrc,
-char*pDst,int nSrcLength){const char tab[]=
-"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46";int i=
-(0x16dc+782-0x19ea);if(pSrc==NULL||pDst==NULL||nSrcLength<(0x634+8340-0x26c8)){
-return-(0x7ed+4719-0x1a5b);}for(i=(0x232d+308-0x2461);i<nSrcLength;i++){*pDst++=
-tab[*pSrc>>(0x16df+2321-0x1fec)];*pDst++=tab[*pSrc&(0x696+4101-0x168c)];pSrc++;}
-*pDst='\0';return nSrcLength*(0x1211+55-0x1246);}static VOID atPb_WebRecodeShow(
-T_zPb_WebContact const*pFromweb){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x49\x6e\x64\x65\x78\x3d\x25\x64" "\n"
-,pFromweb->pbIndex);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x4e\x61\x6d\x65\x3d\x25\x73" "\n",
-pFromweb->name);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x50\x62\x4e\x75\x6d\x31\x3d\x25\x73" "\n"
-,pFromweb->mobilNumber);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x50\x62\x4e\x75\x6d\x32\x3d\x25\x73" "\n"
-,pFromweb->homeNumber);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x50\x62\x4e\x75\x6d\x33\x3d\x25\x73" "\n"
-,pFromweb->officeNumber);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x72\x6f\x6d\x77\x65\x62\x2e\x65\x6d\x61\x69\x6c\x3d\x25\x73" "\n"
-,pFromweb->email);}int atPb_IintPbErr(UINT8*pErrCode){sc_cfg_set(ZPB_NV_INIT,
-ZPB_LOAD_ERROR);return TRUE;}int atPb_ScpbrSetErr(UINT8*pErrCode){printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x50\x62\x5f\x53\x63\x70\x62\x72\x53\x65\x74\x45\x72\x72\x20\x66\x61\x69\x6c\x20\x61\x6e\x64\x20\x72\x65\x74\x75\x72\x6e" "\n"
-);sc_cfg_set(ZPB_NV_INIT,ZPB_OPERATE_SUC);return TRUE;}VOID atBase_IintPbOk(VOID
-){sc_cfg_set(ZPB_NV_INIT,ZPB_OPERATE_SUC);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x50\x62\x5f\x53\x65\x6e\x64\x53\x63\x70\x62\x72\x53\x65\x74\x20\x61\x74\x42\x61\x73\x65\x5f\x49\x69\x6e\x74\x50\x62\x4f\x6b\x20" "\n"
-);}VOID atPb_RecvCpbsReadRsp(T_zPb_AtCpbsReadRes*cpbsInd){CHAR resInfo[
-(0x8f1+3295-0x15bc)]={(0x7b5+188-0x871)};if(strncmp(cpbsInd->locType,"\x53\x4d",
-(0x1fb1+970-0x2379))==(0x147c+3591-0x2283)){(VOID)snprintf(resInfo,
-(0x5b+8805-0x22ac),"\x25\x64",cpbsInd->usedEntries);(VOID)sc_cfg_set(
-NV_PB_USEDENTRIES,resInfo);memset(resInfo,(0x7d+9084-0x23f9),(0x982+1581-0xf9b))
-;(VOID)snprintf(resInfo,(0x11e1+123-0x1248),"\x25\x64",cpbsInd->totalEntries);(
-VOID)sc_cfg_set(NV_PB_TOTALENTRIES,resInfo);g_zPb_SimIndex[(0x190f+1969-0x20c0)]
-=(UINT32)(cpbsInd->totalEntries);}else{printf(
-"\x61\x74\x50\x62\x5f\x52\x65\x63\x76\x43\x70\x62\x73\x52\x65\x61\x64\x52\x73\x70\x20\x6e\x6f\x74\x20\x53\x4d\x3a\x25\x73" "\n"
-,cpbsInd->locType);}}static VOID atPb_SetScpbrResToNv(CHAR const*pbNvKeyWord,
-UINT32 len){char converted[(0x1168+1124-0x15c2)]={(0xad6+5589-0x20ab)};assert(
-pbNvKeyWord!=ZUFI_NULL);(VOID)snprintf(converted,(0xa7c+3868-0x198e),"\x25\x64",
-len);(VOID)sc_cfg_set(pbNvKeyWord,converted);}VOID atPb_ScpbrTestRsp(
-T_zPb_AtScpbrTestRes*scpbsInd){T_zPb_UsimCapacity pbPara={(0x1069+1641-0x16d2)};
-CHAR pbUsed[(0xd6+6381-0x1991)]={(0xb1+7090-0x1c63)};sc_cfg_get(
-NV_PB_USEDENTRIES,pbUsed,sizeof(pbUsed));g_zPb_DelIndex=(UINT32)scpbsInd->
-minIndex;pbPara.simType=ZPB_USIM;pbPara.maxRecordNum=scpbsInd->maxIndex;pbPara.
-usedRecordNum=atoi(pbUsed);pbPara.maxNumberLen=scpbsInd->maxNumberLen;pbPara.
-maxNameLen=scpbsInd->maxTextLen;pbPara.maxAnrLen=scpbsInd->maxNumberLen;pbPara.
-maxAnr1Len=scpbsInd->maxNumberLen;pbPara.maxEmailLen=scpbsInd->maxEmailLen;
-atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMIN,(UINT32)scpbsInd->minIndex);
-atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMAX,(UINT32)scpbsInd->maxIndex);(VOID)
-atPb_SetSimCapacityTable(pbPara);}int atPb_SendScpbrSet_repeat(sem_t tSemId){int
- min=(0xed7+376-0x104f);int max=(0x115c+1397-0x16d1);int res=
-(0x119d+3670-0x1ff3);int index=(0x56f+5369-0x1a68);CHAR pbMin[
-(0x5b9+8181-0x257c)]={(0x1da3+2345-0x26cc)};CHAR pbMax[(0x9ca+390-0xb1e)]={
-(0x2159+375-0x22d0)};int indexmin=(0x517+6115-0x1cfa);int indexmax=
-(0xb6+8889-0x236f);T_zPb_ScpbrReadRes scpbrReadInfo={(0x57+4936-0x139f)};
-sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));sc_cfg_get(
-ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));(VOID)sc_cfg_set(ZPB_NV_INIT,
-ZPB_LOADING);if(strcmp(pbMin,"\x30")==(0x658+8140-0x2624)||strcmp(pbMax,"\x30")
-==(0x6a0+7537-0x2411)){sc_cfg_set(ZPB_NV_INIT,ZPB_OPERATE_SUC);printf(
-"\x61\x74\x50\x62\x5f\x53\x65\x6e\x64\x53\x63\x70\x62\x72\x53\x65\x74\x20\x63\x61\x72\x64\x20\x75\x6e\x73\x75\x70\x70\x6f\x72\x74\x20\x70\x62" "\n"
-);return-(0x31f+3474-0x10b0);}sscanf(pbMin,"\x25\x64",&min);sscanf(pbMax,
-"\x25\x64",&max);if((min<(0x7ac+3088-0x13bc)||min>INT_MAX-(0x1c66+2721-0x2706))
-||(max<(0x1b7+1397-0x72c)||max>INT_MAX-(0x38f+3384-0x10c6))){printf(
-"\x61\x74\x50\x62\x5f\x53\x65\x6e\x64\x53\x63\x70\x62\x72\x53\x65\x74\x20\x70\x62\x20\x6e\x75\x6d\x20\x65\x72\x72\x20\x6d\x69\x6e\x3a\x25\x64\x2c\x20\x6d\x61\x78\x3a\x25\x64" "\n"
-,min,max);return-(0xa13+5589-0x1fe7);}while((0x822+3976-0x17a9)){if(indexmin<min
-){indexmin=min;indexmax=min+ZPB_INIT_LOAD_RECORD_NUM-(0x8cd+1549-0xed9);if(
-indexmax>max){indexmax=max;break;}printf(
-"\x5b\x50\x42\x5d\x20\x31\x31\x31\x20\x69\x6e\x64\x65\x78\x6d\x69\x6e\x3d\x25\x64\x2c\x20\x69\x6e\x64\x65\x78\x6d\x61\x78\x3d\x25\x64\x2c\x28\x25\x64\x2d\x25\x64\x29" "\n"
-,indexmin,indexmax,min,max);}else{indexmin=indexmin+ZPB_INIT_LOAD_RECORD_NUM;if(
-indexmin>max){printf(
-"\x5b\x50\x42\x5d\x20\x33\x33\x33\x20\x69\x6e\x64\x65\x78\x6d\x69\x6e\x3d\x25\x64\x2c\x20\x69\x6e\x64\x65\x78\x6d\x61\x78\x3d\x25\x64\x2c\x28\x25\x64\x2d\x25\x64\x29" "\n"
-,indexmin,indexmax,min,max);break;}indexmax=indexmax+ZPB_INIT_LOAD_RECORD_NUM;if
-(indexmax>max){indexmax=max;}printf(
-"\x5b\x50\x42\x5d\x20\x32\x32\x32\x20\x69\x6e\x64\x65\x78\x6d\x69\x6e\x3d\x25\x64\x2c\x20\x69\x6e\x64\x65\x78\x6d\x61\x78\x3d\x25\x64\x2c\x28\x25\x64\x2d\x25\x64\x29" "\n"
-,indexmin,indexmax,min,max);}scpbrReadInfo.minIndex=indexmin;scpbrReadInfo.
-maxIndex=indexmax;res=ipc_send_message(MODULE_ID_PB,MODULE_ID_AT_CTL,
-MSG_CMD_READ_PB_REQ,sizeof(T_zPb_ScpbrReadRes),&scpbrReadInfo,
-(0x72b+3715-0x15ae));sem_wait(&g_Pb_sem_id);if(g_PbOptRsp.result==-
-(0x2a0+2317-0xbac)){break;}}return g_PbOptRsp.result;}
-#if (0xb07+6241-0x2368)
-int atPb_SendScpbrSet(PSTR pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){UINT32
-indexmin=(0x14ec+1728-0x1bac);UINT32 indexmax=(0xd0b+3131-0x1946);CHAR atcmdMsg[
-(0x6f0+3288-0x1382)]={(0x2236+473-0x240f)};int res=(0x32a+2263-0xc01);CHAR pbMin
-[(0x2ac+8367-0x2329)]={(0xae3+5361-0x1fd4)};CHAR pbMax[(0x155a+2951-0x20af)]={
-(0x1606+3926-0x255c)};sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
-sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));(VOID)sc_cfg_set(ZPB_NV_INIT
-,ZPB_LOADING);if(strcmp(pbMin,"\x30")==(0x16c0+1270-0x1bb6)||strcmp(pbMax,"\x30"
-)==(0x14d+6119-0x1934)){printf(
-"\x61\x74\x50\x62\x5f\x53\x65\x6e\x64\x53\x63\x70\x62\x72\x53\x65\x74\x20\x63\x61\x72\x64\x20\x75\x6e\x73\x75\x70\x70\x6f\x72\x74\x20\x70\x62" "\n"
-);return ZAT_RESULT_OK;}sscanf(pbMin,"\x25\x64",&indexmin);sscanf(pbMax,
-"\x25\x64",&indexmax);(VOID)snprintf(atcmdMsg,sizeof(atcmdMsg),
-"\x41\x54\x5e\x53\x43\x50\x42\x52\x3d\x25\x64\x2c\x25\x64" "\r\n",indexmin,
-indexmax);pthread_mutex_lock(&smsdb_mutex);res=zSvr_SendAtSyn(ZAT_SCPBR_SET_CMD,
-atcmdMsg,cid,pAtRst,atRstSize);pthread_mutex_unlock(&smsdb_mutex);return res;}
+ if (min > temp)
+ {
+ min = temp;
+ }
+
+ if (max < temp)
+ {
+ max = temp;
+ }
+ }
+ }
+
+ printf("[PB] atpb_CvtUcs2ToAlphaField, min=%d, max=%d\n",min, max);
+ // Èç¹ûËùÓÐ×Ö·ûµÄUCSÂë¶¼ÔÚÁ¬ÐøµÄ128µÄ·¶Î§ÄÚ£¬ÄÇôµÚ1¸ö×Ö½Ú¶¼Ïàͬ
+ if ((max - min) < 129)
+ {
+ // Èç¹ûµÚ15λµ½µÚ8λÏàͬ£¬¾Í¿ÉÒÔʹÓÃ81¸ñʽ±àÂë
+ if ((unsigned char) (min & 0x80) == (unsigned char) (max & 0x80))
+ {
+ // Ëã³ö81¸ñʽµÄ³¤¶È£¬³õʼ»¯Ä¿±êÊý×é
+ //dest = new unsigned char[srcLen / 2 + 3];
+ // ÉèÖÃÄ¿±êÊý×éµÄµÚ2¸ö×Ö½ÚΪ³¤¶È
+ dest[1] = (unsigned char) (srcLen / 2);
+ // ÉèÖõÚ1¸ö×Ö½ÚΪ81
+ dest[0] = (unsigned char) 0x81;
+ // »ùַΪµÚ15λµ½µÚ8룬
+ min = (int) (min & 0x7F80);
+ dest[2] = (unsigned char) ((min >> 7) & 0xFF);
+ outOff = 3;
+ printf("[PB] atpb_CvtUcs2ToAlphaField, use 81 code\n");
+ }
+ // µÚ8¸ö×Ö½Ú²»Ò»Ñù£¨Ò»¸öΪ0£¬Ò»¸öΪ1£©£¬ÄÇô¾ÍʹÓÃ82¸ñʽ
+ else
+ {
+ // Ëã³ö82¸ñʽµÄ³¤¶È£¬³õʼ»¯Ä¿±êÊý×é
+ //dest = new unsigned char[srcLen / 2 + 4];
+ // ÉèÖÃÄ¿±êÊý×éµÄµÚ2¸ö×Ö½ÚΪ³¤¶È
+ dest[1] = (unsigned char) (srcLen / 2);
+ // ÉèÖõÚ1¸ö×Ö½ÚΪ82
+ dest[0] = (unsigned char) 0x82;
+ // »ùַΪԴÊý×é×îСֵ£¨µÚ1¸ö×Ö½ÚΪ0µÄ³ýÍ⣩
+ dest[2] = (unsigned char) ((min >> 8) & 0xFF);
+ dest[3] = (unsigned char) (min & 0xFF);
+ outOff = 4;
+ printf("[PB] atpb_CvtUcs2ToAlphaField, use 82 code\n");
+ }
+
+ for (i = 0; i < srcLen; i += 2)
+ {
+ // Èç¹ûµÚ1¸ö×Ö½ÚΪ0£¬ÔòÈ¡7µ½1룬×î¸ßλ²¹0
+ if (src[i] == 0)
+ {
+ dest[outOff] = (unsigned char) (src[i+1] & 0x7F);
+ }
+ // Èç¹ûµÚ1¸ö×Ö½Ú²»Îª0£¬ÔòÓÃUCSÂë¼õÈ¥»ùÖ·£¬×î¸ßλ²¹1
+ else
+ {
+ temp = (int) ((((src[i] << 8) & 0xFF00) | (src[i+1] & 0xFF)) - min);
+ dest[outOff] = (unsigned char) (temp | 0x80);
+ }
+ outOff++;
+ }
+ printf("[PB] atpb_CvtUcs2ToAlphaField, outOff=%d,dest[%d]=%x\n",outOff,outOff,dest[outOff]);
+ return outOff;
+ }
+
+ // ²»Âú×ã81ºÍ82µÄ¸ñʽҪÇó£¬Ê¹ÓÃ80¸ñʽ±àÂë
+ dest[0]=0x80;
+ memcpy(dest+1, src, srcLen);
+ printf("[PB] atpb_CvtUcs2ToAlphaField, use 80 code, len =%d\n",srcLen+1);
+ return srcLen+1;
+}
+
+
+int atPb_GetU80Code(const UINT8 *srcCode, UINT32 srcCodeLen, UINT8 *destCode, UINT32 destCodeLen)
+{
+ assert(destCode != NULL && srcCode != NULL);
+ if(srcCodeLen == 0 || destCodeLen == 0 || destCodeLen < srcCodeLen)
+ {
+ return -1;
+ }
+ memset(destCode, 0, destCodeLen);
+ destCode[0] = 0x80;
+ printf("chenjie -----atPb_GetU80Code-----srcCode[0] = %d\n", srcCode[0]);
+ switch (srcCode[0])
+ {
+ case 0x80:
+ {
+ memcpy(destCode, srcCode, srcCodeLen);
+ return srcCodeLen;
+ }
+ case 0x81:
+ {
+ atPb_CvtU81ToU80(srcCode + 1, srcCodeLen - 1, destCode + 1, destCodeLen - 1);
+ return srcCode[1]*2+1;
+ }
+ case 0x82:
+ {
+ atPb_CvtU82ToU80(srcCode + 1, srcCodeLen - 1, destCode + 1, destCodeLen - 1);
+ return srcCode[1]*2+1;
+ }
+ default:
+ {
+ return -1;//FALSE;
+ }
+ }
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: atPb_CvtU82ToU80
+* ¹¦ÄÜÃèÊö: ½«UCS282¸ñʽµÄ±àÂëת»»Îª80¸ñʽ
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ:
+* ÆäËü˵Ã÷: ²»°üÀ¨±àÂëÍ·×Ö½Ú
+**************************************************************************/
+BOOL atPb_CvtU82ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen)
+{
+ UINT8 chNum = 0;
+ UINT16 basePointer = 0;
+ UINT8 iCurChar = 0;
+ UINT32 iCurSrc = 0;
+
+ chNum = (UINT32)srcData[0];
+ basePointer = (UINT16)srcData[1];
+ basePointer = basePointer << 8;
+ basePointer = basePointer + srcData[2];
+ if(chNum * 2 > destLen)
+ {
+ return FALSE;
+ }
+ for(iCurSrc = 3; iCurSrc < srcLen && iCurChar < chNum; iCurSrc++, iCurChar++)
+ {
+ UINT8 *curDest = destData + 2 * iCurChar;
+ atPb_CvtChCode(basePointer, srcData[iCurSrc], curDest, curDest + 1);
+ }
+ return TRUE;
+}
+
+BOOL atPb_CvtU81ToU80(const UINT8 *srcData, UINT32 srcLen, UINT8 *destData, UINT32 destLen)
+{
+ UINT8 chNum = 0;
+ UINT16 basePointer = 0;
+ UINT8 iCurChar = 0;
+ UINT32 iCurSrc = 0;
+
+ chNum = srcData[0];
+ basePointer = ((UINT16)srcData[1]) << 7;
+ if(chNum * 2 > destLen)
+ {
+ return FALSE;
+ }
+ for(iCurSrc = 2; iCurSrc < srcLen && iCurChar < chNum; iCurSrc++, iCurChar++)
+ {
+ UINT8 *curDest = destData + 2 * iCurChar;
+ atPb_CvtChCode(basePointer, srcData[iCurSrc], curDest, curDest + 1);
+ }
+ return TRUE;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: atPb_CvtChCode
+* ¹¦ÄÜÃèÊö: ½«U81\U82µÄÊý¾ÝÓòת»»ÎªU80µÄÊý¾ÝÓò
+* ²ÎÊý˵Ã÷: (IN)
+* (OUT)
+* ·µ »Ø Öµ:
+* ÆäËü˵Ã÷:
+**************************************************************************/
+VOID atPb_CvtChCode(UINT16 basePointer, UINT8 srcData, UINT8 *chMsb, UINT8 *chLsb)
+{
+ UINT16 curChar = 0;
+
+ assert(chMsb != NULL && chLsb != NULL);
+ if((srcData & 0x80) == 0)
+ {
+ curChar = srcData;
+ }
+ else
+ {
+ curChar = basePointer + (srcData & 0x7f);
+ }
+ *chMsb = (UINT8)(curChar >> 8);
+ *chLsb = (UINT8)((curChar << 8) >> 8);
+ return;
+}
+
+
+ /**************************************************************************
+* º¯ÊýÃû³Æ£º int atPb_String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º ¿É´òÓ¡×Ö·û´®×ª»»Îª×Ö½ÚÊý¾Ý £¬È磺"C8329BFD0E01" --> {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01}
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±êÊý¾ÝÖ¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int atPb_String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i = 0; i < nSrcLength; i += 2)
+ {
+ // Êä³ö¸ß4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst = (*pSrc - '0') << 4;
+ }
+ else
+ {
+ *pDst = ((toupper(*pSrc) - 'A') + 10) << 4;
+ }
+
+ pSrc++;
+
+ // Êä³öµÍ4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst |= *pSrc - '0';
+ }
+ else
+ {
+ *pDst |= (toupper(*pSrc) - 'A') + 10;
+ }
+
+ pSrc++;
+ pDst++;
+ }
+
+ // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
+ return nSrcLength / 2;
+}
+
+ /**************************************************************************
+* º¯ÊýÃû³Æ£º int atPb_Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º ×Ö½ÚÊý¾Ýת»»Îª¿É´òÓ¡×Ö·û´® £¬È磺{0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} --> "C8329BFD0E01"
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´Êý¾ÝÖ¸Õë
+ pDst: Ä¿±ê×Ö·û´®Ö¸Õë
+ nSrcLength: Ô´Êý¾Ý³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int atPb_Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+ const char tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i++)
+ {
+ *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
+ *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
+ pSrc++;
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nSrcLength * 2;
+}
+
+
+/*´òÓ¡web·¢À´µÄµç»°±¾ÐÅÏ¢*/
+static VOID atPb_WebRecodeShow(T_zPb_WebContact const *pFromweb)
+{
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.Index=%d\n",pFromweb->pbIndex);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.Name=%s\n",pFromweb->name);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum1=%s\n",pFromweb->mobilNumber);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum2=%s\n",pFromweb->homeNumber);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.PbNum3=%s\n",pFromweb->officeNumber);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:fromweb.email=%s\n",pFromweb->email);
+}
+
+int atPb_IintPbErr(UINT8 *pErrCode)
+{
+ sc_cfg_set(ZPB_NV_INIT, ZPB_LOAD_ERROR);
+ //need break
+ return TRUE;
+}
+
+int atPb_ScpbrSetErr(UINT8 *pErrCode)
+{
+ printf("[PB] atPb_ScpbrSetErr fail and return\n");
+ sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
+ return TRUE;
+}
+
+VOID atBase_IintPbOk(VOID)
+{
+ sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
+ printf("[PB] atPb_SendScpbrSet atBase_IintPbOk \n");
+}
+
+/*·¢ËÍÉèÖÃSM´æ´¢Æ÷ÃüÁî*/
+/*int atPb_SendCpbsSetReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ return zSvr_SendAtSyn(ZAT_CPBS_SET_CMD,"AT+CPBS=\"SM\"\r\n",cid,pAtRst,atRstSize);
+}*/
+
+/*²éѯpbÐÅÏ¢µÄ×Ü´æ´¢Æ÷¸öÊý¡¢ÒÑÓô洢Æ÷¸öÊýÐÅÏ¢*/
+/*int atPb_SendCpbsReadReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ return zSvr_SendAtSyn(ZAT_CPBS_READ_CMD,"AT+CPBS?\r\n",cid,pAtRst,atRstSize);
+}*/
+
+VOID atPb_RecvCpbsReadRsp(T_zPb_AtCpbsReadRes* cpbsInd)
+{
+ CHAR resInfo[20] = {0};
+
+ if(strncmp(cpbsInd->locType,"SM",2) == 0)
+ {
+ (VOID)snprintf(resInfo, 20,"%d",cpbsInd->usedEntries);
+ (VOID)sc_cfg_set(NV_PB_USEDENTRIES,resInfo);
+ memset(resInfo, 0, 20);
+ (VOID)snprintf(resInfo,20,"%d",cpbsInd->totalEntries);
+ (VOID)sc_cfg_set(NV_PB_TOTALENTRIES,resInfo);
+ g_zPb_SimIndex[0] = (UINT32)(cpbsInd->totalEntries);
+ }
+ else
+ {//teet
+ //atBase_SendMsgToSelf(ZAT_CPBS_SET_CMD, ZUFI_NULL, 0);
+ printf("atPb_RecvCpbsReadRsp not SM:%s\n", cpbsInd->locType);
+ }
+}
+
+/*²éѯpbÐÅÏ¢µÄ×î´óË÷Òý¡¢³¤¶ÈµÈÐÅÏ¢*/
+/*int atPb_SendScpbrTest(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ return zSvr_SendAtSyn(ZAT_SCPBR_TEST_CMD,"AT^SCPBR=?\r\n",cid,pAtRst,atRstSize);
+}*/
+
+static VOID atPb_SetScpbrResToNv(CHAR const*pbNvKeyWord, UINT32 len)
+{
+ char converted[10] = {0};
+
+ assert(pbNvKeyWord != ZUFI_NULL);
+ (VOID)snprintf(converted,10, "%d", len);
+ (VOID)sc_cfg_set(pbNvKeyWord, converted);
+}
+
+VOID atPb_ScpbrTestRsp(T_zPb_AtScpbrTestRes* scpbsInd)
+{
+ T_zPb_UsimCapacity pbPara = {0};
+ CHAR pbUsed[50]={0};
+ sc_cfg_get(NV_PB_USEDENTRIES,pbUsed,sizeof(pbUsed));
+
+ g_zPb_DelIndex = (UINT32)scpbsInd->minIndex;
+ pbPara.simType = ZPB_USIM;
+ pbPara.maxRecordNum = scpbsInd->maxIndex;
+ pbPara.usedRecordNum = atoi(pbUsed);
+ pbPara.maxNumberLen = scpbsInd->maxNumberLen;
+ pbPara.maxNameLen = scpbsInd->maxTextLen;
+ pbPara.maxAnrLen = scpbsInd->maxNumberLen;
+ pbPara.maxAnr1Len = scpbsInd->maxNumberLen;
+ pbPara.maxEmailLen = scpbsInd->maxEmailLen;
+ atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMIN, (UINT32)scpbsInd->minIndex);
+ atPb_SetScpbrResToNv(ZPB_NV_USIMINDEXMAX, (UINT32)scpbsInd->maxIndex);
+
+ /*ÉèÖÃsimÈÝÁ¿Êý¾Ý¿â±í*/
+ (VOID)atPb_SetSimCapacityTable(pbPara);
+}
+
+
+
+/*·Ö¶Î¶à´Î¶ÁÈ¡PB ÐÅÏ¢*/
+int atPb_SendScpbrSet_repeat(sem_t tSemId)
+{
+ int min = 0;//klocwork
+ int max = 0;
+ int res = 0;
+ int index = 0;
+ CHAR pbMin[50]={0};
+ CHAR pbMax[50]={0};
+ int indexmin = 0;
+ int indexmax = 0;
+ T_zPb_ScpbrReadRes scpbrReadInfo = {0};
+
+ sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+
+ (VOID)sc_cfg_set(ZPB_NV_INIT, ZPB_LOADING);
+
+ //assert(strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMIN),"0") != 0 && strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMAX),"0") != 0);
+ if(strcmp(pbMin,"0") == 0 || strcmp(pbMax,"0") == 0)
+ {
+ sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
+ printf("atPb_SendScpbrSet card unsupport pb\n");
+ return -1;
+ }
+
+ sscanf(pbMin, "%d", &min);
+ sscanf(pbMax, "%d", &max);
+ if ((min < 0 || min > INT_MAX-1) ||
+ (max < 0 || max > INT_MAX-1)) { //kw 3
+ printf("atPb_SendScpbrSet pb num err min:%d, max:%d\n", min, max);
+ return -1;
+ }
+
+ while(1)
+ {
+ if(indexmin < min)
+ {
+ indexmin = min;
+ indexmax = min+ZPB_INIT_LOAD_RECORD_NUM-1;
+ if(indexmax > max)
+ {
+ indexmax = max;
+ break;
+ }
+ printf("[PB] 111 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin, indexmax, min, max);
+ }
+ else
+ {
+ indexmin = indexmin+ZPB_INIT_LOAD_RECORD_NUM;
+ if(indexmin > max)
+ {
+ printf("[PB] 333 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin,indexmax,min,max);
+ break;
+ }
+ indexmax = indexmax+ZPB_INIT_LOAD_RECORD_NUM;
+ if(indexmax > max)
+ {
+ indexmax = max;
+ }
+ printf("[PB] 222 indexmin=%d, indexmax=%d,(%d-%d)\n",indexmin, indexmax,min,max);
+ }
+
+ scpbrReadInfo.minIndex = indexmin;
+ scpbrReadInfo.maxIndex = indexmax;
+ res = ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_READ_PB_REQ, sizeof(T_zPb_ScpbrReadRes), &scpbrReadInfo, 0);
+ sem_wait(&g_Pb_sem_id);
+ if(g_PbOptRsp.result == -1)
+ {
+ break;
+ }
+ }
+
+ return g_PbOptRsp.result;
+}
+#if 0
+/*Ò»´Î¶ÁÈ¡PB ÐÅÏ¢*/
+int atPb_SendScpbrSet(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ UINT32 indexmin = 0;
+ UINT32 indexmax = 0;
+ CHAR atcmdMsg[70] = {0};
+ int res = 0;
+ CHAR pbMin[50]={0};
+ CHAR pbMax[50]={0};
+ sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+
+ (VOID)sc_cfg_set(ZPB_NV_INIT, ZPB_LOADING);
+
+ //assert(strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMIN),"0") != 0 && strcmp(cfg_safe_get(ZPB_NV_USIMINDEXMAX),"0") != 0);
+ if(strcmp(pbMin,"0") == 0 || strcmp(pbMax,"0") == 0)
+ {
+ //sc_cfg_set(ZPB_NV_INIT, ZPB_OPERATE_SUC);
+ printf("atPb_SendScpbrSet card unsupport pb\n");
+ return ZAT_RESULT_OK;
+ }
+
+ sscanf(pbMin, "%d", &indexmin);
+ sscanf(pbMax, "%d", &indexmax);
+ (VOID)snprintf(atcmdMsg, sizeof(atcmdMsg), "AT^SCPBR=%d,%d\r\n", indexmin, indexmax);
+
+ pthread_mutex_lock(&smsdb_mutex);
+ res = zSvr_SendAtSyn(ZAT_SCPBR_SET_CMD,atcmdMsg,cid,pAtRst,atRstSize);
+ pthread_mutex_unlock(&smsdb_mutex);
+ return res;
+}
#endif
-UINT8 atPb_EncodeText(CHAR*pbDst,CHAR const*pbTextSrc,UINT32 dstLen){UINT8 i=
-(0x20a8+1020-0x24a4);CHAR strTarget[ZPB_TEXT_SIZE_BYTES]={(0x696+7549-0x2413)};
-if(pbTextSrc!=ZUFI_NULL){if(strlen(pbTextSrc)*(0x1e64+2093-0x268d)+
-ZPB_UCS2_PREFIX_LEN<dstLen){snprintf((CHAR*)&strTarget[(0x133b+782-0x1649)],
-sizeof(strTarget),"\x25\x30\x32\x58",ZPB_UCS2_PREFIX);for(i=(0x656+5034-0x1a00);
-(i<strlen(pbTextSrc))&&(i*(0x1353+4127-0x236e)+ZPB_UCS2_PREFIX_LEN<dstLen);i++){
-snprintf(strTarget+i*(0x17d+7519-0x1ed8)+ZPB_UCS2_PREFIX_LEN,sizeof(strTarget)-i
-*(0x1c0+6052-0x1960)-ZPB_UCS2_PREFIX_LEN,"\x30\x30\x25\x30\x32\x58",pbTextSrc[i]
-);}strncpy(pbDst,strTarget,dstLen-(0xedf+5579-0x24a9));return ZUFI_SUCC;}}return
- ZUFI_FAIL;}VOID atPb_ScpbrSetRsp(T_zPb_ScpbrSetRes*atRes){T_zPb_WebContact
-pbRecord={(0xc20+2211-0x14c3)};CHAR pbDst[ZPB_TEXT_SIZE_BYTES]={
-(0xb89+6920-0x2691)};CHAR text[ZPB_TEXT_SIZE_BYTES]={(0xb6f+5136-0x1f7f)};int
-text_len=(0x118f+4561-0x2360);int tmp_len=(0x1b9f+1868-0x22eb);CHAR tmp[
-ZPB_TEXT_SIZE_BYTES]={(0xe89+4808-0x2151)};if(atRes->coding!=ZPB_UCS2){if(
-atPb_EncodeText(pbDst,atRes->text,ZPB_TEXT_SIZE_BYTES)==ZUFI_SUCC){strncpy(atRes
-->text,pbDst+(0xdc3+447-0xf80),sizeof(atRes->text)-(0x1075+1916-0x17f0));}else{
-slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x53\x63\x70\x62\x72\x53\x65\x74\x52\x73\x70\x65\x6e\x63\x6f\x64\x65\x20\x65\x72\x72\x21\x2e" "\n"
-);return;}}else{text_len=atPb_String2Bytes(&atRes->text,&text,strlen(atRes->text
-));tmp_len=atPb_GetU80Code(&text,text_len,&tmp,ZPB_TEXT_SIZE_BYTES);if(tmp_len<
-(0x1b44+161-0x1be5))return;memset(&text,(0x1133+5562-0x26ed),ZPB_TEXT_SIZE_BYTES
-);text_len=atPb_Bytes2String(&tmp,&text,tmp_len);if(text_len>
-(0x14d6+1895-0x1c3b)){memset(&atRes->text,(0x6ac+5000-0x1a34),
-ZPB_TEXT_SIZE_BYTES);memcpy(&atRes->text,text+(0x3c5+1978-0xb7d),strlen(text)-
-(0x986+2022-0x116a));}}pbRecord.pbId=-(0xdc2+6075-0x257c);pbRecord.pbIndex=(
-SINT32)atRes->index;strncpy(pbRecord.name,atRes->text,sizeof(pbRecord.name)-
-(0x15d2+4024-0x2589));strncpy(pbRecord.mobilNumber,atRes->number1,sizeof(
-pbRecord.mobilNumber)-(0x4ea+2613-0xf1e));strncpy(pbRecord.officeNumber,atRes->
-number2,sizeof(pbRecord.officeNumber)-(0x95f+6821-0x2403));strncpy(pbRecord.
-homeNumber,atRes->number3,sizeof(pbRecord.homeNumber)-(0x2276+682-0x251f));
-strncpy(pbRecord.email,atRes->email,sizeof(pbRecord.email)-(0xdd8+3636-0x1c0b));
-pbRecord.pbLocation=ZPB_LOCATION_USIM;(VOID)atPb_LoadARecToPbmTable(&pbRecord);}
-VOID atPb_SetDelStatusMultOrAll(){if(g_zPb_DelStatusUsim.dealFailNum>
-(0xca0+266-0xdaa)){if(g_zPb_DelStatusUsim.dealSuccNum>(0x179f+1794-0x1ea1)){(
-VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_MUL_DEL_PART_SUC);}else{(VOID)sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_OPERATE_SUC);}}
-#if (0xa1c+4-0xa20)
-VOID atPb_RecvScpbwAddErr(UINT8*pErrCode){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_NEW_ERROR);if((strncmp(pErrCode,ZAT_ERRCODE_MEMORY_FULL,(0x11d3+2262-0x1aa7)
-)==(0xe45+5283-0x22e8))){(VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x79\x65\x73");
-printf(
-"\x70\x62\x3a\x52\x65\x63\x76\x20\x43\x4d\x45\x20\x45\x72\x72\x43\x6f\x64\x65\x3a\x20\x32\x30\x2e" "\n"
-);}else{printf(
-"\x70\x62\x3a\x52\x65\x63\x76\x20\x41\x74\x20\x53\x63\x70\x62\x77\x20\x61\x64\x64\x20\x45\x72\x72\x2e" "\n"
-);}}
+/*¶Ô¶ÁÈ¡µÄPBÐÕÃû±àÂëΪUcs2*/
+UINT8 atPb_EncodeText(CHAR *pbDst,CHAR const*pbTextSrc, UINT32 dstLen)
+{
+ UINT8 i = 0;
+ CHAR strTarget[ZPB_TEXT_SIZE_BYTES] = {0};
+
+ if(pbTextSrc != ZUFI_NULL)
+ {
+ if(strlen(pbTextSrc) *4 + ZPB_UCS2_PREFIX_LEN < dstLen)
+ {
+ snprintf((CHAR *)&strTarget[0], sizeof(strTarget),"%02X", ZPB_UCS2_PREFIX);
+ for (i = 0; (i < strlen(pbTextSrc)) && (i * 4 + ZPB_UCS2_PREFIX_LEN < dstLen); i++ )
+ {
+ snprintf(strTarget + i * 4 + ZPB_UCS2_PREFIX_LEN, sizeof(strTarget)- i*4 -ZPB_UCS2_PREFIX_LEN,"00%02X", pbTextSrc[i] );
+ }
+ strncpy(pbDst, strTarget,dstLen-1);
+ return ZUFI_SUCC;
+ }
+ }
+ return ZUFI_FAIL;
+}
+
+/*¶ÁÈ¡µç»°±¾¼Ç¼Ö÷¶¯Éϱ¨ÏìÓ¦*/
+VOID atPb_ScpbrSetRsp(T_zPb_ScpbrSetRes* atRes)
+{
+ T_zPb_WebContact pbRecord = {0};
+ CHAR pbDst[ZPB_TEXT_SIZE_BYTES] = {0};
+ CHAR text[ZPB_TEXT_SIZE_BYTES] = {0};
+ int text_len = 0;
+ int tmp_len = 0;
+ CHAR tmp[ZPB_TEXT_SIZE_BYTES] = {0};
+
+ if(atRes->coding != ZPB_UCS2)
+ {
+ if(atPb_EncodeText(pbDst, atRes->text, ZPB_TEXT_SIZE_BYTES) == ZUFI_SUCC)
+ {
+ strncpy(atRes->text,pbDst+2,sizeof(atRes->text)-1);//Ìø¹ý80
+ }
+ else
+ {
+ slog(PB_PRINT,SLOG_ERR, "pb:atPb_ScpbrSetRspencode err!.\n");
+ return;
+ }
+ }
+ else
+ {
+ text_len = atPb_String2Bytes(&atRes->text, &text, strlen(atRes->text));
+ tmp_len = atPb_GetU80Code(&text, text_len, &tmp, ZPB_TEXT_SIZE_BYTES);
+ if(tmp_len < 0) return;
+
+ memset(&text, 0, ZPB_TEXT_SIZE_BYTES);
+ text_len = atPb_Bytes2String(&tmp, &text, tmp_len);
+ if (text_len > 2){
+ memset(&atRes->text, 0, ZPB_TEXT_SIZE_BYTES);
+ memcpy(&atRes->text, text+2, strlen(text)-2);
+ }
+ }
+ pbRecord.pbId = -1;
+ pbRecord.pbIndex = (SINT32)atRes->index;/*ת»»µç»°Ë÷Òý*/
+ strncpy(pbRecord.name, atRes->text,sizeof(pbRecord.name)-1);
+ strncpy(pbRecord.mobilNumber,atRes->number1,sizeof(pbRecord.mobilNumber)-1);
+ strncpy(pbRecord.officeNumber,atRes->number2,sizeof(pbRecord.officeNumber)-1);
+ strncpy(pbRecord.homeNumber,atRes->number3,sizeof(pbRecord.homeNumber)-1);
+ strncpy(pbRecord.email,atRes->email,sizeof(pbRecord.email)-1);
+ pbRecord.pbLocation=ZPB_LOCATION_USIM;
+ (VOID)atPb_LoadARecToPbmTable(&pbRecord);
+ //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
+}
+
+VOID atPb_SetDelStatusMultOrAll()
+{
+ if(g_zPb_DelStatusUsim.dealFailNum>0)
+ {
+ if(g_zPb_DelStatusUsim.dealSuccNum>0)
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_MUL_DEL_PART_SUC);
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ }
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
+}
+
+/*·¢ËÍɾ³ýÒ»ÌõPbÐÅÏ¢ÃüÁî*/
+/*int atPb_SendScpbwDelReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ SINT32 pbIndex = 0;
+ CHAR atcmdMsg[70] = {0};
+
+ pbIndex = *((SINT32*)pAtCmdPara);
+ (VOID)snprintf(atcmdMsg,sizeof(atcmdMsg),"AT^SCPBW=%d\r\n", pbIndex);
+ return zSvr_SendAtSyn(ZAT_SCPBW_DEL_CMD,atcmdMsg,cid,pAtRst,atRstSize);
+}*/
+#if 0
+/*Ö§³Ö´íÎóÂë½âÎö£¬20ÄÚ´æÂú*/
+VOID atPb_RecvScpbwAddErr(UINT8 *pErrCode)
+{
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ if((strncmp(pErrCode, ZAT_ERRCODE_MEMORY_FULL, 2) == 0))
+ {
+ /*ÏÔʾ¸øWebÒ³Ãæ£¬É¾³ýÒ»ÌõºóÇåΪ"no"*/
+ (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "yes");
+ printf("pb:Recv CME ErrCode: 20.\n");
+ }
+ else
+ {
+ printf("pb:Recv At Scpbw add Err.\n");
+ }
+
+ //ÐèÒª½«Ö®Ç°±£´æÔÚÊý¾Ý¿âµÄ¼Ç¼ɾ³ý
+ //atPb_DelRecordFromDBWhenAddErr();
+}
#endif
-VOID atPb_RecvScpbwModifyErr(UINT8*pErrCode){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_NEW_ERROR);printf(
-"\x70\x62\x3a\x52\x65\x63\x76\x20\x41\x74\x20\x53\x63\x70\x62\x77\x20\x6d\x6f\x64\x69\x66\x79\x20\x65\x72\x72\x2e" "\n"
-);}VOID pb_AsctoHex(UINT16*pcHex,SINT32 iDstLen,UINT8 const*pcASC,SINT32 iSrcLen
-){UINT32 iOddOrEven=(0xd02+37-0xd27);UINT8 iTemp=(0x2173+735-0x2452);SINT32 i=
-(0x68d+1857-0xdce);if((NULL==pcHex)||(NULL==pcASC)||((0x1452+1445-0x19f7)==
-iDstLen)||(iDstLen<(iSrcLen/(0xbed+468-0xdbf)+(0x1ce6+2225-0x2596)))){return;}
-for(i=(0x4d4+2848-0xff4);i<iSrcLen;i++){if(iOddOrEven%(0x83+9284-0x24c5)==
-(0x6c3+610-0x925)){iTemp=*(pcASC+i);if((iTemp>=((char)(0x960+2068-0x1144)))&&(
-iTemp<=((char)(0x2b5+8245-0x22b1)))){*(pcHex+i/(0x156b+4022-0x251f))|=(UINT8)(
-iTemp-(0x52f+1344-0xa3f))<<(0xd72+1821-0x148b);}else{*(pcHex+i/
-(0x357+6115-0x1b38))|=(UINT8)(iTemp-(0x1c7+4193-0x11f1))<<(0x2ca+4429-0x1413);}}
-else{iTemp=*(pcASC+i);if((iTemp>=((char)(0x2a2+5145-0x168b)))&&(iTemp<=
-((char)(0x624+2612-0x101f)))){*(pcHex+i/(0x738+5534-0x1cd4))|=iTemp-
-(0x14b+7781-0x1f80);}else{*(pcHex+i/(0x629+333-0x774))|=iTemp-
-(0xf10+4781-0x2186);}}iOddOrEven++;}}SINT32 atPb_IfUcs2IsSMS7(UINT16*psUcs2,
-SINT32 iLength){int iRetVal=(0xb6d+1350-0x10b2);char cTemp;int i=
-(0x4d2+2646-0xf28);if(NULL==psUcs2){return-(0x268+6462-0x1ba5);}for(i=
-(0x320+4158-0x135e);i<iLength;i++){if((0xccf+6899-0x26c2)>psUcs2[i]){switch(
-psUcs2[i]){case(0xf29+3426-0x1c7f):case(0x1afb+3129-0x26d9):case
-(0xa1+9593-0x25be):case(0x297+801-0x55b):case(0xb77+2311-0x1420):case
-(0xc04+3858-0x1a9b):case(0x10f1+1197-0x1522):case(0xb78+6249-0x2364):case
-(0x9c+5129-0x1427):case(0xeb5+2730-0x18bb):case(0x119a+2584-0x1b92):{break;}
-default:{cTemp=(char)G_ZPB_NEWUCS2TOGSM[psUcs2[i]];if(ZPB_NON_GSM==cTemp){
-iRetVal=(0x3c5+2086-0xbeb);}break;}}}else{switch(psUcs2[i]){case
-(0x1dbc+1594-0x2062):case(0xbfa+1882-0xfae):case(0x20a4+876-0x207d):case
-(0xe57+7138-0x269e):case(0x185d+2602-0x1ede):case(0x89a+4232-0x1582):case
-(0x24d9+426-0x22bb):case(0x6ad+371-0x47d):case(0x925+526-0x77b):case
-(0x63b+683-0x548):{break;}default:{iRetVal=(0x4cf+8524-0x261b);break;}}}if(
-(0xa66+3140-0x16aa)==iRetVal){break;}}return iRetVal;}static UINT8
-atPb_EncodeNameToUcs2(char*pbDst,UINT32 iDstLen,char const*pbSrc){UINT16 acHex[
-(0x101+6636-0x19ed)]={(0x1d08+2017-0x24e9)};SINT32 srclen=(0x1f6+515-0x3f9);
-SINT32 rest=(0x73d+4794-0x19f7);assert(pbDst!=NULL&&pbSrc!=NULL);srclen=(SINT32)
-strlen(pbSrc);slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x50\x62\x5f\x45\x6e\x63\x6f\x64\x65\x4e\x61\x6d\x65\x54\x6f\x55\x63\x73\x32\x20\x69\x6e\x70\x75\x74\x20\x70\x73\x53\x72\x63\x3d\x25\x73\x2c\x69\x53\x72\x63\x4c\x65\x6e\x3d\x25\x64" "\n"
-,pbSrc,srclen);pb_AsctoHex(acHex,(0x23dd+523-0x24e8),(UINT8*)pbSrc,srclen);rest=
-atPb_IfUcs2IsSMS7(acHex,srclen/(0x1877+227-0x1956));if(rest==(0x48f+5112-0x1886)
-){return atPb_EncodeText(pbDst,pbSrc,iDstLen);}else if(rest==(0x668+2154-0xed2))
-{if(strlen(pbSrc)+(0x6e1+1183-0xb7e)<iDstLen){memcpy(pbDst,"\x38\x30",
-(0x834+7356-0x24ee));memcpy(pbDst+(0x14e5+3816-0x23cb),pbSrc,srclen);return
-ZUFI_SUCC;}}return ZUFI_FAIL;}SINT32 atPb_FindIdleIndex(T_zPb_WebContact const*
-pbRecv,BOOL pbNewFlag){SINT32 count=(0x458+5105-0x1848);SINT32 total=
-(0x17c5+1475-0x1d88);SINT32*IndexType=NULL;if((NULL==pbRecv)){slog(PB_PRINT,
-SLOG_ERR,
-"\x70\x62\x3a\x66\x69\x6e\x64\x5f\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3a\x74\x68\x65\x20\x70\x61\x72\x61\x20\x6f\x66\x20\x66\x69\x6e\x64\x5f\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x20\x61\x72\x65\x20\x4e\x55\x4c\x4c" "\n"
-);return-(0x2441+489-0x2629);}if(TRUE==pbNewFlag){if(ZPB_LOCATION_USIM==pbRecv->
-pbLocation){total=g_zPb_SimIndex[(0x2ba+8322-0x233c)];IndexType=g_zPb_SimIndex;}
-else if(ZPB_LOCATION_AP==pbRecv->pbLocation){total=g_zPb_ApIndex[
-(0x1360+3013-0x1f25)];IndexType=g_zPb_ApIndex;}for(;count<=total;count++){if((
-NULL!=IndexType)&&(IndexType[count]==PBM_ERROR_NOT_FOUND)){break;}}if(count>
-total){slog(PB_PRINT,SLOG_ERR,
-"\x70\x62\x3a\x66\x69\x6e\x64\x5f\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3a\x63\x61\x6e\x20\x6e\x6f\x74\x20\x66\x69\x6e\x64\x20\x69\x6e\x64\x65\x78\x5f\x69\x64\x2c\x69\x6e\x64\x65\x78\x5f\x69\x64\x3d\x25\x64" "\n" "\x2e"
-,count);return-(0x797+4588-0x1982);}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x66\x69\x6e\x64\x5f\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x3a\x20\x69\x6e\x64\x65\x78\x5f\x69\x64\x3d\x25\x64\x2c\x20\x74\x6f\x74\x61\x6c\x20\x69\x73\x20\x25\x64" "\n"
-,count,total);return count;}else{return pbRecv->pbIndex;}}BOOL atPb_GetASCII(
-CHAR*pSrc,CHAR*pDst,SINT32 len){SINT32 j=(0x136b+1208-0x1823);SINT32 i=
-(0xce6+1534-0x12e4);CHAR buf[ZPB_TEXT_SIZE_BYTES]={(0xb0+9044-0x2404)};CHAR str[
-(0x1687+1131-0x1aef)]={(0x230a+1009-0x26fb)};SINT32 length=(0x1a30+856-0x1d88);
-length=atPb_String2Bytes(pSrc,buf,len);for(i=(0x1754+3180-0x23c0);i<length;i+=
-(0x9a8+4789-0x1c5b)){if(buf[i]!=(0x1fb9+736-0x2299)||buf[i+(0x12f6+1387-0x1860)]
->(0x59c+8556-0x2689)){return FALSE;}pDst[j++]=buf[i+(0x8b0+858-0xc09)];}return
-TRUE;}VOID atWeb_AddOrModOnePbUsim(T_zPb_WebContact*pWebPbContact,BOOL pbNewFlag
-,sem_t semId){int atRes=(0xcda+823-0x1011);CHAR pbName[ZPB_TEXT_SIZE_BYTES+
-(0xeec+550-0x110f)]={(0x92+3878-0xfb8)};CHAR buf_src[ZPB_TEXT_SIZE_BYTES+
-(0x263+1734-0x926)]={(0x4a+4954-0x13a4)};CHAR buf_dest[ZPB_TEXT_SIZE_BYTES+
-(0x1a6+6755-0x1c06)]={(0xc77+4874-0x1f81)};T_zPb_ScpbwParam scpbwParam={
-(0x1273+26-0x128d)};int len=(0x154a+1159-0x19d1);atPb_WebRecodeShow(
-pWebPbContact);if(atPb_GetASCII(pWebPbContact->name,pbName,strlen(pWebPbContact
-->name))){scpbwParam.coding=(0x2266+79-0x22b5);}else{len=atPb_String2Bytes(
-pWebPbContact->name,buf_src,strlen(pWebPbContact->name));len=
-atpb_CvtUcs2ToAlphaField(buf_src,len,buf_dest);atPb_Bytes2String(buf_dest,pbName
-,len);scpbwParam.coding=(0x47c+4307-0x154e);}scpbwParam.pbIndex=pWebPbContact->
-pbIndex;strncpy(scpbwParam.name,pbName,sizeof(scpbwParam.name)-
-(0x968+6487-0x22be));strncpy(scpbwParam.mobilNumber,pWebPbContact->mobilNumber,
-sizeof(scpbwParam.mobilNumber)-(0x8a8+5240-0x1d1f));strncpy(scpbwParam.
-officeNumber,pWebPbContact->officeNumber,sizeof(scpbwParam.officeNumber)-
-(0x15d9+2668-0x2044));strncpy(scpbwParam.homeNumber,pWebPbContact->homeNumber,
-sizeof(scpbwParam.homeNumber)-(0x1f52+1685-0x25e6));strncpy(scpbwParam.email,
-pWebPbContact->email,sizeof(scpbwParam.email)-(0x296+1207-0x74c));
-ipc_send_message(MODULE_ID_PB,MODULE_ID_AT_CTL,MSG_CMD_ADD_MODIFY_PB_REQ,sizeof(
-T_zPb_ScpbwParam),(unsigned char*)&scpbwParam,(0x81+1469-0x63e));sem_wait(&
-g_Pb_sem_id);if(g_PbOptRsp.result!=(0x21f6+473-0x23ce)){(VOID)sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_NEW_ERROR);if(TRUE==pbNewFlag){printf(
-"\x70\x62\x3a\x61\x64\x64\x20\x53\x63\x70\x62\x77\x20\x65\x72\x72\x6f\x72\x2e" "\n"
-);}else{printf(
-"\x70\x62\x3a\x6d\x6f\x64\x69\x66\x79\x20\x53\x63\x70\x62\x77\x20\x65\x72\x72\x6f\x72\x2e" "\n"
-);}return;}printf(
-"\x70\x62\x3a\x53\x65\x6e\x64\x20\x53\x63\x70\x62\x77\x20\x6f\x6b\x2e" "\n");if(
-ZPB_DB_OK==atPb_WriteContactToPbmTable(pWebPbContact,pbNewFlag)){(VOID)
-sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);printf(
-"\x70\x62\x3a\x57\x72\x69\x74\x65\x43\x6f\x6e\x74\x61\x63\x74\x54\x6f\x50\x62\x6d\x54\x61\x62\x6c\x65\x20\x6f\x6b\x2e" "\n"
-);}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_NEW_ERROR);printf(
-"\x70\x62\x3a\x57\x72\x69\x74\x65\x43\x6f\x6e\x74\x61\x63\x74\x54\x6f\x50\x62\x6d\x54\x61\x62\x6c\x65\x20\x65\x72\x72\x6f\x72\x2e" "\n"
-);}}VOID atWeb_AddOnePb(T_zPb_WebContact*webPbContact,sem_t semId){SINT32
-idleIndex=(0x14d+7021-0x1cb9);T_zPb_Header pbHeader={(0x51f+3339-0x122a)};BOOL
-pbNewFlag=FALSE;T_zPb_DelInfo delRecord={(0xf28+2666-0x1992)};CHAR ptFlag[
-(0x1090+2436-0x1a00)]={(0x15a9+1530-0x1ba3)};printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x2c\x20\x70\x62\x49\x64\x3d\x25\x64\x21" "\n"
-,webPbContact->pbId);if(-(0x2222+680-0x24c9)==webPbContact->pbId){slog(PB_PRINT,
-SLOG_DEBUG,
-"\x70\x62\x3a\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x20\x6e\x65\x77\x2e" "\n"
-);pbNewFlag=TRUE;idleIndex=atPb_FindIdleIndex(webPbContact,pbNewFlag);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x20\x69\x64\x6c\x65\x49\x6e\x64\x65\x78\x3d\x25\x64\x2e" "\n"
-,idleIndex);if(idleIndex!=-(0x513+1558-0xb28)){webPbContact->pbIndex=idleIndex;}
-else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_NEW_ERROR);printf(
-"\x5b\x50\x42\x5d\x20\x6d\x65\x6d\x6f\x72\x79\x20\x69\x73\x20\x66\x75\x6c\x6c\x2c\x20\x63\x61\x6e\x20\x6e\x6f\x74\x20\x61\x64\x64\x20\x72\x65\x63\x6f\x64\x65\x20\x61\x6e\x79\x20\x6d\x6f\x72\x65\x2e" "\n"
-);return;}}else{printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x20\x6d\x6f\x64\x69\x66\x79\x2e" "\n"
-);pbHeader.pbId=webPbContact->pbId;if(ZPB_DB_OK!=atPb_GetIndexLocationById(&
-pbHeader)){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_NEW_ERROR);return;}
-webPbContact->pbIndex=pbHeader.pbIndex;webPbContact->pbLocation=pbHeader.
-pbLocation;}printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x3a\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64" "\n"
-,webPbContact->pbLocation);if(ZPB_LOCATION_AP==webPbContact->pbLocation){if(
-ZPB_DB_OK!=atPb_WriteContactToPbmTable(webPbContact,pbNewFlag)){(VOID)sc_cfg_set
-(ZPB_NV_WRITE_FLAG,ZPB_NEW_ERROR);}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_OPERATE_SUC);}}else if(ZPB_LOCATION_USIM==webPbContact->pbLocation){
-atWeb_AddOrModOnePbUsim(webPbContact,pbNewFlag,semId);}else{printf(
-"\x5b\x50\x42\x5d\x20\x77\x72\x69\x74\x65\x5f\x70\x62\x6d\x5f\x72\x65\x63\x6f\x72\x64\x3a\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x69\x73\x20\x4e\x55\x4c\x4c" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_LOCATION_IS_NULL);}printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x41\x64\x64\x4f\x6e\x65\x50\x62\x20\x64\x65\x6c\x5f\x69\x64\x3d\x25\x64\x2e" "\n"
-,webPbContact->del_id);sc_cfg_get(ZPB_NV_WRITE_FLAG,ptFlag,sizeof(ptFlag));if(
-(0xf8+4749-0x1385)==strcmp("\x30",ptFlag)&&-(0x910+4682-0x1b59)!=webPbContact->
-del_id){delRecord.delId[(0xa59+909-0xde6)]=webPbContact->del_id;atWeb_DelOnepb(&
-delRecord,semId);}}VOID atWeb_DelOnepb(T_zPb_DelInfo*delRecord,sem_t semId){CHAR
- errCode[ZSVR_AT_RES_CODE_LEN]={(0x1910+2140-0x216c)};int atRes=
-(0x28f+4506-0x1429);SINT32 delTime=(0x5da+67-0x61d);atPb_GetLocationIndexForDel(
-delRecord,delTime);printf(
-"\x5b\x50\x42\x5d\x20\x64\x65\x6c\x5f\x61\x5f\x70\x62\x6d\x5f\x72\x65\x63\x6f\x72\x64\x2d\x2d\x64\x65\x6c\x20\x69\x6e\x64\x65\x78\x3d\x25\x64\x2c\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64" "\n"
-,delRecord->delIndex[(0x7ec+2655-0x124b)],delRecord->delLocation);if(
-ZPB_LOCATION_AP==delRecord->delLocation){if(ZPB_DB_OK==atPb_DelARecFromPbmTable(
-delRecord,delTime)){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4f\x6e\x65\x70\x62\x2d\x2d\x64\x65\x6c\x20\x41\x50\x20\x73\x75\x63\x63\x65\x73\x73" "\n"
-);return;}slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x64\x65\x6c\x5f\x61\x5f\x70\x62\x6d\x5f\x72\x65\x63\x6f\x72\x64\x3a\x72\x65\x6d\x6f\x76\x65\x20\x72\x65\x63\x20\x66\x72\x6f\x6d\x20\x70\x62\x6d\x20\x74\x61\x62\x6c\x65\x20\x66\x61\x69\x6c\x65\x64" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}else if(ZPB_LOCATION_USIM==
-delRecord->delLocation){CHAR pbMax[(0x5c2+4793-0x1849)]={(0x1ecb+2068-0x26df)};
-sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));if((delRecord->delIndex[
-(0x1d3+475-0x3ae)]>=(0x14f2+3011-0x20b4))&&(delRecord->delIndex[
-(0x1c88+697-0x1f41)]<=atoi(pbMax))){ipc_send_message(MODULE_ID_PB,
-MODULE_ID_AT_CTL,MSG_CMD_DELETE_PB_REQ,sizeof(int),(unsigned char*)&delRecord->
-delIndex[(0x500+899-0x883)],(0x13ea+600-0x1642));sem_wait(&g_Pb_sem_id);if(
-g_PbOptRsp.result!=(0x15a7+3380-0x22da)){sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_DEL_ERROR);}sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x6e\x6f");}if(ZPB_DB_OK==
-atPb_DelARecFromPbmTable(delRecord,delTime)){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_OPERATE_SUC);printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4f\x6e\x65\x70\x62\x2d\x2d\x64\x65\x6c\x20\x53\x49\x4d\x20\x73\x75\x63\x63\x65\x73\x73" "\n"
-);return;}(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}else{slog(PB_PRINT,
-SLOG_DEBUG,
-"\x70\x62\x3a\x64\x65\x6c\x5f\x61\x5f\x70\x62\x6d\x5f\x72\x65\x63\x6f\x72\x64\x3a\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x69\x73\x20\x4e\x55\x4c\x4c" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_LOCATION_IS_NULL);}}VOID
-atWeb_DelMultPb(T_zPb_DelInfo*delRecord,sem_t semId){CHAR errCode[
-ZSVR_AT_RES_CODE_LEN]={(0x176d+1338-0x1ca7)};int atRes=(0xa4c+5551-0x1ffb);
-SINT32 delCount=(0x1a5d+1347-0x1fa0);(VOID)sc_cfg_set(NV_PHO_DEL,"");memset(&
-g_zPb_DelStatusUsim,(0x1409+3362-0x212b),sizeof(T_zPb_DelStatusMultiOrAll));
-g_zPb_DelStatusUsim.dealFlag=ZPB_DEL_MULTI_RECORD_USIM;for(;delCount<delRecord->
-delTotal;delCount++){slog(PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x33\x3a\x64\x65\x6c\x49\x64\x5b\x25\x64\x5d\x3d\x25\x64\x2c\x64\x65\x6c\x5f\x70\x62\x6d\x5f\x69\x6e\x64\x65\x78\x5b\x25\x64\x5d\x3d\x25\x64" "\n"
-,delCount,delRecord->delId[delCount],delCount,delRecord->delIndex[delCount]);
-atPb_GetLocationIndexForDel(delRecord,delCount);if(ZPB_LOCATION_AP==delRecord->
-delLocation){if(ZPB_DB_OK!=atPb_DelARecFromPbmTable(delRecord,delCount)){slog(
-PB_PRINT,SLOG_DEBUG,
-"\x70\x62\x3a\x70\x62\x6d\x3a\x72\x65\x6d\x6f\x76\x65\x20\x74\x68\x65\x20\x69\x28\x25\x64\x29\x20\x72\x65\x63\x20\x66\x72\x6f\x6d\x20\x70\x62\x6d\x20\x74\x61\x62\x6c\x65\x20\x66\x61\x69\x6c\x65\x64" "\n"
-,delCount);g_zPb_DelStatusUsim.dealFailNum++;continue;}g_zPb_DelStatusUsim.
-dealSuccNum++;}else if(ZPB_LOCATION_USIM==delRecord->delLocation){CHAR pbMax[
-(0x740+6194-0x1f40)]={(0x12ec+2982-0x1e92)};sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax
-,sizeof(pbMax));if((delRecord->delIndex[delCount]>=(0x69+8538-0x21c2))&&(
-delRecord->delIndex[delCount]<=atoi(pbMax))){printf(
-"\x70\x62\x39\x3a\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x4d\x75\x6c\x74\x50\x62\x3a\x72\x65\x6d\x6f\x76\x65\x20\x74\x68\x65\x20\x69\x6e\x64\x65\x78\x28\x25\x64\x29\x20\x72\x65\x63\x20\x66\x72\x6f\x6d\x20\x70\x62\x6d\x20\x74\x61\x62\x6c\x65" "\n"
-,delRecord->delIndex[delCount]);ipc_send_message(MODULE_ID_PB,MODULE_ID_AT_CTL,
-MSG_CMD_DELETE_PB_REQ,sizeof(int),(unsigned char*)&delRecord->delIndex[delCount]
-,(0x88a+675-0xb2d));sem_wait(&g_Pb_sem_id);if(g_PbOptRsp.result!=
-(0x97f+1491-0xf51)){g_zPb_DelStatusUsim.dealFailNum++;sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}else{g_zPb_DelStatusUsim.dealSuccNum++;
-sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x6e\x6f");}}else{continue;}(VOID)
-atPb_DelSimRecFromPbTable(delRecord->delIndex[delCount]);}else{slog(PB_PRINT,
-SLOG_DEBUG,
-"\x70\x62\x3a\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x69\x73\x20\x4e\x55\x4c\x4c" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_LOCATION_IS_NULL);}}
-atPb_SetDelStatusMultOrAll();}T_zPb_DbResult atPb_DelRecByGroup(VOID){
-T_zPb_DbResult result=ZPB_DB_OK;T_zPb_ApIndex index={(0xab2+3638-0x18e8)};SINT32
- i=(0xfef+1393-0x155f);result=atPb_DelRecFromPbmTableByGroup(&index);if(
-ZPB_DB_OK!=result){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);return
-result;}(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);for(i=
-(0xd12+5648-0x2321);i<=ZPB_AP_MAX_RECORD;i++){if((0x174a+2766-0x2218)!=index.
-apIndex[i]){g_zPb_ApIndex[(index.apIndex[i])]=PBM_ERROR_NOT_FOUND;}}return
-result;}VOID atPb_DelAllRecsSimDb(VOID){CHAR sql[ZPB_MAX_BYTES_DB]={
-(0x4dd+5671-0x1b04)};snprintf(sql,sizeof(sql)-(0x4d9+1248-0x9b8),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);if(ZPB_DB_OK==atPb_ExecDbSql(sql,NULL,NULL)
-){atPb_ClearSimPbmIndexArray();if(ZPB_DB_OK!=atPb_ExecDbSql(
-ZTE_DROP_PBM_SIM_CAPABILITY_SQL,NULL,NULL)){printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x50\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x52\x65\x63\x73\x53\x69\x6d\x44\x62\x20\x65\x78\x65\x63\x44\x62\x20\x32\x32\x32\x32\x20\x66\x61\x69\x6c" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);return;}(VOID)sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_DEL_ERROR);}}VOID atPb_DelAllRecsSim(T_zPb_DelInfo*pdelRecord,sem_t semId){
-CHAR errCode[ZSVR_AT_RES_CODE_LEN]={(0x50a+2178-0xd8c)};int atRes=
-(0x719+849-0xa6a);UINT32 i=(0x91d+5291-0x1dc8);CHAR sql[ZPB_MAX_BYTES_DB]={
-(0x1ea1+126-0x1f1f)};UINT32 count=(0xe98+2267-0x1773);if(pdelRecord!=NULL){
-memset(&g_zPb_DelStatusUsim,(0xbbd+4097-0x1bbe),sizeof(T_zPb_DelStatusMultiOrAll
-));g_zPb_DelStatusUsim.dealFlag=ZPB_DEL_ALL_RECORD_USIM;snprintf(sql,sizeof(sql)
--(0xeb4+264-0xfbb),
-"\x73\x65\x6c\x65\x63\x74\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);(VOID)atPb_ExecDbSql(sql,
-atPb_DbCountTableLineCb,&count);if((0x1ca0+359-0x1e07)<count){CHAR pbMin[
-(0x23f+3520-0xfcd)]={(0xf45+3938-0x1ea7)};CHAR pbMax[(0x63b+366-0x777)]={
-(0x8bd+7078-0x2463)};UINT32 i_pbMin=(0x2bc+2170-0xb36);UINT32 i_pbMax=
-(0xe3c+3960-0x1db4);sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
-sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));i_pbMin=atoi(pbMin);i_pbMax=
-atoi(pbMax);if(i_pbMin>ZPB_SIM_MAX_RECORD||i_pbMax>ZPB_SIM_MAX_RECORD){printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x50\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x52\x65\x63\x73\x53\x69\x6d\x20\x73\x69\x6d\x20\x69\x6e\x64\x65\x78\x20\x74\x6f\x6f\x20\x6c\x61\x72\x67\x65" "\n"
-);return;}for(i=i_pbMin;i<=i_pbMax;i++){ipc_send_message(MODULE_ID_PB,
-MODULE_ID_AT_CTL,MSG_CMD_DELETE_PB_REQ,sizeof(int),(unsigned char*)&i,
-(0x15e2+3771-0x249d));sem_wait(&g_Pb_sem_id);if(g_PbOptRsp.result!=
-(0x503+7292-0x217e)){g_zPb_DelStatusUsim.dealFailNum++;sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}else{g_zPb_DelStatusUsim.dealSuccNum++;
-sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x6e\x6f");}}snprintf(sql,sizeof(sql)-
-(0x1055+3126-0x1c8a),
-"\x64\x65\x6c\x65\x74\x65\x20\x66\x72\x6f\x6d\x20\x25\x73\x20\x77\x68\x65\x72\x65\x20\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64"
-,ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);if(ZPB_DB_OK==atPb_ExecDbSql(sql,NULL,NULL)
-){(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);atPb_ClearSimPbmIndexArray
-();}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);}
-atPb_SetDelStatusMultOrAll();(VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL,"\x6e\x6f");
-}}}VOID atWeb_DelAllpb(T_zPb_DelInfo*delRecord,sem_t semId){printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x70\x62\x20\x64\x65\x6c\x4c\x6f\x63\x61\x74\x69\x6f\x6e\x3d\x25\x64" "\n"
-,delRecord->delLocation);if(ZPB_LOCATION_AP==delRecord->delLocation){if(
-ZPB_DB_OK==atPb_DelAllRecsFromPbmTable(delRecord)){(VOID)sc_cfg_set(
-ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);}else{(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,
-ZPB_DEL_ERROR);}}else if(ZPB_LOCATION_USIM==delRecord->delLocation){
-atPb_DelAllRecsSim(delRecord,semId);}else if(ZPB_LOCATION_ALL==delRecord->
-delLocation){delRecord->delLocation=ZPB_LOCATION_AP;(VOID)
-atPb_DelAllRecsFromPbmTable(delRecord);delRecord->delLocation=ZPB_LOCATION_USIM;
-atPb_DelAllRecsSim(delRecord,semId);}else if(ZPB_LOCATION_GROUP==delRecord->
-delLocation){(VOID)atPb_DelRecByGroup();}else{printf(
-"\x5b\x50\x42\x5d\x20\x61\x74\x57\x65\x62\x5f\x44\x65\x6c\x41\x6c\x6c\x70\x62\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x69\x73\x20\x4e\x55\x4c\x4c" "\n"
-);(VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_LOCATION_IS_NULL);return;}}
+VOID atPb_RecvScpbwModifyErr(UINT8 *pErrCode)
+{
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ printf("pb:Recv At Scpbw modify err.\n");
+}
+
+
+/*****************************************************************************
+* º¯ÊýÃû³Æ£ºweb_AsctoHex
+* ¹¦ÄÜ˵Ã÷£ºÕâ¸öº¯ÊýÓÃÓÚ½«×Ö½Úת»»³É°ë×Ö½Ú¡£ÀýÈ罫"8090ed"ת»»³É
+ 0x8090ed;½«"a4"ת»»³É0xa4
+* ÊäÈë²ÎÊý£ºpcASC£º Ä¿±ê×Ö·û´®µÄ´æ·Å»º³å£»
+ iDstLen£º Ä¿±ê»º³åµÄ³¤¶È£»
+ pcHex£º Ô´×Ö·û´®»º³å£»
+ iSrcLen£º Ô´×Ö·û´®³¤¶È±¶¡£
+* Êä³ö²ÎÊý£ºÎÞ
+* ·µ»ØÖµ£º ÎÞ
+****************************************************************************/
+VOID pb_AsctoHex(UINT16 *pcHex, SINT32 iDstLen, UINT8 const *pcASC,SINT32 iSrcLen)
+{
+ UINT32 iOddOrEven = 0;// 1±íʾOdd,0±íʾEven;
+ UINT8 iTemp = 0;
+ SINT32 i = 0;
+
+ if((NULL == pcHex )
+ ||(NULL == pcASC)
+ ||(0 == iDstLen)
+ ||(iDstLen < (iSrcLen/2 +1)))
+ {
+ return;
+ }
+
+ for(i=0; i<iSrcLen; i++)
+ {
+ if(iOddOrEven%2 == 0)
+ {
+ iTemp = *(pcASC + i);
+ if((iTemp >='0')&& (iTemp <='9'))
+ {
+ *(pcHex + i/2) |= (UINT8)(iTemp -48) << 4;
+ }
+ else
+ {
+ *(pcHex + i/2) |= (UINT8)(iTemp -55) << 4;
+ }
+ }
+ else
+ {
+ iTemp = *(pcASC + i);
+ if((iTemp >='0')&& (iTemp <='9'))
+ {
+ *(pcHex + i/2) |= iTemp -48;
+ }
+ else
+ {
+ *(pcHex + i/2) |= iTemp -55;
+ }
+ }
+ iOddOrEven++;
+ }
+}
+
+/**********************************************************************
+* º¯ÊýÃû³Æ£º IfaUcs2IsSMS7
+* ¹¦ÄÜÃèÊö£º Õâ¸öº¯ÊýÓÃÓÚÅжÏUcs2Âë×Ö·û´®ÊÇ·ñ°üº¬ÔÚGsm·ûºÅ±íÖÐ
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º ÎÞ
+* ÊäÈë²ÎÊý£º psUcs2£º ÊäÈëµÄUCS2±àÂë´®£»
+ iLength£º ÊäÈëµÄUCS2×Ö·û´®³¤¶È£¨¿í×Ö·û£©
+* Êä³ö²ÎÊý£º ÎÞ
+* ·µ »Ø Öµ£º ÕûÐÍ 0£ºÃ»Óаüº¬ÔÚ·ûºÅ±íÖУ»1£º°üº¬ÔÚ·ûºÅ±íÖÐ
+* ÆäËü˵Ã÷£º ÎÞ
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------------------------------
+* 2005/06/30 v1.0 yusong ´´½¨
+***********************************************************************/
+SINT32 atPb_IfUcs2IsSMS7(UINT16 *psUcs2, SINT32 iLength)
+{
+ int iRetVal = 1;
+ char cTemp;
+ int i = 0;
+
+ if(NULL == psUcs2 )
+ {
+ return -1;
+ }
+ for(i = 0; i<iLength; i++)
+ {
+ // СÓÚµÈÓÚ0x00ffµÄUCS2ÂëµÄ´¦Àí
+ if (256 > psUcs2[i])
+ {
+ switch (psUcs2[i])
+ {
+ // ûÓаüº¬ÔÚ×Ô¶¨ÒåµÄUcs2µ½Gsm7ת»»Êý×éÖеÄ×Ö·ûµÄ´¦Àí¡£
+ case 0x0c://12
+ case 0x5b://91
+ case 0x5c://92
+ case 0x5d://93
+ case 0x5e://94
+ case 0x7b://123
+ case 0x7c://124
+ case 0x7d://125
+ case 0x7e://126
+ case 0xa4://164
+ case 0x20://¿Õ¸ñ
+ {
+ break;
+ }
+ // Èç¹ûÔÚ±íÖв鵽µÄ½á¹ûΪZPB_NON_GSM£¬±íÃ÷²»ÊÇGSM7±àÂë
+ default:
+ {
+ cTemp = (char)G_ZPB_NEWUCS2TOGSM[psUcs2[i]];
+ if (ZPB_NON_GSM == cTemp)
+ {
+ iRetVal = 0;
+ }
+ break;
+ }
+ }
+ }
+ // ³¬³öÊý×鷶Χ£¬µ«Óм¸¸öÌØÊâÖµÈÔÊÇGSM7±àÂë
+ else
+ {
+ switch (psUcs2[i])
+ {
+ case 0x0394:
+ case 0x03a6:
+ case 0x0393:
+ case 0x039b:
+ case 0x03a9:
+ case 0x03a0:
+ case 0x03c8:
+ case 0x03a3:
+ case 0x03b8:
+ case 0x039e:
+ {
+ break;
+ }
+ default:
+ {
+ iRetVal = 0;
+ break;
+ }
+ }
+ }
+ if (0 == iRetVal)
+ {
+ break;
+ }
+ }
+ return iRetVal;
+}
+static UINT8 atPb_EncodeNameToUcs2(char *pbDst, UINT32 iDstLen, char const *pbSrc)
+{
+ UINT16 acHex[256] = {0};
+ SINT32 srclen = 0;
+ SINT32 rest = 0;
+ assert(pbDst!= NULL && pbSrc != NULL);
+
+ srclen = (SINT32)strlen(pbSrc);
+ slog(PB_PRINT,SLOG_DEBUG,"pb:atPb_EncodeNameToUcs2 input psSrc=%s,iSrcLen=%d\n", pbSrc, srclen);
+ pb_AsctoHex(acHex, 256, (UINT8 *)pbSrc, srclen);
+
+ rest = atPb_IfUcs2IsSMS7(acHex, srclen/4);
+ if(rest == 1)
+ {
+ return atPb_EncodeText(pbDst, pbSrc, iDstLen);
+ }
+ else if(rest == 0)
+ {
+ if(strlen(pbSrc) + 2 < iDstLen)
+ {
+ memcpy(pbDst, "80", 2);
+ memcpy(pbDst + 2, pbSrc, srclen);
+ return ZUFI_SUCC;
+ }
+ }
+ return ZUFI_FAIL;
+}
+
+
+SINT32 atPb_FindIdleIndex(T_zPb_WebContact const *pbRecv, BOOL pbNewFlag)
+{
+ SINT32 count = 1;
+ SINT32 total = 0;
+ SINT32 *IndexType = NULL;
+
+ if ((NULL == pbRecv))
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:find_pbm_index:the para of find_pbm_index are NULL\n");
+ return -1;
+ }
+
+ if (TRUE == pbNewFlag) //new a pbm record
+ {
+ if(ZPB_LOCATION_USIM == pbRecv->pbLocation)
+ {
+ total = g_zPb_SimIndex[0];
+ IndexType = g_zPb_SimIndex;
+ }
+ else if(ZPB_LOCATION_AP== pbRecv->pbLocation)
+ {
+ total = g_zPb_ApIndex[0];
+ IndexType = g_zPb_ApIndex;
+ }
+
+ for(; count<=total; count++)
+ {
+ if ((NULL != IndexType) && (IndexType[count] == PBM_ERROR_NOT_FOUND))
+ {
+ break;
+ }
+ }
+ if (count > total)
+ {
+ slog(PB_PRINT,SLOG_ERR,"pb:find_pbm_index:can not find index_id,index_id=%d\n.",count);
+ return -1;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:find_pbm_index: index_id=%d, total is %d\n", count, total);
+ return count;
+ }
+ else
+ {
+ /*modify a pbm record*/
+ return pbRecv->pbIndex;
+ }
+}
+
+BOOL atPb_GetASCII(CHAR *pSrc, CHAR *pDst, SINT32 len)
+{
+ SINT32 j = 0;
+ SINT32 i = 0;
+ CHAR buf[ZPB_TEXT_SIZE_BYTES] = {0};
+ CHAR str[3] = {0};
+ SINT32 length = 0;
+
+ length = atPb_String2Bytes(pSrc, buf, len);
+
+ for(i = 0; i < length; i+=2)
+ {
+ if (buf[i] != 0 || buf[i+1] > 127)
+ {
+ return FALSE;
+ }
+ pDst[j++] = buf[i+1];
+ }
+ return TRUE;
+}
+
+VOID atWeb_AddOrModOnePbUsim(T_zPb_WebContact *pWebPbContact, BOOL pbNewFlag, sem_t semId)
+{
+ //CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+ CHAR pbName[ZPB_TEXT_SIZE_BYTES+3] = {0};
+ CHAR buf_src[ZPB_TEXT_SIZE_BYTES+3] = {0};
+ CHAR buf_dest[ZPB_TEXT_SIZE_BYTES+3] = {0};
+ T_zPb_ScpbwParam scpbwParam = {0};
+ int len = 0;
+
+ atPb_WebRecodeShow(pWebPbContact);
+
+ //ÏÈ·¢ATÃüÁî
+ if(atPb_GetASCII(pWebPbContact->name, pbName,strlen(pWebPbContact->name)))
+ {
+ scpbwParam.coding = 0;
+ }
+ else
+ {
+ len = atPb_String2Bytes(pWebPbContact->name,buf_src,strlen(pWebPbContact->name));
+ len = atpb_CvtUcs2ToAlphaField(buf_src,len, buf_dest);
+ atPb_Bytes2String(buf_dest,pbName, len);
+
+ //sprintf((CHAR *)&pbName[0], "%02X", ZPB_UCS2_PREFIX);
+ //strncat(pbName,pWebPbContact->name,ZPB_TEXT_SIZE_BYTES);
+ scpbwParam.coding = 1;
+ }
+ /*web·¢ÏÂÀ´µÄÊý¾ÝÖÐÖ»ÓÐÈý¸öºÅÂ룬ûÓд«ÕæºÅÂë*/
+ scpbwParam.pbIndex = pWebPbContact->pbIndex;
+ strncpy(scpbwParam.name,pbName,sizeof(scpbwParam.name)-1);
+ strncpy(scpbwParam.mobilNumber,pWebPbContact->mobilNumber, sizeof(scpbwParam.mobilNumber)-1);
+ strncpy(scpbwParam.officeNumber,pWebPbContact->officeNumber, sizeof(scpbwParam.officeNumber)-1);
+ strncpy(scpbwParam.homeNumber,pWebPbContact->homeNumber,sizeof(scpbwParam.homeNumber)-1);
+ strncpy(scpbwParam.email,pWebPbContact->email,sizeof(scpbwParam.email)-1);
+
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_ADD_MODIFY_PB_REQ, sizeof(T_zPb_ScpbwParam), (unsigned char *)&scpbwParam, 0);
+ sem_wait(&g_Pb_sem_id);
+ if(g_PbOptRsp.result != 1)
+ {
+ /*Ìí¼Óµç»°±¾*/
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ if(TRUE == pbNewFlag)
+ {
+ //atPb_RecvScpbwAddErr(errCode);
+ printf("pb:add Scpbw error.\n");
+ }
+ /*Ð޸ĵ绰±¾*/
+ else
+ {
+ //atPb_RecvScpbwModifyErr(errCode);
+ printf("pb:modify Scpbw error.\n");
+ }
+ return;
+ }
+
+ printf("pb:Send Scpbw ok.\n");
+ //g_zPb_pbIndex = 0;
+ if(ZPB_DB_OK == atPb_WriteContactToPbmTable(pWebPbContact, pbNewFlag))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ printf("pb:WriteContactToPbmTable ok.\n");
+ //g_zPb_pbIndex = pWebPbContact->pbIndex;
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ printf("pb:WriteContactToPbmTable error.\n");
+ }
+}
+
+VOID atWeb_AddOnePb(T_zPb_WebContact* webPbContact, sem_t semId)
+{
+ SINT32 idleIndex = 1;
+ T_zPb_Header pbHeader = {0};
+ BOOL pbNewFlag = FALSE;
+ T_zPb_DelInfo delRecord = {0};
+ CHAR ptFlag[20]={0};
+
+ printf("[PB] atWeb_AddOnePb, pbId=%d!\n",webPbContact->pbId);
+
+ if(-1 == webPbContact->pbId) /*new*/
+ {
+ slog(PB_PRINT,SLOG_DEBUG, "pb:atWeb_AddOnePb new.\n");
+ pbNewFlag = TRUE;
+ idleIndex = atPb_FindIdleIndex(webPbContact, pbNewFlag);
+ printf("[PB] atWeb_AddOnePb idleIndex=%d.\n", idleIndex);
+
+ if(idleIndex!= -1)
+ {
+ webPbContact->pbIndex = idleIndex;
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ printf("[PB] memory is full, can not add recode any more.\n");// (VOID)sc_cfg_set("memory","full");
+ return;
+ }
+ }
+ else /*according to id to select index and location when modify a record*/
+ {
+ printf("[PB] atWeb_AddOnePb modify.\n");
+ pbHeader.pbId = webPbContact->pbId;
+ if(ZPB_DB_OK != atPb_GetIndexLocationById(&pbHeader))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ return;
+ }
+ webPbContact->pbIndex = pbHeader.pbIndex;
+ webPbContact->pbLocation = pbHeader.pbLocation;
+ }
+ printf("[PB] atWeb_AddOnePb:location=%d\n",webPbContact->pbLocation);
+
+ //É豸²â
+ if (ZPB_LOCATION_AP == webPbContact->pbLocation)
+ {
+ if(ZPB_DB_OK != atPb_WriteContactToPbmTable(webPbContact, pbNewFlag))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_NEW_ERROR);
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ }
+ //¿¨²â
+ else if (ZPB_LOCATION_USIM == webPbContact->pbLocation)
+ {
+ atWeb_AddOrModOnePbUsim(webPbContact, pbNewFlag, semId);
+ }
+ //ÆäËü
+ else
+ {
+ printf("[PB] write_pbm_record:location is NULL\n");
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
+ }
+ printf("[PB] atWeb_AddOnePb del_id=%d.\n",webPbContact->del_id);
+
+ //³É¹¦²Åɾ³ý
+ sc_cfg_get(ZPB_NV_WRITE_FLAG,ptFlag,sizeof(ptFlag));
+ if(0 == strcmp("0",ptFlag) && -1 != webPbContact->del_id)
+ {
+ delRecord.delId[0] = webPbContact->del_id;
+ atWeb_DelOnepb(&delRecord, semId);
+ }
+}
+
+
+VOID atWeb_DelOnepb(T_zPb_DelInfo *delRecord, sem_t semId)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+ SINT32 delTime = 0;
+
+ /*¸ù¾ÝҪɾ³ýpb¼Ç¼µÄID»ñµÃλÖúÍË÷ÒýÖµ*/
+ atPb_GetLocationIndexForDel(delRecord, delTime);
+ printf("[PB] del_a_pbm_record--del index=%d,location=%d\n",delRecord->delIndex[0],delRecord->delLocation);
+
+ if (ZPB_LOCATION_AP == delRecord->delLocation)
+ {
+ if(ZPB_DB_OK == atPb_DelARecFromPbmTable(delRecord, delTime))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ printf("[PB] atWeb_DelOnepb--del AP success\n");
+ return;
+ }
+ slog(PB_PRINT,SLOG_DEBUG,"pb:del_a_pbm_record:remove rec from pbm table failed\n");/*lint !e26*/
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ }
+ else if (ZPB_LOCATION_USIM == delRecord->delLocation)
+ {
+ CHAR pbMax[50]={0};
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+ if((delRecord->delIndex[0]>=1)&&(delRecord->delIndex[0]<=atoi(pbMax)))/*×î´óÖµ*/
+ {
+ //g_zAt_AtActTab[ZAT_SCPBW_DEL_CMD].atBase_AtSendReq((PSTR)&delRecord->delIndex[0]);
+ //atRes = atPb_SendScpbwDelReq((PSTR)&delRecord->delIndex[0],cid,errCode,ZSVR_AT_RES_CODE_LEN);
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&delRecord->delIndex[0], 0);
+ sem_wait(&g_Pb_sem_id);
+ if(g_PbOptRsp.result != 1)
+ {
+ sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
+ }
+ sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
+ }
+
+ if(ZPB_DB_OK == atPb_DelARecFromPbmTable(delRecord,delTime))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_OPERATE_SUC);
+ printf("[PB] atWeb_DelOnepb--del SIM success\n");
+ return;
+ }
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
+ }
+ else
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:del_a_pbm_record:location is NULL\n");
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
+ }
+}
+
+VOID atWeb_DelMultPb(T_zPb_DelInfo *delRecord, sem_t semId)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+ SINT32 delCount = 0;
+
+ (VOID)sc_cfg_set(NV_PHO_DEL,"");
+ memset(&g_zPb_DelStatusUsim,0,sizeof(T_zPb_DelStatusMultiOrAll));
+ g_zPb_DelStatusUsim.dealFlag = ZPB_DEL_MULTI_RECORD_USIM;
+ for(; delCount < delRecord->delTotal; delCount++)
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb3:delId[%d]=%d,del_pbm_index[%d]=%d\n",delCount,delRecord->delId[delCount],delCount, delRecord->delIndex[delCount] );
+ atPb_GetLocationIndexForDel(delRecord,delCount);
+ if (ZPB_LOCATION_AP == delRecord->delLocation)
+ {
+ if(ZPB_DB_OK != atPb_DelARecFromPbmTable(delRecord, delCount))
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:pbm:remove the i(%d) rec from pbm table failed\n", delCount);
+ g_zPb_DelStatusUsim.dealFailNum++;
+ continue;
+ }
+ g_zPb_DelStatusUsim.dealSuccNum++;
+ }
+ else if (ZPB_LOCATION_USIM == delRecord->delLocation)
+ {
+ CHAR pbMax[50]={0};
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+ if((delRecord->delIndex[delCount]>=1)&&(delRecord->delIndex[delCount]<= atoi(pbMax)))/*×î´óÖµ*/
+ {
+ printf("pb9:atWeb_DelMultPb:remove the index(%d) rec from pbm table\n", delRecord->delIndex[delCount]);
+ //atBase_SendMsgToSelf(ZAT_SCPBW_DEL_CMD,(PSTR)&delRecord->delIndex[delCount],10);//strlen(delRecord->delIndex[delCount]));
+ //atRes = atPb_SendScpbwDelReq((PSTR)&delRecord->delIndex[delCount],cid,errCode,ZSVR_AT_RES_CODE_LEN);
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&delRecord->delIndex[delCount], 0);
+ sem_wait(&g_Pb_sem_id);
+ if(g_PbOptRsp.result != 1)
+ {
+ g_zPb_DelStatusUsim.dealFailNum++;
+ sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
+ }
+ else
+ {
+ g_zPb_DelStatusUsim.dealSuccNum++;
+ sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
+ }
+ }
+ else
+ {
+ continue;
+ }
+ (VOID)atPb_DelSimRecFromPbTable(delRecord->delIndex[delCount]);
+ }
+ else
+ {
+ slog(PB_PRINT,SLOG_DEBUG,"pb:location is NULL\n");
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
+ }
+ }
+ /*ɾ³ýÍê±ÏºóÉèÖÃNV*/
+ atPb_SetDelStatusMultOrAll();
+}
+
+T_zPb_DbResult atPb_DelRecByGroup(VOID)
+{
+ T_zPb_DbResult result = ZPB_DB_OK;
+ T_zPb_ApIndex index = {0};
+ SINT32 i = 1;
+
+ result = atPb_DelRecFromPbmTableByGroup(&index);
+ //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
+ if(ZPB_DB_OK != result)
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ return result;
+ }
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+
+ for(i=1; i<=ZPB_AP_MAX_RECORD; i++)
+ {
+ if(0 != index.apIndex[i])
+ {
+ g_zPb_ApIndex[(index.apIndex[i])] = PBM_ERROR_NOT_FOUND;
+ }
+ }
+ return result;
+}
+VOID atPb_DelAllRecsSimDb(VOID)
+{
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM);
+ if(ZPB_DB_OK == atPb_ExecDbSql(sql,NULL,NULL))
+ {
+ atPb_ClearSimPbmIndexArray();
+
+ if(ZPB_DB_OK != atPb_ExecDbSql(ZTE_DROP_PBM_SIM_CAPABILITY_SQL,NULL,NULL))
+ {
+ printf("[PB] atPb_DelAllRecsSimDb execDb 2222 fail\n");
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ return;
+ }
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ }
+}
+VOID atPb_DelAllRecsSim(T_zPb_DelInfo *pdelRecord, sem_t semId)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+ UINT32 i = 0;
+
+ CHAR sql[ZPB_MAX_BYTES_DB] = {0};
+ UINT32 count = 0;
+
+ if (pdelRecord != NULL)
+ {
+ memset(&g_zPb_DelStatusUsim,0,sizeof(T_zPb_DelStatusMultiOrAll));
+ g_zPb_DelStatusUsim.dealFlag = ZPB_DEL_ALL_RECORD_USIM;
+ snprintf(sql,sizeof(sql)-1,"select count(*) from %s where Location=%d",ZPB_DB_PBM_TABLE,ZPB_LOCATION_USIM);
+ (VOID)atPb_ExecDbSql(sql,atPb_DbCountTableLineCb,&count);
+ if(0 < count)
+ {
+ CHAR pbMin[50]={0};
+ CHAR pbMax[50]={0};
+ UINT32 i_pbMin = 0;
+ UINT32 i_pbMax = 0;
+ sc_cfg_get(ZPB_NV_USIMINDEXMIN,pbMin,sizeof(pbMin));
+ sc_cfg_get(ZPB_NV_USIMINDEXMAX,pbMax,sizeof(pbMax));
+ //klocwork
+ i_pbMin = atoi(pbMin);
+ i_pbMax = atoi(pbMax);
+ if (i_pbMin > ZPB_SIM_MAX_RECORD || i_pbMax > ZPB_SIM_MAX_RECORD) {
+ printf("[PB] atPb_DelAllRecsSim sim index too large\n");
+ return;
+ }
+
+ for(i = i_pbMin; i <= i_pbMax; i++)
+ {
+ //atRes = atPb_SendScpbwDelReq((PSTR)&i,cid,errCode,ZSVR_AT_RES_CODE_LEN);
+ ipc_send_message(MODULE_ID_PB, MODULE_ID_AT_CTL, MSG_CMD_DELETE_PB_REQ, sizeof(int), (unsigned char *)&i, 0);
+ sem_wait(&g_Pb_sem_id);
+ if(g_PbOptRsp.result != 1)
+ {
+ g_zPb_DelStatusUsim.dealFailNum++;
+ sc_cfg_set(ZPB_NV_WRITE_FLAG,ZPB_DEL_ERROR);
+ }
+ else
+ {
+ g_zPb_DelStatusUsim.dealSuccNum++;
+ sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
+ }
+ }
+ /*ɾ³ýÍê±Ï,ɾ³ýÊý¾Ý¿âÀïµÄ¼Ç¼*/
+ snprintf(sql,sizeof(sql)-1,"delete from %s where Location=%d",ZPB_DB_PBM_TABLE, ZPB_LOCATION_USIM);
+ if(ZPB_DB_OK == atPb_ExecDbSql(sql,NULL,NULL))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ atPb_ClearSimPbmIndexArray();
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ }
+ atPb_SetDelStatusMultOrAll(); (VOID)sc_cfg_set(ZPB_NV_USIMMEMORYFULL, "no");
+ }
+ }
+}
+
+VOID atWeb_DelAllpb(T_zPb_DelInfo *delRecord, sem_t semId)
+{
+ printf("[PB] atWeb_DelAllpb delLocation=%d\n",delRecord->delLocation);
+ if (ZPB_LOCATION_AP == delRecord->delLocation)
+ {
+ if(ZPB_DB_OK == atPb_DelAllRecsFromPbmTable(delRecord))
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_OPERATE_SUC);
+ }
+ else
+ {
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_DEL_ERROR);
+ }
+ //(VOID)system("adb push /etc_rw/config/pbm.db /usr/zte/zte_conf/config");
+ }
+ else if (ZPB_LOCATION_USIM == delRecord->delLocation)
+ {
+ atPb_DelAllRecsSim(delRecord, semId);
+ }
+ else if(ZPB_LOCATION_ALL == delRecord->delLocation)
+ {
+ delRecord->delLocation = ZPB_LOCATION_AP;
+ (VOID)atPb_DelAllRecsFromPbmTable(delRecord);
+ delRecord->delLocation = ZPB_LOCATION_USIM;
+ atPb_DelAllRecsSim(delRecord, semId);
+ }
+ else if(ZPB_LOCATION_GROUP == delRecord->delLocation)
+ {
+ (VOID)atPb_DelRecByGroup();
+ }
+ else
+ {
+ printf("[PB] atWeb_DelAllpb location is NULL\n");
+ (VOID)sc_cfg_set(ZPB_NV_WRITE_FLAG, ZPB_LOCATION_IS_NULL);
+ return;
+ }
+}
+
diff --git a/ap/app/zte_comm/sms/src/sms_code.c b/ap/app/zte_comm/sms/src/sms_code.c
index 9475a71..5d475d6 100755
--- a/ap/app/zte_comm/sms/src/sms_code.c
+++ b/ap/app/zte_comm/sms/src/sms_code.c
@@ -1,2030 +1,6168 @@
-
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2008, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º sms_code.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º SMSÄ£¿é¶Ô¶ÌÐÅÄÚÈݽøÐбà½âÂë
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷ Õߣº zhengyt
+* Íê³ÉÈÕÆÚ£º 2008-12-13
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
#include <time.h>
#include <ctype.h>
#include "os_type_def.h"
#include "sms_code.h"
+
+
+
#ifdef WIN32
#include <wchar.h>
#endif
-#define NON_GSM (0x13ac+798-0x16aa)
+/**************************************************************************
+ * ºê *
+ **************************************************************************/
+#define NON_GSM 0x20
#define NON_GSM_P NON_GSM
-extern T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;static const wms_udh_s_type*
-const_header;char g_zUfiSms_DigAscMap[(0x2ef+7960-0x21f7)]={
-((char)(0x1b71+454-0x1d07)),((char)(0x18fd+622-0x1b3a)),
-((char)(0x30b+4063-0x12b8)),((char)(0x163b+1532-0x1c04)),
-((char)(0xca4+4042-0x1c3a)),((char)(0x52+6832-0x1acd)),((char)(0xc2a+959-0xfb3))
-,((char)(0x159a+1072-0x1993)),((char)(0x486+5732-0x1ab2)),
-((char)(0x57+1072-0x44e)),((char)(0x2073+187-0x20ed)),
-((char)(0x603+5623-0x1bb8)),((char)(0xeac+5100-0x2255)),
-((char)(0x937+524-0xaff)),((char)(0xec6+3693-0x1cee)),
-((char)(0x17bf+2686-0x21f7))};extern SMS_PARAM g_zUfiSms_SendingSms;extern
-UINT16 g_zUfiSms_IsLanguageShift;extern int g_zUfiSms_Language;static int
-SerializeNumbers_sms(const char*pSrc,char*pDst,int nSrcLength);const unsigned
-short g_zUfiSms_AsciiToGsmdefaultTable[]={((char)(0x208+330-0x332)),
-((char)(0x97b+5759-0x1fda)),((char)(0x92+1508-0x656)),
-((char)(0x12c8+829-0x15e5)),((char)(0xb85+3682-0x19c7)),
-((char)(0x63d+2260-0xef1)),((char)(0x11f4+2973-0x1d71)),
-((char)(0xa08+5423-0x1f17)),((char)(0x3b2+8801-0x25f3)),
-((char)(0x184b+302-0x1959)),((char)(0x377+7840-0x21f7)),
-((char)(0x692+6229-0x1ec7)),((char)(0x1dd2+517-0x1fb7)),((char)(0xa29+69-0xa4e))
-,((char)(0x3e8+6618-0x1da2)),((char)(0x6b3+194-0x755)),
-((char)(0xfe4+5193-0x240d)),((char)(0x29+8353-0x20aa)),
-((char)(0x1310+2738-0x1da2)),((char)(0x101d+5026-0x239f)),
-((char)(0x965+6078-0x2103)),((char)(0x1c1d+696-0x1eb5)),
-((char)(0x90d+2640-0x133d)),((char)(0xa77+3076-0x165b)),
-((char)(0x950+5846-0x2006)),((char)(0x84f+235-0x91a)),
-((char)(0x11fb+1534-0x17d9)),((char)(0x710+5978-0x1e4a)),
-((char)(0x1723+1410-0x1c85)),((char)(0x3fa+282-0x4f4)),
-((char)(0x981+6183-0x2188)),((char)(0x79d+7961-0x2696)),
-((char)(0x270+8716-0x245c)),((char)(0x33c+9202-0x270d)),(0x16e1+327-0x1806),
-((char)(0x4d8+2823-0xfbc)),(0x1e08+2174-0x2684),((char)(0x4e9+4549-0x1689)),
-((char)(0x8a2+3101-0x1499)),(0x1186+1292-0x166b),((char)(0x6a+1540-0x646)),
-((char)(0x1328+2235-0x1bba)),((char)(0x129b+3907-0x21b4)),
-((char)(0x45c+5531-0x19cc)),((char)(0x1387+1422-0x18e9)),
-((char)(0x42b+5918-0x1b1c)),((char)(0x1810+3245-0x248f)),
-((char)(0x15d0+2499-0x1f64)),((char)(0xf75+4445-0x20a2)),
-((char)(0xb6c+2548-0x152f)),((char)(0xd71+3992-0x1cd7)),
-((char)(0x734+6961-0x2232)),((char)(0x64f+5557-0x1bd0)),
-((char)(0xd25+5379-0x21f3)),((char)(0xd7d+6106-0x2521)),
-((char)(0x14c2+3573-0x2280)),((char)(0x54b+7352-0x21cb)),
-((char)(0xbac+2372-0x14b7)),((char)(0x1db1+1645-0x23e4)),
-((char)(0x5c1+5177-0x19bf)),((char)(0x19f+5275-0x15fe)),
-((char)(0x282+4258-0x12e7)),((char)(0x1003+2659-0x1a28)),
-((char)(0x1835+2658-0x2258)),(0x91f+2492-0x12db),((char)(0x1153+2224-0x19c2)),
-((char)(0x599+4094-0x1555)),((char)(0x2187+994-0x2526)),
-((char)(0x8c0+6277-0x2101)),((char)(0xa8+1164-0x4ef)),
-((char)(0x664+4411-0x1759)),((char)(0xa77+4832-0x1d10)),
-((char)(0x175a+2081-0x1f33)),((char)(0x1535+3916-0x2438)),
-((char)(0x1244+1982-0x19b8)),((char)(0x3a3+6995-0x1eab)),
-((char)(0xa96+1101-0xe97)),((char)(0x15c2+3472-0x2305)),
-((char)(0x5df+4518-0x1737)),((char)(0x19d6+686-0x1c35)),
-((char)(0x1257+1304-0x171f)),((char)(0x1383+3265-0x1ff3)),
-((char)(0x3bb+7892-0x223d)),((char)(0x1b40+1502-0x20cb)),
-((char)(0x25d+3953-0x117a)),((char)(0xa32+1712-0x108d)),
-((char)(0x879+4091-0x181e)),((char)(0x16bc+197-0x172a)),
-((char)(0x1f13+904-0x2243)),((char)(0xf38+16-0xeef)),((char)(0x6a3+5750-0x1cbf))
-,(0x22e2+6276-0x202a),(0x240b+431-0xa8b),(0x2468+5270-0x1dc0),
-(0x1d38+3544-0xffc),(0x25f+7115-0x1e19),((char)(0x5f9+523-0x7e4)),
-((char)(0xf31+3616-0x1cf0)),((char)(0x414+2593-0xdd3)),
-((char)(0x3c0+7585-0x20fe)),((char)(0x11d4+3207-0x1df7)),
-((char)(0x10dd+5133-0x2485)),((char)(0xbc0+4570-0x1d34)),
-((char)(0x47a+3378-0x1145)),((char)(0xd52+2912-0x184a)),
-((char)(0xf36+1033-0x12d6)),((char)(0x10bf+2990-0x1c03)),
-((char)(0xa11+5856-0x2086)),((char)(0x4c2+5826-0x1b18)),
-((char)(0x574+3159-0x115e)),((char)(0x8ab+1606-0xe83)),
-((char)(0x541+6290-0x1d64)),((char)(0xb3+2091-0x86e)),((char)(0xaf5+857-0xddd)),
-((char)(0x1ef9+988-0x2263)),((char)(0x1860+1143-0x1c64)),
-((char)(0x1082+438-0x11c4)),((char)(0x20d5+381-0x21dd)),
-((char)(0x43b+3990-0x135b)),((char)(0xc3+8491-0x2177)),
-((char)(0x88c+4129-0x1835)),((char)(0x15ac+736-0x1813)),
-((char)(0xaf7+2804-0x1571)),6952,6976,6953,(0x1c40+7120-0x1cd3),
-((char)(0x5a9+3995-0x1524)),((char)(0xbc+7571-0x1e2f)),
-((char)(0x120+8041-0x2069)),((char)(0xf74+4922-0x228e)),
-((char)(0x5c3+4121-0x15bc)),((char)(0xb03+3338-0x17ed)),
-((char)(0x1352+1535-0x1931)),((char)(0x1dea+2273-0x26ab)),
-((char)(0x115+3461-0xe7a)),((char)(0x137f+3449-0x20d8)),
-((char)(0x987+7221-0x259c)),((char)(0x653+2043-0xe2e)),
-((char)(0x564+1898-0xcae)),((char)(0x42f+3425-0x1170)),
-((char)(0x5ed+2942-0x114b)),((char)(0x2249+1092-0x266d)),
-((char)(0x1401+4469-0x2556)),((char)(0x1932+2490-0x22cc)),
-((char)(0x7d8+173-0x865)),((char)(0x10ff+4530-0x2291)),
-((char)(0xdf2+3041-0x19b3)),((char)(0xbe2+3568-0x19b2)),
-((char)(0x68c+1793-0xd6d)),((char)(0x1f4f+221-0x200c)),
-((char)(0x1d55+2153-0x259e)),((char)(0x1e6f+474-0x2029)),
-((char)(0xf0b+1724-0x15a7)),((char)(0xc2c+6874-0x26e6)),
-((char)(0xd35+3106-0x1937)),((char)(0x394+2101-0xba9)),
-((char)(0x1363+979-0x1716)),((char)(0xba+2114-0x8dc)),
-((char)(0x1f08+1676-0x2574)),((char)(0x77b+3506-0x150d)),(0x98a+1111-0xda1),
-((char)(0x2c8+6405-0x1bad)),(0xc25+743-0xf0b),(0xc35+3628-0x1a3d),
-(0x1534+751-0x1820),((char)(0x605+4140-0x1611)),(0x1c91+2098-0x2464),
-((char)(0x12c7+4436-0x23fb)),((char)(0x15c6+4454-0x270c)),
-((char)(0x1068+3026-0x1c1a)),((char)(0x1fa5+403-0x2118)),
-((char)(0x230+266-0x31a)),((char)(0x1454+1542-0x1a3a)),
-((char)(0x683+5651-0x1c76)),((char)(0x1e4c+1795-0x252f)),
-((char)(0x942+4512-0x1ac2)),((char)(0x5b0+2840-0x10a8)),
-((char)(0x9f5+177-0xa86)),((char)(0xd5b+6055-0x24e2)),
-((char)(0xdea+1035-0x11d5)),((char)(0x2c5+7745-0x20e6)),
-((char)(0xf87+2102-0x179d)),((char)(0xd26+3598-0x1b14)),(0x3b9+6022-0x1b34),
-((char)(0x125a+4413-0x2377)),((char)(0x1a30+1369-0x1f69)),
-((char)(0xc85+4579-0x1e48)),((char)(0xa43+4816-0x1cf3)),
-((char)(0x220a+1201-0x269b)),((char)(0x15d6+3910-0x24fc)),(0x6bf+8108-0x260b),
-((char)(0xbd1+5428-0x20e5)),((char)(0xb28+5008-0x1e98)),
-((char)(0x1805+639-0x1a64)),((char)(0xc86+2576-0x1676)),(0x142a+3080-0x1fd7),
-(0x58+1111-0x4a1),(0x669+5387-0x1b58),(0xf6f+3493-0x1d0b),
-((char)(0x2f+4440-0x1167)),(0x708+1188-0xb8d),((char)(0x1a7+7627-0x1f52)),
-((char)(0x1861+1430-0x1dd7)),((char)(0x12a6+4813-0x2553)),
-((char)(0x1b74+2472-0x24fc)),((char)(0xa67+910-0xdd5)),
-((char)(0x3b0+4481-0x1511)),((char)(0x1f36+109-0x1f83)),(0x41c+5203-0x1812),
-((char)(0x613+6825-0x209c)),((char)(0xd7d+4034-0x1d1f)),
-((char)(0x12cd+3453-0x202a)),((char)(0x1f1d+1230-0x23cb)),(0x12a0+4196-0x22a8),
-((char)(0x510+7563-0x227b)),((char)(0x1d88+2365-0x26a5)),
-((char)(0x1ec4+993-0x2285)),((char)(0x1fd6+1465-0x256f)),
-((char)(0xf5b+4245-0x1fd0)),(0x116c+5014-0x24a4),((char)(0xaf5+6460-0x2411)),
-((char)(0x15cd+1126-0x1a13)),(0x85a+1499-0xe17),(0xe97+2791-0x18ff),
-((char)(0x2b0+5988-0x19f4)),((char)(0x1500+2528-0x1ec0)),
-((char)(0x107a+5108-0x244e)),(0x1ed+3469-0xeff),(0x59a+7952-0x249b),
-(0x861+3132-0x1480),((char)(0x263+3559-0x102a)),(0x1494+1807-0x1b9f),
-(0x904+3400-0x1647),((char)(0x1bc5+1230-0x2073)),((char)(0x737+3407-0x1466)),
-(0x13c+3999-0x10d4),((char)(0x459+2676-0xead)),((char)(0x10ad+2196-0x1921)),
-((char)(0x1971+1296-0x1e61)),((char)(0x1408+1372-0x1944)),(0x101+2883-0xbc7),
-(0x450+6099-0x1c1b),((char)(0x110d+662-0x1383)),((char)(0x1ea+8105-0x2173)),
-((char)(0x13d4+1680-0x1a44)),(0x24b+4668-0x140b),((char)(0xbb9+433-0xd4a)),
-(0xa90+5625-0x207d),(0x296+1392-0x800),((char)(0x15a1+2743-0x2038)),
-((char)(0xf2a+1281-0x140b)),(0x519+8318-0x2519),((char)(0x1b8+5247-0x1617)),
-((char)(0x1177+570-0x1391)),((char)(0x11db+2473-0x1b64)),};const unsigned short
-zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[][(0x14b0+2340-0x1dd2)]={{
-(0x233d+43-0x235f),(0xb10+2469-0x13ce)},{(0xbcd+1080-0xffb),(0x6c+7417-0x1d59)},
-{(0x15e9+2733-0x2089),(0x13a2+281-0x14ae)},{(0x105d+197-0x110e),
-(0xe52+1968-0x15a4)},{(0x171d+85-0x174a),(0x78b+7014-0x2276)},{
-(0x8d7+2905-0x1407),(0x5d3+3019-0x1121)},{(0x6ac+8094-0x261b),
-(0x2034+1047-0x23ef)},{(0x5a5+2990-0x1117),(0xb84+6829-0x25d6)},{
-(0x1076+4826-0x2313),(0x65a+127-0x65b)},{(0x1a8d+1360-0x1f9f),
-(0x16bd+3098-0x227a)},{(0x13fd+746-0x16a7),(0x399+6183-0x1b44)},{
-(0x13d8+4108-0x23a3),(0x127a+1041-0x15ca)},{(0x12d4+778-0x1595),
-(0xe42+5768-0x23fd)},{(0xc91+6144-0x2442),(0x527+1500-0xa30)},{
-(0xa72+5105-0x1e0e),(0x12fc+4210-0x2294)},{(0x196a+180-0x19bd),
-(0x2194+27-0x20ce)},{(0x853+7293-0x246b),(0x22c7+5012-0x15af)},{
-(0xee0+5004-0x2203),(0x1387+3175-0x1f01)},{(0x1095+3340-0x1d32),
-(0x1c0+7304-0x1d55)},{(0x1170+4045-0x20c8),(0x8b1+2981-0x135c)},};const unsigned
- short Ucs2_To_Gsm7_SPANISH_Table_UCS[][(0x797+2377-0x10de)]={{(0xcf2+85-0xd37),
-(0x1ae7+130-0x17d5)},{(0x542+2827-0x103b),(0x15fa+2665-0x1cbd)},{
-(0x1367+2313-0x1c5d),(0x61d+5618-0x187c)},{(0xee2+2579-0x18e1),
-(0x7ec+3877-0x1376)},{(0x118a+1347-0x16b8),(0x1a73+592-0x191a)},{
-(0x2c+7093-0x1bcb),(0xacf+2900-0x1283)},{(0x38d+743-0x65d),(0x1dff+2796-0x2543)}
-,{(0x4cc+4728-0x172c),(0x74f+1610-0x9f6)},{(0x200+5709-0x1834),
-(0x57c+8308-0x2258)},{(0x4e9+7367-0x2196),(0x20f0+1891-0x24b5)},};const unsigned
- char Ucs2_To_Gsm7_SPANISH_Table_ASC[]={NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x13ff+868-0x1759),NON_GSM,NON_GSM,
-(0x4ff+4417-0x1633),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,(0x26d+5720-0x18a5),(0x832+3306-0x14fb),(0xbd8+3873-0x1ad7),
-(0x19ff+2669-0x2449),(0x678+3286-0x134c),(0x3ac+1975-0xb3e),(0xfcb+5509-0x252a),
-(0xde2+3041-0x199c),(0x1901+2616-0x2311),(0x516+7085-0x209a),
-(0x18d8+3009-0x246f),(0xf06+2876-0x1a17),(0x1aab+2770-0x2551),(0x257+1391-0x799)
-,(0x36d+2321-0xc50),(0x237+7447-0x1f1f),(0xbf4+3481-0x195d),(0x103+7608-0x1e8a),
-(0x65b+6568-0x1fd1),(0xcd+1943-0x831),(0x983+6726-0x2395),(0x64a+2358-0xf4b),
-(0x11a9+3319-0x1e6a),(0x3c+6396-0x1901),(0x557+4920-0x1857),(0x123f+1009-0x15f7)
-,(0x1467+43-0x1458),(0x4c+2649-0xa6a),(0x1025+861-0x1346),(0x1054+3460-0x1d9b),
-(0x9c0+4349-0x1a7f),(0x186b+1213-0x1ce9),(0xb05+5681-0x2136),(0x1a4+2233-0xa1c),
-(0x39f+6903-0x1e54),(0x172b+2197-0x1f7d),(0x4eb+3446-0x121d),(0x13e7+937-0x174b)
-,(0xc01+2119-0x1402),(0x1b98+1487-0x2120),(0x1ba3+109-0x1bc8),
-(0x811+6055-0x1f6f),(0x7f0+6100-0x1f7a),(0x1f5+1727-0x869),(0x19b0+2905-0x24bd),
-(0x1b76+2207-0x23c8),(0x1892+2791-0x232b),(0x531+8131-0x24a5),(0x114+105-0x12d),
-(0xd3a+2584-0x1701),(0x1bb1+2570-0x2569),(0x7dc+1746-0xe5b),(0xb55+2273-0x13e2),
-(0xdb2+1701-0x1402),(0x7f0+7516-0x24f6),(0x149+335-0x241),(0x10f9+123-0x111c),
-(0x2205+1121-0x260d),(0xe74+1260-0x1306),NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-(0x104+6555-0x1a8e),NON_GSM,(0x5f9+7886-0x2466),(0x233+3328-0xed1),
-(0x1f72+36-0x1f33),(0x42d+1838-0xaf7),(0x100f+1585-0x15db),(0x1952+3494-0x2692),
-(0x1ada+42-0x1a9d),(0x2d8+1990-0xa36),(0x1171+330-0x1252),(0x116b+2406-0x1a67),
-(0xb06+2356-0x13cf),(0x17e9+2059-0x1f88),(0xe66+6098-0x25cb),(0x9f7+850-0xcdb),
-(0xe3c+1403-0x1348),(0xcf2+2944-0x1802),(0x1e25+409-0x1f4d),(0x2ba+3076-0xe4c),
-(0x1d83+883-0x2083),(0xaf9+6864-0x2555),(0x1a68+2046-0x21f1),(0x86c+17-0x807),
-(0x1006+1107-0x13e2),(0x1967+2071-0x2106),(0x1f2+2337-0xa9a),(0x156d+284-0x160f)
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x1448+2786-0x1f0f),
-(0xa1c+2238-0x129a),NON_GSM,(0x5ed+2397-0xf49),(0x120a+107-0x1251),
-(0x162b+3099-0x2243),NON_GSM,(0x80f+6771-0x2223),NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-(0x166+1293-0x613),NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0xecd+4523-0x201d),
-(0x218d+345-0x22d8),(0x12d2+3450-0x2030),(0x88a+5970-0x1fd3),NON_GSM,
-(0xb5a+145-0xbcc),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-(0x177f+65-0x1763),NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x190c+3553-0x2691),NON_GSM,
-(0x19bc+2956-0x253d),NON_GSM,NON_GSM,NON_GSM,(0x8af+4818-0x1b23),NON_GSM,NON_GSM
-,(0x31+2136-0x86b),(0x1776+1650-0x1d69),NON_GSM,NON_GSM,NON_GSM,
-(0x15b4+1554-0x1b4b),(0x9b5+5277-0x1e43),(0x9c2+2107-0x11e0),NON_GSM,
-(0x2166+569-0x239b),(0xa3d+744-0xd20),NON_GSM,NON_GSM,(0x1b3+7737-0x1fe5),
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x288+8299-0x2276),(0x28+7724-0x1e4c),NON_GSM,
-NON_GSM,NON_GSM,(0x8d7+2501-0x1220),NON_GSM,(0x1f8c+1314-0x24a2),
-(0x7e6+2375-0x1127),NON_GSM,NON_GSM,(0x244b+130-0x244f),NON_GSM,NON_GSM,NON_GSM}
-;const unsigned short zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[][
-(0x13db+1223-0x18a0)]={{(0x608+2318-0xf11),(0x1723+2120-0x1e81)},{
-(0x1707+1781-0x1df3),(0x1105+760-0x1316)},{(0x1e9+4376-0x12f7),
-(0x2145+1373-0x2696)},{(0x542+8243-0x256a),(0x818+4095-0x1743)},{
-(0xc35+2594-0x164b),(0x24b+5590-0x172d)},{(0x210f+202-0x21cc),(0x108+5-0x100)},{
-(0xc6+4324-0x119c),(0x639+227-0x65b)},{(0x719+1939-0xe9d),(0x130a+4184-0x2281)},
-{(0x749+6193-0x1f68),(0x110f+2880-0x18a9)},{(0x1033+4322-0x2102),
-(0xa87+1019-0xaef)},{(0x9ea+148-0xa6a),(0x20e6+1488-0x2658)},{
-(0x50f+3197-0x1177),(0xe27+5912-0x2196)},{(0x18f1+1703-0x1f82),
-(0x242b+719-0x235a)},{(0x1744+2663-0x2194),(0xde7+5110-0x1e35)},{
-(0x41d+6453-0x1d3a),(0x1721+914-0x1710)},{(0xa51+7218-0x266a),
-(0x9c9+5431-0x1b68)},{(0x62a+5264-0x1a9b),(0x1cc8+2460-0x259a)},{
-(0x1d9c+2021-0x2559),(0xca3+2981-0x17cd)},{(0x3a8+5478-0x18e5),
-(0x182c+597-0x1a04)},{(0x2452+58-0x245d),(0x2306+567-0x24e1)},{
-(0xed+3962-0x102b),(0x7f0+5413-0x1cba)},{(0x13ad+3061-0x1f65),
-(0x76d+5825-0x1db0)},{(0xbcb+1978-0x1347),(0x2091+620-0x22a0)},{
-(0x6c7+1872-0xdd7),(0x93+5670-0x163d)},{(0x1c9a+552-0x1e81),(0x390+1152-0x750)},
-{(0xd29+6579-0x2693),(0x22c5+333-0x2345)},{(0xec6+4967-0x21de),
-(0x340+1940-0xa01)},{(0x1f71+283-0x2037),(0x2502+161-0x24c9)},{
-(0x8fb+7245-0x24ed),(0x115+2415-0x9c1)},{(0x15f1+2687-0x2014),(0x30a+3067-0xe30)
-},{(0xda9+1244-0x1224),(0x862+710-0xa66)},{(0x1241+1407-0x175b),8364},{
-(0x2200+893-0x2514),(0x14ed+3843-0x2303)},{(0x1ef+6225-0x19d1),
-(0x350+1416-0x7e5)},{(0x6bf+1412-0xbce),(0xf1b+2972-0x19bd)},{
-(0x2ca+6380-0x1b3b),(0x11c5+4224-0x2162)},{(0x1539+515-0x16c0),
-(0x12e4+571-0x142a)},{(0x6e0+5055-0x1a20),(0x763+5763-0x1d04)},};const unsigned
-short Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[][(0x36b+7206-0x1f8f)]={{
-(0x2ff+3678-0x114d),(0x684+4709-0x1555)},{(0x755+4942-0x1a8e),
-(0x25a7+5507-0x1849)},{(0x17af+397-0x1924),8364},{(0x30c+5149-0x16c4),8364},};
-const unsigned char Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[]={NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0xf68+4332-0x204a),
-NON_GSM,NON_GSM,(0x1a3+3932-0x10f2),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,(0x4ec+2544-0xebc),(0x490+4632-0x1687),
-(0x16aa+2336-0x1fa8),(0x2477+428-0x2600),(0x1a8a+2602-0x24b2),
-(0xbdb+5393-0x20c7),(0xce6+5507-0x2243),(0x96a+3848-0x184b),(0x78+8066-0x1fd2),
-(0x2bf+1416-0x81e),(0xcb4+4029-0x1c47),(0xbf1+346-0xd20),(0x7d0+3777-0x1665),
-(0x523+1802-0xc00),(0x42d+7493-0x2144),(0x1dda+598-0x2001),(0xe53+4402-0x1f55),
-(0x11ef+1108-0x1612),(0xd34+6056-0x24aa),(0x165b+3776-0x24e8),
-(0x480+5175-0x1883),(0x7b9+5800-0x1e2c),(0x9b+9424-0x2535),(0x1123+4471-0x2263),
-(0x5c+3401-0xd6d),(0xed5+5285-0x2341),(0x692+5373-0x1b55),(0x22a4+1133-0x26d6),
-(0x12fc+3995-0x225b),(0xf65+1009-0x1319),(0x46+6937-0x1b21),(0x13f9+3572-0x21ae)
-,(0xfed+5880-0x26e5),(0xc70+854-0xf85),(0x17b4+3145-0x23bb),(0xd6b+3018-0x18f2),
-(0x83b+3360-0x1517),(0x6b6+1007-0xa60),(0x1278+2692-0x1cb6),(0xf6b+4863-0x2223),
-(0x8d3+4193-0x18ec),(0x77a+7184-0x2341),(0x72a+4823-0x19b7),(0x858+5494-0x1d83),
-(0x11e9+4030-0x215b),(0x16f+8642-0x22e4),(0x8a4+7091-0x2409),
-(0x149f+3438-0x21be),(0x21b8+171-0x2213),(0x1161+481-0x12f1),(0xd19+416-0xe67),
-(0x1d90+1097-0x2186),(0xc1d+464-0xd99),(0x825+4064-0x17b0),(0x326+3343-0xfdf),
-(0x1c3+3286-0xe42),(0xb96+3270-0x1804),(0xc98+4071-0x1c26),(0x48f+7849-0x22de),
-NON_GSM,(0x150a+1423-0x1a82),NON_GSM,(0x58f+4381-0x1696),(0xe66+1154-0x12d7),
-(0x1f4f+734-0x21b0),(0x77+154-0xb0),(0x1beb+2193-0x241a),(0x108b+5134-0x2436),
-(0xb15+1263-0xfa0),(0xb17+5270-0x1f48),(0x205d+152-0x208f),(0x2b9+5749-0x18c7),
-(0x1392+2404-0x1c8e),(0x1b1b+1486-0x2080),(0x88b+5594-0x1dfb),
-(0x1bb1+2048-0x2346),(0xe25+4097-0x1dba),(0x408+5641-0x19a4),
-(0x181a+1692-0x1e48),(0x354+7775-0x2144),(0x2c8+8662-0x242e),(0x131+2318-0x9ce),
-(0xdc5+3357-0x1a70),(0x8b8+7030-0x23bb),(0x1c72+944-0x1fae),(0xf60+2752-0x19ab),
-(0x695+5415-0x1b46),(0x3b5+7263-0x1f9d),(0x34c+3634-0x1106),(0xef1+328-0xfc0),
-(0x2023+968-0x2371),NON_GSM,(0x666+7705-0x2465),NON_GSM,(0xbf3+5178-0x1fcd),
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,(0x2cf+1689-0x94d),NON_GSM_P,NON_GSM,(0xd74+2839-0x188a)
-,NON_GSM_P,(0x909+6047-0x20a5),NON_GSM,(0xcb2+1732-0x1317),NON_GSM,NON_GSM,
-(0x12cc+3077-0x1ebf),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0xdaf+4079-0x1d7a)
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x50f+6482-0x1e4d),(0x5da+6287-0x1e5b)
-,(0x118b+5438-0x26ad),(0xa4d+1703-0x1099),NON_GSM_P,NON_GSM_P,NON_GSM_P,
-(0xa9d+2032-0x127a),NON_GSM,(0x829+2642-0x125c),(0xeba+4935-0x21e3),NON_GSM,
-NON_GSM,(0xdd1+5686-0x23c7),NON_GSM,NON_GSM,NON_GSM,NON_GSM_P,NON_GSM,
-(0x1756+317-0x187a),(0x1cc6+979-0x208e),(0x255+6304-0x1a99),NON_GSM_P,NON_GSM,
-NON_GSM_P,NON_GSM,(0x9a6+3952-0x18b9),NON_GSM,(0xc3+7854-0x1f13),NON_GSM,NON_GSM
-,NON_GSM_P,(0x1579+905-0x1883),(0x15d4+2456-0x1f5d),(0xb86+6112-0x2349),
-(0x1509+1324-0x19ba),NON_GSM_P,NON_GSM_P,NON_GSM_P,(0x10c+6244-0x1967),NON_GSM_P
-,(0x15d1+2048-0x1dcc),(0xbc4+2818-0x16c2),NON_GSM,NON_GSM_P,(0x190c+764-0x1c01),
-NON_GSM,NON_GSM,NON_GSM,NON_GSM_P,NON_GSM_P,(0x1e3c+454-0x1ffa),
-(0x13f6+1625-0x1a43),(0x541+581-0x70a),NON_GSM_P,NON_GSM,NON_GSM_P,NON_GSM_P,
-(0xc8a+6729-0x26cd),NON_GSM,(0x759+3405-0x1428),NON_GSM,NON_GSM,NON_GSM};const
-unsigned short zte_sms_GSMDefault_To_UCS2_Table_Ex[][(0x578+560-0x7a6)]={{
-(0x1ca+195-0x283),(0xf51+1277-0x1442)},{(0x496+2870-0xfb8),(0x1bb+2927-0xccc)},{
-(0xe66+33-0xe5f),(0x54c+817-0x802)},{(0x17f+2319-0xa65),(0xd06+3112-0x18b1)},{
-(0xd84+6294-0x25eb),(0x765+452-0x8cd)},{(0xf2f+1396-0x1467),(0x140b+4669-0x25ed)
-},{(0xbb1+4663-0x1dab),(0x1268+1511-0x17d1)},{(0x6fa+687-0x96b),
-(0x5b7+1962-0xd04)},{(0x43b+929-0x79c),(0x1dcd+94-0x1daf)},{(0x185c+3320-0x24ef)
-,8364},};const unsigned short UCS2_To_GSMDefault_Table_UCS2[][
-(0x859+7800-0x26cf)]={{(0x645+4249-0x16ce),(0x63c+2285-0xb95)},{
-(0x1616+187-0x16bf),(0x1cef+1332-0x1e7d)},{(0x10a5+3951-0x2001),
-(0x1e7b+363-0x1c53)},{(0x390+1429-0x911),(0xcb9+6605-0x22eb)},{
-(0x48b+4608-0x1676),(0xcb4+3405-0x1658)},{(0x9a9+4599-0x1b8a),
-(0x1de8+2011-0x2223)},{(0x15e3+2530-0x1fae),(0xd60+4686-0x1c06)},{
-(0xd46+2754-0x17f0),(0x261a+1055-0x2696)},{(0x4a2+4288-0x1549),
-(0x61a+2932-0xdf6)},{(0x1636+1236-0x1af0),(0x1348+5579-0x2575)},};const unsigned
- char UCS2_To_GSMDefault_Table_ASC[]={NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x1e2f+2048-0x2625),NON_GSM,NON_GSM,
-(0x36a+5906-0x1a6f),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,(0x638+113-0x689),(0x1b4+3255-0xe4a),(0x5a0+1524-0xb72),
-(0x881+236-0x94a),(0x1924+1201-0x1dd3),(0x656+1966-0xddf),(0x3e4+6583-0x1d75),
-(0x479+3564-0x123e),(0x12ad+4866-0x2587),(0xb45+1676-0x11a8),(0x704+5720-0x1d32)
-,(0x671+2429-0xfc3),(0x84c+4302-0x18ee),(0x572+2163-0xdb8),(0x19ff+2845-0x24ee),
-(0x95f+1673-0xfb9),(0xda+2996-0xc5e),(0x79d+5192-0x1bb4),(0x4c2+2492-0xe4c),
-(0x53a+6288-0x1d97),(0x13f1+567-0x15f4),(0x177b+2928-0x22b6),(0x754+2375-0x1065)
-,(0xd38+5275-0x219c),(0xa98+831-0xd9f),(0xfdb+3286-0x1c78),(0x286+78-0x29a),
-(0x524+4667-0x1724),(0x148c+3053-0x203d),(0x725+2714-0x1182),(0xdc7+6422-0x269f)
-,(0x1c20+2381-0x252e),(0x17cb+352-0x192b),(0x2004+1708-0x266f),
-(0x124+5571-0x16a5),(0xc36+1708-0x129f),(0x1a11+1752-0x20a5),(0x3b8+7659-0x215e)
-,(0xeb8+4075-0x1e5d),(0x1a9+1669-0x7e7),(0xaca+272-0xb92),(0xae7+678-0xd44),
-(0x16d+8033-0x2084),(0x16f6+2953-0x2234),(0x796+3813-0x162f),(0x4cf+5319-0x1949)
-,(0x12e7+1104-0x16e9),(0x720+2087-0xef8),(0x1111+1657-0x173a),
-(0xd78+1915-0x14a2),(0x37d+3539-0x10fe),(0x648+4673-0x1836),(0x105b+3420-0x1d63)
-,(0x98b+3679-0x1795),(0x1f7+4045-0x116e),(0x73+4173-0x1069),(0x1096+1208-0x14f6)
-,(0x8bc+3796-0x1737),(0x1ee2+1498-0x2462),NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-(0x16c+662-0x3f1),NON_GSM,(0x1b4+2886-0xc99),(0x8fa+5537-0x1e39),
-(0x907+6816-0x2344),(0x1255+3875-0x2114),(0x1468+3900-0x233f),(0x237+1806-0x8df)
-,(0x15c8+328-0x16a9),(0x105f+4823-0x22ce),(0x1802+1313-0x1cba),
-(0xc95+4529-0x1ddc),(0x1005+3062-0x1b90),(0x143+9625-0x2670),(0xea7+4149-0x1e6f)
-,(0xd2b+6682-0x26d7),(0x19f+7121-0x1d01),(0x515+1016-0x89d),(0x1461+958-0x17ae),
-(0xe46+397-0xf61),(0x4d1+5618-0x1a50),(0x480+8593-0x259d),(0x1d1+3387-0xe97),
-(0x1896+1774-0x1f0e),(0x11f4+5504-0x26fd),(0x5d0+2386-0xeaa),
-(0x14ec+2357-0x1da8),(0x587+4320-0x15ed),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM
-,NON_GSM,NON_GSM,(0x2274+15-0x2268),(0x1e9+6693-0x1bce),NON_GSM,
-(0x10d3+4782-0x2380),(0x997+6521-0x22ec),(0xdaa+4242-0x1e39),NON_GSM,
-(0x3b4+8250-0x238f),NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x2a1+1846-0x977),NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,(0x15a+3157-0xd54),(0x5f0+5412-0x1b06),
-(0x1139+352-0x127d),(0xf76+4463-0x20dc),NON_GSM,(0x2431+178-0x24c4),NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,NON_GSM,(0x3c2+2454-0xcfb),NON_GSM,
-NON_GSM,NON_GSM,NON_GSM,(0x1033+4384-0x20f7),NON_GSM,(0x16a7+678-0x1942),NON_GSM
-,NON_GSM,NON_GSM,(0x197+797-0x456),NON_GSM,NON_GSM,(0x2583+270-0x2673),
-(0x1047+4693-0x221d),NON_GSM,NON_GSM,NON_GSM,(0x42b+7596-0x215c),
-(0x1b74+1523-0x2158),(0x25d+8759-0x2477),NON_GSM,(0x602+3338-0x1308),
-(0x471+2938-0xfe6),NON_GSM,NON_GSM,(0x1ee6+1544-0x24e7),NON_GSM,NON_GSM,NON_GSM,
-NON_GSM,(0x702+1415-0xc0c),(0x15f+3338-0xe61),NON_GSM,NON_GSM,NON_GSM,
-(0x1164+4336-0x21d8),NON_GSM,(0x4dc+5675-0x1afb),(0x1e2d+1020-0x2223),NON_GSM,
-NON_GSM,(0x4d3+7461-0x217a),NON_GSM,NON_GSM,NON_GSM};const unsigned short
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[]={(0x151d+3958-0x2453),(0x3d5+549-0x557),
-(0x19d3+2129-0x2200),(0x99f+7233-0x253b),(0x1b4c+2679-0x24d9),
-(0x19f2+808-0x1c31),(0x80d+2130-0xf65),(0x8b9+7357-0x2489),(0xa5d+5976-0x20c2),
-(0xf31+3942-0x1db0),(0x247a+95-0x24cf),(0x18a+8504-0x21ee),(0x9d1+3393-0x161e),
-(0x1478+4355-0x256e),(0x931+1968-0x1020),(0x14c2+4629-0x25f6),
-(0x553+5301-0x1674),(0x1229+3069-0x1dc7),(0xba4+506-0xcf4),(0x144+4415-0x11bc),
-(0x1386+2954-0x1e50),8734,(0x1ee8+150-0x1f20),(0x1a4b+1195-0x1e9a),8364,
-(0x860+5346-0x1c6f),(0x1737+1090-0x1afd),(0x15a0+2040-0x1cf8),
-(0x36a+7284-0x1f1c),(0x1edd+1807-0x250a),(0x8fb+860-0xb8d),(0x1324+4548-0x241f),
-(0x10f0+2576-0x1ae0),(0x1cd5+1739-0x237f),(0x1d92+121-0x1de9),
-(0xceb+2654-0x1726),(0x1971+2588-0x22dd),(0x3f1+2089-0xbf5),(0x6e6+5131-0x1acb),
-(0x2da+3762-0x1165),(0xd39+3609-0x1b2a),(0xd10+6691-0x270a),(0x11d0+1121-0x1607)
-,(0x612+4515-0x178a),(0x5e0+7229-0x21f1),(0xcf8+1796-0x13cf),(0x1aaa+33-0x1a9d),
-(0x16a2+1180-0x1b0f),(0x5bf+4238-0x161d),(0x18d+9542-0x26a2),(0x81d+1236-0xcbf),
-(0x111d+5123-0x24ed),(0x22bd+547-0x24ac),(0xf40+3691-0x1d76),(0x2bd+6309-0x1b2c)
-,(0x311+3924-0x122e),(0x2327+197-0x23b4),(0x2a9+3197-0xeed),(0xc39+3274-0x18c9),
-(0xd4a+5749-0x2384),(0x7fd+4376-0x18d9),(0x28b+6040-0x19e6),(0xd56+6537-0x26a1),
-(0x438+695-0x6b0),(0x9b4+3482-0x1681),(0x1fa1+925-0x22fd),(0x9db+3605-0x17ae),
-(0x19a2+2416-0x22cf),(0x1abf+833-0x1dbc),(0x1c99+1630-0x22b2),(0x2b3+1041-0x67e)
-,(0xa72+2976-0x15cb),(0x427+6320-0x1c8f),(0x170f+3952-0x2636),
-(0x1117+2374-0x1a13),(0x1f9b+1038-0x235e),(0x507+2598-0xee1),
-(0x1710+2619-0x20fe),(0x99f+3436-0x16bd),(0xafa+6576-0x245b),
-(0x211b+1281-0x25cc),(0x1254+2707-0x1c96),(0x150a+4345-0x25b1),
-(0x1287+5132-0x2640),(0x1259+5203-0x2658),(0x23d7+567-0x25b9),
-(0x122+4987-0x1447),(0x1714+2417-0x202e),(0x11fb+3585-0x1fa4),
-(0x1149+5062-0x24b6),(0x719+6527-0x203e),(0x1c7b+1387-0x2123),
-(0xdad+1423-0x1267),(0x1606+1050-0x1946),(0x4bf+3118-0x1011),(0xf67+2337-0x17e1)
-,(0xfe3+4998-0x22eb),(0x14a5+1739-0x1b0f),(0x511+1247-0x98e),(0x69f+589-0x889),
-(0xf97+4402-0x2065),(0xd01+6217-0x24e5),(0x1040+840-0x1322),(0x1b8c+2416-0x2495)
-,(0x1d6+1346-0x6b0),(0x9bb+291-0xa75),(0x1f7+1393-0x6fe),(0x803+7292-0x2414),
-(0x8a6+7740-0x2676),(0xd1a+6167-0x24c4),(0x189f+3223-0x24c8),(0x95f+5582-0x1ebe)
-,(0x13f6+3188-0x1ffa),(0xc8c+3587-0x1a1e),(0xa1b+6075-0x2164),
-(0x1f14+1600-0x24e1),(0x1c21+1157-0x2032),(0xf41+2005-0x16a1),
-(0x1a2d+728-0x1c8f),(0x2b9+3038-0xe20),(0x173b+4103-0x26ca),(0x623+7244-0x21f6),
-(0xcfc+2530-0x1664),(0x1044+5506-0x24e3),(0x64b+1045-0x96b),(0x770+6957-0x223d),
-(0xcb5+5449-0x2102),(0x1fa3+62-0x1f01)};const unsigned short
-zte_sms_GSMDefault_To_UCS2_Table[]={(0xdeb+3752-0x1c53),(0x504+7926-0x2357),
-(0x19b+2271-0xa56),(0x3c5+5489-0x1891),(0x492+7074-0x1f4c),(0x9b7+1747-0xfa1),
-(0xca3+3827-0x1a9d),(0x385+3435-0x1004),(0x241+4967-0x14b6),(0x113b+5129-0x247d)
-,(0x1432+3611-0x2243),(0x382+4165-0x12ef),(0x1656+2025-0x1d47),
-(0x8f3+5768-0x1f6e),(0x3b8+7608-0x20ab),(0x7fd+1635-0xd7b),(0xdf9+7057-0x25f6),
-(0xce7+3020-0x1854),(0xf9a+5368-0x20ec),(0x1026+4350-0x1d91),(0x5ab+2661-0xc75),
-(0xfb3+800-0xf2a),(0x1a5f+756-0x19b3),(0x48a+8486-0x2208),(0x56b+2441-0xb51),
-(0xb32+8044-0x2706),(0x432+3599-0xea3),(0x51c+824-0x7b4),(0x1bb+9571-0x2658),
-(0x77d+3427-0x13fa),(0xf5d+2110-0x16bc),(0x1b69+1273-0x1f99),
-(0x1b91+1286-0x2077),(0xb96+4624-0x1d85),(0x494+2878-0xfb0),(0x1316+250-0x13ed),
-(0x151b+888-0x17ef),(0x156d+1039-0x1957),(0x3eb+8042-0x232f),
-(0x1094+4594-0x225f),(0x4da+7313-0x2143),(0x14a4+651-0x1706),
-(0x1856+1789-0x1f29),(0xf68+1447-0x14e4),(0x78d+4840-0x1a49),(0x15f+3789-0xfff),
-(0x7c9+3147-0x13e6),(0x1538+2112-0x1d49),(0x1355+4326-0x240b),
-(0x146+4973-0x1482),(0x9d8+6441-0x22cf),(0x225b+332-0x2374),(0x55b+5257-0x19b0),
-(0xf7b+1801-0x164f),(0x780+2375-0x1091),(0xa61+6454-0x2360),(0x586+6991-0x209d),
-(0x963+6330-0x21e4),(0x434+8381-0x24b7),(0x1295+46-0x1288),(0x7a2+4999-0x1aed),
-(0x8a7+4545-0x1a2b),(0x12dc+4367-0x23ad),(0x14e6+3651-0x22ea),
-(0x561+8426-0x25aa),(0x42c+6256-0x1c5b),(0xcfb+6008-0x2431),(0x7d1+236-0x87a),
-(0x17f7+913-0x1b44),(0x1da5+1582-0x238e),(0xcd5+5023-0x202e),(0x1f3+9145-0x2565)
-,(0x1461+319-0x1558),(0x1a7b+1547-0x203d),(0x748+4731-0x1979),
-(0x186+6019-0x18be),(0x1245+4803-0x24bc),(0x7cc+1103-0xbce),(0x4fd+7244-0x20fb),
-(0x698+2851-0x116c),(0x10a8+5538-0x25fa),(0xf28+4407-0x200e),(0x1eb+3073-0xd9a),
-(0x47f+2051-0xc2f),(0x7cf+3278-0x1449),(0x228+1854-0x911),(0x1869+3833-0x270c),
-(0x3fb+2912-0xf04),(0xad2+3421-0x17d7),(0x14b3+3882-0x2384),(0x1faa+1960-0x26f8)
-,(0xe38+4578-0x1f56),(0x1370+3271-0x1f61),(0x3e8+4728-0x158f),
-(0xc52+1568-0x1196),(0x668+5161-0x19ea),(0x1070+1846-0x16e7),(0x2a0+3483-0xfda),
-(0x708+1000-0xa8e),(0x15b0+1075-0x1980),(0x757+2367-0x1032),(0x1901+1345-0x1ddd)
-,(0x75d+2960-0x1287),(0xd11+1203-0x115d),(0x1be2+2242-0x243c),
-(0x1842+662-0x1a6f),(0x1233+3062-0x1dbf),(0x9b+8265-0x2079),(0x1fa+8245-0x21c3),
-(0x15c6+4429-0x26a6),(0x1a25+1495-0x1f8e),(0x14c6+3574-0x224d),
-(0xfc3+2633-0x199c),(0x72f+3210-0x1348),(0x86+5619-0x1607),(0x3b7+519-0x54b),
-(0xc33+3269-0x1884),(0x862+379-0x968),(0xeea+5227-0x22df),(0x1f8+4378-0x129b),
-(0x1313+1517-0x1888),(0x15cb+3505-0x2303),(0x256a+417-0x2691),
-(0xd0f+1189-0x10d0),(0x99f+5456-0x1df9),(0x1278+2357-0x1abc),
-(0x1ff6+1170-0x238c),(0x1292+3564-0x1f9e)};int Bytes2String(const unsigned char*
-pSrc,char*pDst,int nSrcLength){const char tab[]="0123456789ABCDEF";int i=
-(0xacf+4260-0x1b73);if(pSrc==NULL||pDst==NULL||nSrcLength<(0x2081+192-0x2141)){
-return-(0x929+4454-0x1a8e);}for(i=(0x3bc+7039-0x1f3b);i<nSrcLength;i++){*pDst++=
-tab[*pSrc>>(0xfea+3094-0x1bfc)];*pDst++=tab[*pSrc&(0x12a7+4829-0x2575)];pSrc++;}
-*pDst='\0';return nSrcLength*(0x432+1740-0xafc);}int String2Bytes(const char*
-pSrc,unsigned char*pDst,int nSrcLength){int i=(0x11a+4572-0x12f6);if(pSrc==NULL
-||pDst==NULL||nSrcLength<(0x139b+4717-0x2608)){return-(0xf8b+2960-0x1b1a);}for(i
-=(0x18b0+46-0x18de);i<nSrcLength;i+=(0x131a+1994-0x1ae2)){if(*pSrc>=
-((char)(0x530+7142-0x20e6))&&*pSrc<=((char)(0xb77+4547-0x1d01))){*pDst=(*pSrc-
-((char)(0x534+818-0x836)))<<(0x1994+541-0x1bad);}else{*pDst=((toupper(*pSrc)-
-((char)(0x132d+552-0x1514)))+(0x1645+414-0x17d9))<<(0x358+2360-0xc8c);}pSrc++;if
-(*pSrc>=((char)(0x7e5+375-0x92c))&&*pSrc<=((char)(0x1931+103-0x195f))){*pDst|=*
-pSrc-((char)(0x1046+2350-0x1944));}else{*pDst|=(toupper(*pSrc)-
-((char)(0x118c+2834-0x1c5d)))+(0x12f4+3606-0x2100);}pSrc++;pDst++;}return
-nSrcLength/(0x42f+7254-0x2083);}int EncodeUcs2(const char*pSrc,unsigned char*
-pDst,int nSrcLength){if(pSrc==NULL||pDst==NULL||nSrcLength<(0x9ad+1944-0x1145)){
-return-(0x3f7+913-0x787);}(void)String2Bytes(pSrc,pDst,(int)nSrcLength);return
-nSrcLength/(0x1397+811-0x16c0);}int Encode7bit(const char*pSrc,unsigned char*
-pDst,int nSrcLength){int nSrc;int nDst;int nChar;unsigned char nLeft=
-(0x2e5+4968-0x164d);if(pSrc==NULL||pDst==NULL||nSrcLength<(0x819+4435-0x196c)){
-return-(0x1d02+2281-0x25ea);}nSrc=(0x1f61+555-0x218c);nDst=(0x528+8115-0x24db);
-while(nSrc<nSrcLength){nChar=nSrc&(0x1227+2148-0x1a84);if(nChar==
-(0x8a9+5895-0x1fb0)){nLeft=*pSrc;if((g_zUfiSms_ConcatSms.total_msg>
-(0x1ad6+117-0x1b4a))&&(nSrc==(nSrcLength-(0x1044+5514-0x25cd)))){nDst++;}}else{*
-pDst=(*pSrc<<((0x65a+1349-0xb97)-nChar))|nLeft;nLeft=*pSrc>>nChar;pDst++;nDst++;
-}pSrc++;nSrc++;}return nDst;}SINT32 zUfiSms_EncodePdu_DeliverReport(CHAR*pDst,
-UINT8 TP_FCS){SINT32 nLength=(0x1916+789-0x1c2b);SINT32 nDstLength=
-(0x1602+3575-0x23f9);UINT8 buf[(0xeed+4879-0x20fc)]={(0x610+5777-0x1ca1)};if(
-NULL==pDst){return-(0x9ec+1479-0xfb2);}if(TP_FCS!=(0xc72+5228-0x20de)){buf[
-(0x148+7053-0x1cd5)]=(0x152+9466-0x264c);buf[(0x3c8+7523-0x212a)]=TP_FCS;buf[
-(0x24+5623-0x1619)]=(0xc6a+3849-0x1b73);nDstLength+=Bytes2String(buf,&pDst[
-nDstLength],(0x883+4830-0x1b5e));}else{buf[(0x1013+796-0x132f)]=
-(0x4d2+3870-0x13f0);buf[(0x1b6d+2162-0x23de)]=(0x981+7414-0x2677);nDstLength+=
-Bytes2String(buf,&pDst[nDstLength],(0x9ca+5301-0x1e7d));}return nDstLength;}
-unsigned long zUfiSms_ConvertAsciiToGsmDefault(const unsigned char*inputs,
-unsigned char*outputs,unsigned long len){unsigned long i=(0x662+1802-0xd6c);
-unsigned long j=(0xbec+1876-0x1340);unsigned long k=(0x1d02+1225-0x21cb);if(NULL
-==inputs||NULL==outputs){printf(
-"\x73\x6d\x73\x3a\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73");
-return(0x86d+2202-0x1107);}for(i=(0x29a+3523-0x105d);i<len;i++){j=inputs[i];if(
-g_zUfiSms_AsciiToGsmdefaultTable[j]<(0x181d+1907-0x1e91)){outputs[k]=
-g_zUfiSms_AsciiToGsmdefaultTable[j];}else{outputs[k]=(
-g_zUfiSms_AsciiToGsmdefaultTable[j]&65280)>>(0x1114+2100-0x1940);k++;outputs[k]=
-(g_zUfiSms_AsciiToGsmdefaultTable[j]&(0x19b+6300-0x1938));}k++;}return k;}
-unsigned long zUfiSms_ConvertUcs2ToSpanish(const unsigned char*def,unsigned char
-*gsm_default,unsigned long len){unsigned long i=(0x8d+8516-0x21d1);unsigned long
- k=(0x364+1312-0x884);unsigned long p=(0x942+970-0xd0c);unsigned long tmp=
-(0xbf+9055-0x241e);unsigned long s1=(0x445+143-0x4d4),s2=(0xf39+2901-0x1a8e);
-unsigned long q=(0x79f+2207-0x103e);s1=sizeof(
-zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex)/sizeof(
-zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[(0x7a9+4490-0x1933)]);s2=sizeof(
-Ucs2_To_Gsm7_SPANISH_Table_UCS)/sizeof(Ucs2_To_Gsm7_SPANISH_Table_UCS[
-(0x19d1+3286-0x26a7)]);for(i=(0xdf4+5337-0x22cd);i<len;i++){if(def[i]==
-(0x718+4335-0x1807)){i++;if(Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]]!=NON_GSM){
-gsm_default[k]=Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]];k++;continue;}else if((
-Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]]==NON_GSM)&&(def[i]==(0x571+5085-0x192e)))
-{gsm_default[k]=(0xd70+4168-0x1d98);k++;continue;}for(q=(0x11ef+3478-0x1f85);q<
-s1;q++){if(def[i]==zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[q][(0xe5c+6014-0x25d9)]
-){gsm_default[k]=(0x2f+4487-0x119b);k++;gsm_default[k]=
-zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[q][(0x1c36+217-0x1d0f)];break;}}}else{tmp=
-(def[i]<<(0x2f2+5360-0x17da))+def[i+(0x1c59+2262-0x252e)];i++;if(tmp==8364){
-gsm_default[k]=(0xd91+5886-0x2474);k++;gsm_default[k]=(0x347+7664-0x20d2);k++;}
-for(p=(0xae0+967-0xea7);p<s2;p++){if(tmp==Ucs2_To_Gsm7_SPANISH_Table_UCS[p][
-(0x14b4+938-0x185d)]){gsm_default[k]=Ucs2_To_Gsm7_SPANISH_Table_UCS[p][
-(0x2359+817-0x268a)];break;}}}k++;}gsm_default[k]='\0';return k;}unsigned long
-zUfiSms_ConvertUcs2ToPortuguese(const unsigned char*def,unsigned char*
-gsm_default,unsigned long len){unsigned long i=(0x420+2654-0xe7e);unsigned long
-k=(0xb49+1127-0xfb0);unsigned long p=(0x12b+762-0x425);unsigned long tmp=
-(0xb3f+6957-0x266c);unsigned long s1=(0xd86+2634-0x17d0),s2=(0x94c+2811-0x1447);
-unsigned long q=(0xb+7015-0x1b72);s1=sizeof(
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex)/sizeof(
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[(0x341+2467-0xce4)]);s2=sizeof(
-Ucs2_To_Gsm7_PORTUGUESE_Table_UCS)/sizeof(Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[
-(0x4ac+4613-0x16b1)]);for(i=(0x1277+1286-0x177d);i<len;i++){if(def[i]==
-(0x9f+5239-0x1516)){i++;if(Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]]!=NON_GSM){
-gsm_default[k]=Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]];k++;continue;}else if((
-Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]]==NON_GSM)&&(def[i]==
-(0x1a3+5972-0x18d7))){gsm_default[k]=(0x1157+1634-0x1799);k++;continue;}for(q=
-(0x21+1193-0x4ca);q<s1;q++){if(def[i]==zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[
-q][(0xf91+4645-0x21b5)]){gsm_default[k]=(0x653+3159-0x128f);k++;gsm_default[k]=
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[q][(0x11d3+2294-0x1ac9)];break;}}}else{
-tmp=(def[i]<<(0x13d2+2058-0x1bd4))+def[i+(0xa51+6931-0x2563)];i++;if(tmp==8364){
-gsm_default[k]=(0x180+4778-0x140f);k++;gsm_default[k]=(0x1fb5+1319-0x2477);k++;
-continue;}for(p=(0x216+6451-0x1b49);p<s2;p++){if(tmp==
-Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[p][(0xa90+4923-0x1dca)]){gsm_default[k]=
-Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[p][(0x30d+2685-0xd8a)];break;}}}k++;}
-gsm_default[k]='\0';return k;}unsigned long zUfiSms_ConvertUcs2ToGsmDefault(
-const unsigned char*def,unsigned char*gsm_default,unsigned long len){unsigned
-long i=(0x1383+3046-0x1f69);unsigned long k=(0xc28+1599-0x1267);unsigned long p=
-(0x857+2410-0x11c1);unsigned long tmp=(0x821+1971-0xfd4);unsigned long s1=
-(0x530+1330-0xa62),s2=(0x143+804-0x467);unsigned long q=(0x13b0+495-0x159f);s1=
-sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof(
-zte_sms_GSMDefault_To_UCS2_Table_Ex[(0x3fa+7886-0x22c8)]);s2=sizeof(
-UCS2_To_GSMDefault_Table_UCS2)/sizeof(UCS2_To_GSMDefault_Table_UCS2[
-(0xd47+3437-0x1ab4)]);for(i=(0xd4c+5580-0x2318);i<len;i++){if(def[i]==
-(0x998+6437-0x22bd)){i++;if(UCS2_To_GSMDefault_Table_ASC[def[i]]!=NON_GSM){
-gsm_default[k]=UCS2_To_GSMDefault_Table_ASC[def[i]];k++;continue;}else if((
-UCS2_To_GSMDefault_Table_ASC[def[i]]==NON_GSM)&&(def[i]==(0x748+6103-0x1eff))){
-gsm_default[k]=(0xd94+1454-0x1322);k++;continue;}for(q=(0x94f+1785-0x1048);q<s1;
-q++){if(def[i]==zte_sms_GSMDefault_To_UCS2_Table_Ex[q][(0xf9c+3150-0x1be9)]){
-gsm_default[k]=(0x742+7258-0x2381);k++;gsm_default[k]=
-zte_sms_GSMDefault_To_UCS2_Table_Ex[q][(0x106+1224-0x5ce)];break;}}}else{tmp=(
-def[i]<<(0x220a+1065-0x262b))+def[i+(0x5b7+6702-0x1fe4)];i++;if(tmp==8364){
-gsm_default[k]=(0x1825+254-0x1908);k++;gsm_default[k]=(0x912+4652-0x1ad9);k++;
-continue;}for(p=(0x1dec+1480-0x23b4);p<s2;p++){if(tmp==
-UCS2_To_GSMDefault_Table_UCS2[p][(0x1bb6+259-0x1cb8)]){gsm_default[k]=
-UCS2_To_GSMDefault_Table_UCS2[p][(0x696+697-0x94f)];break;}}}k++;}gsm_default[k]
-='\0';return k;}UINT8 zUfiSms_TsIntToBcd(const UINT8 i){return(UINT8)(((i%
-(0x18f9+97-0x1950))+((i/(0x168+6625-0x1b3f))<<(0x7df+3389-0x1518))));}void
-zUfiSms_DecodeRelativeTime(UINT8 iValidTime,T_zUfiSms_TimeStamp*ptTimeStamp){
-uint32 i=(0x879+7654-0x265f);if(ptTimeStamp!=NULL){memset((void*)ptTimeStamp,
-(0x1da+3022-0xda8),sizeof(wms_timestamp_s_type));if(iValidTime<
-(0x8bc+4375-0x1943)){i=(iValidTime+(0x43f+5144-0x1856))*(0x19f5+523-0x1bfb);
-ptTimeStamp->hour=(UINT8)zUfiSms_TsIntToBcd((UINT8)(i/(0x1109+4969-0x2436)));
-ptTimeStamp->minute=(UINT8)zUfiSms_TsIntToBcd((UINT8)(i%(0xed4+6199-0x26cf)));}
-else if(iValidTime<(0xd43+4804-0x1f60)){i=(iValidTime-(0x11ba+2510-0x1af9))*
-(0xc73+4328-0x1d3d);ptTimeStamp->hour=(UINT8)zUfiSms_TsIntToBcd((UINT8)(
-(0x64+3945-0xfc1)+i/(0x1b23+851-0x1e3a)));ptTimeStamp->minute=(UINT8)
-zUfiSms_TsIntToBcd((UINT8)(i%(0x177+4971-0x14a6)));}else if(iValidTime<
-(0x313+6870-0x1d24)){i=iValidTime-(0xe13+1553-0x137e);ptTimeStamp->month=(UINT8)
-zUfiSms_TsIntToBcd((UINT8)(i/(0xdf1+2283-0x16be)));ptTimeStamp->day=(UINT8)
-zUfiSms_TsIntToBcd((UINT8)(i%(0xc4b+2804-0x1721)));}else{i=(iValidTime-
-(0x830+4761-0x1a09))*(0x869+977-0xc33);ptTimeStamp->year=(UINT8)
-zUfiSms_TsIntToBcd((UINT8)(i/(0xd56+3451-0x1964)));ptTimeStamp->month=(UINT8)
-zUfiSms_TsIntToBcd((UINT8)((i%(0x1f97+294-0x1f50))/(0x21d6+553-0x23e1)));
-ptTimeStamp->day=(UINT8)zUfiSms_TsIntToBcd((UINT8)((i%(0x7ef+1304-0xb9a))%
-(0x19fc+817-0x1d0f)));}}else{printf(
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x72\x65\x6c\x61\x74\x69\x76\x65\x5f\x74\x69\x6d\x65"
-);}}int zUfiSms_CharToInt(char*pCharArray,int iLen,unsigned char*pIntArray){int
-i=(0x1e38+2111-0x2677);if(pIntArray==NULL||pCharArray==NULL){return ZUFI_FAIL;}
-for(i=(0x1cb+3560-0xfb3);i<iLen;i++){pIntArray[i]=pCharArray[i]-
-((char)(0x3a0+856-0x6c8));}return ZUFI_SUCC;}void zUfiSms_FillGlobalTpudGsm7(
-T_zUfiSms_SubmitTpdu*ptSubmit,T_zUfiSms_ConcatInfo*ptConcatSms,
-T_zUfiSms_DbStoreData*ptDbSaveData){int i=(0xfec+4090-0x1fe6);if(ptConcatSms->
-total_msg>(0x1b92+1652-0x2205)){g_zUfiSms_SendingSms.TP_UDHI=(0x49c+6242-0x1cfd)
-;g_zUfiSms_SendingSms.TP_UD[(0x11af+3679-0x200e)]=(0x491+6534-0x1e12);
-g_zUfiSms_SendingSms.TP_UD[(0x7e0+6908-0x22db)]=(0x23b+7892-0x210a);
-g_zUfiSms_SendingSms.TP_UD[(0x279+137-0x300)]=(0xa10+5539-0x1fb0);
-g_zUfiSms_SendingSms.TP_UD[(0x10e6+1457-0x1694)]=(char)ptDbSaveData->concat_info
-[(0xa03+825-0xd3c)]%(0x1650+3525-0x2316);g_zUfiSms_SendingSms.TP_UD[
-(0x1724+1902-0x1e8e)]=(char)ptConcatSms->total_msg;g_zUfiSms_SendingSms.TP_UD[
-(0xe2a+1623-0x147c)]=(char)ptConcatSms->current_sending+(0x369+9096-0x26f0);
-g_zUfiSms_SendingSms.TP_UD[(0x928+4597-0x1b17)]=(0x3f5+8240-0x241f);for(i=
-(0xb67+3814-0x1a4d);i<ptSubmit->user_data.sm_len;i++){g_zUfiSms_SendingSms.TP_UD
-[i+(0x1e3b+1977-0x25ed)]=ptSubmit->user_data.sm_data[i];}g_zUfiSms_SendingSms.
-TP_UDLength=ptSubmit->user_data.sm_len+(0x1073+4641-0x228d);}else{for(i=
-(0x272+5526-0x1808);i<ptSubmit->user_data.sm_len;i++){g_zUfiSms_SendingSms.TP_UD
-[i]=ptSubmit->user_data.sm_data[i];}g_zUfiSms_SendingSms.TP_UDLength=ptSubmit->
-user_data.sm_len;}}void zUfiSms_FillGlobalTpudUcs2(T_zUfiSms_SubmitTpdu*ptSubmit
-,T_zUfiSms_ConcatInfo*ptConcatSms,T_zUfiSms_DbStoreData*ptDbSaveData){if(
-ptConcatSms->total_msg>(0xe40+6102-0x2615)){g_zUfiSms_SendingSms.TP_UDHI=
-(0x1e6a+188-0x1f25);g_zUfiSms_SendingSms.TP_UD[(0x289+1027-0x68c)]=
-(0xb77+5175-0x1fa9);g_zUfiSms_SendingSms.TP_UD[(0x901+794-0xc1a)]=
-(0x131f+3192-0x1f92);g_zUfiSms_SendingSms.TP_UD[(0x196+9306-0x25ee)]=
-(0x16ca+2371-0x200a);g_zUfiSms_SendingSms.TP_UD[(0xee9+800-0x1206)]=(char)
-ptDbSaveData->concat_info[(0x2d+6694-0x1a53)]%(0x16a9+2163-0x1e1d);
-g_zUfiSms_SendingSms.TP_UD[(0x1888+3461-0x2609)]=(char)ptConcatSms->total_msg;
-g_zUfiSms_SendingSms.TP_UD[(0xd2d+6006-0x249e)]=(char)ptConcatSms->
-current_sending+(0x49+9320-0x24b0);(void)Bytes2String(ptSubmit->user_data.
-sm_data,&g_zUfiSms_SendingSms.TP_UD[(0xca9+1631-0x1302)],ptSubmit->user_data.
-sm_len);}else{(void)Bytes2String(ptSubmit->user_data.sm_data,
-g_zUfiSms_SendingSms.TP_UD,ptSubmit->user_data.sm_len);}}unsigned char
-zUfiSms_Low2High(unsigned char x){if(x>=((char)(0x103d+5205-0x2431))&&x<
-((char)(0x8d3+2059-0x1077))){x=(x-((char)(0x10f6+789-0x13aa)))+
-((char)(0x10e4+5097-0x248c));}return x;}unsigned char zUfiSms_Char2Dec(unsigned
-char x){unsigned char d=(0xc3a+6252-0x24a6);if(x>=((char)(0x863+226-0x904))&&x<
-((char)(0x1103+4572-0x2298))){d=(x-((char)(0x1b90+110-0x1bbd)))+
-(0xbf+5126-0x14bb);}else{d=x-((char)(0x5c5+1077-0x9ca));}return d;}unsigned char
- zUfiSms_Char2Byte(unsigned char a,unsigned char b){unsigned char data=
-(0x9d3+7124-0x25a7);unsigned char l=(0x1a43+3091-0x2656),h=(0x12a+2225-0x9db);a=
-zUfiSms_Low2High(a);b=zUfiSms_Low2High(b);h=zUfiSms_Char2Dec(a);l=
-zUfiSms_Char2Dec(b);data=h*(0xb74+3692-0x19d0)+l;return data;}void
-zUfiSms_Str2Bytes(unsigned char*text,int text_len,unsigned char*data,int
-data_len){int i=(0xc7+899-0x44a);while((0x592+3350-0x12a6)*i+(0xcf0+6352-0x25bf)
-<text_len){data[i]=zUfiSms_Char2Byte(text[(0x16e3+2507-0x20ac)*i],text[
-(0x110d+909-0x1498)*i+(0x1bf+7640-0x1f96)]);i++;}}int zUfiSms_SplitString(char*
-input,char***output,char cMatchChar){int src=(0x18c3+2553-0x22bc);int dst=
-(0xbf4+1718-0x12aa);int count=(0xd83+5863-0x246a);int size=(0x9df+587-0xc22);
-char quoted=(0x6d2+3563-0x14bd);char**tmpout=NULL;*output=(char**)malloc(sizeof(
-char*)*size);if(NULL==*output){return-(0xd61+3283-0x1a33);}(*output)[count++]=
-input;for(src=dst=(0x531+4125-0x154e);input[src];){char cInputChar=input[src];if
-(!quoted&&cInputChar==cMatchChar){input[dst++]=(0xf4c+1304-0x1464);while(input[
-++src]&&(int)isspace(input[src])){};if(count>=size){size+=(0x15+1789-0x702);
-tmpout=(char**)realloc(*output,sizeof(char*)*size);if(NULL==tmpout){return-
-(0x6a5+8102-0x264a);}*output=tmpout;}(*output)[count++]=input+dst;}else if(!
-quoted&&(cInputChar=='\''||cInputChar==((char)(0x1c33+729-0x1eea)))){quoted=
-cInputChar;src++;}else if(cInputChar==quoted){quoted=(0x1825+249-0x191e);src++;}
-else{if(cInputChar=='\\'&"ed!='\''){src++;cInputChar=input[src];if(!
-cInputChar){free(*output);*output=NULL;return-(0x341+5070-0x170e);}}input[dst++]
-=cInputChar;src++;}}input[dst]=(0xe43+2550-0x1839);if(quoted){free(*output);*
-output=NULL;return-(0x1c76+808-0x1f9d);}return count;}int zUfiSms_atohex(char c)
-{int result=(0x18e4+1509-0x1ec9);if(c>=((char)(0x109c+3967-0x1feb))&&c<=
-((char)(0xa63+2818-0x152c))){result=c-((char)(0xfe8+5284-0x245c));}else if(c>=
-((char)(0x507+6560-0x1e46))&&c<=((char)(0x160d+3099-0x21c2))){result=(c-
-((char)(0x6fc+7684-0x249f)))+(0x166a+3551-0x243f);}else if(c>=
-((char)(0x28a+6484-0x1b9d))&&c<=((char)(0x176+7171-0x1d33))){result=(c-
-((char)(0x1bb+2486-0xb30)))+(0x3d+8829-0x22b0);}else{at_print(LOG_DEBUG,
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x61\x74\x6f\x68\x65\x78\x20\x65\x72\x72\x6f\x72\x2c\x63\x61\x6e\x20\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x63\x68\x61\x72\x3a\x25\x63" "\n"
-,c);return result;}return result;}int zUfiSms_DispatchWtoi(unsigned char*in_ptr,
-int iLength,unsigned char*out_ptr){int low=(0x1d77+10-0x1d81);int high=
-(0xe6c+71-0xeb3);if(in_ptr==NULL||out_ptr==NULL){printf(
-"\x73\x6d\x73\x3a\x69\x6e\x76\x61\x69\x6c\x64\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72" "\n"
-);return ZUFI_FAIL;}while(iLength>(0x15c1+1901-0x1d2e)){low=in_ptr[iLength-
-(0x1008+3487-0x1da6)]&(0x1cd0+891-0x203c);high=(in_ptr[iLength-
-(0xba4+2403-0x1506)]&(0xee7+2821-0x18fc))>>(0x811+410-0x9a7);out_ptr[
-(0x2f1+2455-0xc86)*iLength-(0x154+4340-0x1247)]=g_zUfiSms_DigAscMap[low];out_ptr
-[(0x249+7935-0x2146)*iLength-(0x1466+3831-0x235b)]=g_zUfiSms_DigAscMap[high];
-iLength--;}return ZUFI_SUCC;}unsigned int zte_wms_convert_PORTUGUESE_To_UCS2(
-const unsigned char*gsmdef,unsigned char*ucs2,unsigned int len){unsigned int i=
-(0x1402+2970-0x1f9c);unsigned int j=(0x98+8064-0x2018);unsigned int k=
-(0xc9+9344-0x2549);unsigned int p=(0x13d+105-0x1a6);unsigned int s=
-(0xe29+1173-0x12be);s=sizeof(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex)/sizeof(
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[(0x102d+1543-0x1634)]);for(i=
-(0x11a2+5322-0x266c);i<len;i++){j=gsmdef[i];if(j==(0x8b+5260-0x14fc)){i++;for(p=
-(0x13cc+1785-0x1ac5);p<s;p++){if(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][
-(0x608+5615-0x1bf7)]==gsmdef[i]){ucs2[k]=
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][(0x12+6876-0x1aed)]>>
-(0xa7+2278-0x985);k++;ucs2[k]=(unsigned char)(
-zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][(0x1a6c+2184-0x22f3)]);break;}}}else
-{ucs2[k]=zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]>>(0x144b+3657-0x228c);k++;ucs2
-[k]=(unsigned char)(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]);}k++;}ucs2[k]='\0'
-;return k;}unsigned int zte_wms_convert_PORTUGUESE_To_UCS2_USE_GSM7_SS_PORTU_LS(
-const unsigned char*gsmdef,unsigned char*ucs2,unsigned int len){unsigned int i=
-(0x306+4785-0x15b7);unsigned int j=(0xfe9+2894-0x1b37);unsigned int k=
-(0x3ea+7081-0x1f93);unsigned int p=(0xd64+4260-0x1e08);unsigned int s=
-(0x68a+7413-0x237f);s=sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof(
-zte_sms_GSMDefault_To_UCS2_Table_Ex[(0x366+4452-0x14ca)]);for(i=
-(0x1585+2354-0x1eb7);i<len;i++){j=gsmdef[i];if(j==(0x60b+6662-0x1ff6)){i++;for(p
-=(0x78b+5145-0x1ba4);p<s;p++){if(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][
-(0x4b3+7043-0x2036)]==gsmdef[i]){ucs2[k]=zte_sms_GSMDefault_To_UCS2_Table_Ex[p][
-(0x1ed5+1107-0x2327)]>>(0x159f+933-0x193c);k++;ucs2[k]=(unsigned char)(
-zte_sms_GSMDefault_To_UCS2_Table_Ex[p][(0x5d6+3651-0x1418)]);break;}}}else{ucs2[
-k]=zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]>>(0xa1b+4408-0x1b4b);k++;ucs2[k]=(
-unsigned char)(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]);}k++;}ucs2[k]='\0';
-return k;}unsigned long zte_wms_convert_GSMDefault_to_UCS2(const unsigned char*
-gsmdef,unsigned char*ucs2,unsigned long len){unsigned long i=(0xcd6+5375-0x21d5)
-;unsigned long j=(0x52+5005-0x13df);unsigned long k=(0x3dd+5824-0x1a9d);unsigned
- long p=(0xae3+349-0xc40);unsigned long s=(0x13e9+1312-0x1909);unsigned long
-is_find=(0xd1c+5342-0x21fa);s=sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof
-(zte_sms_GSMDefault_To_UCS2_Table_Ex[(0x82f+1940-0xfc3)]);for(i=
-(0x1e59+800-0x2179);i<len;i++){j=gsmdef[i];if(j==(0xc6d+3796-0x1b26)){i++;for(p=
-(0xf4b+2945-0x1acc);p<s;p++){if(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][
-(0x995+670-0xc33)]==gsmdef[i]){ucs2[k]=zte_sms_GSMDefault_To_UCS2_Table_Ex[p][
-(0x4cb+7006-0x2028)]>>(0x331+470-0x4ff);k++;ucs2[k]=(unsigned char)(
-zte_sms_GSMDefault_To_UCS2_Table_Ex[p][(0xa3c+2752-0x14fb)]);is_find=
-(0x8c3+1184-0xd62);break;}}if(!is_find){at_print(LOG_DEBUG,
-"\x73\x6d\x73\x3a\x20\x64\x61\x74\x61\x20\x3d\x20\x25\x64\x20\x6e\x6f\x74\x20\x66\x69\x6e\x64\x20\x69\x6e\x20\x67\x73\x6d\x64\x65\x66\x61\x75\x6c\x74\x20\x65\x78\x74\x65\x6e\x73\x69\x6f\x6e\x20\x74\x61\x62\x6c\x65" "\n"
-,gsmdef[i]);i--;ucs2[k]=zte_sms_GSMDefault_To_UCS2_Table[j]>>(0x652+347-0x7a5);k
-++;ucs2[k]=(unsigned char)(zte_sms_GSMDefault_To_UCS2_Table[j]);}}else{ucs2[k]=
-zte_sms_GSMDefault_To_UCS2_Table[j]>>(0x159d+43-0x15c0);k++;ucs2[k]=(unsigned
-char)(zte_sms_GSMDefault_To_UCS2_Table[j]);}k++;}ucs2[k]='\0';return k;}void
-zUfiSms_ConvertUcs2(char*data,UINT16 sms_len,char*out_content){char
-ascii_content[(0x4e4+7604-0x2296)*ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX+
-(0x1f43+1579-0x256d)]={(0x26b+267-0x376)};UINT16 len=(0x1290+2694-0x1d16);switch
-(g_zUfiSms_Language){case DCS_PORTUGUESE:if(g_zUfiSms_IsLanguageShift==
-WMS_UDH_NAT_LANG_SS){len=zte_wms_convert_PORTUGUESE_To_UCS2((const UINT8*)data,(
-UINT8*)ascii_content,sms_len);}else if(g_zUfiSms_IsLanguageShift==
-WMS_UDH_NAT_LANG_LS){len=zte_wms_convert_PORTUGUESE_To_UCS2_USE_GSM7_SS_PORTU_LS
-((const UINT8*)data,(UINT8*)ascii_content,sms_len);}break;case DCS_USC:default:
-len=zte_wms_convert_GSMDefault_to_UCS2((const UINT8*)data,(UINT8*)ascii_content,
-sms_len);break;}(void)zUfiSms_DispatchWtoi((char*)ascii_content,len,(char*)
-out_content);}boolean zUfiSms_DecodeContent(char*msg_content,UINT16 sms_len,
-boolean isEsc,char*out_content){boolean endEsc=FALSE;char*p=NULL;static char
-data[(0x2bb+6895-0x1da9)+(0x3a2+6652-0x1cfe)+(0xa98+5718-0x20ed)]={
-(0xb5a+2595-0x157d)};int len=(0xf27+394-0x10b1);if(msg_content==NULL||
-out_content==NULL||sms_len>(0x1a3d+986-0x1cd7)||sms_len<(0x1923+2378-0x226b)){
-return endEsc;}len=sms_len;memset(data,(0xb07+6111-0x22e6),(0x9f2+1745-0x1021));
-p=data;if(isEsc){*p=(0x141c+519-0x1608);p++;}zUfiSms_Str2Bytes((unsigned char*)
-msg_content,len,(unsigned char*)p,(0xf41+5478-0x2407));if(p[len/
-(0xe3a+1266-0x132a)-(0x31+7294-0x1cae)]==(0xe14+4742-0x207f)){endEsc=TRUE;}
-zUfiSms_ConvertUcs2(data,len/(0x9d7+3061-0x15ca)+(isEsc?(0x18c9+855-0x1c1f):
-(0x1b9f+254-0x1c9d))-(endEsc?(0x8a8+4701-0x1b04):(0x633+7394-0x2315)),
-out_content);return endEsc;}byte*zUfiSms_SmsiUtilitoa(uint32 v,byte*s,UINT16 r){
-byte buf[(0x16a0+1565-0x1c9c)],c;int n;n=sizeof(buf)-(0xa42+171-0xaec);buf[n]=
-'\0';do{c=(byte)(v%r);if(n<=(0x39f+4111-0x13ae)){printf(
-"\x4f\x56\x45\x52\x46\x4c\x4f\x57\x20");break;}buf[--n]=(byte)((c>
-(0x6d5+5404-0x1be8))?c+((char)(0x123d+4776-0x24a4))-(0x40a+2099-0xc33):c+
-((char)(0xcf7+1990-0x148d)));}while((v/=r)>(0xbd2+2613-0x1607));while((*s++=buf[
-n++])!=(0xb7c+2450-0x150e));return(s-(0x9f1+326-0xb36));}byte*
-zUfiSms_SmsiAddrToStr(wms_address_s_type addr,byte*res_ptr,UINT8*type_of_addr){
-byte bcd_idx=(0x92d+1164-0xdb9);UINT8 temp=(0xb4d+2882-0x168f);*type_of_addr=
-(0x51f+606-0x77d);temp=(UINT8)((uint32)addr.number_type&(0xdcb+2009-0x159d));*
-type_of_addr=(UINT8)((*type_of_addr|temp)<<(0x9d2+4254-0x1a6c));temp=(UINT8)((
-uint32)addr.number_plan&(0x9db+3955-0x1947));*type_of_addr=*type_of_addr|temp;*
-type_of_addr=*type_of_addr|(0xd62+5217-0x2143);while(bcd_idx<addr.
-number_of_digits){if(addr.digits[bcd_idx]==(0x11ac+2270-0x1a80)){addr.digits[
-bcd_idx]=(0x1ad3+2666-0x253d);}res_ptr=zUfiSms_SmsiUtilitoa((uint32)addr.digits[
-bcd_idx],res_ptr,(0x594+3749-0x1429));bcd_idx++;}return res_ptr;}byte*
-zUfiSms_SmsiUtilitoaFill(word v,byte*rb_ptr){int n;byte c,*ptr;ptr=rb_ptr+
-(0xb24+4964-0x1e86);*ptr='\0';for(n=(0x41c+1992-0xbe4);n<(0x310+1134-0x77c);++n)
-{c=(byte)(v%(0x7c9+6469-0x2104));v/=(0xfa8+1677-0x162b);*--ptr=(c+
-((char)(0xceb+4482-0x1e3d)));}return rb_ptr+(0xb36+6886-0x261a);}void
-zUfiSms_SprintfTime(char*str_time,int len,int t){if(t<(0x1510+2262-0x1ddc)){
-snprintf(str_time,len,"\x30\x25\x78",t);}else{snprintf(str_time,len,"\x25\x78",t
-);}}static void zUfiSms_ParseDeliverConcat8(T_zUfiSms_UdhConcat8*concat_8,
-T_zUfiSms_DbStoreData*db_data){int mux=(0xe60+5788-0x24fc);concat_8->seq_num--;
-if(concat_8->total_sm>ZTE_WMS_CONCAT_SMS_COUNT_MAX){mux=(concat_8->seq_num-
-concat_8->seq_num%ZTE_WMS_CONCAT_SMS_COUNT_MAX)/ZTE_WMS_CONCAT_SMS_COUNT_MAX;}
-db_data->concat_sms=(0x16f7+1411-0x1c79);db_data->concat_info[
-(0x204+4250-0x129e)]=(0x77d+2123-0xec9)*mux+concat_8->msg_ref;db_data->
-concat_info[(0xb00+5445-0x2043)]=concat_8->seq_num%ZTE_WMS_CONCAT_SMS_COUNT_MAX+
-(0xa0d+5315-0x1ecf);db_data->concat_info[(0xe43+3393-0x1b83)]=concat_8->total_sm
--ZTE_WMS_CONCAT_SMS_COUNT_MAX*mux>ZTE_WMS_CONCAT_SMS_COUNT_MAX-
-(0x5ea+7958-0x24ff)?ZTE_WMS_CONCAT_SMS_COUNT_MAX:(concat_8->total_sm%
-ZTE_WMS_CONCAT_SMS_COUNT_MAX);}static void zUfiSms_ParserLangSs(wms_udh_s_type*
-user_data_header){if(user_data_header==NULL){return;}switch(user_data_header->u.
-nat_lang_ss.nat_lang_id){case WMS_UDH_NAT_LANG_PORTUGUESE:g_zUfiSms_Language=
-DCS_PORTUGUESE;break;default:break;}}static void zUfiSms_ParserLangLs(
-T_zUfiSms_Udh*user_data_header){if(user_data_header==NULL){return;}switch(
-user_data_header->u.nat_lang_ss.nat_lang_id){case WMS_UDH_NAT_LANG_PORTUGUESE:
-g_zUfiSms_Language=DCS_PORTUGUESE;break;default:break;}}static void
-zUfiSms_ParseDeliverConcat16(T_zUfiSms_UdhConcat16*concat_16,
-T_zUfiSms_DbStoreData*db_data){int mux=(0x1aef+2531-0x24d2);concat_16->seq_num--
-;db_data->concat_sms=(0x1ee8+1663-0x2566);
-#if (0xfa0+494-0x118e)
-db_data->concat_info[(0x2038+247-0x212f)]=concat_16->msg_ref;db_data->
-concat_info[(0xf4a+5755-0x25c4)]=concat_16->total_sm;db_data->concat_info[
-(0x1b8+2115-0x9f9)]=concat_16->seq_num;
+extern T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;
+
+//static pthread_mutex_t wmsts_mutex = PTHREAD_MUTEX_INITIALIZER;
+static const wms_udh_s_type *const_header;
+
+char g_zUfiSms_DigAscMap[16] =
+{
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+};
+
+extern SMS_PARAM g_zUfiSms_SendingSms;
+extern UINT16 g_zUfiSms_IsLanguageShift;
+extern int g_zUfiSms_Language;
+
+static int SerializeNumbers_sms(const char* pSrc, char* pDst, int nSrcLength);
+
+/**************************************************************************
+ * ¾Ö²¿º¯ÊýÔÐÍ *
+ **************************************************************************/
+ const unsigned short g_zUfiSms_AsciiToGsmdefaultTable[] =
+{
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',' ',' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', '!',0x22, '#', 0x02, '%', '&',0x27, '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
+ 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0x1b3c, 0x1b2f, 0x1b3e, 0x1b14, 0x11,
+ ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0x1b28, 0x1b40, 0x1b29,0x1b3d, ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 0x40, ' ', 0x01, 0x24, 0x03, ' ', 0x5F, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0B, ' ', ' ', ' ', ' ', ' ', ' ', 0x60,
+ ' ', ' ', ' ', ' ', 0x5B, 0x0E, 0x1C, 0x09, ' ', 0x1F, ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', 0x5D, ' ', ' ', ' ', ' ', 0x5C, ' ', ' ', ' ', ' ', ' ', 0x5E, ' ', ' ', 0x1E,
+ 0x7F, ' ', ' ', ' ', 0x7B, 0x0F, 0x1D, ' ', 0x04, 0x05, ' ', ' ', 0x07, ' ', ' ', ' ',
+ ' ', 0x7D, 0x08, ' ', ' ', ' ', 0x7C, ' ', 0x0C, 0x06, ' ', ' ', 0x7E, ' ', ' ', ' ',
+};
+
+ const unsigned short zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[][2] =
+{
+ { 0x09, 0x00E7 },
+ { 0x0A, 0x000C }, /* FORM FEED */
+ { 0x0D, 0x000D },
+ { 0x14, 0x005E }, /* CIRCUMFLEX ACCENT */
+ { 0x28, 0x007B }, /* LEFT CURLY BRACKET */
+ { 0x29, 0x007D }, /* RIGHT CURLY BRACKET */
+ { 0x2F, 0x005C }, /* REVERSE SOLIDUS */
+ { 0x3C, 0x005B }, /* LEFT SQUARE BRACKET */
+ { 0x3D, 0x007E }, /* TILDE */
+ { 0x3E, 0x005D }, /* RIGHT SQUARE BRACKET */
+ { 0x40, 0x007C }, /* VERTICAL LINE */
+ { 0x41, 0x00C1 },
+ { 0x49, 0x00CD },
+ { 0x4F, 0x00D3 },
+ { 0x55, 0x00DA },
+ { 0x61, 0x00E1 },
+ { 0x65, 0x20AC }, /* EURO SIGN */
+ { 0x69, 0x00ED },
+ { 0x6F, 0x00F3 },
+ { 0x75, 0x00FA },
+};
+
+ const unsigned short Ucs2_To_Gsm7_SPANISH_Table_UCS[][2] =
+{
+ { 0x10 , 0x0394 }, /* GREEK CAPITAL LETTER DELTA */
+ { 0x12 , 0x03A6 }, /* GREEK CAPITAL LETTER PHI */
+ { 0x13 , 0x0393 }, /* GREEK CAPITAL LETTER GAMMA */
+ { 0x14 , 0x039B }, /* GREEK CAPITAL LETTER LAMDA */
+ { 0x15 , 0x03A9 }, /* GREEK CAPITAL LETTER OMEGA */
+ { 0x16 , 0x03A0 }, /* GREEK CAPITAL LETTER PI */
+ { 0x17 , 0x03A8 }, /* GREEK CAPITAL LETTER PSI */
+ { 0x18 , 0x03A3 }, /* GREEK CAPITAL LETTER SIGMA */
+ { 0x19 , 0x0398 }, /* GREEK CAPITAL LETTER THETA */
+ { 0x1A , 0x039E }, /* GREEK CAPITAL LETTER XI */
+};
+
+ const unsigned char Ucs2_To_Gsm7_SPANISH_Table_ASC[] =
+{
+ /* +0x0 +0x1 +0x2 +0x3 +0x4 +0x5 +0x6 +0x7*/
+ /*0x00*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x08*/ NON_GSM, NON_GSM, 0x0a, NON_GSM, NON_GSM, 0x0d, NON_GSM, NON_GSM,
+ /* . . \r. . \d. . */
+ /*0x10*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x18*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x20*/ 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27,
+ /* ! " # $ % & ' */
+ /*0x28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ /* ( ) * + , - . / */
+ /*0x30*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0 1 2 3 4 5 6 7 */
+ /*0x38*/ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 8 9 : ; < = > ? */
+ /*0x40*/ 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* @ A B C D E F G */
+ /*0x48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* H I J K L M N O */
+ /*0x50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* P Q R S T U V W */
+ /*0x58*/ 0x58, 0x59, 0x5a, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x11, /* X Y Z . . . . _ */
+ /*0x60*/ NON_GSM, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* . a b c d e f g */
+ /*0x68*/ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* h i j k l m n o */
+ /*0x70*/ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* p q r s t u v w */
+ /*0x78*/ 0x78, 0x79, 0x7a, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* x y z . . . . . */
+ /*0x80*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x88*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x90*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x98*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xa0*/ 0x1b, 0x40, NON_GSM, 0x01, 0x24, 0x03, NON_GSM, 0x5f, /* . . . . . . . . */
+ /*0xa8*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xb0*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xb8*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x60, /* . . . . . . . . */
+ /*0xc0*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x5b, 0x0e, 0x1c, 0x09, /* . . . . . . . . */
+ /*0xc8*/ NON_GSM, 0x1f, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xd0*/ NON_GSM, 0x5d, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x5c, NON_GSM, /* . . . . . . . . */
+ /*0xd8*/ 0x0b, NON_GSM, NON_GSM, NON_GSM, 0x5e, NON_GSM, NON_GSM, 0x1e, /* . . . . . . . . */
+ /*0xe0*/ 0x7f, NON_GSM, NON_GSM, NON_GSM, 0x7b, 0x0f, 0x1d, NON_GSM, /* . . . . . . . . */
+ /*0xe8*/ 0x04, 0x05, NON_GSM, NON_GSM, 0x07, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xf0*/ NON_GSM, 0x7d, 0x08 , NON_GSM, NON_GSM, NON_GSM, 0x7c, NON_GSM, /* . . . . . . . . */
+ /*0xf8*/ 0x0c, 0x06, NON_GSM, NON_GSM, 0x7e, NON_GSM, NON_GSM, NON_GSM /* . . . . . . . . */
+};
+
+ const unsigned short zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[][2] =
+{
+ { 0x05, 0x00EA },
+ { 0x09, 0x00E7 },
+ { 0x0A, 0x000C }, /* FORM FEED */
+ { 0x0B, 0x00D4 },
+ { 0x0C, 0x00F4 },
+ { 0x0D, 0x000D },
+ { 0x0E, 0x00C1 },
+ { 0x0F, 0x00E1 },
+ { 0x12, 0x03A6 },
+ { 0x13, 0x0393 },
+ { 0x14, 0x005E }, /* CIRCUMFLEX ACCENT */
+ { 0x15, 0x03A9 },
+ { 0x16, 0x03A0 },
+ { 0x17, 0x03A8 },
+ { 0x18, 0x03A3 },
+ { 0x19, 0x0398 },
+ { 0x1F, 0x00CA },
+ { 0x28, 0x007B }, /* LEFT CURLY BRACKET */
+ { 0x29, 0x007D }, /* RIGHT CURLY BRACKET */
+ { 0x2F, 0x005C }, /* REVERSE SOLIDUS */
+ { 0x3C, 0x005B }, /* LEFT SQUARE BRACKET */
+ { 0x3D, 0x007E }, /* TILDE */
+ { 0x3E, 0x005D }, /* RIGHT SQUARE BRACKET */
+ { 0x40, 0x007C }, /* VERTICAL LINE */
+ { 0x41, 0x00C0 },
+ { 0x49, 0x00CD },
+ { 0x4F, 0x00D3 },
+ { 0x55, 0x00DA },
+ { 0x5B, 0x00C3 },
+ { 0x5C, 0x00D5 },
+ { 0x61, 0x00C2 },
+ { 0x65, 0x20AC }, /* EURO SIGN */
+ { 0x69, 0x00ED },
+ { 0x6F, 0x00F3 },
+ { 0x75, 0x00FA },
+ { 0x7B, 0x00E3 },
+ { 0x7C, 0x00F5 },
+ { 0x7F, 0x00E2 },
+};
+
+ const unsigned short Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[][2] =
+{
+ { 0x10 , 0x0394 }, /* GREEK CAPITAL LETTER DELTA */
+ //{ 0x12 , 0x03A6 }, /* GREEK CAPITAL LETTER PHI */
+ //{ 0x13 , 0x0393 }, /* GREEK CAPITAL LETTER GAMMA */
+ //{ 0x14 , 0x039B }, /* GREEK CAPITAL LETTER LAMDA */
+ { 0x15 , 0x22E1 },
+ //{ 0x16 , 0x03A0 }, /* GREEK CAPITAL LETTER PI */
+ //{ 0x17 , 0x03A8 }, /* GREEK CAPITAL LETTER PSI */
+ { 0x18 , 0x20AC },
+ //{ 0x19 , 0x0398 }, /* GREEK CAPITAL LETTER THETA */
+ //{ 0x1A , 0x039E }, /* GREEK CAPITAL LETTER XI */
+ { 0x65 , 0x20AC }, /* EURO SIGN */
+};
+ const unsigned char Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[] =
+{
+ /* +0x0 +0x1 +0x2 +0x3 +0x4 +0x5 +0x6 +0x7*/
+ /*0x00*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x08*/ NON_GSM, NON_GSM, 0x0a, NON_GSM, NON_GSM, 0x0d, NON_GSM, NON_GSM, /* . . \r. . \d. . */
+ /*0x10*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x18*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x20*/ 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27, /* ! " # $ % & ' */
+ /*0x28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* ( ) * + , - . / */
+ /*0x30*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0 1 2 3 4 5 6 7 */
+ /*0x38*/ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 8 9 : ; < = > ? */
+ /*0x40*/ 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* @ A B C D E F G */
+ /*0x48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* H I J K L M N O */
+ /*0x50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* P Q R S T U V W */
+ /*0x58*/ 0x58, 0x59, 0x5a, NON_GSM, 0x0017, NON_GSM, 0x0016, 0x11, /* X Y Z . . . . _ */
+ /*0x60*/ 0x007D, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* . a b c d e f g */
+ /*0x68*/ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* h i j k l m n o */
+ /*0x70*/ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* p q r s t u v w */
+ /*0x78*/ 0x78, 0x79, 0x7a, NON_GSM, 0x001A, NON_GSM, 0x0060, NON_GSM, /* x y z . . . . . */
+ /*0x80*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x88*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x90*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0x98*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xa0*/ 0x1b, NON_GSM_P,NON_GSM, 0x01, NON_GSM_P,0x03, NON_GSM, 0x5f, /* . . . . . . . . */
+ /*0xa8*/ NON_GSM, NON_GSM, 0x0012, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xb0*/ 0X0024, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xb8*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xc0*/ 0x0014, 0x000E, 0x001C, 0x005B, NON_GSM_P,NON_GSM_P,NON_GSM_P,0x0013, /* . . . . . . . . */
+ /*0xc8*/ NON_GSM, 0x1f, 0x001E, NON_GSM, NON_GSM, 0x0040, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xd0*/ NON_GSM, NON_GSM_P,NON_GSM, 0x0019, 0x000B, 0x005C, NON_GSM_P,NON_GSM, /* . . . . . . . . */
+ /*0xd8*/ NON_GSM_P,NON_GSM, 0x005D, NON_GSM, 0x5e, NON_GSM, NON_GSM, NON_GSM_P,/* . . . . . . . . */
+ /*0xe0*/ 0x7f, 0x000F, 0x001D, 0x007B, NON_GSM_P,NON_GSM_P,NON_GSM_P,0x09, /* . . . . . . . . */
+ /*0xe8*/ NON_GSM_P,0x05, 0x0004, NON_GSM, NON_GSM_P,0x0007, NON_GSM, NON_GSM, /* . . . . . . . . */
+ /*0xf0*/ NON_GSM, NON_GSM_P,NON_GSM_P,0x0008, 0x000C, 0x007C, NON_GSM_P,NON_GSM, /* . . . . . . . . */
+ /*0xf8*/ NON_GSM_P,NON_GSM_P,0x0006, NON_GSM, 0x7e, NON_GSM, NON_GSM, NON_GSM /* . . . . . . . . */
+};
+
+ const unsigned short zte_sms_GSMDefault_To_UCS2_Table_Ex[][2] =
+{
+ { 0x0A, 0x000C }, /* FORM FEED */
+ { 0x14, 0x005E }, /* CIRCUMFLEX ACCENT */
+ { 0x28, 0x007B }, /* LEFT CURLY BRACKET */
+ { 0x29, 0x007D }, /* RIGHT CURLY BRACKET */
+ { 0x2F, 0x005C }, /* REVERSE SOLIDUS */
+ { 0x3C, 0x005B }, /* LEFT SQUARE BRACKET */
+ { 0x3D, 0x007E }, /* TILDE */
+ { 0x3E, 0x005D }, /* RIGHT SQUARE BRACKET */
+ { 0x40, 0x007C }, /* VERTICAL LINE */
+ { 0x65, 0x20AC }, /* EURO SIGN */
+};
+
+ const unsigned short UCS2_To_GSMDefault_Table_UCS2[][2] =
+{
+ { 0x10 , 0x0394 }, /* GREEK CAPITAL LETTER DELTA */
+ { 0x12 , 0x03A6 }, /* GREEK CAPITAL LETTER PHI */
+ { 0x13 , 0x0393 }, /* GREEK CAPITAL LETTER GAMMA */
+ { 0x14 , 0x039B }, /* GREEK CAPITAL LETTER LAMDA */
+ { 0x15 , 0x03A9 }, /* GREEK CAPITAL LETTER OMEGA */
+ { 0x16 , 0x03A0 }, /* GREEK CAPITAL LETTER PI */
+ { 0x17 , 0x03A8 }, /* GREEK CAPITAL LETTER PSI */
+ { 0x18 , 0x03A3 }, /* GREEK CAPITAL LETTER SIGMA */
+ { 0x19 , 0x0398 }, /* GREEK CAPITAL LETTER THETA */
+ { 0x1A , 0x039E }, /* GREEK CAPITAL LETTER XI */
+};
+
+ const unsigned char UCS2_To_GSMDefault_Table_ASC[] =
+{
+ /* +0x0 +0x1 +0x2 +0x3 +0x4 +0x5 +0x6 +0x7*/
+ /*0x00*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x08*/ NON_GSM, NON_GSM, 0x0a, NON_GSM, NON_GSM, 0x0d, NON_GSM, NON_GSM,
+ /* . . \r. . \d. . */
+ /*0x10*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x18*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x20*/ 0x20, 0x21, 0x22, 0x23, 0x02, 0x25, 0x26, 0x27,
+ /* ! " # $ % & ' */
+ /*0x28*/ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ /* ( ) * + , - . / */
+ /*0x30*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ /* 0 1 2 3 4 5 6 7 */
+ /*0x38*/ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ /* 8 9 : ; < = > ? */
+ /*0x40*/ 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ /* @ A B C D E F G */
+ /*0x48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ /* H I J K L M N O */
+ /*0x50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ /* P Q R S T U V W */
+ /*0x58*/ 0x58, 0x59, 0x5a, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x11,
+ /* X Y Z . . . . _ */
+ /*0x60*/ NON_GSM, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ /* . a b c d e f g */
+ /*0x68*/ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ /* h i j k l m n o */
+ /*0x70*/ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ /* p q r s t u v w */
+ /*0x78*/ 0x78, 0x79, 0x7a, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* x y z . . . . . */
+ /*0x80*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x88*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x90*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0x98*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0xa0*/ 0x1b, 0x40, NON_GSM, 0x01, 0x24, 0x03, NON_GSM, 0x5f,
+ /* . . . . . . . . */
+ /*0xa8*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0xb0*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0xb8*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x60,
+ /* . . . . . . . . */
+ /*0xc0*/ NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x5b, 0x0e, 0x1c, 0x09,
+ /* . . . . . . . . */
+ /*0xc8*/ NON_GSM, 0x1f, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0xd0*/ NON_GSM, 0x5d, NON_GSM, NON_GSM, NON_GSM, NON_GSM, 0x5c, NON_GSM,
+ /* . . . . . . . . */
+ /*0xd8*/ 0x0b, NON_GSM, NON_GSM, NON_GSM, 0x5e, NON_GSM, NON_GSM, 0x1e,
+ /* . . . . . . . . */
+ /*0xe0*/ 0x7f, NON_GSM, NON_GSM, NON_GSM, 0x7b, 0x0f, 0x1d, NON_GSM,
+ /* . . . . . . . . */
+ /*0xe8*/ 0x04, 0x05, NON_GSM, NON_GSM, 0x07, NON_GSM, NON_GSM, NON_GSM,
+ /* . . . . . . . . */
+ /*0xf0*/ NON_GSM, 0x7d, 0x08 , NON_GSM, NON_GSM, NON_GSM, 0x7c, NON_GSM,
+ /* . . . . . . . . */
+ /*0xf8*/ 0x0c, 0x06, NON_GSM, NON_GSM, 0x7e, NON_GSM, NON_GSM, NON_GSM
+ /* . . . . . . . . */
+};
+
+ const unsigned short zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[] =
+{
+ /* 0x00 */ 0x0040, /* COMMERCIAL AT */
+ /* 0x01 */ 0x00A3, /* POUND SIGN */
+ /* 0x02 */ 0x0024, /* DOLLAR SIGN */
+ /* 0x03 */ 0x00A5, /* YEN SIGN */
+ /* 0x04 */ 0x00EA, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+ /* 0x05 */ 0x00E9, /* LATIN SMALL LETTER E WITH ACUTE */
+ /* 0x06 */ 0x00FA, /* LATIN SMALL LETTER U WITH ACUTE */
+ /* 0x07 */ 0x00ED, /* LATIN SMALL LETTER I WITH ACUTE */
+ /* 0x08 */ 0x00F3, /* LATIN SMALL LETTER O WITH ACUTE */
+ /* 0x09 */ 0x00E7, /* LATIN SMALL LETTER C WITH CEDILLA */
+ /* 0x0A */ 0x000A, /* LINE FEED */
+ /* 0x0B */ 0x00D4, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+ /* 0x0C */ 0x00F4, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+ /* 0x0D */ 0x000D, /* CARRIAGE RETURN */
+ /* 0x0E */ 0x00C1, /* LATIN CAPITAL LETTER A WITH ACUTE */
+ /* 0x0F */ 0x00E1, /* LATIN SMALL LETTER A WITH ACUTE */
+ /* 0x10 */ 0x0394, /* GREEK CAPITAL LETTER DELTA */
+ /* 0x11 */ 0x005F, /* LOW LINE */
+ /* 0x12 */ 0x00AA, /* FEMININE ORDINAL INDICATOR */
+ /* 0x13 */ 0x00C7,
+ /* 0x14 */ 0x00C0, /* LATIN CAPITAL LETTER A WITH GRAVE */
+ /* 0x15 */ 0x221E, /* INFINITY */
+ /* 0x16 */ 0x005E,
+ /* 0x17 */ 0x005C,
+ /* 0x18 */ 0x20AC,
+ /* 0x19 */ 0x00D3,
+ /* 0x1A */ 0x007C,
+ /* 0x1B */ 0x00A0, /* ESCAPE TO EXTENSION TABLE */
+ /* 0x1C */ 0x00C2, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+ /* 0x1D */ 0x00E2, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+ /* 0x1E */ 0x00CA, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+ /* 0x1F */ 0x00C9, /* LATIN CAPITAL LETTER E WITH ACUTE */
+ /* 0x20 */ 0x0020, /* SPACE */
+ /* 0x21 */ 0x0021, /* EXCLAMATION MARK */
+ /* 0x22 */ 0x0022, /* QUOTATION MARK */
+ /* 0x23 */ 0x0023, /* NUMBER SIGN */
+ /* 0x24 */ 0x00B0, /* MASCULINE ORDINAL INDICATOR */
+ /* 0x25 */ 0x0025, /* PERCENT SIGN */
+ /* 0x26 */ 0x0026, /* AMPERSAND */
+ /* 0x27 */ 0x0027, /* APOSTROPHE */
+ /* 0x28 */ 0x0028, /* LEFT PARENTHESIS */
+ /* 0x29 */ 0x0029, /* RIGHT PARENTHESIS */
+ /* 0x2A */ 0x002A, /* ASTERISK */
+ /* 0x2B */ 0x002B, /* PLUS SIGN */
+ /* 0x2C */ 0x002C, /* COMMA */
+ /* 0x2D */ 0x002D, /* HYPHEN-MINUS */
+ /* 0x2E */ 0x002E, /* FULL STOP */
+ /* 0x2F */ 0x002F, /* SOLIDUS */
+ /* 0x30 */ 0x0030, /* DIGIT ZERO */
+ /* 0x31 */ 0x0031, /* DIGIT ONE */
+ /* 0x32 */ 0x0032, /* DIGIT TWO */
+ /* 0x33 */ 0x0033, /* DIGIT THREE */
+ /* 0x34 */ 0x0034, /* DIGIT FOUR */
+ /* 0x35 */ 0x0035, /* DIGIT FIVE */
+ /* 0x36 */ 0x0036, /* DIGIT SIX */
+ /* 0x37 */ 0x0037, /* DIGIT SEVEN */
+ /* 0x38 */ 0x0038, /* DIGIT EIGHT */
+ /* 0x39 */ 0x0039, /* DIGIT NINE */
+ /* 0x3A */ 0x003A, /* COLON */
+ /* 0x3B */ 0x003B, /* SEMICOLON */
+ /* 0x3C */ 0x003C, /* LESS-THAN SIGN */
+ /* 0x3D */ 0x003D, /* EQUALS SIGN */
+ /* 0x3E */ 0x003E, /* GREATER-THAN SIGN */
+ /* 0x3F */ 0x003F, /* QUESTION MARK */
+ /* 0x40 */ 0x00CD, /* LATIN CAPITAL LETTER I WITH ACUTE */
+ /* 0x41 */ 0x0041, /* LATIN CAPITAL LETTER A */
+ /* 0x42 */ 0x0042, /* LATIN CAPITAL LETTER B */
+ /* 0x43 */ 0x0043, /* LATIN CAPITAL LETTER C */
+ /* 0x44 */ 0x0044, /* LATIN CAPITAL LETTER D */
+ /* 0x45 */ 0x0045, /* LATIN CAPITAL LETTER E */
+ /* 0x46 */ 0x0046, /* LATIN CAPITAL LETTER F */
+ /* 0x47 */ 0x0047, /* LATIN CAPITAL LETTER G */
+ /* 0x48 */ 0x0048, /* LATIN CAPITAL LETTER H */
+ /* 0x49 */ 0x0049, /* LATIN CAPITAL LETTER I */
+ /* 0x4A */ 0x004A, /* LATIN CAPITAL LETTER J */
+ /* 0x4B */ 0x004B, /* LATIN CAPITAL LETTER K */
+ /* 0x4C */ 0x004C, /* LATIN CAPITAL LETTER L */
+ /* 0x4D */ 0x004D, /* LATIN CAPITAL LETTER M */
+ /* 0x4E */ 0x004E, /* LATIN CAPITAL LETTER N */
+ /* 0x4F */ 0x004F, /* LATIN CAPITAL LETTER O */
+ /* 0x50 */ 0x0050, /* LATIN CAPITAL LETTER P */
+ /* 0x51 */ 0x0051, /* LATIN CAPITAL LETTER Q */
+ /* 0x52 */ 0x0052, /* LATIN CAPITAL LETTER R */
+ /* 0x53 */ 0x0053, /* LATIN CAPITAL LETTER S */
+ /* 0x54 */ 0x0054, /* LATIN CAPITAL LETTER T */
+ /* 0x55 */ 0x0055, /* LATIN CAPITAL LETTER U */
+ /* 0x56 */ 0x0056, /* LATIN CAPITAL LETTER V */
+ /* 0x57 */ 0x0057, /* LATIN CAPITAL LETTER W */
+ /* 0x58 */ 0x0058, /* LATIN CAPITAL LETTER X */
+ /* 0x59 */ 0x0059, /* LATIN CAPITAL LETTER Y */
+ /* 0x5A */ 0x005A, /* LATIN CAPITAL LETTER Z */
+ /* 0x5B */ 0x00C3, /* LATIN CAPITAL LETTER A WITH TILDE */
+ /* 0x5C */ 0x00D5, /* LATIN CAPITAL LETTER O WITH TILDE */
+ /* 0x5D */ 0x00DA, /* LATIN CAPITAL LETTER U WITH ACUTE */
+ /* 0x5E */ 0x00DC, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+ /* 0x5F */ 0x00A7, /* SECTION SIGN */
+ /* 0x60 */ 0x007E, /* INVERTED QUESTION MARK */
+ /* 0x61 */ 0x0061, /* LATIN SMALL LETTER A */
+ /* 0x62 */ 0x0062, /* LATIN SMALL LETTER B */
+ /* 0x63 */ 0x0063, /* LATIN SMALL LETTER C */
+ /* 0x64 */ 0x0064, /* LATIN SMALL LETTER D */
+ /* 0x65 */ 0x0065, /* LATIN SMALL LETTER E */
+ /* 0x66 */ 0x0066, /* LATIN SMALL LETTER F */
+ /* 0x67 */ 0x0067, /* LATIN SMALL LETTER G */
+ /* 0x68 */ 0x0068, /* LATIN SMALL LETTER H */
+ /* 0x69 */ 0x0069, /* LATIN SMALL LETTER I */
+ /* 0x6A */ 0x006A, /* LATIN SMALL LETTER J */
+ /* 0x6B */ 0x006B, /* LATIN SMALL LETTER K */
+ /* 0x6C */ 0x006C, /* LATIN SMALL LETTER L */
+ /* 0x6D */ 0x006D, /* LATIN SMALL LETTER M */
+ /* 0x6E */ 0x006E, /* LATIN SMALL LETTER N */
+ /* 0x6F */ 0x006F, /* LATIN SMALL LETTER O */
+ /* 0x70 */ 0x0070, /* LATIN SMALL LETTER P */
+ /* 0x71 */ 0x0071, /* LATIN SMALL LETTER Q */
+ /* 0x72 */ 0x0072, /* LATIN SMALL LETTER R */
+ /* 0x73 */ 0x0073, /* LATIN SMALL LETTER S */
+ /* 0x74 */ 0x0074, /* LATIN SMALL LETTER T */
+ /* 0x75 */ 0x0075, /* LATIN SMALL LETTER U */
+ /* 0x76 */ 0x0076, /* LATIN SMALL LETTER V */
+ /* 0x77 */ 0x0077, /* LATIN SMALL LETTER W */
+ /* 0x78 */ 0x0078, /* LATIN SMALL LETTER X */
+ /* 0x79 */ 0x0079, /* LATIN SMALL LETTER Y */
+ /* 0x7A */ 0x007A, /* LATIN SMALL LETTER Z */
+ /* 0x7B */ 0x00E3, /* LATIN SMALL LETTER A WITH TILDE */
+ /* 0x7C */ 0x00F5, /* LATIN SMALL LETTER O WITH TILDE */
+ /* 0x7D */ 0x0060, /* GRAVE ACCENT */
+ /* 0x7E */ 0x00FC, /* LATIN SMALL LETTER U WITH DIAERESIS */
+ /* 0x7F */ 0x00E0 /* LATIN SMALL LETTER A WITH GRAVE */
+};
+
+ const unsigned short zte_sms_GSMDefault_To_UCS2_Table[] =
+{
+ /* 0x00 */ 0x0040, /* COMMERCIAL AT */
+ /* 0x01 */ 0x00A3, /* POUND SIGN */
+ /* 0x02 */ 0x0024, /* DOLLAR SIGN */
+ /* 0x03 */ 0x00A5, /* YEN SIGN */
+ /* 0x04 */ 0x00E8, /* LATIN SMALL LETTER E WITH GRAVE */
+ /* 0x05 */ 0x00E9, /* LATIN SMALL LETTER E WITH ACUTE */
+ /* 0x06 */ 0x00F9, /* LATIN SMALL LETTER U WITH GRAVE */
+ /* 0x07 */ 0x00EC, /* LATIN SMALL LETTER I WITH GRAVE */
+ /* 0x08 */ 0x00F2, /* LATIN SMALL LETTER O WITH GRAVE */
+ /* 0x09 */ 0x00C7, /* LATIN SMALL LETTER C WITH CEDILLA */
+ /* 0x0A */ 0x000A, /* LINE FEED */
+ /* 0x0B */ 0x00D8, /* LATIN CAPITAL LETTER O WITH STROKE */
+ /* 0x0C */ 0x00F8, /* LATIN SMALL LETTER O WITH STROKE */
+ /* 0x0D */ 0x000D, /* CARRIAGE RETURN */
+ /* 0x0E */ 0x00C5, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+ /* 0x0F */ 0x00E5, /* LATIN SMALL LETTER A WITH RING ABOVE */
+ /* 0x10 */ 0x0394, /* GREEK CAPITAL LETTER DELTA */
+ /* 0x11 */ 0x005F, /* LOW LINE */
+ /* 0x12 */ 0x03A6, /* GREEK CAPITAL LETTER PHI */
+ /* 0x13 */ 0x0393, /* GREEK CAPITAL LETTER GAMMA */
+ /* 0x14 */ 0x039B, /* GREEK CAPITAL LETTER LAMDA */
+ /* 0x15 */ 0x03A9, /* GREEK CAPITAL LETTER OMEGA */
+ /* 0x16 */ 0x03A0, /* GREEK CAPITAL LETTER PI */
+ /* 0x17 */ 0x03A8, /* GREEK CAPITAL LETTER PSI */
+ /* 0x18 */ 0x03A3, /* GREEK CAPITAL LETTER SIGMA */
+ /* 0x19 */ 0x0398, /* GREEK CAPITAL LETTER THETA */
+ /* 0x1A */ 0x039E, /* GREEK CAPITAL LETTER XI */
+ /* 0x1B */ 0x00A0, /* ESCAPE TO EXTENSION TABLE */
+ /* 0x1C */ 0x00C6, /* LATIN CAPITAL LETTER AE */
+ /* 0x1D */ 0x00E6, /* LATIN SMALL LETTER AE */
+ /* 0x1E */ 0x00DF, /* LATIN SMALL LETTER SHARP S (German) */
+ /* 0x1F */ 0x00C9, /* LATIN CAPITAL LETTER E WITH ACUTE */
+ /* 0x20 */ 0x0020, /* SPACE */
+ /* 0x21 */ 0x0021, /* EXCLAMATION MARK */
+ /* 0x22 */ 0x0022, /* QUOTATION MARK */
+ /* 0x23 */ 0x0023, /* NUMBER SIGN */
+ /* 0x24 */ 0x00A4, /* CURRENCY SIGN */
+ /* 0x25 */ 0x0025, /* PERCENT SIGN */
+ /* 0x26 */ 0x0026, /* AMPERSAND */
+ /* 0x27 */ 0x0027, /* APOSTROPHE */
+ /* 0x28 */ 0x0028, /* LEFT PARENTHESIS */
+ /* 0x29 */ 0x0029, /* RIGHT PARENTHESIS */
+ /* 0x2A */ 0x002A, /* ASTERISK */
+ /* 0x2B */ 0x002B, /* PLUS SIGN */
+ /* 0x2C */ 0x002C, /* COMMA */
+ /* 0x2D */ 0x002D, /* HYPHEN-MINUS */
+ /* 0x2E */ 0x002E, /* FULL STOP */
+ /* 0x2F */ 0x002F, /* SOLIDUS */
+ /* 0x30 */ 0x0030, /* DIGIT ZERO */
+ /* 0x31 */ 0x0031, /* DIGIT ONE */
+ /* 0x32 */ 0x0032, /* DIGIT TWO */
+ /* 0x33 */ 0x0033, /* DIGIT THREE */
+ /* 0x34 */ 0x0034, /* DIGIT FOUR */
+ /* 0x35 */ 0x0035, /* DIGIT FIVE */
+ /* 0x36 */ 0x0036, /* DIGIT SIX */
+ /* 0x37 */ 0x0037, /* DIGIT SEVEN */
+ /* 0x38 */ 0x0038, /* DIGIT EIGHT */
+ /* 0x39 */ 0x0039, /* DIGIT NINE */
+ /* 0x3A */ 0x003A, /* COLON */
+ /* 0x3B */ 0x003B, /* SEMICOLON */
+ /* 0x3C */ 0x003C, /* LESS-THAN SIGN */
+ /* 0x3D */ 0x003D, /* EQUALS SIGN */
+ /* 0x3E */ 0x003E, /* GREATER-THAN SIGN */
+ /* 0x3F */ 0x003F, /* QUESTION MARK */
+ /* 0x40 */ 0x00A1, /* INVERTED EXCLAMATION MARK */
+ /* 0x41 */ 0x0041, /* LATIN CAPITAL LETTER A */
+ /* 0x42 */ 0x0042, /* LATIN CAPITAL LETTER B */
+ /* 0x43 */ 0x0043, /* LATIN CAPITAL LETTER C */
+ /* 0x44 */ 0x0044, /* LATIN CAPITAL LETTER D */
+ /* 0x45 */ 0x0045, /* LATIN CAPITAL LETTER E */
+ /* 0x46 */ 0x0046, /* LATIN CAPITAL LETTER F */
+ /* 0x47 */ 0x0047, /* LATIN CAPITAL LETTER G */
+ /* 0x48 */ 0x0048, /* LATIN CAPITAL LETTER H */
+ /* 0x49 */ 0x0049, /* LATIN CAPITAL LETTER I */
+ /* 0x4A */ 0x004A, /* LATIN CAPITAL LETTER J */
+ /* 0x4B */ 0x004B, /* LATIN CAPITAL LETTER K */
+ /* 0x4C */ 0x004C, /* LATIN CAPITAL LETTER L */
+ /* 0x4D */ 0x004D, /* LATIN CAPITAL LETTER M */
+ /* 0x4E */ 0x004E, /* LATIN CAPITAL LETTER N */
+ /* 0x4F */ 0x004F, /* LATIN CAPITAL LETTER O */
+ /* 0x50 */ 0x0050, /* LATIN CAPITAL LETTER P */
+ /* 0x51 */ 0x0051, /* LATIN CAPITAL LETTER Q */
+ /* 0x52 */ 0x0052, /* LATIN CAPITAL LETTER R */
+ /* 0x53 */ 0x0053, /* LATIN CAPITAL LETTER S */
+ /* 0x54 */ 0x0054, /* LATIN CAPITAL LETTER T */
+ /* 0x55 */ 0x0055, /* LATIN CAPITAL LETTER U */
+ /* 0x56 */ 0x0056, /* LATIN CAPITAL LETTER V */
+ /* 0x57 */ 0x0057, /* LATIN CAPITAL LETTER W */
+ /* 0x58 */ 0x0058, /* LATIN CAPITAL LETTER X */
+ /* 0x59 */ 0x0059, /* LATIN CAPITAL LETTER Y */
+ /* 0x5A */ 0x005A, /* LATIN CAPITAL LETTER Z */
+ /* 0x5B */ 0x00C4, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+ /* 0x5C */ 0x00D6, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+ /* 0x5D */ 0x00D1, /* LATIN CAPITAL LETTER N WITH TILDE */
+ /* 0x5E */ 0x00DC, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+ /* 0x5F */ 0x00A7, /* SECTION SIGN */
+ /* 0x60 */ 0x00BF, /* INVERTED QUESTION MARK */
+ /* 0x61 */ 0x0061, /* LATIN SMALL LETTER A */
+ /* 0x62 */ 0x0062, /* LATIN SMALL LETTER B */
+ /* 0x63 */ 0x0063, /* LATIN SMALL LETTER C */
+ /* 0x64 */ 0x0064, /* LATIN SMALL LETTER D */
+ /* 0x65 */ 0x0065, /* LATIN SMALL LETTER E */
+ /* 0x66 */ 0x0066, /* LATIN SMALL LETTER F */
+ /* 0x67 */ 0x0067, /* LATIN SMALL LETTER G */
+ /* 0x68 */ 0x0068, /* LATIN SMALL LETTER H */
+ /* 0x69 */ 0x0069, /* LATIN SMALL LETTER I */
+ /* 0x6A */ 0x006A, /* LATIN SMALL LETTER J */
+ /* 0x6B */ 0x006B, /* LATIN SMALL LETTER K */
+ /* 0x6C */ 0x006C, /* LATIN SMALL LETTER L */
+ /* 0x6D */ 0x006D, /* LATIN SMALL LETTER M */
+ /* 0x6E */ 0x006E, /* LATIN SMALL LETTER N */
+ /* 0x6F */ 0x006F, /* LATIN SMALL LETTER O */
+ /* 0x70 */ 0x0070, /* LATIN SMALL LETTER P */
+ /* 0x71 */ 0x0071, /* LATIN SMALL LETTER Q */
+ /* 0x72 */ 0x0072, /* LATIN SMALL LETTER R */
+ /* 0x73 */ 0x0073, /* LATIN SMALL LETTER S */
+ /* 0x74 */ 0x0074, /* LATIN SMALL LETTER T */
+ /* 0x75 */ 0x0075, /* LATIN SMALL LETTER U */
+ /* 0x76 */ 0x0076, /* LATIN SMALL LETTER V */
+ /* 0x77 */ 0x0077, /* LATIN SMALL LETTER W */
+ /* 0x78 */ 0x0078, /* LATIN SMALL LETTER X */
+ /* 0x79 */ 0x0079, /* LATIN SMALL LETTER Y */
+ /* 0x7A */ 0x007A, /* LATIN SMALL LETTER Z */
+ /* 0x7B */ 0x00E4, /* LATIN SMALL LETTER A WITH DIAERESIS */
+ /* 0x7C */ 0x00F6, /* LATIN SMALL LETTER O WITH DIAERESIS */
+ /* 0x7D */ 0x00F1, /* LATIN SMALL LETTER N WITH TILDE */
+ /* 0x7E */ 0x00FC, /* LATIN SMALL LETTER U WITH DIAERESIS */
+ /* 0x7F */ 0x00E0 /* LATIN SMALL LETTER A WITH GRAVE */
+};
+ /**************************************************************************
+* º¯ÊýÃû³Æ£º int Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º ×Ö½ÚÊý¾Ýת»»Îª¿É´òÓ¡×Ö·û´® £¬È磺{0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01} --> "C8329BFD0E01"
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´Êý¾ÝÖ¸Õë
+ pDst: Ä¿±ê×Ö·û´®Ö¸Õë
+ nSrcLength: Ô´Êý¾Ý³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int Bytes2String(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+ const char tab[]="0123456789ABCDEF"; // 0x0-0xfµÄ×Ö·û²éÕÒ±í
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i=0; i<nSrcLength; i++)
+ {
+ *pDst++ = tab[*pSrc >> 4]; // Êä³öµÍ4λ
+ *pDst++ = tab[*pSrc & 0x0f]; // Êä³ö¸ß4λ
+ pSrc++;
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nSrcLength * 2;
+}
+
+ /**************************************************************************
+* º¯ÊýÃû³Æ£º int String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º ¿É´òÓ¡×Ö·û´®×ª»»Îª×Ö½ÚÊý¾Ý £¬È磺"C8329BFD0E01" --> {0xC8, 0x32, 0x9B, 0xFD, 0x0E, 0x01}
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±êÊý¾ÝÖ¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int String2Bytes(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ for(i = 0; i < nSrcLength; i += 2)
+ {
+ // Êä³ö¸ß4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst = (*pSrc - '0') << 4;
+ }
+ else
+ {
+ *pDst = ((toupper(*pSrc) - 'A') + 10) << 4;
+ }
+
+ pSrc++;
+
+ // Êä³öµÍ4λ
+ if(*pSrc >= '0' && *pSrc <= '9')
+ {
+ *pDst |= *pSrc - '0';
+ }
+ else
+ {
+ *pDst |= (toupper(*pSrc) - 'A') + 10;
+ }
+
+ pSrc++;
+ pDst++;
+ }
+
+ // ·µ»ØÄ¿±êÊý¾Ý³¤¶È
+ return nSrcLength / 2;
+}
+
+int EncodeUcs2(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+ (void)String2Bytes(pSrc, pDst, (int)nSrcLength);
+ return nSrcLength / 2;
+}
+
+
+int Encode7bit(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ int nSrc; // Ô´×Ö·û´®µÄ¼ÆÊýÖµ
+ int nDst; // Ä¿±ê±àÂë´®µÄ¼ÆÊýÖµ
+ int nChar; // µ±Ç°ÕýÔÚ´¦ÀíµÄ×éÄÚ×Ö·û×Ö½ÚµÄÐòºÅ£¬·¶Î§ÊÇ0-7
+ unsigned char nLeft = 0; // ÉÏÒ»×Ö½Ú²ÐÓàµÄÊý¾Ý
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ // ¼ÆÊýÖµ³õʼ»¯
+ nSrc = 0;
+ nDst = 0;
+
+ // ½«Ô´´®Ã¿8¸ö×Ö½Ú·ÖΪһ×飬ѹËõ³É7¸ö×Ö½Ú
+ // Ñ»·¸Ã´¦Àí¹ý³Ì£¬Ö±ÖÁÔ´´®±»´¦ÀíÍê
+ // Èç¹û·Ö×é²»µ½8×Ö½Ú£¬Ò²ÄÜÕýÈ·´¦Àí
+ while(nSrc<nSrcLength)
+ {
+ // ȡԴ×Ö·û´®µÄ¼ÆÊýÖµµÄ×îµÍ3λ
+ nChar = nSrc & 7;
+
+ // ´¦ÀíÔ´´®µÄÿ¸ö×Ö½Ú
+ if(nChar == 0)
+ {
+ // ×éÄÚµÚÒ»¸ö×Ö½Ú£¬Ö»ÊDZ£´æÆðÀ´£¬´ý´¦ÀíÏÂÒ»¸ö×Ö½ÚʱʹÓÃ
+ nLeft = *pSrc;
+ if((g_zUfiSms_ConcatSms.total_msg > 1) && (nSrc == (nSrcLength -1)))
+ {
+ nDst++;
+ }
+ }
+ else
+ {
+ // ×éÄÚÆäËü×Ö½Ú£¬½«ÆäÓұ߲¿·ÖÓë²ÐÓàÊý¾ÝÏà¼Ó£¬µÃµ½Ò»¸öÄ¿±ê±àÂë×Ö½Ú
+ *pDst = (*pSrc << (8-nChar)) | nLeft;
+
+ // ½«¸Ã×Ö½ÚʣϵÄ×ó±ß²¿·Ö£¬×÷Ϊ²ÐÓàÊý¾Ý±£´æÆðÀ´
+ nLeft = *pSrc >> nChar;
+
+ // ÐÞ¸ÄÄ¿±ê´®µÄÖ¸ÕëºÍ¼ÆÊýÖµ
+ pDst++;
+ nDst++;
+ }
+
+ // ÐÞ¸ÄÔ´´®µÄÖ¸ÕëºÍ¼ÆÊýÖµ
+ pSrc++;
+ nSrc++;
+ }
+
+ // ·µ»ØÄ¿±ê´®³¤¶È
+ return nDst;
+}
+
+SINT32 zUfiSms_EncodePdu_DeliverReport(CHAR* pDst, UINT8 TP_FCS)
+{
+ SINT32 nLength = 0;
+ SINT32 nDstLength = 0; // Ä¿±êPDU´®³¤¶È
+ UINT8 buf[256] = {0}; // ÄÚ²¿ÓõĻº³åÇø
+
+ if(NULL == pDst)
+ {
+ return -1;
+ }
+ if(TP_FCS != 0x00)//rp_error
+ {
+ buf[0] = 0x00;
+ buf[1] = TP_FCS;
+ buf[2] = 0x00;
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 3);//tp_fcs
+ }
+ else
+ {
+ buf[0] = 0x00;
+ buf[1] = 0x00;
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 2);//tp_fcs
+ }
+
+ return nDstLength;
+}
+
+
+unsigned long zUfiSms_ConvertAsciiToGsmDefault(
+ const unsigned char * inputs, unsigned char * outputs, unsigned long len)
+{
+ unsigned long i = 0;
+ unsigned long j = 0;
+ unsigned long k = 0;
+
+ if(NULL == inputs || NULL == outputs)
+ {
+ printf("sms:invalid inputs");
+ return 0;
+ }
+ for( i = 0; i < len; i++)
+ {
+ j = inputs[i];
+ if (g_zUfiSms_AsciiToGsmdefaultTable[j] < 255)
+ {
+ outputs[k] = g_zUfiSms_AsciiToGsmdefaultTable[j];
+ }
+ else
+ {
+ outputs[k] = (g_zUfiSms_AsciiToGsmdefaultTable[j] & 0xff00) >> 8;
+ k ++;
+ outputs[k] = (g_zUfiSms_AsciiToGsmdefaultTable[j] & 0xff);
+ }
+ k++;
+ }
+ return k;
+}
+
+
+unsigned long zUfiSms_ConvertUcs2ToSpanish
+(
+ const unsigned char * def,
+ unsigned char * gsm_default,
+ unsigned long len
+)
+{
+ unsigned long i = 0;
+ unsigned long k = 0;
+ unsigned long p = 0;
+ unsigned long tmp = 0;
+ unsigned long s1 = 0, s2 = 0;
+ unsigned long q = 0;
+
+ s1 = sizeof(zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex)/sizeof(zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[0]);
+ s2 = sizeof(Ucs2_To_Gsm7_SPANISH_Table_UCS)/sizeof(Ucs2_To_Gsm7_SPANISH_Table_UCS[0]);
+
+
+ for(i = 0; i < len; i++)
+ {
+ if(def[i] == 0)
+ {
+ // is_find = 0;
+ i++;
+ if(Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]] != NON_GSM)
+ {
+ gsm_default[k] = Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]];
+ k++;
+ continue;
+ }
+ else if((Ucs2_To_Gsm7_SPANISH_Table_ASC[def[i]] == NON_GSM) && (def[i] == 0x20))
+ {
+ gsm_default[k] = 0x20;
+ k++;
+ continue;
+ }
+
+ for(q = 0; q < s1; q++)
+ {
+ if(def[i] == zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[q][1])
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = zte_sms_GSM7_SPANISH_To_UCS2_Table_Ex[q][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // is_find = 0;
+ tmp = (def[i] << 8) + def[i+1];
+ i++;
+ if(tmp == 0x20AC) /* EURO SIGN */
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = 0x65;
+ // is_find = 1;
+ k++;
+ }
+ for(p = 0; p < s2; p++)
+ {
+ if(tmp == Ucs2_To_Gsm7_SPANISH_Table_UCS[p][1])
+ {
+ gsm_default[k] = Ucs2_To_Gsm7_SPANISH_Table_UCS[p][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ k++;
+ }
+ gsm_default[k] = '\0';
+ return k;
+}
+
+ unsigned long zUfiSms_ConvertUcs2ToPortuguese
+(
+ const unsigned char * def,
+ unsigned char * gsm_default,
+ unsigned long len
+)
+{
+ unsigned long i = 0;
+ unsigned long k = 0;
+ unsigned long p = 0;
+ unsigned long tmp = 0;
+ unsigned long s1 = 0, s2 = 0;
+// unsigned long is_find = 0;
+ unsigned long q = 0;
+
+ s1 = sizeof(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex)/sizeof(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[0]);
+ s2 = sizeof(Ucs2_To_Gsm7_PORTUGUESE_Table_UCS)/sizeof(Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[0]);
+
+
+ for(i = 0; i < len; i++)
+ {
+ if(def[i] == 0)
+ {
+ // is_find = 0;
+ i++;
+ if(Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]] != NON_GSM)
+ {
+ gsm_default[k] = Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]];
+ k++;
+ continue;
+ }
+ else if((Ucs2_To_Gsm7_PORTUGUESE_Table_ASC[def[i]] == NON_GSM) && (def[i] == 0x20))
+ {
+ gsm_default[k] = 0x20;
+ k++;
+ continue;
+ }
+ for(q = 0; q < s1; q++)
+ {
+ if(def[i] == zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[q][1])
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[q][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // is_find = 0;
+ tmp = (def[i] << 8) + def[i+1];
+ i++;
+ if(tmp == 0x20AC) /* EURO SIGN */
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = 0x65;
+ // is_find = 1;
+ k++;
+ continue;
+ }
+ for(p = 0; p < s2; p++)
+ {
+ if(tmp == Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[p][1])
+ {
+ gsm_default[k] = Ucs2_To_Gsm7_PORTUGUESE_Table_UCS[p][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ k++;
+ }
+ gsm_default[k] = '\0';
+ return k;
+}
+
+ unsigned long zUfiSms_ConvertUcs2ToGsmDefault
+( const unsigned char * def, unsigned char * gsm_default, unsigned long len)
+{
+ unsigned long i = 0;
+ unsigned long k = 0;
+ unsigned long p = 0;
+ unsigned long tmp = 0;
+ unsigned long s1 = 0, s2 = 0;
+ unsigned long q = 0;
+
+ s1 = sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex[0]);
+ s2 = sizeof(UCS2_To_GSMDefault_Table_UCS2)/sizeof(UCS2_To_GSMDefault_Table_UCS2[0]);
+ for(i = 0; i < len; i++)
+ {
+ if(def[i] == 0)
+ {
+ // is_find = 0;
+ i++;
+ if(UCS2_To_GSMDefault_Table_ASC[def[i]] != NON_GSM)
+ {
+ gsm_default[k] = UCS2_To_GSMDefault_Table_ASC[def[i]];
+ k++;
+ continue;
+ }
+ else if((UCS2_To_GSMDefault_Table_ASC[def[i]] == NON_GSM) && (def[i] == 0x20))
+ {
+ gsm_default[k] = 0x20;
+ k++;
+ continue;
+ }
+ for(q = 0; q < s1; q++)
+ {
+ if(def[i] == zte_sms_GSMDefault_To_UCS2_Table_Ex[q][1])
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = zte_sms_GSMDefault_To_UCS2_Table_Ex[q][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ // is_find = 0;
+ tmp = (def[i] << 8) + def[i+1];
+ i++;
+ if(tmp == 0x20AC) /* EURO SIGN */
+ {
+ gsm_default[k] = 0x1b;
+ k++;
+ gsm_default[k] = 0x65;
+ // is_find = 1;
+ k++;
+ continue;
+ }
+ for(p = 0; p < s2; p++)
+ {
+ if(tmp == UCS2_To_GSMDefault_Table_UCS2[p][1])
+ {
+ gsm_default[k] = UCS2_To_GSMDefault_Table_UCS2[p][0];
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ k++;
+ }
+
+ gsm_default[k] = '\0';
+ return k;
+}
+
+UINT8 zUfiSms_TsIntToBcd( const UINT8 i )
+{
+ return (UINT8)(((i % 10) + ((i / 10) << 4)));
+}
+
+void zUfiSms_DecodeRelativeTime(UINT8 iValidTime, T_zUfiSms_TimeStamp *ptTimeStamp)
+{
+ uint32 i = 0;
+
+ if (ptTimeStamp != NULL)
+ {
+ memset( (void*) ptTimeStamp, 0, sizeof(wms_timestamp_s_type) );
+
+ if( iValidTime < 144 )
+ {
+ i = ( iValidTime + 1 ) * 5; /* minutes */
+ ptTimeStamp->hour = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i/60));
+ ptTimeStamp->minute = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i % 60));
+ }
+ else if (iValidTime < 167)
+ {
+ i = ( iValidTime - 143 ) * 30; /* minutes */
+ ptTimeStamp->hour = (UINT8)zUfiSms_TsIntToBcd((UINT8)(12 + i/60));
+ ptTimeStamp->minute = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i % 60));
+ }
+ else if (iValidTime < 197)
+ {
+ i = iValidTime - 166; /* days */
+ ptTimeStamp->month = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i/30));
+ ptTimeStamp->day = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i % 30));
+ }
+ else
+ {
+ i = ( iValidTime - 192 ) * 7; /* days */
+ ptTimeStamp->year = (UINT8)zUfiSms_TsIntToBcd((UINT8)(i/365));
+ ptTimeStamp->month = (UINT8)zUfiSms_TsIntToBcd((UINT8)((i%365)/30));
+ ptTimeStamp->day = (UINT8)zUfiSms_TsIntToBcd((UINT8)(( i % 365 ) % 30));
+ }
+
+ }
+ else
+ {
+ printf("null pointer in wms_ts_decode_relative_time");
+ }
+} /* wms_ts_decode_relative_time() */
+
+ /* ½«addrÖеÄ×Ö·ûת»¯ÎªÊý×Ö£¬´æ´¢ÔÚdigitsÖÐ */
+int zUfiSms_CharToInt(char *pCharArray, int iLen, unsigned char *pIntArray)
+{
+ int i = 0;
+
+ if (pIntArray == NULL || pCharArray == NULL)
+ {
+ return ZUFI_FAIL;
+ }
+
+ for (i = 0; i < iLen; i++)
+ {
+ pIntArray[i] = pCharArray[i] - '0';
+ }
+ return ZUFI_SUCC;
+}
+
+
+//gsm7¸ñʽµÄ¼Ç¼ÐÅÏ¢´æÈëÈ«¾ÖÊý¾Ýg_zUfiSms_SendingSmsÖÐ
+void zUfiSms_FillGlobalTpudGsm7
+(
+ T_zUfiSms_SubmitTpdu *ptSubmit,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ int i = 0;
+
+ if(ptConcatSms->total_msg > 1)
+ {
+ //¼¶Áª¶ÌÐÅ£¬¼Ó7¸ö×Ö½ÚµÄÍ·
+ g_zUfiSms_SendingSms.TP_UDHI = 1;
+ g_zUfiSms_SendingSms.TP_UD[0] = 5;
+ g_zUfiSms_SendingSms.TP_UD[1] = 5;
+ g_zUfiSms_SendingSms.TP_UD[2] = 3;
+ g_zUfiSms_SendingSms.TP_UD[3] = (char)ptDbSaveData->concat_info[0] % 0xff;
+ g_zUfiSms_SendingSms.TP_UD[4] = (char) ptConcatSms->total_msg;
+ g_zUfiSms_SendingSms.TP_UD[5] = (char) ptConcatSms->current_sending+1;
+ g_zUfiSms_SendingSms.TP_UD[6] = 6;
+
+ for(i = 0; i < ptSubmit->user_data.sm_len; i++)
+ {
+ g_zUfiSms_SendingSms.TP_UD[i+7] = ptSubmit->user_data.sm_data[i] ;
+ }
+ g_zUfiSms_SendingSms.TP_UDLength = ptSubmit->user_data.sm_len + 7;
+ }
+ else
+ {
+ for(i = 0; i < ptSubmit->user_data.sm_len; i++)
+ {
+ g_zUfiSms_SendingSms.TP_UD[i] = ptSubmit->user_data.sm_data[i] ;
+ }
+ g_zUfiSms_SendingSms.TP_UDLength = ptSubmit->user_data.sm_len;
+ }
+}
+//ucs2¸ñʽµÄ¼Ç¼ÐÅÏ¢´æÈëÈ«¾ÖÊý¾Ýg_zUfiSms_SendingSmsÖÐ
+void zUfiSms_FillGlobalTpudUcs2
+(
+ T_zUfiSms_SubmitTpdu *ptSubmit,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ if(ptConcatSms->total_msg > 1)
+ {
+ g_zUfiSms_SendingSms.TP_UDHI = 1;
+ g_zUfiSms_SendingSms.TP_UD[0] = 5;
+ g_zUfiSms_SendingSms.TP_UD[1] = 5;
+ g_zUfiSms_SendingSms.TP_UD[2] = 3;
+ g_zUfiSms_SendingSms.TP_UD[3] = (char) ptDbSaveData->concat_info[0] % 0xff;
+ g_zUfiSms_SendingSms.TP_UD[4] = (char) ptConcatSms->total_msg;
+ g_zUfiSms_SendingSms.TP_UD[5] = (char) ptConcatSms->current_sending+1;
+ (void)Bytes2String(ptSubmit->user_data.sm_data, &g_zUfiSms_SendingSms.TP_UD[6], ptSubmit->user_data.sm_len);
+ }
+ else
+ {
+ (void)Bytes2String(ptSubmit->user_data.sm_data, g_zUfiSms_SendingSms.TP_UD, ptSubmit->user_data.sm_len);
+ }
+}
+
+unsigned char zUfiSms_Low2High(unsigned char x)
+{
+ if (x >= 'a' && x < 'g')
+ {
+ x = (x - 'a') + 'A';
+ }
+
+ return x;
+}
+
+unsigned char zUfiSms_Char2Dec(unsigned char x)
+{
+ unsigned char d = 0;
+
+ if (x >= 'A' && x <'G')
+ {
+ d = (x - 'A') + 10;
+ }
+ else
+ {
+ d = x - '0';
+ }
+
+ return d;
+}
+
+unsigned char zUfiSms_Char2Byte(unsigned char a, unsigned char b)
+{
+ unsigned char data = 0;
+ unsigned char l = 0, h = 0;
+
+ a = zUfiSms_Low2High(a);
+ b = zUfiSms_Low2High(b);
+ h = zUfiSms_Char2Dec(a);
+ l = zUfiSms_Char2Dec(b);
+
+ data = h*16 + l;
+
+ return data;
+}
+
+
+void zUfiSms_Str2Bytes(unsigned char *text, int text_len,unsigned char *data, int data_len)
+{
+ int i = 0;
+
+ while (2 * i + 1 < text_len)
+ {
+ data[i] = zUfiSms_Char2Byte(text[2*i], text[2*i + 1]);
+ i ++;
+ }
+}
+
+
+//½«inputÖеÄ×Ö·û´®ÒÔ×Ö·ûcMatchCharΪ·Ö¸î·û½øÐзָ·Ö¸îºóÒÀ´Î·Åµ½Ö¸ÕëÊý×éoutputÖУ¬·µ»ØÖ¸ÕëÊý×éµÄ¸öÊý
+int zUfiSms_SplitString(char *input, char ***output,char cMatchChar)
+{
+ int src = 0;
+ int dst = 0;
+ int count = 0;
+ int size = 8;
+ char quoted = 0;
+ char **tmpout = NULL;
+
+ //ÏÈ·Ö8×Ö½Ú£¬ºóÐø¸ù¾ÝÐèÒªÀ´Ðø¿ª
+ *output = (char**)malloc(sizeof(char*) * size);
+ if(NULL == *output)
+ {
+ return -1;
+ }
+
+ /* split alias_string */
+ (*output)[count++] = input;
+ for (src = dst = 0; input[src];)
+ {
+ char cInputChar = input[src];
+ if (!quoted && cInputChar == cMatchChar)
+ {
+ input[dst++] = 0;
+ while (input[++src] && (int)isspace(input[src])) {} ; /* Ìø¹ý¿Õ¸ñ */
+ if (count >= size)
+ {
+ size += 16;
+ //*output = (char**)realloc(*output, sizeof(char*) * size);
+ //klocwork
+ tmpout = (char**)realloc(*output, sizeof(char*) * size);
+ if (NULL == tmpout) {
+ return -1;
+ }
+ *output = tmpout;
+ }
+ (*output)[count++] = input + dst;
+ }
+ else if (!quoted && (cInputChar == '\'' || cInputChar == '"'))
+ {
+ quoted = cInputChar;
+ src++;
+ }
+ else if (cInputChar == quoted)
+ {
+ quoted = 0;
+ src++;
+ }
+ else
+ {
+ if (cInputChar == '\\' && quoted != '\'')
+ {
+ src++;
+ cInputChar = input[src];
+ if (!cInputChar)
+ {
+ free(*output);
+ *output = NULL;
+ return -1;
+ }
+ }
+ input[dst++] = cInputChar;
+ src++;
+ }
+ }
+ input[dst] = 0;
+
+ if (quoted)
+ {
+ free(*output);
+ *output = NULL;
+ return -1;
+ }
+ return count;
+}
+
+int zUfiSms_atohex(char c)
+{
+ int result = 0;
+
+ if(c >= '0' && c <= '9')
+ {
+ result = c - '0';
+ }
+ else if(c>='a' && c<='f')
+ {
+ result = (c - 'a') + 10;
+ }
+ else if(c>='A' && c<='F')
+ {
+ result = (c - 'A') + 10;
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"zUfiSms_atohex error,can unknown char:%c\n",c);
+ return result;
+ }
+ return result;
+}
+
+/* °Ñin_ptrµÄÊý¾ÝÒ»¸ö²ðÁ½¸ö£¬·Ö³É16½øÖÆ£¬´æÈëout_ptr*/
+int zUfiSms_DispatchWtoi(unsigned char *in_ptr,int iLength,unsigned char *out_ptr)
+{
+ int low = 0;
+ int high = 0;
+
+ if (in_ptr == NULL || out_ptr == NULL)
+ {
+ printf("sms:invaild parameter\n");
+ return ZUFI_FAIL;
+ }
+
+ while (iLength > 0)
+ {
+ low = in_ptr[iLength - 1] & 0xf;
+ high = (in_ptr[iLength - 1] & 0xf0) >> 4;
+ out_ptr[2*iLength - 1] = g_zUfiSms_DigAscMap[low];
+ out_ptr[2*iLength - 2] = g_zUfiSms_DigAscMap[high];
+ iLength --;
+ }
+ return ZUFI_SUCC;
+}
+ unsigned int zte_wms_convert_PORTUGUESE_To_UCS2
+(
+ const unsigned char *gsmdef,
+ unsigned char *ucs2,
+ unsigned int len
+)
+{
+ unsigned int i = 0;
+ unsigned int j = 0;
+ unsigned int k = 0;
+ unsigned int p = 0;
+ unsigned int s = 0;
+// unsigned int is_find = 0;
+
+ s = sizeof(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex)/sizeof(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[0]);
+ for( i = 0; i < len; i++ )
+ {
+ j = gsmdef[i];
+ if (j == 0x1b)
+ {
+ i++;
+ for(p = 0; p < s; p++)
+ {
+ if(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][0] == gsmdef[i])
+ {
+ ucs2[k] = zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][1] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table_Ex[p][1]);
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ ucs2[k] = zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]);
+ }
+ k++;
+ }
+ ucs2[k] = '\0';
+
+ return k;
+}
+
+ unsigned int zte_wms_convert_PORTUGUESE_To_UCS2_USE_GSM7_SS_PORTU_LS
+(
+ const unsigned char *gsmdef,
+ unsigned char *ucs2,
+ unsigned int len
+)
+{
+ unsigned int i = 0;
+ unsigned int j = 0;
+ unsigned int k = 0;
+ unsigned int p = 0;
+ unsigned int s = 0;
+// unsigned int is_find = 0;
+
+ s = sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex[0]);
+ for( i = 0; i < len; i++ )
+ {
+ j = gsmdef[i];
+ if (j == 0x1b)
+ {
+ i++;
+ for(p = 0; p < s; p++)
+ {
+ if(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][0] == gsmdef[i])
+ {
+ ucs2[k] = zte_sms_GSMDefault_To_UCS2_Table_Ex[p][1] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][1]);
+ // is_find = 1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ ucs2[k] = zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSM7_PORTUGUESE_To_UCS2_Table[j]);
+ }
+ k++;
+ }
+ ucs2[k] = '\0';
+
+ return k;
+}
+
+ unsigned long zte_wms_convert_GSMDefault_to_UCS2
+(
+ const unsigned char *gsmdef,
+ unsigned char *ucs2,
+ unsigned long len
+)
+{
+ unsigned long i = 0;
+ unsigned long j = 0;
+ unsigned long k = 0;
+ unsigned long p = 0;
+ unsigned long s = 0;
+ unsigned long is_find = 0;
+
+ s = sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex)/sizeof(zte_sms_GSMDefault_To_UCS2_Table_Ex[0]);
+ for( i = 0; i < len; i++ )
+ {
+ j = gsmdef[i];
+ if (j == 0x1b)
+ {
+ i++;
+ for(p = 0; p < s; p++)
+ {
+ if(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][0] == gsmdef[i])
+ {
+ ucs2[k] = zte_sms_GSMDefault_To_UCS2_Table_Ex[p][1] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSMDefault_To_UCS2_Table_Ex[p][1]);
+ is_find = 1;
+ break;
+ }
+ }
+ if(!is_find)
+ {
+ at_print(LOG_DEBUG,"sms: data = %d not find in gsmdefault extension table\n", gsmdef[i]);
+ /*ʵ¼ÊÂëÁ÷¿ÉÄܾÍÊÇ0x1b£¬ÐèÒª»ØÍË´¦Àí*/
+ i--;
+ ucs2[k] = zte_sms_GSMDefault_To_UCS2_Table[j] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSMDefault_To_UCS2_Table[j]);
+ }
+ }
+ else
+ {
+ ucs2[k] = zte_sms_GSMDefault_To_UCS2_Table[j] >> 8;
+ k++;
+ ucs2[k] = (unsigned char)(zte_sms_GSMDefault_To_UCS2_Table[j]);
+ }
+ k++;
+ }
+ ucs2[k] = '\0';
+
+ return k;
+}
+
+
+void zUfiSms_ConvertUcs2(char *data, UINT16 sms_len, char *out_content)
+{
+ char ascii_content [2 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX+1] = {0};
+ UINT16 len = 0;
+
+ switch (g_zUfiSms_Language)
+ {
+ case DCS_PORTUGUESE:
+ if (g_zUfiSms_IsLanguageShift == WMS_UDH_NAT_LANG_SS)
+ {
+ len = zte_wms_convert_PORTUGUESE_To_UCS2 (
+ (const UINT8*)data,
+ (UINT8*)ascii_content,sms_len);
+ }
+ else if (g_zUfiSms_IsLanguageShift == WMS_UDH_NAT_LANG_LS)
+ {
+ len = zte_wms_convert_PORTUGUESE_To_UCS2_USE_GSM7_SS_PORTU_LS(
+ (const UINT8*)data,
+ (UINT8*)ascii_content,sms_len);
+ }
+ break;
+ /* added by zhangjingkun for locking shift 20130114 end*/
+ case DCS_USC:
+ default:
+ len = zte_wms_convert_GSMDefault_to_UCS2(
+ (const UINT8*)data,
+ (UINT8*)ascii_content,sms_len);
+ break;
+ }
+ (void)zUfiSms_DispatchWtoi((char*)ascii_content, len, (char*)out_content);
+}
+
+
+boolean zUfiSms_DecodeContent(char *msg_content, UINT16 sms_len, boolean isEsc, char *out_content)
+{
+ boolean endEsc = FALSE;
+ char *p = NULL;
+ static char data [1 + 160 + 1] = {0};
+ int len = 0;
+ //klocwork
+ if (msg_content == NULL || out_content == NULL || sms_len > 320 || sms_len < 2)
+ {
+ return endEsc;
+ }
+
+ len = sms_len;
+ memset(data, 0, 162);
+ p = data;
+ if (isEsc)
+ {
+ *p = 0x1b;
+ p++;
+ }
+ zUfiSms_Str2Bytes ((unsigned char *)msg_content, len, (unsigned char *)p, 160);
+ if (p[len / 2 -1] == 0x1b)
+ {
+ endEsc = TRUE;
+ }
+ zUfiSms_ConvertUcs2(data,len/2 + (isEsc?1:0) - (endEsc?1:0), out_content);
+ return endEsc;
+}
+
+byte * zUfiSms_SmsiUtilitoa
+(
+ uint32 v, /* Value to convert to ASCII */
+ byte *s, /* Pointer to string for result */
+ UINT16 r /* Conversion radix */
+)
+{
+ byte buf[33], c;
+ int n;
+
+ n = sizeof(buf) - 1;
+ buf[n] = '\0';
+
+ do
+ {
+ c = (byte) (v % r);
+ if (n <= 0)
+ {
+ printf("OVERFLOW " );
+ break;
+ }
+ buf[--n] = (byte) ( (c > 9) ? c + 'A' - 10 : c + '0');
+ }
+ while ( (v /= r) > 0);
+ while ( (*s++ = buf[n++]) != 0);
+
+ return (s-1);
+}
+
+byte* zUfiSms_SmsiAddrToStr
+(
+ wms_address_s_type addr, /* Address data structure */
+ byte * res_ptr, /* pointer to result buffer */
+ UINT8 * type_of_addr /* pointer to type of address field */
+)
+{
+ byte bcd_idx=0;
+ UINT8 temp = 0;
+
+ *type_of_addr = 0;
+ temp = (UINT8)((uint32)addr.number_type & 0x07);
+ *type_of_addr = (UINT8)((*type_of_addr | temp ) << 4);
+ temp = (UINT8)((uint32)addr.number_plan & 0x07);
+ *type_of_addr = *type_of_addr | temp ;
+ *type_of_addr = *type_of_addr | 0x80;
+
+ while(bcd_idx < addr.number_of_digits)
+ {
+ if (addr.digits[bcd_idx] == 0xa)
+ {
+ addr.digits[bcd_idx] = 0;
+ }
+ res_ptr = zUfiSms_SmsiUtilitoa((uint32) addr.digits[bcd_idx], res_ptr, 16);
+ bcd_idx++;
+ }
+
+ return res_ptr;
+}/* dsatetsismsi_addr_to_str */
+
+ byte * zUfiSms_SmsiUtilitoaFill(word v, byte *rb_ptr)
+{
+ int n;
+ byte c, *ptr;
+
+ ptr = rb_ptr + 2;
+ *ptr = '\0';
+
+ for (n = 0; n < 2; ++n)
+ {
+ c = (byte) (v % 10);
+ v /= 10;
+ *--ptr = (c + '0');
+ }
+
+ return rb_ptr + 2;
+}
+
+ void zUfiSms_SprintfTime(char *str_time, int len,int t)
+{
+ if (t < 10)
+ {
+ snprintf(str_time, len,"0%x", t);
+ }
+ else
+ {
+ snprintf(str_time, len,"%x", t);
+ }
+}
+
+
+/* parse the deliver 8bit header **/
+static void zUfiSms_ParseDeliverConcat8
+(
+ T_zUfiSms_UdhConcat8 *concat_8,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ int mux = 0;
+
+ concat_8->seq_num--;
+
+ if (concat_8->total_sm > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ mux = (concat_8->seq_num - concat_8->seq_num %
+ ZTE_WMS_CONCAT_SMS_COUNT_MAX) / ZTE_WMS_CONCAT_SMS_COUNT_MAX;
+ }
+
+ db_data->concat_sms = 1;
+ db_data->concat_info[0] = 255 * mux + concat_8->msg_ref;
+ db_data->concat_info[2] = concat_8->seq_num % ZTE_WMS_CONCAT_SMS_COUNT_MAX + 1;
+ db_data->concat_info[1] =
+ concat_8->total_sm - ZTE_WMS_CONCAT_SMS_COUNT_MAX * mux >
+ ZTE_WMS_CONCAT_SMS_COUNT_MAX -1 ? ZTE_WMS_CONCAT_SMS_COUNT_MAX :
+ (concat_8->total_sm % ZTE_WMS_CONCAT_SMS_COUNT_MAX);
+}
+
+
+static void zUfiSms_ParserLangSs( wms_udh_s_type *user_data_header)
+{
+ if (user_data_header == NULL)
+ {
+ return ;
+ }
+
+ switch(user_data_header->u.nat_lang_ss.nat_lang_id)
+ {
+ case WMS_UDH_NAT_LANG_PORTUGUESE:
+ g_zUfiSms_Language = DCS_PORTUGUESE;
+ break;
+ default:
+ break;
+ }
+}
+
+static void zUfiSms_ParserLangLs(T_zUfiSms_Udh *user_data_header)
+{
+ if (user_data_header == NULL)
+ {
+ return ;
+ }
+ switch(user_data_header->u.nat_lang_ss.nat_lang_id)
+ {
+ case WMS_UDH_NAT_LANG_PORTUGUESE:
+ g_zUfiSms_Language = DCS_PORTUGUESE;
+ break;
+ default:
+ break;
+ }
+
+}
+
+/** parse the deliver 16bit header ***/
+static void zUfiSms_ParseDeliverConcat16
+(
+ T_zUfiSms_UdhConcat16 *concat_16,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ int mux = 0;
+ concat_16->seq_num--;
+ db_data->concat_sms = 1;
+#if 0
+ db_data->concat_info[0] = concat_16->msg_ref;
+ db_data->concat_info[1] = concat_16->total_sm;
+ db_data->concat_info[2] = concat_16->seq_num;
#endif
-if(concat_16->total_sm>ZTE_WMS_CONCAT_SMS_COUNT_MAX){mux=(concat_16->seq_num-
-concat_16->seq_num%ZTE_WMS_CONCAT_SMS_COUNT_MAX)/ZTE_WMS_CONCAT_SMS_COUNT_MAX;}
-db_data->concat_info[(0x1d0+6786-0x1c52)]=(0x318+4582-0x13ff)*mux+concat_16->
-msg_ref;db_data->concat_info[(0x1bf4+1851-0x232d)]=concat_16->seq_num%
-ZTE_WMS_CONCAT_SMS_COUNT_MAX+(0x12ff+2568-0x1d06);db_data->concat_info[
-(0xb1a+5609-0x2102)]=concat_16->total_sm-ZTE_WMS_CONCAT_SMS_COUNT_MAX*mux>
-ZTE_WMS_CONCAT_SMS_COUNT_MAX-(0x1d0+162-0x271)?ZTE_WMS_CONCAT_SMS_COUNT_MAX:(
-concat_16->total_sm%ZTE_WMS_CONCAT_SMS_COUNT_MAX);}static int
-zUfiSms_ParseUdhiData(T_zUfiSms_Udh*user_data_header,T_zUfiSms_DbStoreData*
-db_data){if(NULL==user_data_header||NULL==db_data){printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73\x2e");return ZUFI_FAIL
-;}switch(user_data_header->header_id){case WMS_UDH_CONCAT_8:db_data->concat_sms=
-(0x322+5940-0x1a55);zUfiSms_ParseDeliverConcat8(&(user_data_header->u.concat_8),
-db_data);break;case WMS_UDH_CONCAT_16:db_data->concat_sms=(0xf16+5144-0x232d);
-zUfiSms_ParseDeliverConcat16(&(user_data_header->u.concat_16),db_data);break;
-case WMS_UDH_NAT_LANG_SS:g_zUfiSms_IsLanguageShift=WMS_UDH_NAT_LANG_SS;
-zUfiSms_ParserLangSs(user_data_header);break;case WMS_UDH_NAT_LANG_LS:
-g_zUfiSms_IsLanguageShift=WMS_UDH_NAT_LANG_LS;zUfiSms_ParserLangLs(
-user_data_header);break;default:printf(
-"\x6e\x6f\x74\x20\x73\x75\x70\x70\x6f\x72\x74\x20\x74\x68\x6f\x73\x65\x20\x75\x73\x65\x72\x20\x68\x65\x61\x64\x65\x72"
-);break;}return ZUFI_SUCC;}int zUfiSms_FormatDeliverDbdata(
-T_zUfiSms_ClientTsData*ts_data_ptr,T_zUfiSms_DbStoreData*db_data){int result=
-ZUFI_SUCC;wms_address_s_type*address_ptr=NULL;wms_gw_alphabet_e_type tp_dcs=
-WMS_GW_ALPHABET_MAX32;int i=(0x376+6528-0x1cf6);int ind=(0x120a+1353-0x1753);if(
-(NULL==ts_data_ptr)||(NULL==db_data)){printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73\x2e");return ZUFI_FAIL
-;}address_ptr=&(ts_data_ptr->u.gw_pp.u.deliver.address);if(
-WMS_NUMBER_INTERNATIONAL==address_ptr->number_type){memset(db_data->number,
-(0xa93+5959-0x21da),ZTE_WMS_ADDRESS_LEN_MAX+(0x196c+46-0x1999));db_data->number[
-(0x6bd+5378-0x1bbf)]=((char)(0x37f+8904-0x261c));for(i=(0x50+3684-0xeb4);i<
-address_ptr->number_of_digits;i++){if((0xdab+269-0xeae)==address_ptr->digits[i])
-{db_data->number[i+(0xf90+4937-0x22d8)]=((char)(0x24ed+47-0x24ec));}else{db_data
-->number[i+(0x400+5258-0x1889)]=((char)(0x10aa+4277-0x212f))+address_ptr->digits
-[i];}}}else if(WMS_NUMBER_ALPHANUMERIC==address_ptr->number_type){memcpy(db_data
-->number,address_ptr->digits,address_ptr->number_of_digits);}else{if(address_ptr
-->digit_mode==WMS_DIGIT_MODE_8_BIT){memcpy(&(db_data->number[(0xe83+2912-0x19e2)
-]),address_ptr->digits,address_ptr->number_of_digits);}else{for(i=
-(0x129f+2873-0x1dd8);i<address_ptr->number_of_digits;i++){if((0x3a3+6656-0x1d99)
-==address_ptr->digits[i]){db_data->number[i]=((char)(0xd2c+5449-0x2245));}else{
-db_data->number[i]=((char)(0x18ff+491-0x1aba))+address_ptr->digits[i];}}}}(void)
-zUfiSms_UtilTimeStamp(ts_data_ptr->u.gw_pp.u.deliver.timestamp,db_data->tp_scts,
-&db_data->julian_date);if(ts_data_ptr->u.gw_pp.u.deliver.
-user_data_header_present){db_data->tp_udhi=(0x16ff+1543-0x1d05);}else{db_data->
-tp_udhi=(0x23c4+457-0x258d);}if(db_data->tp_udhi==(0x8c2+7143-0x24a8)){for(ind=
-(0x885+6755-0x22e8);ind<ts_data_ptr->u.gw_pp.u.deliver.user_data.num_headers;ind
-++){result=zUfiSms_ParseUdhiData(&(ts_data_ptr->u.gw_pp.u.deliver.user_data.
-headers[ind]),db_data);if(ZTE_WMS_CONCAT_SMS_COUNT_MAX<db_data->concat_info[
-(0x1c2f+1550-0x223c)]){printf(
-"\x74\x68\x65\x20\x63\x6f\x6e\x63\x61\x74\x20\x73\x6d\x73\x20\x73\x65\x67\x6d\x65\x6e\x74\x20\x69\x73\x20\x25\x64\x2c\x61\x6e\x64\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x65\x6e\x20\x74\x68\x65\x20\x20\x73\x75\x70\x70\x6f\x72\x74\x65\x64\x20\x25\x64\x20\x73\x65\x67\x6d\x65\x6e\x74\x73\x2c\x73\x6f\x20\x64\x69\x64\x20\x6e\x6f\x74\x20\x64\x65\x61\x6c\x20\x74\x68\x65\x20\x63\x6f\x6e\x63\x61\x74\x20\x73\x6d\x73\x2e\x20"
-,db_data->concat_info[(0x51d+4611-0x171f)],ZTE_WMS_CONCAT_SMS_COUNT_MAX);if(
-WMS_STORAGE_TYPE_NV_V01==db_data->mem_store){zUfiSms_DelModemSms(db_data->index)
-;}result=ZUFI_FAIL;}}}tp_dcs=ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet;db_data
-->sms_class=ts_data_ptr->u.gw_pp.u.deliver.dcs.msg_class;if(
-WMS_GW_ALPHABET_8_BIT>=tp_dcs){db_data->tp_dcs=(unsigned char)
-(0x302+4607-0x1500);}else if(WMS_GW_ALPHABET_UCS2==tp_dcs){db_data->tp_dcs=(
-unsigned char)(0x1373+1572-0x1995);}else{printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x74\x70\x5f\x64\x63\x73\x3d\x25\x64",tp_dcs);}
-db_data->tp_pid=(unsigned char)ts_data_ptr->u.gw_pp.u.deliver.pid;if(ts_data_ptr
-->u.gw_pp.u.deliver.dcs.alphabet==WMS_GW_ALPHABET_UCS2){result=
-zUfiSms_DispatchWtoi(ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data,
-ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_len,db_data->sms_content);db_data->
-alphabet=WMS_GW_ALPHABET_UCS2;}else if(ts_data_ptr->u.gw_pp.u.deliver.dcs.
-alphabet==WMS_GW_ALPHABET_8_BIT){for(ind=(0x158c+4208-0x25fc);ind<ts_data_ptr->u
-.gw_pp.u.deliver.user_data.sm_len;ind++){db_data->sms_content[
-(0x869+4815-0x1b34)*ind]=((char)(0xc94+2137-0x14bd));db_data->sms_content[
-(0x62a+8253-0x2663)*ind+(0xed1+3084-0x1adc)]=((char)(0x22bf+958-0x264d));db_data
-->sms_content[(0x361+4192-0x13bd)*ind+(0xcb5+1069-0x10e0)]=g_zUfiSms_DigAscMap[(
-(ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data[ind]&(0x151c+4771-0x26cf))>>
-(0x72d+4676-0x196d))];db_data->sms_content[(0x882+6746-0x22d8)*ind+
-(0x36a+6882-0x1e49)]=g_zUfiSms_DigAscMap[(ts_data_ptr->u.gw_pp.u.deliver.
-user_data.sm_data[ind]&(0x533+5829-0x1be9))];db_data->alphabet=
-WMS_GW_ALPHABET_UCS2;}}else if(ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet==
-WMS_GW_ALPHABET_7_BIT_DEFAULT){result=zUfiSms_DispatchWtoi(ts_data_ptr->u.gw_pp.
-u.deliver.user_data.sm_data,ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_len,
-db_data->sms_content);db_data->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;db_data->
-tp_dcs=(unsigned char)(0x55a+469-0x72d);}return result;}int
-zUfiSms_FormatSubmitDbdata(T_zUfiSms_ClientTsData*ts_data_ptr,
-T_zUfiSms_DbStoreData*db_data){int result=ZUFI_SUCC;wms_address_s_type*
-address_ptr=NULL;wms_gw_alphabet_e_type tp_dcs=WMS_GW_ALPHABET_MAX32;int i=
-(0x460+8702-0x265e);int ind=(0xa58+803-0xd7b);if((NULL==ts_data_ptr)||(NULL==
-db_data)){printf("\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73\x2e")
-;return ZUFI_FAIL;}address_ptr=&(ts_data_ptr->u.gw_pp.u.submit.address);if((
-WMS_NUMBER_INTERNATIONAL==address_ptr->number_type)){db_data->number[
-(0xb44+1002-0xf2e)]=((char)(0x6b5+2327-0xfa1));for(i=(0x9d3+2722-0x1475);i<
-address_ptr->number_of_digits;i++){if((0x210c+463-0x22d1)==address_ptr->digits[i
-]){db_data->number[i+(0x1821+2253-0x20ed)]=((char)(0x178a+610-0x19bc));}else{
-db_data->number[i+(0x820+3210-0x14a9)]=((char)(0x2256+1078-0x265c))+address_ptr
-->digits[i];}}}else{for(i=(0x13b6+1066-0x17e0);i<address_ptr->number_of_digits;i
-++){if((0x1e21+2011-0x25f2)==address_ptr->digits[i]){db_data->number[i]=
-((char)(0x94+7176-0x1c6c));}else{db_data->number[i]=((char)(0xd9c+2473-0x1715))+
-address_ptr->digits[i];}}}tp_dcs=ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet;
-db_data->sms_class=ts_data_ptr->u.gw_pp.u.submit.dcs.msg_class;if(
-WMS_GW_ALPHABET_8_BIT>=tp_dcs){db_data->tp_dcs=(unsigned char)
-(0xe72+5642-0x247b);}else if(WMS_GW_ALPHABET_UCS2==tp_dcs){db_data->tp_dcs=(
-unsigned char)(0x12a6+4848-0x2594);}else{printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x74\x70\x5f\x64\x63\x73\x3d\x25\x64",tp_dcs);}
-db_data->tp_pid=(unsigned char)ts_data_ptr->u.gw_pp.u.submit.pid;db_data->
-msg_ref=(unsigned char)ts_data_ptr->u.gw_pp.u.submit.message_reference;if(
-ts_data_ptr->u.gw_pp.u.submit.user_data_header_present){db_data->tp_udhi=
-(0x2b7+8477-0x23d3);}else{db_data->tp_udhi=(0xda6+5827-0x2469);}if(db_data->
-tp_udhi==(0x17f2+2328-0x2109)){for(ind=(0xe5c+3417-0x1bb5);ind<ts_data_ptr->u.
-gw_pp.u.submit.user_data.num_headers;ind++){result=zUfiSms_ParseUdhiData(&(
-ts_data_ptr->u.gw_pp.u.submit.user_data.headers[ind]),db_data);if(
-ZTE_WMS_CONCAT_SMS_COUNT_MAX<db_data->concat_info[(0xc30+4860-0x1f2b)]){printf(
-"\x74\x68\x65\x20\x63\x6f\x6e\x63\x61\x74\x20\x73\x6d\x73\x20\x73\x65\x67\x6d\x65\x6e\x74\x20\x69\x73\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x65\x6e\x20\x74\x68\x65\x20\x20\x73\x75\x70\x70\x6f\x72\x74\x65\x64\x20\x73\x65\x67\x6d\x65\x6e\x74\x73\x2c\x73\x6f\x20\x64\x69\x64\x20\x6e\x6f\x74\x20\x64\x65\x61\x6c\x20\x74\x68\x65\x20\x63\x6f\x6e\x63\x61\x74\x20\x73\x6d\x73\x2e"
-);if(WMS_STORAGE_TYPE_NV_V01==db_data->mem_store){zUfiSms_DelModemSms(db_data->
-index);}result=ZUFI_FAIL;}}}if(ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet==
-WMS_GW_ALPHABET_UCS2){result=zUfiSms_DispatchWtoi(ts_data_ptr->u.gw_pp.u.submit.
-user_data.sm_data,ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len,db_data->
-sms_content);db_data->alphabet=WMS_GW_ALPHABET_UCS2;}else if(ts_data_ptr->u.
-gw_pp.u.submit.dcs.alphabet==WMS_GW_ALPHABET_8_BIT){for(ind=(0xc15+5549-0x21c2);
-ind<ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len;ind++){db_data->sms_content[
-(0x173f+2821-0x2240)*ind]=((char)(0x355+3022-0xef3));db_data->sms_content[
-(0x6fd+1633-0xd5a)*ind+(0x139d+1343-0x18db)]=((char)(0x40a+3535-0x11a9));db_data
-->sms_content[(0x176c+660-0x19fc)*ind+(0x303+4058-0x12db)]=g_zUfiSms_DigAscMap[(
-(ts_data_ptr->u.gw_pp.u.submit.user_data.sm_data[ind]&(0x1c90+2162-0x2412))>>
-(0xe68+5895-0x256b))];db_data->sms_content[(0xdea+765-0x10e3)*ind+
-(0xe67+2106-0x169e)]=g_zUfiSms_DigAscMap[(ts_data_ptr->u.gw_pp.u.submit.
-user_data.sm_data[ind]&(0x1f40+1657-0x25aa))];db_data->alphabet=
-WMS_GW_ALPHABET_UCS2;}}else if(ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet==
-WMS_GW_ALPHABET_7_BIT_DEFAULT){result=zUfiSms_DispatchWtoi(ts_data_ptr->u.gw_pp.
-u.submit.user_data.sm_data,ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len,
-db_data->sms_content);db_data->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;db_data->
-tp_dcs=(unsigned char)(0x3df+4127-0x13fc);}return result;}int InvertNumbers(
-const char*pSrc,char*pDst,int nSrcLength){int nDstLength;char ch;int i=
-(0xf87+4277-0x203c);if(pSrc==NULL||pDst==NULL||nSrcLength<(0x2248+1002-0x2632)){
-return-(0x1c8d+1650-0x22fe);}nDstLength=nSrcLength;for(i=(0xcc5+718-0xf93);i<
-nSrcLength;i+=(0x10c2+5270-0x2556)){ch=*pSrc++;*pDst++=*pSrc++;*pDst++=ch;}if(
-nSrcLength&(0x2+9904-0x26b1)){*(pDst-(0xa98+6226-0x22e8))=
-((char)(0x768+1322-0xc4c));nDstLength++;}*pDst='\0';return nDstLength;}int
-code_is_gsm7(const SMS_PARAM*pSrc,unsigned char buf[],int nLength){if(pSrc->
-TP_UDHI==(0x1b92+2230-0x2447)){buf[(0x1922+827-0x1c5a)]=(unsigned char)nLength;
-buf[(0x162f+2073-0x1e44)]=(unsigned char)pSrc->TP_UD[(0x190c+937-0x1cb5)];buf[
-(0x16c5+3609-0x24d9)]=(0x1eaa+16-0x1eba);buf[(0x14fa+1378-0x1a56)]=(unsigned
-char)pSrc->TP_UD[(0x215d+708-0x241f)];buf[(0x210a+431-0x22b2)]=(unsigned char)
-pSrc->TP_UD[(0x558+6767-0x1fc4)];buf[(0xa19+6600-0x23d9)]=(unsigned char)pSrc->
-TP_UD[(0x830+7206-0x2452)];buf[(0x19f+6471-0x1add)]=(unsigned char)pSrc->TP_UD[
-(0x1ea+898-0x567)];buf[(0xc97+5009-0x201e)]=(unsigned char)pSrc->TP_UD[
-(0xe1a+3835-0x1d0e)];buf[(0xf10+1556-0x151a)]=(unsigned char)(buf[
-(0x16f7+4117-0x2702)]<<(0x3c3+2153-0xc2b));nLength=nLength-(0x71+6277-0x18ef);
-nLength=Encode7bit(&(pSrc->TP_UD[(0xe31+5949-0x2566)]),&buf[(0x21c8+951-0x2574)]
-,nLength+(0x197+5128-0x159e))+(0xd6f+1466-0x1325)+(0x1776+933-0x1b15);
-#if (0x187+7156-0x1d7b)
-nLength+=(0x5e1+1835-0xd0a);
+ if (concat_16->total_sm > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ mux = (concat_16->seq_num - concat_16->seq_num %
+ ZTE_WMS_CONCAT_SMS_COUNT_MAX) / ZTE_WMS_CONCAT_SMS_COUNT_MAX;
+ }
+
+ db_data->concat_info[0] = 255 * mux + concat_16->msg_ref;
+ db_data->concat_info[2] = concat_16->seq_num % ZTE_WMS_CONCAT_SMS_COUNT_MAX + 1;
+ db_data->concat_info[1] =
+ concat_16->total_sm - ZTE_WMS_CONCAT_SMS_COUNT_MAX * mux >
+ ZTE_WMS_CONCAT_SMS_COUNT_MAX -1 ? ZTE_WMS_CONCAT_SMS_COUNT_MAX :
+ (concat_16->total_sm % ZTE_WMS_CONCAT_SMS_COUNT_MAX);
+}
+
+static int zUfiSms_ParseUdhiData
+(
+ T_zUfiSms_Udh *user_data_header,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ if(NULL == user_data_header || NULL == db_data)
+ {
+ printf("invalid inputs.");
+ return ZUFI_FAIL;
+ }
+ switch (user_data_header->header_id)
+ {
+ case WMS_UDH_CONCAT_8:
+ db_data->concat_sms = 1;
+ zUfiSms_ParseDeliverConcat8(&(user_data_header->u.concat_8), db_data);
+ break;
+ case WMS_UDH_CONCAT_16:
+ db_data->concat_sms = 1;
+ zUfiSms_ParseDeliverConcat16(&(user_data_header->u.concat_16), db_data);
+ break;
+ case WMS_UDH_NAT_LANG_SS:
+ g_zUfiSms_IsLanguageShift = WMS_UDH_NAT_LANG_SS;
+ zUfiSms_ParserLangSs(user_data_header);
+ break;
+
+ case WMS_UDH_NAT_LANG_LS:
+ g_zUfiSms_IsLanguageShift = WMS_UDH_NAT_LANG_LS;
+ zUfiSms_ParserLangLs(user_data_header);
+ break;
+
+ default:
+ printf("not support those user header");
+ break;
+ }
+ return ZUFI_SUCC;
+}
+
+int zUfiSms_FormatDeliverDbdata
+(
+ T_zUfiSms_ClientTsData *ts_data_ptr,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ int result = ZUFI_SUCC;
+ wms_address_s_type *address_ptr = NULL;
+ wms_gw_alphabet_e_type tp_dcs = WMS_GW_ALPHABET_MAX32;
+ int i = 0;
+ int ind = 0;
+
+ if((NULL == ts_data_ptr) || (NULL == db_data))
+ {
+ printf("invalid inputs.");
+ return ZUFI_FAIL;
+ }
+
+ //g_zUfiSms_Language = 0;
+
+ address_ptr = &(ts_data_ptr->u.gw_pp.u.deliver.address);/*set number address */
+ if(WMS_NUMBER_INTERNATIONAL == address_ptr->number_type)
+ {
+ memset(db_data->number, 0,ZTE_WMS_ADDRESS_LEN_MAX+1);
+ db_data->number[0] = '+';
+ for ( i = 0; i < address_ptr->number_of_digits; i++)
+ {
+ if (0x0a == address_ptr->digits[i])
+ {
+ db_data->number[i+1] = '0';
+ }
+ else
+ {
+ db_data->number[i+1] = '0'+address_ptr->digits[i];
+ }
+ }
+ }
+ else if (WMS_NUMBER_ALPHANUMERIC == address_ptr->number_type)
+ {
+ memcpy(db_data->number, address_ptr->digits, address_ptr->number_of_digits);
+ }
+ else
+ {
+ if (address_ptr->digit_mode == WMS_DIGIT_MODE_8_BIT)
+ {
+ memcpy(&(db_data->number[1]), address_ptr->digits, address_ptr->number_of_digits);
+ }
+ else
+ {
+ for ( i = 0; i < address_ptr->number_of_digits; i++)
+ {
+ if (0x0a == address_ptr->digits[i])
+ {
+ db_data->number[i] = '0';
+ }
+ else
+ {
+ db_data->number[i] = '0'+address_ptr->digits[i];
+ }
+ }
+ }
+ }
+ (void)zUfiSms_UtilTimeStamp(ts_data_ptr->u.gw_pp.u.deliver.timestamp,
+ db_data->tp_scts, &db_data->julian_date);
+
+ if (ts_data_ptr->u.gw_pp.u.deliver.user_data_header_present)
+ {
+ db_data->tp_udhi = 1;
+ }
+ else
+ {
+ db_data->tp_udhi = 0;
+ }
+ if (db_data->tp_udhi == 1)
+ {
+ for (ind = 0; ind < ts_data_ptr->u.gw_pp.u.deliver.user_data.num_headers; ind ++)
+ {
+ result = zUfiSms_ParseUdhiData(
+ &(ts_data_ptr->u.gw_pp.u.deliver.user_data.headers[ind]),
+ db_data);
+ if(ZTE_WMS_CONCAT_SMS_COUNT_MAX < db_data->concat_info[1])
+ {
+ printf("the concat sms segment is %d,and larger then the supported %d segments,so did not deal the concat sms. ",
+ db_data->concat_info[1],ZTE_WMS_CONCAT_SMS_COUNT_MAX);
+ if(WMS_STORAGE_TYPE_NV_V01 == db_data->mem_store)
+ {
+ zUfiSms_DelModemSms(db_data->index);
+ }
+ result = ZUFI_FAIL;
+ }
+ }
+ }
+ tp_dcs = ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet; /*dcs,pid*/
+ db_data->sms_class = ts_data_ptr->u.gw_pp.u.deliver.dcs.msg_class;//added by tianfuling 20130301 for sms class
+ if (WMS_GW_ALPHABET_8_BIT >= tp_dcs)
+ {
+ db_data->tp_dcs = (unsigned char)1; /*1-->ASCII, 2-->UNICODE*/
+ }
+ else if (WMS_GW_ALPHABET_UCS2 == tp_dcs)
+ {
+ db_data->tp_dcs = (unsigned char)2;
+ }
+ else
+ {
+ printf("invalid tp_dcs=%d",tp_dcs);
+ }
+ db_data->tp_pid = (unsigned char)ts_data_ptr->u.gw_pp.u.deliver.pid;
+
+ if (ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet == WMS_GW_ALPHABET_UCS2)
+ {
+ result = zUfiSms_DispatchWtoi(
+ ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data,
+ ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_len,
+ db_data->sms_content);
+ db_data->alphabet = WMS_GW_ALPHABET_UCS2; //added by tianfuling for extension character bug 20121126
+ }
+ else if (ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet == WMS_GW_ALPHABET_8_BIT)
+ {
+ for (ind = 0; ind < ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_len; ind ++)
+ {
+ db_data->sms_content[4 * ind] = '0';
+ db_data->sms_content[4 * ind + 1] = '0';
+ db_data->sms_content[4 * ind + 2] =
+ g_zUfiSms_DigAscMap[((ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data[ind] & 0xf0) >> 4)];
+ db_data->sms_content[4 * ind + 3] =
+ g_zUfiSms_DigAscMap[(ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data[ind] & 0xf)];
+ db_data->alphabet = WMS_GW_ALPHABET_UCS2;
+ }
+ }
+ else if (ts_data_ptr->u.gw_pp.u.deliver.dcs.alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT)
+ {
+ result = zUfiSms_DispatchWtoi(
+ ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_data,
+ ts_data_ptr->u.gw_pp.u.deliver.user_data.sm_len,
+ db_data->sms_content);
+ db_data->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ //modified by tianfuling for extension character bug 20121126 end
+ db_data->tp_dcs = (unsigned char)2;
+ }
+ return result;
+}
+
+int zUfiSms_FormatSubmitDbdata
+(
+ T_zUfiSms_ClientTsData *ts_data_ptr,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ int result = ZUFI_SUCC;
+ wms_address_s_type *address_ptr = NULL;
+ wms_gw_alphabet_e_type tp_dcs = WMS_GW_ALPHABET_MAX32;
+ int i = 0;
+ int ind = 0;
+
+ if((NULL == ts_data_ptr) || (NULL == db_data))
+ {
+ printf("invalid inputs.");
+ return ZUFI_FAIL;
+ }
+
+ /*set number address */
+ address_ptr = &(ts_data_ptr->u.gw_pp.u.submit.address);
+ if ((WMS_NUMBER_INTERNATIONAL == address_ptr->number_type))
+ {
+ db_data->number[0] = '+'; /*need a plus */
+ for ( i = 0; i < address_ptr->number_of_digits; i++)
+ {
+ if (0x0a == address_ptr->digits[i])
+ {
+ db_data->number[i+1] = '0';
+ }
+ else
+ {
+ db_data->number[i+1] = '0'+address_ptr->digits[i];
+ }
+ }
+ }
+ else
+ {
+ for ( i = 0; i < address_ptr->number_of_digits; i++)
+ {
+ if (0x0a == address_ptr->digits[i])
+ {
+ db_data->number[i] = '0';
+ }
+ else
+ {
+ db_data->number[i] = '0'+address_ptr->digits[i];
+ }
+ }
+ }
+
+ /*dcs,pid*/
+ tp_dcs = ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet;
+ db_data->sms_class = ts_data_ptr->u.gw_pp.u.submit.dcs.msg_class;//added by tianfuling 20130301 for sms class
+ if (WMS_GW_ALPHABET_8_BIT >= tp_dcs)
+ {
+ db_data->tp_dcs = (unsigned char)1; /*1-->ASCII, 2-->UNICODE*/
+ }
+ else if (WMS_GW_ALPHABET_UCS2 == tp_dcs)
+ {
+ db_data->tp_dcs = (unsigned char)2;
+ }
+ else
+ {
+ printf("invalid tp_dcs=%d",tp_dcs);
+ }
+ db_data->tp_pid = (unsigned char)ts_data_ptr->u.gw_pp.u.submit.pid;
+ /*db_data->tp_vp*/
+ db_data->msg_ref = (unsigned char)ts_data_ptr->u.gw_pp.u.submit.message_reference;
+ /*only for submit msg*/
+ if (ts_data_ptr->u.gw_pp.u.submit.user_data_header_present)
+ {
+ db_data->tp_udhi = 1;
+ }
+ else
+ {
+ db_data->tp_udhi = 0;
+ }
+ if (db_data->tp_udhi == 1)
+ {
+ for (ind = 0; ind < ts_data_ptr->u.gw_pp.u.submit.user_data.num_headers; ind ++)
+ {
+ result = zUfiSms_ParseUdhiData(&(ts_data_ptr->u.gw_pp.u.submit.user_data.headers[ind]),db_data);
+ if(ZTE_WMS_CONCAT_SMS_COUNT_MAX < db_data->concat_info[1])
+ {
+ printf("the concat sms segment is larger then the supported segments,so did not deal the concat sms.");
+ if(WMS_STORAGE_TYPE_NV_V01 == db_data->mem_store)
+ {
+ zUfiSms_DelModemSms(db_data->index);
+ }
+ result = ZUFI_FAIL;
+ }
+ }
+ }
+ if (ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet == WMS_GW_ALPHABET_UCS2)
+ {
+ result = zUfiSms_DispatchWtoi(
+ ts_data_ptr->u.gw_pp.u.submit.user_data.sm_data,
+ ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len,
+ db_data->sms_content);
+ db_data->alphabet = WMS_GW_ALPHABET_UCS2; //added by tianfuling for extension character bug 20121126
+ }
+ else if (ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet == WMS_GW_ALPHABET_8_BIT)
+ {
+
+ for (ind = 0; ind < ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len; ind ++)
+ {
+ db_data->sms_content[4 * ind] = '0';
+ db_data->sms_content[4 * ind + 1] = '0';
+ db_data->sms_content[4 * ind + 2] =
+ g_zUfiSms_DigAscMap[((ts_data_ptr->u.gw_pp.u.submit.user_data.sm_data[ind]
+ & 0xf0) >> 4)];
+ db_data->sms_content[4 * ind + 3] =
+ g_zUfiSms_DigAscMap[(ts_data_ptr->u.gw_pp.u.submit.user_data.sm_data[ind] & 0xf)];
+ db_data->alphabet = WMS_GW_ALPHABET_UCS2;
+ }
+ }
+ else if (ts_data_ptr->u.gw_pp.u.submit.dcs.alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT)
+ {
+ result = zUfiSms_DispatchWtoi(
+ ts_data_ptr->u.gw_pp.u.submit.user_data.sm_data,
+ ts_data_ptr->u.gw_pp.u.submit.user_data.sm_len,
+ db_data->sms_content);
+ db_data->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ //modified by tianfuling for extension character bug 20121126 end
+
+ db_data->tp_dcs = (unsigned char)2;
+ }
+ return result;
+}
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int InvertNumbers(const char* pSrc, char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º Õý³£Ë³ÐòµÄ×Ö·û´®×ª»»ÎªÁ½Á½µßµ¹µÄ×Ö·û´®£¬Èô³¤¶ÈÎªÆæÊý£¬²¹'F'´Õ³ÉżÊý£¬
+ È磺"8613851872468" --> "683158812764F8"
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±ê±àÂë´®Ö¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int InvertNumbers(const char* pSrc, char* pDst, int nSrcLength)
+{
+ int nDstLength; // Ä¿±ê×Ö·û´®³¤¶È
+ char ch; // ÓÃÓÚ±£´æÒ»¸ö×Ö·û
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ // ¸´ÖÆ´®³¤¶È
+ nDstLength = nSrcLength;
+
+ // Á½Á½µßµ¹
+ for(i=0; i<nSrcLength;i+=2)
+ {
+ ch = *pSrc++; // ±£´æÏȳöÏÖµÄ×Ö·û
+ *pDst++ = *pSrc++; // ¸´Öƺó³öÏÖµÄ×Ö·û
+ *pDst++ = ch; // ¸´ÖÆÏȳöÏÖµÄ×Ö·û
+ }
+
+ // Ô´´®³¤¶ÈÊÇÆæÊýÂð£¿
+ if(nSrcLength & 1)
+ {
+ *(pDst-2) = 'F'; // ²¹'F'
+ nDstLength++; // Ä¿±ê´®³¤¶È¼Ó1
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nDstLength;
+}
+
+int code_is_gsm7(const SMS_PARAM* pSrc, unsigned char buf[], int nLength)
+{
+ //begin add for concat sms
+ //int i = 0;
+ /*for(i=0;i<100;i++)
+ {
+ at_print(LOG_DEBUG, "in code_is_gsm7 buf[%d] is %d\n", i,buf[i]);
+ }*/
+ if (pSrc->TP_UDHI == 1)
+ {
+ buf[3] = (unsigned char) nLength;
+ buf[4] = (unsigned char) pSrc->TP_UD[0];
+ buf[5] = 0;
+ buf[6] = (unsigned char) pSrc->TP_UD[2];
+ buf[7] = (unsigned char) pSrc->TP_UD[3];
+ buf[8] = (unsigned char) pSrc->TP_UD[4];
+ buf[9] = (unsigned char) pSrc->TP_UD[5];
+ //buf[10] = (unsigned char) pSrc->TP_UD[6];//cov m
+ buf[10] = (unsigned char) pSrc->TP_UD[7];
+ buf[10] = (unsigned char) (buf[10] << 1); //µÚÒ»¸ö×Ö·û×óÒÆÒ»Î»
+
+ nLength = nLength - 7;
+ nLength = Encode7bit(&(pSrc->TP_UD[8]), &buf[11], nLength + 1) + 4 + 6; // ת»»TP-DAµ½Ä¿±êPDU´® // ת»»TP-DAµ½Ä¿±êPDU´®
+#if 0//ndef TSP_MODEL
+ nLength += 2;/// test for tsp
#endif
-}else{nLength=pSrc->TP_UDLength;buf[(0xe4+3570-0xed3)]=nLength;nLength=
-Encode7bit(pSrc->TP_UD,&buf[(0xdc6+3651-0x1c05)],nLength+(0x1fc5+1206-0x247a))+
-(0x8ca+7504-0x2616);}at_print(LOG_DEBUG,
-"\x62\x75\x66\x20\x69\x73\x20\x25\x73" "\n",buf);return nLength;}int
-code_is_ucs2(const SMS_PARAM*pSrc,unsigned char buf[],int nLength){nLength=
-strlen(pSrc->TP_UD);if(pSrc->TP_UDHI==(0x1d55+774-0x205a)){buf[
-(0x18fa+893-0x1c74)]=(unsigned char)nLength;buf[(0x1d5+548-0x3f5)]=(unsigned
-char)pSrc->TP_UD[(0x14e9+346-0x1643)];buf[(0x1764+836-0x1aa3)]=
-(0xe00+2514-0x17d2);buf[(0x422+4605-0x1619)]=(unsigned char)pSrc->TP_UD[
-(0x10f+7830-0x1fa3)];buf[(0x17d+4015-0x1125)]=(unsigned char)pSrc->TP_UD[
-(0x17ec+1072-0x1c19)];buf[(0x194d+500-0x1b39)]=(unsigned char)pSrc->TP_UD[
-(0xb88+5128-0x1f8c)];buf[(0xcfd+234-0xdde)]=(unsigned char)pSrc->TP_UD[
-(0x12cd+107-0x1333)];buf[(0x132d+1980-0x1ae6)]=(unsigned char)(EncodeUcs2(&(pSrc
-->TP_UD[(0x1059+4971-0x23be)]),&buf[(0x1783+2827-0x2284)],nLength-
-(0xd2+441-0x285))+(0x1b97+2351-0x24c0));nLength=buf[(0x2440+137-0x24c6)]+
-(0x976+147-0xa05);}else{buf[(0x381+6753-0x1ddf)]=EncodeUcs2(pSrc->TP_UD,&buf[
-(0x224+9147-0x25db)],nLength);nLength=buf[(0x1397+1822-0x1ab2)]+
-(0x905+2135-0x1158);}return nLength;}int Encode8bit(const char*pSrc,unsigned
-char*pDst,int nSrcLength){if(pSrc==NULL||pDst==NULL||nSrcLength<
-(0x2f4+8964-0x25f8)){return-(0x12e3+801-0x1603);}memcpy(pDst,pSrc,nSrcLength);
-return nSrcLength;}int EncodePdu_Submit(const SMS_PARAM*pSrc,char*pDst){int
-nLength=(0x98d+1320-0xeb5);int nDstLength=(0x3d7+3579-0x11d2);unsigned char buf[
-(0x136+7997-0x1f73)]={(0x34+3452-0xdb0)};char tmpSCA[(0x112f+4312-0x21e3)]={
-(0xe24+2416-0x1794)};int check_udl=(0x927+6403-0x222a);memset(tmpSCA,
-(0x25e6+284-0x2702),sizeof(tmpSCA));if(pSrc==NULL||pDst==NULL){return-
-(0xfe6+4458-0x214f);}
-#if (0x8f6+4269-0x19a2)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x20\x45\x6e\x63\x6f\x64\x65\x50\x64\x75\x5f\x53\x75\x62\x6d\x69\x74\x20\x6d\x61\x6b\x65\x20\x70\x64\x75\x20\x64\x61\x74\x61" "\n"
-);printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x74\x70\x75\x64\x3a\x25\x73" "\n",pSrc
-->TP_UD);printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x70\x64\x73\x74\x31\x3a\x25\x73" "\n",
-pDst);printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x73\x63\x61\x3a\x25\x73" "\n",pSrc->
-SCA);
-#endif
-nLength=strlen(pSrc->SCA);buf[(0xb01+4137-0x1b2a)]=(char)(((nLength)&
-(0x8e5+362-0xa4e))==(0x42a+1043-0x83d)?(nLength):nLength+(0x13a7+2690-0x1e28))/
-(0x98c+1300-0xe9e)+(0xa74+3277-0x1740);buf[(0xf50+3288-0x1c27)]=
-(0x10c2+5623-0x2638);strncpy(tmpSCA,pSrc->SCA,sizeof(tmpSCA)-(0x450+2753-0xf10))
-;if(!(strncmp(pSrc->SCA,"\x30\x30\x38\x36",(0x1330+3098-0x1f46)))){memset(tmpSCA
-,(0x34a+2724-0xdee),sizeof(tmpSCA));nLength=nLength-(0xb6+5008-0x1445);
-#if (0xcac+1693-0x1348)
-nLength=nLength-(0x23c+4034-0x11fd);strncpy(tmpSCA,&(pSrc->SCA[
-(0x16e2+1518-0x1cce)]),sizeof(tmpSCA)-(0x297+731-0x571));
+ }
+ else
+ {
+ // 7-bit±àÂ뷽ʽ
+ nLength = pSrc->TP_UDLength;
+ buf[3] = nLength;
+ //at_print(LOG_DEBUG, "when set buf[3] buf is %d\n", buf);
+ /* for(i=0;i<100;i++)
+ {
+ at_print(LOG_DEBUG, "when set buf[3] buf[%d] is %d.\n", i,buf[i]);
+ }*/
+ nLength = Encode7bit(pSrc->TP_UD, &buf[4], nLength+1)+ 4; // GSM7±àÂ룬ת»»TP-UDµ½Ä¿±êPDU´®
+ }
+ //end add for concat sms
+ at_print(LOG_DEBUG, "buf is %s\n", buf);
+ return nLength;
+}
+int code_is_ucs2(const SMS_PARAM* pSrc,unsigned char buf[], int nLength)
+{
+ //begin add for concat sms
+ nLength = strlen(pSrc->TP_UD);
+ if (pSrc->TP_UDHI == 1)
+ {
+ buf[3] = (unsigned char) nLength;
+ buf[4] = (unsigned char) pSrc->TP_UD[0];
+ buf[5] = 0;
+ buf[6] = (unsigned char) pSrc->TP_UD[2];
+ buf[7] = (unsigned char) pSrc->TP_UD[3];
+ buf[8] = (unsigned char) pSrc->TP_UD[4];
+ buf[9] = (unsigned char) pSrc->TP_UD[5];
+ buf[3] = (unsigned char) (EncodeUcs2(&(pSrc->TP_UD[6]), &buf[10], nLength-6) + 6); // ת»»TP-DAµ½Ä¿±êPDU´®,nLengthµÈÓڸöÎÊý¾Ý³¤¶È
+ nLength = buf[3] + 4;
+ }
+ else
+ {
+ // UCS2±àÂ뷽ʽ
+
+ buf[3] = EncodeUcs2(pSrc->TP_UD, &buf[4], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ nLength = buf[3] + 4; // nLengthµÈÓڸöÎÊý¾Ý³¤¶È
+
+
+ }
+ //end add for concat sms
+ return nLength;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int Encode8bit(const char* pSrc, unsigned char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º GSM8λ±àÂë
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±ê±àÂë´®Ö¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int Encode8bit(const char* pSrc, unsigned char* pDst, int nSrcLength)
+{
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ // ¼òµ¥¸´ÖÆ
+ memcpy(pDst, pSrc, nSrcLength);
+
+ return nSrcLength;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int EncodePdu_Submit(const SM_PARAM* pSrc, char* pDst)
+* ¹¦ÄÜÃèÊö£º PDU±àÂ룬ÓÃÓÚ±àÖÆ Submit ¶ÌÏûÏ¢
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ const SM_PARAM* pSrc: ¶ÌÏûÏ¢½á¹¹ÃèÊö £¬Ô´PDU²ÎÊýÖ¸Õë
+ pDst: Ä¿±ê±àÂë´®Ö¸Õë
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+* 2005/9/20 V1.0 ÅËÇÙ¸ñ Ð޸ĸú¯Êý
+**************************************************************************/
+int EncodePdu_Submit(const SMS_PARAM* pSrc, char* pDst)
+{
+ int nLength = 0; // ÄÚ²¿ÓõĴ®³¤¶È
+ int nDstLength = 0; // Ä¿±êPDU´®³¤¶È
+ unsigned char buf[256] = {0}; // ÄÚ²¿ÓõĻº³åÇø
+ char tmpSCA[36] = {0};
+ int check_udl = 0;
+ memset(tmpSCA,0,sizeof(tmpSCA));
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL)
+ {
+ return -1;
+ }
+ #if 1//corem for debug
+ printf("[SMScorem] EncodePdu_Submit make pdu data\n");
+ printf("[SMScorem]tpud:%s\n",pSrc->TP_UD);
+ printf("[SMScorem]pdst1:%s\n",pDst);
+ printf("[SMScorem]sca:%s\n",pSrc->SCA);
+ #endif
+ // SMSCµØÖ·ÐÅÏ¢¶Î
+ nLength = strlen(pSrc->SCA); // SMSCµØÖ·×Ö·û´®µÄ³¤¶È
+ buf[0] = (char)(((nLength) & 1) == 0 ? (nLength) : nLength+1) / 2 + 1; // SMSCµØÖ·ÐÅÏ¢³¤¶È
+ buf[1] = 0x81; // ¹Ì¶¨: Óùú¼Ê¸ñʽºÅÂë
+ strncpy(tmpSCA,pSrc->SCA,sizeof(tmpSCA)-1);
+ //´¦Àí0086·¢¶ÌÏûϢʱ·¢ËÍʧ°ÜµÄÎÊÌ⣬°Ñ0086¸ÄΪ+86·¢ÏÂÈ¥ ÅËÇÙ¸ñ 2005.9.20
+ if(!(strncmp(pSrc->SCA , "0086",4)))
+ {
+ memset(tmpSCA,0,sizeof(tmpSCA));
+ nLength = nLength - 1;
+#if 1//def TSP_MODEL /*add by sunxj delete '+' in SCA,20120718*/
+ nLength = nLength - 1;
+ strncpy(tmpSCA,&(pSrc->SCA[2]),sizeof(tmpSCA)-1);
#else
-tmpSCA[(0x189f+252-0x199b)]=((char)(0x2073+880-0x23b8));strcpy(&(tmpSCA[
-(0x969+728-0xc40)]),&(pSrc->SCA[(0xbd3+82-0xc23)]));
+ tmpSCA[0] = '+';
+ strcpy(&(tmpSCA[1]),&(pSrc->SCA[2]));
#endif
-buf[(0x3f4+2304-0xcf4)]=(char)((nLength&(0x6a9+8212-0x26bc))==
-(0x18d9+1120-0x1d39)?nLength:nLength+(0x136a+1711-0x1a18))/(0xdd1+1127-0x1236)+
-(0xe21+601-0x1079);buf[(0x7b+1206-0x530)]=(0x13af+1035-0x1729);}else if(
-((char)(0xa82+5511-0x1fde))==pSrc->SCA[(0x976+5542-0x1f1c)]){memset(tmpSCA,
-(0x148d+1970-0x1c3f),sizeof(tmpSCA));
-#if (0x1348+4834-0x2629)
-nLength=nLength-(0x5d+2250-0x926);strncpy(tmpSCA,&(pSrc->SCA[(0x39a+880-0x709)])
-,sizeof(tmpSCA)-(0x75+5172-0x14a8));
+ buf[0] = (char)((nLength & 1) == 0 ? nLength : nLength + 1) / 2 + 1; // SMSCµØÖ·ÐÅÏ¢³¤¶È
+ buf[1] = 0x91;
+
+ }
+ else if('+' == pSrc->SCA[0])
+ {
+ memset(tmpSCA,0,sizeof(tmpSCA));
+#if 1//def TSP_MODEL /*add by sunxj delete '+' in SCA,20120718*/
+ nLength = nLength - 1;
+ strncpy(tmpSCA,&(pSrc->SCA[1]),sizeof(tmpSCA)-1);
#else
-strcpy(tmpSCA,pSrc->SCA);
+ strcpy(tmpSCA,pSrc->SCA);
#endif
-buf[(0x79d+2313-0x10a6)]=(char)((nLength&(0x1d4+3054-0xdc1))==
-(0x1b43+834-0x1e85)?(nLength):nLength+(0x2673+67-0x26b5))/(0x4ea+5768-0x1b70)+
-(0x798+7767-0x25ee);buf[(0x1c2c+1204-0x20df)]=(0x8bc+836-0xb6f);}
-#if (0x809+7113-0x23d1)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x70\x64\x73\x74\x32\x3a\x25\x73" "\n",
-pDst);
+ buf[0] = (char)((nLength & 1) == 0 ? (nLength) : nLength+1) / 2 + 1; // SMSCµØÖ·ÐÅÏ¢³¤¶È
+ buf[1] = 0x91; // ¹Ì¶¨: Óùú¼Ê¸ñʽºÅÂë
+ }
+ #if 1//corem for debug
+ printf("[SMScorem]pdst2:%s\n",pDst);
+ #endif
+ if (nLength < 1 || nLength >= sizeof(tmpSCA))//klocwork
+ return -1;
+ nDstLength = Bytes2String(buf, pDst, 2); // ת»»2¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(tmpSCA, &pDst[nDstLength], nLength); // ת»»SMSCºÅÂ뵽Ŀ±êPDU´®
+
+ #if 1//corem for debug
+ printf("[SMScorem]pdst3:%s\n",pDst);
+ #endif
+ // TPDU¶Î»ù±¾²ÎÊý¡¢Ä¿±êµØÖ·µÈ
+
+ if(pSrc->TPA[0] == '+')
+ {
+ nLength = strlen(&(pSrc->TPA[1])); // TP-DAµØÖ·×Ö·û´®µÄ³¤¶È
+ }
+ else
+ {
+ nLength = strlen(pSrc->TPA); // TP-DAµØÖ·×Ö·û´®µÄ³¤¶È
+ }
+ //begin add for concat sms
+ if (pSrc->TP_UDHI == 0)
+ {
+ if (pSrc->TP_SRR == 0) //²»ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ buf[0] = 0x11;
+ }
+
+ if (pSrc->TP_SRR == 1) //ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ buf[0] = 0x31;
+ }
+ }
+ if (pSrc->TP_UDHI == 1)
+ {
+ if (pSrc->TP_SRR == 0) //²»ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ buf[0] = 0x51;
+ }
+
+ if (pSrc->TP_SRR == 1) //ÒªÇó·¢ËÍ״̬±¨¸æ
+ {
+ buf[0] = 0x71;
+ }
+ }
+
+ //end add for concat sms
+ buf[1] = 0; // TP-MR=0
+ buf[2] = (char)nLength; // Ä¿±êµØÖ·Êý×Ö¸öÊý(TP-DAµØÖ·×Ö·û´®ÕæÊµ³¤¶È)
+
+ if(pSrc->TPA[0] == '+')
+ {
+ buf[3] = 0x91; // ¹Ì¶¨: ¹ú¼ÊºÅÂë¸ñʽ
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 4); // ת»»4¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(&(pSrc->TPA[1]), &pDst[nDstLength], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ }
+ else if(!(strncmp(pSrc->TPA , "0086",4)))
+ {
+ buf[2] = (char)nLength-2;
+ buf[3] = 0x91; // ¹Ì¶¨: ¹ú¼ÊºÅÂë¸ñʽ
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 4); // ת»»4¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(&(pSrc->TPA[2]), &pDst[nDstLength], nLength-2); // ת»»TP-DAµ½Ä¿±êPDU´®
+
+ }
+ else
+ {
+ buf[3] = 0x81; // ¹Ì¶¨: ²»Ö¸Ã÷ºÅÂë¸ñʽ
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], 4); // ת»»4¸ö×Ö½Úµ½Ä¿±êPDU´®
+ nDstLength += InvertNumbers(pSrc->TPA, &pDst[nDstLength], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ }
+ #if 1//corem for debug
+ printf("[SMScorem]pdst4:%s\n",pDst);
+ #endif
+
+ // TPDU¶ÎÐÒé±êʶ¡¢±àÂ뷽ʽ¡¢Óû§ÐÅÏ¢µÈ
+
+ //nLength = strlen(pSrc->TP_UD); // Óû§ÐÅÏ¢×Ö·û´®µÄ³¤¶È
+ nLength = (int) pSrc->TP_UDLength;
+ buf[0] = pSrc->TP_PID; // ÐÒé±êʶ(TP-PID)
+ buf[1] = pSrc->TP_DCS; // Óû§ÐÅÏ¢±àÂ뷽ʽ(TP-DCS)
+ buf[2] = pSrc->TP_VP; // ÓÐЧÆÚ(TP-VP)
+
+ if(pSrc->TP_DCS == CODE_GSM7)
+ {
+ nLength = code_is_gsm7(pSrc,buf, nLength);
+ }
+ else if(pSrc->TP_DCS == CODE_UCS2)
+ {
+ nLength = code_is_ucs2(pSrc,buf, nLength);
+ }
+ else
+ {
+ // 8-bit±àÂ뷽ʽ
+ //begin add for concat sms
+ nLength = strlen(pSrc->TP_UD);
+ if (pSrc->TP_UDHI == 1)
+ {
+ buf[3] = (unsigned char) nLength;
+ buf[4] = (unsigned char) pSrc->TP_UD[0];
+ buf[5] = 0;
+ buf[6] = (unsigned char) pSrc->TP_UD[2];
+ buf[7] = (unsigned char) pSrc->TP_UD[3];
+ buf[8] = (unsigned char) pSrc->TP_UD[4];
+ buf[9] = (unsigned char) pSrc->TP_UD[5];
+ if (nLength - 6 <= 0 || nLength - 6 >= sizeof(buf) - 10) //klocwork
+ return -1;
+ buf[3] = (unsigned char) (Encode8bit(&(pSrc->TP_UD[6]), &buf[10], (unsigned short) (nLength - 6)) + 6); // ת»»TP-DAµ½Ä¿±êPDU´®,nLengthµÈÓڸöÎÊý¾Ý³¤¶È
+ nLength = buf[3] + 4;
+ }
+ else
+ {
+ if (nLength <= 0 || nLength >= sizeof(buf) - 4) //klocwork
+ return -1;
+ buf[3] = Encode8bit(pSrc->TP_UD, &buf[4], nLength); // ת»»TP-DAµ½Ä¿±êPDU´®
+ nLength = buf[3] + 4; // nLengthµÈÓڸöÎÊý¾Ý³¤¶È
+ }
+ //end add for concat sms
+ }
+ check_udl = nLength -4;
+
+ nDstLength += Bytes2String(buf, &pDst[nDstLength], nLength); // ת»»¸Ã¶ÎÊý¾Ýµ½Ä¿±êPDU´®
+ sc_cfg_set(NV_CHECK_UDL,"");
+ if(check_udl>140)
+ {
+ sc_cfg_set(NV_CHECK_UDL,"error");
+ }
+ #if 1//corem for debug
+ printf("[SMScorem] EncodePdu_Submit end make pdu data\n");
+ printf("[SMScorem]len:%d, tpud:%s\n",nDstLength, pSrc->TP_UD);
+ #endif
+ #if 1//corem for debug
+ printf("[SMScorem]pdst5:%s\n",pDst);
+ #endif
+ return nDstLength; // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int Decode7bit(const unsigned char* pSrc, char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º GSM7λ½âÂë
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±ê±àÂë´®Ö¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int Decode7bit(const unsigned char* pSrc, char* pDst, int nSrcLength)
+{
+ int nSrc; // Ô´×Ö·û´®µÄ¼ÆÊýÖµ
+ int nDst; // Ä¿±ê½âÂë´®µÄ¼ÆÊýÖµ
+ int nByte; // µ±Ç°ÕýÔÚ´¦ÀíµÄ×éÄÚ×Ö½ÚµÄÐòºÅ£¬·¶Î§ÊÇ0-6
+ unsigned char nLeft; // ÉÏÒ»×Ö½Ú²ÐÓàµÄÊý¾Ý
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ // ¼ÆÊýÖµ³õʼ»¯
+ nSrc = 0;
+ nDst = 0;
+
+ // ×éÄÚ×Ö½ÚÐòºÅºÍ²ÐÓàÊý¾Ý³õʼ»¯
+ nByte = 0;
+ nLeft = 0;
+
+ // ½«Ô´Êý¾Ýÿ7¸ö×Ö½Ú·ÖΪһ×飬½âѹËõ³É8¸ö×Ö½Ú
+ // Ñ»·¸Ã´¦Àí¹ý³Ì£¬Ö±ÖÁÔ´Êý¾Ý±»´¦ÀíÍê
+ // Èç¹û·Ö×é²»µ½7×Ö½Ú£¬Ò²ÄÜÕýÈ·´¦Àí
+ while(nSrc<nSrcLength)
+ {
+ // ½«Ô´×Ö½ÚÓұ߲¿·ÖÓë²ÐÓàÊý¾ÝÏà¼Ó£¬È¥µô×î¸ß룬µÃµ½Ò»¸öÄ¿±ê½âÂë×Ö½Ú
+ *pDst = ((*pSrc << nByte) | nLeft) & 0x7f;
+
+ // ½«¸Ã×Ö½ÚʣϵÄ×ó±ß²¿·Ö£¬×÷Ϊ²ÐÓàÊý¾Ý±£´æÆðÀ´
+ nLeft = *pSrc >> (7-nByte);
+
+ // ÐÞ¸ÄÄ¿±ê´®µÄÖ¸ÕëºÍ¼ÆÊýÖµ
+ pDst++;
+ nDst++;
+
+ // ÐÞ¸Ä×Ö½Ú¼ÆÊýÖµ
+ nByte++;
+
+ // µ½ÁËÒ»×éµÄ×îºóÒ»¸ö×Ö½Ú
+ if(nByte == 7)
+ {
+ // ¶îÍâµÃµ½Ò»¸öÄ¿±ê½âÂë×Ö½Ú
+ *pDst = nLeft;
+
+ // ÐÞ¸ÄÄ¿±ê´®µÄÖ¸ÕëºÍ¼ÆÊýÖµ
+ pDst++;
+ nDst++;
+
+ // ×éÄÚ×Ö½ÚÐòºÅºÍ²ÐÓàÊý¾Ý³õʼ»¯
+ nByte = 0;
+ nLeft = 0;
+ }
+
+ // ÐÞ¸ÄÔ´´®µÄÖ¸ÕëºÍ¼ÆÊýÖµ
+ pSrc++;
+ nSrc++;
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê´®³¤¶È
+ return nDst;
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int DecodePushPdu(const char* pSrcPdu, SM_PARAM* pDst)
+* ¹¦ÄÜÃèÊö£º PDU½âÂ룬ÓÃÓÚ½ÓÊÕ¡¢ÔĶÁdelevery ¶ÌÏûÏ¢
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ const char* pSrcPdu: Ô´PDU²ÎÊýÖ¸Õë
+ pDst: Ä¿±ê½á¹¹Ö¸Õë
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º 0 not push 1 push 2 notification 3 bootstrap
+ £»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+int DecodePushPdu(const char* pSrcPdu, SMS_PARAM* pDst)
+{
+ int nDstLength = 0; // Ä¿±êPDU´®³¤¶È
+ unsigned char tmp = 0; // ÄÚ²¿ÓõÄÁÙʱ×Ö½Ú±äÁ¿
+ int ud_length = 0;
+ unsigned char buf[256] = {0}; // ÄÚ²¿ÓõĻº³åÇø
+ char temp_num[100] = {0};
+ unsigned char first_octet = 0; //ÓÃÀ´±£´æ±£´æfirst octetµÄÐÅÏ¢
+ unsigned char udhl = 0; //ÓÃÀ´±£´æÓû§Êý¾ÝÍ·ÐÅÏ¢ÔªËØµÄ³¤¶È
+ unsigned int halftmp = 0;//klocwork
+ char tp_ra[3] = {0};
+ int tmplen =0;
+ unsigned char IEIDL;
+ int pushType = 0;
+ const char *pSrc = pSrcPdu;
+
+ if(pSrcPdu == NULL || pDst == NULL)
+ {
+ printf( "DecodePushPdu para null. \n");
+ return -1;
+ }
+ //at_print(LOG_DEBUG, "DecodePushPdu input = %s.\n", pSrc);
+ String2Bytes(pSrc, &tmp, 2); // SMSCµØÖ·ÐÅÏ¢¶Î, È¡³¤¶È
+
+ at_print(LOG_DEBUG, "DecodePushPdu tmp = %d.\n", tmp);
+ if(tmp == 0)// Èç¹û¶ÌÏûÏ¢ÖÐÐĵØÖ·³¤¶ÈΪ0£¬ÔòÖ¸ÕëÖµÖ»¼Ó2
+ {
+ pSrc += 2;
+ }
+ else// Èç¹û¶ÌÏûÏ¢ÖÐÐĵØÖ·³¤¶È²»Îª0£¬ÔòÖ¸ÕëÖµ°´tmpµÄÖµ¼Ó
+ {
+ tmp = (tmp - 1) * 2;// SMSCºÅÂë´®³¤¶È
+ pSrc += 4;// Ö¸ÕëºóÒÆ£¬ºöÂÔÁËSMSCµØÖ·¸ñʽ
+ if(tmp > 32)//modified by panqinge 2005.06.30 ±ÜÃâÊý×éÔ½½ç
+ {
+ SerializeNumbers_sms(pSrc, pDst->SCA, 32);
+ tmp = 32;
+ }
+ else
+ {
+ SerializeNumbers_sms(pSrc, pDst->SCA, tmp);// ת»»SMSCºÅÂ뵽Ŀ±êPDU´®
+ }
+ pSrc += tmp;// Ö¸ÕëºóÒÆ
+ }
+ String2Bytes(pSrc, &tmp, 2);// TPDU¶Î»ù±¾²ÎÊý¡¢»Ø¸´µØÖ·µÈÈ¡»ù±¾²ÎÊý
+ //at_print(LOG_DEBUG, "DecodePushPdu tmp = %d.\n", tmp);
+ first_octet = tmp;//¼Çסfirst octet µÄÐÅÏ¢
+ pSrc += 2;// Ö¸ÕëºóÒÆ
+ String2Bytes(pSrc, &tmp, 2);// È¡³¤¶È
+ //at_print(LOG_DEBUG, "DecodePushPdu tmp = %d.\n", tmp);
+ halftmp = tmp;
+ if(tmp & 1) tmp += 1;// µ÷ÕûÆæÅ¼ÐÔ
+ pSrc += 2;// Ö¸ÕëºóÒÆ£¬»Ø¸´µØÖ·(TP-RA)¸ñʽ
+ memset(tp_ra,0,sizeof(tp_ra));
+ String2Bytes(pSrc, tp_ra, 2);
+ //at_print(LOG_DEBUG, "DecodePushPdu tp_ra = 0x%02x, 0x%02x.\n", tp_ra[0], tp_ra[1]);
+ pSrc += 2;
+ // added by panqinge,·¢¼þÈ˺ÅÂë¿ÉÄÜÊÇÓ¢ÎÄ×Ö·û£¬¹ÊÌí¼ÓÅжϺÍÓ¢ÎÄ×Ö·ûµÄ½âÂ뺯Êý
+ if((tp_ra[0] & 0x50) == 0x50) //Èç¹ûÊÇÎÄ×ÖÓëÊý×ֵĵØÖ·±àÂë¸ñʽ23.040,9.1.2.5
+ {
+ char tempra[128]; //¹ÊÔÚ½âÂëǰӦ»Ö¸´ÎªÊµ¼ÊµÄ×Ö½ÚÊý
+ char acAsc[128];
+ if(halftmp >=14)
+ {
+ halftmp = (tmp/2)/7 + (tmp/2); //modified by panqinge 2005.8.1 ÊÕ¼þÈËʱ³¤¶ÈÊǰ´Ñ¹ËõºóµÄ°ë×Ö½Ú
+ }
+ else
+ {
+ halftmp = tmp/2;
+ }
+ //at_print(LOG_DEBUG, "DecodePushPdu halftmp = %d.\n", halftmp);
+
+ memset(tempra,0,sizeof(tempra));
+ memcpy(tempra, pSrc, tmp);
+ //at_print(LOG_DEBUG, "DecodePushPdu tempra = %s.\n", tempra);
+
+ memset(acAsc,0,sizeof(acAsc));
+ nDstLength = String2Bytes(tempra, buf, halftmp & 7 ? (int)halftmp * 7 / 4 + 2 : (int)halftmp * 7 / 4); // ¸ñʽת»»
+ halftmp = Decode7bit(buf, acAsc, nDstLength); // ת»»µ½TP-DU
+ memset(pDst->TPA, 0 , sizeof(pDst->TPA));
+ if(halftmp > 32)
+ {
+ memcpy(pDst->TPA,acAsc,32);
+ tmp = 32;
+ }
+ else
+ {
+ memcpy(pDst->TPA,acAsc,halftmp);//klocwork
+ }
+ }
+ else
+ {
+ if(tmp > 32)//modified by panqinge 2005.06.30 ±ÜÃâÊý×éÔ½½ç
+ {
+ SerializeNumbers_sms(pSrc, pDst->TPA, 32); // È¡TP-RAºÅÂë
+ }
+ else
+ {
+ SerializeNumbers_sms(pSrc, pDst->TPA, tmp); // È¡TP-RAºÅÂë
+ }
+ if((tp_ra[0] & 0x91) == 0x91) //ºÅÂëÀàÐÍΪInternation Number
+ {
+ memset(temp_num,0,sizeof(temp_num));
+ if(pDst->TPA[0] != '+') //µÚһλ²»ÊÇ"+"
+ {
+ snprintf(temp_num,sizeof(temp_num),"%s%s","+",pDst->TPA);
+ if(strlen(temp_num) > 32)
+ {
+ snprintf(pDst->TPA,sizeof(pDst->TPA),"%32s",temp_num);
+ }
+ else
+ {
+ snprintf(pDst->TPA,sizeof(pDst->TPA),"%s",temp_num);
+ }
+ }
+ }
+ }
+ pSrc += tmp;// Ö¸ÕëºóÒÆ
+ //at_print(LOG_DEBUG, "DecodePushPdu TPA = %s.\n", pDst->TPA);
+
+ String2Bytes(pSrc, (unsigned char*)&pDst->TP_PID, 2); // TPDU¶ÎÐÒé±êʶ¡¢±àÂ뷽ʽ¡¢Óû§ÐÅÏ¢µÈ,È¡ÐÒé±êʶ(TP-PID)
+ pSrc += 2; // Ö¸ÕëºóÒÆ
+ String2Bytes(pSrc, (unsigned char*)&pDst->TP_DCS, 2); // È¡±àÂ뷽ʽ(TP-DCS)
+ pSrc += 2; // Ö¸ÕëºóÒÆ
+ SerializeNumbers_sms(pSrc, pDst->TP_SCTS, 14); // ·þÎñʱ¼ä´Á×Ö·û´®(TP_SCTS)
+ pSrc += 14; // Ö¸ÕëºóÒÆ
+ String2Bytes(pSrc, &tmp, 2); // Óû§ÐÅÏ¢³¤¶È(TP-UDL)
+ pSrc += 2; // Ö¸ÕëºóÒÆ
+ //at_print(LOG_DEBUG, "DecodePushPdu TP_DCS = 0x%02x.\n", pDst->TP_DCS);
+ memset(pDst->TP_UD, 0 , sizeof(pDst->TP_UD));
+
+ at_print(LOG_DEBUG, "DecodePushPdu first_octet = 0x%02x.\n", first_octet);
+ //add for wap
+ if (first_octet & 0x40) //˵Ã÷ÊÇÓû§Êý¾Ýº¬ÓÐÍ·²¿ÐÅÏ¢µÄ
+ {
+ const char *temp = pSrc;
+ unsigned char pduType;
+ unsigned char wspLen;
+ unsigned char udhLen;
+ unsigned char DestPort1;
+ unsigned char DestPort2;
+ unsigned char RefNum1;
+ unsigned char RefNum2;
+
+ pushType = SMS_NO_PUSH;
+ String2Bytes(temp, &udhl, 2); //ȡһ¸ö×ֽڷŵ½tp_udhlÖÐ,ÐÅÏ¢ÔªËØ³¤¶È
+ temp += 2; //Ö¸ÕëºóÒÆ
+ tmplen = String2Bytes(temp, &pDst->TP_IEI, 2); //È¡ÐÅÏ¢ÔªËØÖ¸Ê¾Æ÷£¬Îª0±íʾÊÇÁ´½Ó¶ÌÏûÏ¢
+ at_print(LOG_DEBUG, "DecodePushPdu TP_IEI = 0x%02x.\n", pDst->TP_IEI);
+ if(pDst->TP_IEI == 5)
+ {
+ temp += 2 * tmplen+2;
+ tmplen = String2Bytes(temp, &DestPort1, 2);
+ at_print(LOG_DEBUG, "DecodePushPdu DestPort1 = 0x%02x.\n", DestPort1);
+ temp += 2 * tmplen;
+ tmplen = String2Bytes(temp, &DestPort2, 2);
+ at_print(LOG_DEBUG, "DecodePushPdu DestPort2 = 0x%02x.\n", DestPort2);
+ if((DestPort1==0x0B)&&((DestPort2==0X84)||(DestPort2==0X85)))
+ {
+ pushType = SMS_PUSH;
+ }
+ }
+
+ if(SMS_PUSH !=pushType)
+ {
+ return pushType;
+ }
+
+ temp = pSrc + udhl * 2 + 4;
+ tmplen = String2Bytes(temp, &pduType, 2);
+ if(pduType==6)
+ {
+ pushType = SMS_PUSH;
+ temp += 4;
+ tmplen = String2Bytes(temp, &pduType, 2);
+ if(pduType==0xC4)
+ {
+ //notification
+ pushType = SMS_NOTIFICATION;
+ }
+ else
+ {
+ temp += 4;
+ tmplen = String2Bytes(temp, &pduType, 2);
+ if((pduType==0xC2)||(pduType==0xB6))
+ {
+ //bootstrap
+ pushType = SMS_BOOTSTRAP;
+ }
+ }
+ }
+
+ if((pDst->TP_IEI == 4)||(pDst->TP_IEI == 5)||(pDst->TP_IEI == 8))
+ {
+ temp = pSrc+4;
+ tmplen = String2Bytes(temp, &IEIDL, 2); //È¡ÐÅÏ¢ÔªËØÊý¾Ý³¤¶È£¬¶ÔÓÚÁ´½Ó¶ÌÏûÏ¢À´Ëµ£¬Ò»°ãΪ3
+ if(IEIDL==(udhl-2))
+ {
+
+ }
+ else
+ {
+ temp += 2 * 6;
+ tmplen = String2Bytes(temp, &udhLen, 2);
+ if(udhLen==3)
+ {
+ temp += 2 * tmplen;
+ tmplen = String2Bytes(temp, &RefNum1, 2); //È¡²Î¿¼ºÅÂ룬һÌõÁ´½Ó¶ÌÏûÏ¢µÄ¸÷¶ÎÓÐÏàͬµÄ²Î¿¼ºÅÂë
+ pDst->TP_ReferNum = RefNum1;
+ temp += 2 * tmplen; //Ö¸ÕëºóÒÆ
+ tmplen = String2Bytes(temp, &pDst->TP_AllPieceNum, 2); //È¡¸ÃÌõÁ´½Ó¶ÌÏûÏ¢±»·Ö³ÉµÄ×ܵĶÎÊý
+ temp += 2 * tmplen; //Ö¸ÕëºóÒÆ
+ tmplen = String2Bytes(temp, &pDst->TP_CurrentPieceNum, 2); //È¡µ±Ç°¶ÎµÄ¶ÎÊý
+ temp += 2 * tmplen;
+ }
+ else if(udhLen==4)
+ {
+ temp += 2 * tmplen ;
+ tmplen = String2Bytes(temp, &RefNum1, 2); //È¡²Î¿¼ºÅÂ룬һÌõÁ´½Ó¶ÌÏûÏ¢µÄ¸÷¶ÎÓÐÏàͬµÄ²Î¿¼ºÅÂë
+ temp += 2 * tmplen ;
+ tmplen = String2Bytes(temp, &RefNum2, 2); //È¡²Î¿¼ºÅÂ룬һÌõÁ´½Ó¶ÌÏûÏ¢µÄ¸÷¶ÎÓÐÏàͬµÄ²Î¿¼ºÅÂë
+ int ReferNum = RefNum2+ RefNum1*256;
+ pDst->TP_ReferNum = ReferNum;
+ temp += 2 * tmplen; //Ö¸ÕëºóÒÆ
+ tmplen = String2Bytes(temp, &pDst->TP_AllPieceNum, 2); //È¡¸ÃÌõÁ´½Ó¶ÌÏûÏ¢±»·Ö³ÉµÄ×ܵĶÎÊý
+ temp += 2 * tmplen; //Ö¸ÕëºóÒÆ
+ tmplen = String2Bytes(temp, &pDst->TP_CurrentPieceNum, 2); //È¡µ±Ç°¶ÎµÄ¶ÎÊý
+ temp += 2 * tmplen;
+ }
+ }
+ }
+ at_print(LOG_DEBUG, "DecodePushPdu ReferNum = %d,AllNum =%d,CurNum =%d.\n", pDst->TP_ReferNum,pDst->TP_AllPieceNum,pDst->TP_CurrentPieceNum);
+
+ if(SMS_NOTIFICATION==pushType)
+ {
+ temp= pSrc + udhl * 2+6;
+ tmplen = String2Bytes(temp, &wspLen, 2);
+ temp = temp+wspLen *2+2;
+ }
+ else //if((SMS_PUSH==pushType)||(SMS_BOOTSTRAP==pushType)) //kw 3
+ {
+ temp= pSrc + udhl * 2+2;
+ }
+ //klocwork
+ nDstLength = ((strlen(temp) < sizeof(pDst->TP_UD)) ? strlen(temp) : (sizeof(pDst->TP_UD) - 1));
+ memcpy(pDst->TP_UD, temp, nDstLength);
+ at_print(LOG_DEBUG, "DecodePushPdu pDst->TP_UD = %s.\n", pDst->TP_UD);
+ }
+ at_print(LOG_DEBUG, "DecodePushPdu pushType = %d.\n", pushType);
+ return pushType;
+ // end add for wap
+}
+
+
+/**************************************************************************
+* º¯ÊýÃû³Æ£º int SerializeNumbers(const char* pSrc, char* pDst, int nSrcLength)
+* ¹¦ÄÜÃèÊö£º Á½Á½µßµ¹µÄ×Ö·û´®×ª»»ÎªÕý³£Ë³ÐòµÄ×Ö·û´®
+ È磺"683158812764F8" --> "8613851872468"
+* ·ÃÎÊµÄ±í£º
+* ÐÞ¸ÄµÄ±í£º
+* ÊäÈë²ÎÊý£º
+ pSrc: Ô´×Ö·û´®Ö¸Õë
+ pDst: Ä¿±ê±àÂë´®Ö¸Õë
+ nSrcLength: Ô´×Ö·û´®³¤¶È
+* Êä³ö²ÎÊý£º
+ ÎÞ£»
+* ·µ »Ø Öµ£º
+ Ä¿±êÊý¾Ý³¤¶È£»
+* ÆäËü˵Ã÷£º
+* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+* -----------------------------------------------
+* 2004/10/18 V1.0 À×ÓîÁú ´´½¨¸Ãº¯Êý
+**************************************************************************/
+static int SerializeNumbers_sms(const char* pSrc, char* pDst, int nSrcLength)
+{
+ int nDstLength; // Ä¿±ê×Ö·û´®³¤¶È
+ char ch; // ÓÃÓÚ±£´æÒ»¸ö×Ö·û
+ int i=0;
+
+ //УÑé²ÎÊý
+ if(pSrc == NULL || pDst == NULL || nSrcLength < 0)
+ {
+ return -1;
+ }
+
+ // ¸´ÖÆ´®³¤¶È
+ nDstLength = nSrcLength;
+
+ // Á½Á½µßµ¹
+ for(i=0; i<nSrcLength;i+=2)
+ {
+ ch = *pSrc++; // ±£´æÏȳöÏÖµÄ×Ö·û
+ *pDst++ = *pSrc++; // ¸´Öƺó³öÏÖµÄ×Ö·û
+ *pDst++ = ch; // ¸´ÖÆÏȳöÏÖµÄ×Ö·û
+ }
+
+ // ×îºóµÄ×Ö·ûÊÇ'F'Âð£¿
+ if(*(pDst-1) == 'F')
+ {
+ pDst--;
+ nDstLength--; // Ä¿±ê×Ö·û´®³¤¶È¼õ1
+ }
+
+ // Êä³ö×Ö·û´®¼Ó¸ö½áÊø·û
+ *pDst = '\0';
+
+ // ·µ»ØÄ¿±ê×Ö·û´®³¤¶È
+ return nDstLength;
+}
+
+UINT16 wms_ts_pack_gw_7_bit_chars
+(
+ const UINT8 * in,
+ UINT16 in_len, /* Number of 7-bit characters */
+ UINT16 shift,
+ UINT16 out_len_max, /* Number of 7-bit characters */
+ UINT8 * out
+)
+{
+ UINT16 i=0;
+ UINT16 pos = 0;
+
+ if (in == NULL || out == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_pack_gw_7_bit_chars");
+ return 0;
+ }
+ /* pack the ASCII characters */
+ shift %= 7;
+
+ if (shift != 0)
+ {
+ /* Pack the upper bytes of the first character */
+ out[pos] |= (UINT8) (in[i] << shift);
+ shift = (7 - shift) + 1;
+ if (shift == 7)
+ {
+ shift = 0;
+ i++;
+ }
+ pos++;
+ }
+
+ for( ; pos < out_len_max && i < in_len;
+ pos++, i++ )
+ {
+ /* pack the low bits */
+ out[pos] = in[i] >> shift;
+
+ if( i+1 < in_len )
+ {
+ /* pack the high bits using the low bits of the next character */
+ out[pos] |= (UINT8) (in[i+1] << (7-shift));
+
+ shift ++;
+
+ if( shift == 7 )
+ {
+ shift = 0;
+ i ++;
+ }
+ }
+ }
+
+ /* done */
+ return pos;
+
+} /* wms_ts_pack_gw_7_bit_chars() */
+
+UINT8 wms_ts_encode_address
+(
+ const wms_address_s_type * addr,
+ UINT8 * data
+)
+{
+ UINT8 i, pos = 0;
+
+ if( addr->number_of_digits > WMS_GW_ADDRESS_MAX )
+ {
+ at_print(LOG_DEBUG,"Addr len too long: %d", addr->number_of_digits);
+ return 0;
+ }
+
+ if (addr->number_type == WMS_NUMBER_ALPHANUMERIC )
+ {
+ data[pos] = (UINT8)((addr->number_of_digits*7 + 3)/4);
+ }
+ else
+ {
+ /* Len field: */
+ data[pos] = addr->number_of_digits;
+ }
+ pos ++;
+
+ /* TON & NPI: */
+ data[pos] = 0x80;
+ data[pos] |= (UINT8) ((UINT8) addr->number_type << 4);
+ data[pos] |= (UINT8) addr->number_plan;
+ pos ++;
+
+ if (addr->number_type == WMS_NUMBER_ALPHANUMERIC )
+ {
+ /* Alphanumberic Number Type */
+ pos += (UINT8)wms_ts_pack_gw_7_bit_chars
+ (
+ addr->digits,
+ addr->number_of_digits,
+ 0,
+ WMS_GW_ADDRESS_MAX,
+ &data[pos]
+ );
+ }
+ else
+ {
+ /* the digits: */
+ for( i=0; i<addr->number_of_digits; i++ )
+ {
+ /* pack two digits each time */
+ data[pos] = (UINT8) (addr->digits[i++] & 0x0F);
+ //kw 3
+ //if( i == addr->number_of_digits )
+ //{
+ // data[pos] |= 0xF0;
+ //}
+ //else
+ {
+ data[pos] |= (UINT8)(addr->digits[i] << 4);
+ }
+ pos ++;
+ }
+ }
+ /* done */
+ return pos;
+} /* wms_ts_encode_address() */
+
+UINT8 wms_ts_encode_dcs
+(
+ const wms_gw_dcs_s_type *dcs, /* IN */
+ UINT8 *data /* OUT */
+)
+{
+ UINT8 pos = 0;
+
+ if( dcs->msg_waiting == WMS_GW_MSG_WAITING_NONE )
+ {
+ /* Using the pattern 00xx xxxx */
+
+ /* bit 5 */
+ data[pos] = dcs->is_compressed ? 0x20 : 0;
+
+ /* bit 4 */
+ data[pos] |= (dcs->msg_class != WMS_MESSAGE_CLASS_NONE ) ? 0x10 : 0;
+
+ /* bits 3-2 */
+ data[pos] |= dcs->alphabet << 2;
+
+ /* bits 1-0 */
+ data[pos] |= dcs->msg_class & 0x03;
+ }
+ else if (dcs->msg_waiting == WMS_GW_MSG_WAITING_NONE_1111)
+ {
+ /* Using the pattern 1111 xxxx */
+
+ data[pos] = 0xf0;
+
+ /*bit 2*/
+ if (dcs->alphabet == WMS_GW_ALPHABET_8_BIT)
+ data[pos] |= 0x04;
+
+
+ /* bits 1-0 */
+ data[pos] |= dcs->msg_class & 0x03;
+ }
+ else
+ {
+ /* bits 7-4 */
+ if( dcs->msg_waiting == WMS_GW_MSG_WAITING_DISCARD )
+ {
+ data[pos] = 0xc0;
+ }
+ else if( dcs->msg_waiting == WMS_GW_MSG_WAITING_STORE &&
+ dcs->alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT )
+ {
+ data[pos] = 0xd0;
+ }
+ else
+ {
+ data[pos] = 0xe0;
+ }
+
+ /* bit 3 */
+ data[pos] |= ( dcs->msg_waiting_active == TRUE ) ? 0x08 : 0;
+
+ /* bit 2 is reserved, set to 0 */
+
+ /* bits 1-0 */
+ data[pos] |= dcs->msg_waiting_kind & 0x03;
+ }
+
+ pos ++;
+
+ return pos;
+} /* wms_ts_encode_dcs() */
+
+UINT8 wms_ts_bcd_to_int
+(
+ const UINT8 bcd, /*IN*/
+ UINT8 *result /*OUT*/
+)
+{
+ //kw 3 ,kw bug
+ //if ( (bcd & 0x0F) > 9 || ((bcd & 0xF0) >> 4) > 9)
+ unsigned char low_bit = (bcd & 0x0F);
+ unsigned char high_bit = ((bcd & 0xF0) >> 4);
+ if(low_bit > 9 || high_bit > 9)
+ {
+ at_print(LOG_DEBUG,"Invalid BCD digit!");
+ *result = 0;
+ return FALSE;
+ }
+ else
+ {
+ *result = ( (bcd & 0x0F) + (((bcd & 0xF0) >> 4) * 10) );
+ return TRUE;
+ }
+}
+
+UINT8 wms_ts_encode_timestamp
+(
+ const wms_timestamp_s_type *timestamp, /* IN */
+ UINT8 *data /* OUT */
+)
+{
+ sint7 i;
+ UINT8 pos = 0, j;
+
+ /* year check */
+ if ( !wms_ts_bcd_to_int(timestamp->year, &j) )
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->year & 0x0F) << 4) + ((timestamp->year& 0xF0) >> 4);
+ pos ++;
+
+ /* month check */
+ if ( wms_ts_bcd_to_int(timestamp->month, &j) )
+ {
+ if (j > 12 || j < 1)
+ {
+ at_print(LOG_DEBUG,"Month is invalid: %d", j);
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->month & 0x0F) << 4) + ((timestamp->month & 0xF0) >> 4);
+ pos ++;
+
+ /* day check */
+ if ( wms_ts_bcd_to_int(timestamp->day, &j) )
+ {
+ if (j > 31 || j < 1)
+ {
+ at_print(LOG_DEBUG,"Day is invalid: %d", j);
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->day & 0x0F) << 4) + ((timestamp->day & 0xF0) >> 4);
+ pos ++;
+
+ /* hour check */
+ if ( wms_ts_bcd_to_int(timestamp->hour, &j) )
+ {
+ if (j > 23)
+ {
+ at_print(LOG_DEBUG,"Hour is invalid: %d", j);
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->hour & 0x0F) << 4) + ((timestamp->hour & 0xF0) >> 4);
+ pos ++;
+
+ /* minute check */
+ if ( wms_ts_bcd_to_int(timestamp->minute, &j) )
+ {
+ if (j > 59)
+ {
+ at_print(LOG_DEBUG,"Minute is invalid: %d", j);
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->minute & 0x0F) << 4) + ((timestamp->minute & 0xF0) >> 4);
+ pos ++;
+
+ /* second check */
+ if ( wms_ts_bcd_to_int(timestamp->second, &j) )
+ {
+ if (j > 59)
+ {
+ at_print(LOG_DEBUG,"Second is invalid: %d", j);
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ data[pos] = ((timestamp->second & 0x0F) << 4) + ((timestamp->second & 0xF0) >> 4);
+ pos ++;
+
+ /* timezone check */
+ i = (sint7)timestamp->timezone;
+ if (i > 48|| i < -48)
+ {
+ at_print(LOG_DEBUG,"Timezone is out of bound: %d", i);
+ return 0;
+ }
+
+ if (i >= 0)
+ {
+ data[pos] = (UINT8) (((UINT8)( i % 10 )) << 4);
+ data[pos] |= ( i / 10 );
+ }
+ else
+ {
+ i *= (-1);
+ data[pos] = (UINT8) (((UINT8)( i % 10 )) << 4);
+ data[pos] |= ( i / 10 );
+ data[pos] |= 0x08;
+ }
+ pos ++;
+
+ return pos;
+
+} /* wms_ts_encode_timestamp() */
+
+
+UINT8 wms_ts_get_udh_length(const wms_udh_s_type *udh)
+{
+ UINT8 length = 0;
+ if (udh != NULL)
+ {
+ switch(udh->header_id)
+ {
+ /* 0x00 */
+ case WMS_UDH_CONCAT_8:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_CONCAT8;
+ break;
+
+ /* 0x08 */
+ case WMS_UDH_CONCAT_16:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_CONCAT16;
+ break;
+
+ /* 0x01 */
+ case WMS_UDH_SPECIAL_SM:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_SPECIAL_SM;
+ break;
+
+ /* 0x02 - 0x03 Reserved */
+
+ /* 0x04 */
+ case WMS_UDH_PORT_8:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_PORT8;
+ break;
+
+ /* 0x05 */
+ case WMS_UDH_PORT_16:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_PORT16;
+ break;
+
+ /* 0x06 */
+ case WMS_UDH_SMSC_CONTROL:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + udh->u.other.header_length;
+ break;
+
+ /* 0x07 */
+ case WMS_UDH_SOURCE:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + udh->u.other.header_length;
+ break;
+
+ /* 0x09 */
+ case WMS_UDH_WCMP:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + udh->u.other.header_length;
+ break;
+
+ /* 0x0A */
+ case WMS_UDH_TEXT_FORMATING:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ if(!udh->u.text_formating.is_color_present)
+ {
+ length = 1 + 1 + WMS_UDH_OCTETS_TEXT_FORMATTING;
+ }
+ else
+ {
+ /* Header ID Octet + Header Length Octet + Header Length + text color octet */
+ length = 1 + 1 + WMS_UDH_OCTETS_TEXT_FORMATTING + 1;
+ }
+ break;
+
+ /* 0x0B */
+ case WMS_UDH_PRE_DEF_SOUND:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_PRE_DEF;
+ break;
+
+ /* 0x0C */
+ case WMS_UDH_USER_DEF_SOUND:
+ /* Header ID Octet + Header Length Octet + Header Length + 1 (for position octet)*/
+ length = 1 + 1 + udh->u.user_def_sound.data_length + 1;
+ break;
+
+ /* 0x0D */
+ case WMS_UDH_PRE_DEF_ANIM:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + WMS_UDH_OCTETS_PRE_DEF;
+ break;
+
+ /* 0x0E */
+ case WMS_UDH_LARGE_ANIM:
+ /* Header ID Octet + Header Length Octet + Header Length + 1 (for position octet)*/
+ length = 1 + 1 + WMS_UDH_LARGE_BITMAP_SIZE * WMS_UDH_ANIM_NUM_BITMAPS + 1;
+ break;
+
+ /* 0x0F */
+ case WMS_UDH_SMALL_ANIM:
+ /* Header ID Octet + Header Length Octet + Header Length + 1 (for position octet)*/
+ length = 1 + 1 + WMS_UDH_SMALL_BITMAP_SIZE * WMS_UDH_ANIM_NUM_BITMAPS + 1;
+ break;
+
+ /* 0x10 */
+ case WMS_UDH_LARGE_PICTURE:
+ /* Header ID Octet + Header Length Octet + Header Length + 1 (for position octet)*/
+ length = 1 + 1 + WMS_UDH_LARGE_PIC_SIZE + 1;
+ break;
+
+ /* 0x11 */
+ case WMS_UDH_SMALL_PICTURE:
+ /* Header ID Octet + Header Length Octet + Header Length + 1 (for position octet)*/
+ length = 1 + 1 + WMS_UDH_SMALL_PIC_SIZE + 1;
+ break;
+
+ /* 0x12 */
+ case WMS_UDH_VAR_PICTURE:
+ /* Header ID Octet + Header Length Octet + Header Length + 3 (for height, width and position octets)*/
+ length = 1 + 1 + (UINT8)(udh->u.var_picture.height * udh->u.var_picture.width/8) + 3;
+ break;
+
+ /* 0x13 - 0x1F Reserved for future EMS*/
+
+ /* 0x20 */
+ case WMS_UDH_RFC822:
+ /* Header ID Octet + Header Length Octet + Header Length*/
+ length = 1 + 1 + WMS_UDH_OCTETS_RFC822;
+ break;
+ /*add by yangpeng, 2011.4.5, begin*/
+ /* 0x24 */
+ case WMS_UDH_NAT_LANG_SS:
+ /* Header ID Octet + Header Length Octet + Header Length*/
+ length = 1 + 1 + WMS_UDH_OCTETS_NAT_LANG_SS;
+ break;
+
+ /* 0x25 */
+ case WMS_UDH_NAT_LANG_LS:
+ /* Header ID Octet + Header Length Octet + Header Length*/
+ length = 1 + 1 + WMS_UDH_OCTETS_NAT_LANG_LS;
+ break;
+ /*add by yangpeng, 2011.4.5, end*/
+
+ /* 0x21 - 0x6F Reserved for future use*/
+ /* 0x70 - 0x7f Reserved for (U)SIM Toolkit Security Headers */
+ /* 0x80 - 0x9F SME to SME specific use*/
+ /* 0xA0 - 0xBF Reserved for future use*/
+ /* 0xC0 - 0xDF SC specific use*/
+ /* 0xE0 - 0xFF Reserved for future use*/
+ case WMS_UDH_USER_PROMPT:
+ length = 1 + 1 + WMS_UDH_OCTETS_USER_PROMPT;
+ break;
+
+ case WMS_UDH_EXTENDED_OBJECT:
+ length = 1 + 1 + udh->u.eo.content.length;
+ if( udh->u.eo.first_segment == TRUE )
+ {
+ length += WMS_UDH_OCTETS_EO_HEADER;
+ }
+ break;
+
+ default:
+ /* Header ID Octet + Header Length Octet + Header Length */
+ length = 1 + 1 + udh->u.other.header_length;
+ break;
+
+ }
+ }
+ return length;
+}
+
+uint32 wms_ts_compute_user_data_header_length
+(
+ const UINT8 num_headers,
+ const wms_udh_s_type *headers
+)
+{
+ uint32 length = 0;
+
+ uint32 i;
+
+ if( headers == NULL )
+ {
+ at_print(LOG_DEBUG,"Null pointer in wms_ts_compute_user_data_header_length!");
+ return 0;
+ }
+
+ if (num_headers > 0)
+ {
+ length += 1; /* 1 UINT8 for UDHL UINT8 */
+
+ /* User Data Headers Length */
+ for ( i=0 ; i<num_headers && i<WMS_MAX_UD_HEADERS ; i++)
+ {
+ length += (uint32)wms_ts_get_udh_length(&headers[i]);
+ }
+ }
+
+ return length;
+}
+
+
+uint32 wms_ts_compute_gw_user_data_length
+(
+ const wms_gw_dcs_s_type *dcs,
+ const wms_gw_user_data_s_type *user_data
+)
+{
+ uint32 length = 0;
+
+ if( dcs == NULL || user_data == NULL )
+ {
+ at_print(LOG_DEBUG,"Null pointer in wms_ts_compute_gw_user_data_length!");
+ return 0;
+ }
+
+ length += wms_ts_compute_user_data_header_length(user_data->num_headers, user_data->headers);
+
+ if( dcs->alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT )
+ {
+ length += ((user_data->sm_len * 7) + 7)/8;
+ }
+ else
+ {
+ length += user_data->sm_len;
+ }
+
+ return length;
+
+} /* wms_ts_compute_gw_user_data_length */
+
+
+static int wms_ts_encode_udh_concat_8
+(
+ UINT8 *udh
+)
+{
+ int pos =0;
+
+ if ( const_header->u.concat_8.total_sm == 0 ||
+ const_header->u.concat_8.seq_num == 0 ||
+ const_header->u.concat_8.seq_num > const_header->u.concat_8.total_sm)
+
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header id %d Present with no Data", const_header->header_id);
+ return 0;
+ }
+
+
+ udh[pos++] = (UINT8) WMS_UDH_CONCAT_8;
+ udh[pos++] = (UINT8) WMS_UDH_OCTETS_CONCAT8;
+ udh[pos++] = const_header->u.concat_8.msg_ref;
+ udh[pos++] = const_header->u.concat_8.total_sm;
+ udh[pos++] = const_header->u.concat_8.seq_num;
+
+ return pos;
+}/*wms_ts_encode_udh_concat_8*/
+
+static int wms_ts_encode_udh_concat16
+(
+ UINT8 *udh
+)
+{
+ int pos=0;
+
+ if (const_header->u.concat_16.total_sm == 0 ||
+ const_header->u.concat_16.seq_num == 0 ||
+ const_header->u.concat_16.seq_num > const_header->u.concat_16.total_sm)
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header id %d Present with no Data", const_header->header_id);
+ return 0;
+ }
+
+ udh[pos++] = (UINT8) WMS_UDH_CONCAT_16;
+ udh[pos++] = (UINT8) WMS_UDH_OCTETS_CONCAT16;
+ udh[pos++] = (UINT8)((const_header->u.concat_16.msg_ref & 0xFF00) >> 8);
+ udh[pos++] = (UINT8)(const_header->u.concat_16.msg_ref & 0x00FF);
+ udh[pos++] = const_header->u.concat_16.total_sm;
+ udh[pos++] = const_header->u.concat_16.seq_num;
+
+ return pos;
+}/*wms_ts_encode_udh_concat16*/
+
+int wms_ts_encode_udh_nat_lang_ss
+(
+ UINT8 *udh
+)
+{
+ int pos=0;
+
+ udh[pos++] = (UINT8) WMS_UDH_NAT_LANG_SS;
+ udh[pos++] = (UINT8) WMS_UDH_OCTETS_NAT_LANG_SS;
+ udh[pos++] = (UINT8)const_header->u.nat_lang_ss.nat_lang_id;
+
+ return pos;
+}/*wms_ts_encode_udh_nat_lang_ss*/
+
+
+int wms_ts_encode_udh_nat_lang_ls
+(
+ UINT8 *udh
+)
+{
+ int pos=0;
+
+ udh[pos++] = (UINT8) WMS_UDH_NAT_LANG_LS;
+ udh[pos++] = (UINT8) WMS_UDH_OCTETS_NAT_LANG_LS;
+ udh[pos++] = (UINT8)const_header->u.nat_lang_ls.nat_lang_id;
+
+ return pos;
+}/*wms_ts_encode_udh_nat_lang_ss*/
+
+int wms_ts_encode_udh_other
+(
+ UINT8 *udh,
+ wms_udh_id_e_type header_id
+)
+{
+ int i=0;
+ int pos =0;
+
+ udh[pos++] = (UINT8) const_header->u.other.header_id;
+ udh[pos++] = const_header->u.other.header_length;
+
+ for(i = 0; i< const_header->u.other.header_length; i++)
+ {
+ udh[pos++] = const_header->u.other.data[i];
+ }
+
+ return pos;
+}
+
+UINT8 wms_ts_encode_user_data_header
+(
+ UINT8 num_headers, /* IN */
+ const wms_udh_s_type * headers, /* IN */
+ UINT8 *data /* OUT */
+)
+{
+ int i,pos=0;
+
+ if (num_headers == 0)
+ return 0;
+
+ ++pos; /*Fill the user data header length later*/
+
+
+ for (i=0; i<WMS_MAX_UD_HEADERS && i< num_headers; i++)
+ {
+ const_header = &headers[i];
+ switch(const_header->header_id)
+ {
+ case WMS_UDH_CONCAT_8:
+ pos+= wms_ts_encode_udh_concat_8(data+pos);
+ break;
+
+ case WMS_UDH_CONCAT_16:
+ pos+= wms_ts_encode_udh_concat16(data+pos);
+ break;
+#if 0
+ case WMS_UDH_SPECIAL_SM:
+ pos+= wms_ts_encode_udh_special_sm(data+pos);
+ break;
+
+ case WMS_UDH_PORT_8:
+ pos+= wms_ts_encode_udh_port_8(data+pos);
+ break;
+
+ case WMS_UDH_PORT_16:
+ pos+= wms_ts_encode_udh_port16(data+pos);
+ break;
+
+ case WMS_UDH_TEXT_FORMATING:
+ pos+= wms_ts_encode_udh_text_formatting(data+pos);
+ break;
+
+
+ case WMS_UDH_PRE_DEF_SOUND:
+ pos+= wms_ts_encode_udh_pre_def_sound(data+pos);
+ break;
+
+ case WMS_UDH_USER_DEF_SOUND:
+ pos+= wms_ts_encode_udh_user_def_sound(data+pos);
+ break;
+
+ case WMS_UDH_PRE_DEF_ANIM:
+ pos+= wms_ts_encode_udh_pre_def_anim(data+pos);
+ break;
+
+ case WMS_UDH_LARGE_ANIM:
+ pos+= wms_ts_encode_udh_large_anim(data+pos);
+ break;
+
+ case WMS_UDH_SMALL_ANIM:
+ pos+= wms_ts_encode_udh_small_anim(data+pos);
+ break;
+
+ case WMS_UDH_LARGE_PICTURE:
+ pos+= wms_ts_encode_udh_large_picture(data+pos);
+ break;
+
+ case WMS_UDH_SMALL_PICTURE:
+ pos+= wms_ts_encode_udh_small_picture(data+pos);
+ break;
+
+ case WMS_UDH_VAR_PICTURE:
+ pos+= wms_ts_encode_udh_var_picture(data+pos);
+ break;
+
+ case WMS_UDH_USER_PROMPT:
+ pos+= wms_ts_encode_udh_user_prompt(data+pos);
+ break;
+
+ case WMS_UDH_EXTENDED_OBJECT:
+ pos+= wms_ts_encode_udh_eo(data+pos);
+ break;
+
+ case WMS_UDH_RFC822:
+ pos+= wms_ts_encode_udh_rfc822(data+pos);
+ break;
+ #endif
+ /*add by yangpeng, 2011.4.5, begin*/
+ case WMS_UDH_NAT_LANG_SS:
+ pos+= wms_ts_encode_udh_nat_lang_ss(data+pos);
+ break;
+
+ case WMS_UDH_NAT_LANG_LS:
+ pos+= wms_ts_encode_udh_nat_lang_ls(data+pos);
+ break;
+ /*add by yangpeng, 2011.4.5, end*/
+
+ default:
+ pos+= wms_ts_encode_udh_other(data+pos,const_header->header_id);
+ }
+
+ }
+ data[0] = (UINT8)(pos-1); /*User Data Header Length*/
+ return ((UINT8)(pos-1));
+
+} /*wms_ts_encode_user_data_header*/
+
+
+UINT8 wms_ts_encode_gw_user_data
+(
+ const wms_gw_dcs_s_type *dcs,
+ const wms_gw_user_data_s_type *user_data,
+ UINT8 *data
+)
+{
+ UINT16 i, pos=0;
+ UINT8 fill_bits = 0;
+ UINT16 total_bits_occupied;
+
+ UINT8 user_data_header_length;
+ UINT16 user_data_length; /*User Data Length with the header*/
+
+ data[pos] = (UINT8)user_data->sm_len; /*User Data length*/
+ pos++;
+ if( dcs->alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT )
+ {
+ /* pack GSM default characters */
+ if (user_data->num_headers > 0)
+ {
+ /* Check for Memory Corruption - data[WMS_MAX_LEN] */
+ if (wms_ts_compute_user_data_header_length(user_data->num_headers, user_data->headers) <= WMS_SMS_UDL_MAX_8_BIT)
+ {
+
+ user_data_header_length = wms_ts_encode_user_data_header( user_data->num_headers,
+ user_data->headers,
+ data+pos);
+
+ pos += user_data_header_length + 1;
+
+ total_bits_occupied = (user_data_header_length + 1) * 8;
+ fill_bits = (total_bits_occupied % 7); /* fill_bits vary from 0 to 6 */
+
+ if (fill_bits != 0)
+ {
+ fill_bits = 7 - fill_bits;
+ }
+
+ user_data_length = (total_bits_occupied + fill_bits + (user_data->sm_len * 7)) / 7;
+
+ data[0] = (UINT8)user_data_length; /* UDL */
+ data[1] = user_data_header_length; /* UDHL */
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Encode User Data Header Exceeds Capacity - Skipping UDH");
+ }
+ }
+
+ i = wms_ts_pack_gw_7_bit_chars( user_data->sm_data,
+ user_data->sm_len,
+ fill_bits,
+ (UINT16) (WMS_MAX_LEN - pos),
+ & data[pos] );
+ pos += i;
+ }
+ else
+ {
+ if (user_data->num_headers > 0)
+ {
+ /* Check for Memory Corruption - data[WMS_MAX_LEN] */
+ if (wms_ts_compute_user_data_header_length(user_data->num_headers, user_data->headers) <= WMS_SMS_UDL_MAX_8_BIT)
+ {
+ user_data_header_length =
+ wms_ts_encode_user_data_header(user_data->num_headers,
+ user_data->headers,
+ data+pos);
+
+ /*TP-UDL is modified to actual user data + udhl */
+ data[0] = (UINT8)(user_data->sm_len + user_data_header_length +1);
+ pos += user_data_header_length+1;
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Encode User Data Header Exceeds Capacity - Skipping UDH");
+ }
+ }
+
+ memcpy( & data[pos],
+ user_data->sm_data,
+ user_data->sm_len );
+ pos += user_data->sm_len;
+ }
+
+ return (UINT8)pos;
+
+} /* wms_ts_encode_gw_user_data() */
+
+
+
+wms_status_e_type wms_ts_encode_deliver
+(
+ const wms_gw_deliver_s_type *deliver,
+ T_zUfiSms_RawTsData *raw_ts_data_ptr
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ UINT8 *data;
+ UINT8 pos = 0, i;
+
+ if( deliver == NULL || raw_ts_data_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"Null pointer in wms_ts_encode_deliver!");
+ return WMS_NULL_PTR_S;
+ }
+
+ data = raw_ts_data_ptr->data;
+
+ /* Setting Data to 0 */
+ (void)memset(data, 0, WMS_MAX_LEN);
+
+ /* TP-MTI, TP-MMS, TP-SRI, TP_UDHI, TP-RP:
+ */
+ data[pos] = 0x00; /* DELIVER: bits 0, 1 */
+ data[pos] |= deliver->more ? 0 : 0x04; /* bit 2 */
+ /* bits 3, 4 are not used */
+ data[pos] |= deliver->status_report_enabled ? 0x20 : 0; /* bit 5 */
+ data[pos] |= deliver->user_data_header_present ? 0x40 : 0; /* bit 6 */
+ data[pos] |= deliver->reply_path_present ? 0x80 : 0; /* bit 7 */
+ pos ++;
+
+ /* TP-OA
+ */
+ i = wms_ts_encode_address( & deliver->address, & data[pos] );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+ pos += i;
+
+ /* TP-PID
+ */
+ data[pos] = deliver->pid;
+ pos ++;
+
+ /* TP-DCS
+ */
+ pos += wms_ts_encode_dcs( & deliver->dcs, data+pos );
+
+ /* TP-SCTS
+ */
+ i = wms_ts_encode_timestamp( & deliver->timestamp, data+pos );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+ /* TP-UDL
+ */
+ /* data[pos] = (UINT8)deliver->user_data.sm_len;
+ pos ++;*/
+
+ /*TP_UDL is filled in encode_gw_user_data function*/
+ /* TP-UD
+ */
+ if (wms_ts_compute_gw_user_data_length( &deliver->dcs, &deliver->user_data) > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ at_print(LOG_DEBUG,"User Data Length has exceeded capacity");
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+ else
+ {
+ i = wms_ts_encode_gw_user_data( & deliver->dcs,
+ & deliver->user_data,
+ data+pos );
+ pos += i;
+ }
+
+ raw_ts_data_ptr->tpdu_type = WMS_TPDU_DELIVER;
+ raw_ts_data_ptr->len = pos;
+
+ return st;
+
+} /* wms_ts_encode_deliver() */
+
+UINT8 wms_ts_encode_relative_time
+(
+ const wms_timestamp_s_type *timestamp
+)
+{
+ uint32 i;
+ UINT8 v = 0, j;
+ /* round up to the next time unit boundary*/
+
+ if (timestamp != NULL)
+ {
+ if ( !wms_ts_bcd_to_int(timestamp->year, &j) )
+ {
+ at_print(LOG_DEBUG,"Year is invalid: %d", j);
+ }
+ i = j * 365;
+
+ if ( !wms_ts_bcd_to_int(timestamp->month, &j) )
+ {
+ at_print(LOG_DEBUG,"Month is invalid: %d", j);
+ }
+ i = i + j * 30;
+
+ if ( !wms_ts_bcd_to_int(timestamp->day, &j) )
+ {
+ at_print(LOG_DEBUG,"Day is invalid: %d", j);
+ }
+ i += j;
+
+ if( i > 30 )
+ {
+ /* 197 - 255: (TP-VP - 192) weeks */
+ v = (UINT8) ( (i+6) / 7 + 192 );
+ }
+ else if( i >= 1 )
+ {
+ /* 168 to 196: (TP-VP - 166 ) days */
+ v = (UINT8) ( i + 166 );
+ }
+ else
+ {
+ if ( !wms_ts_bcd_to_int(timestamp->day, &j) )
+ {
+ at_print(LOG_DEBUG,"Day is invalid: %d", j);
+ }
+ i = j * 24 * 60;
+
+ if ( !wms_ts_bcd_to_int(timestamp->hour, &j) )
+ {
+ at_print(LOG_DEBUG,"Hour is invalid: %d", j);
+ }
+ i = i + j * 60;
+
+ if ( !wms_ts_bcd_to_int(timestamp->minute, &j) )
+ {
+ at_print(LOG_DEBUG,"Minute is invalid: %d", j);
+ }
+ i += j;
+
+ if( i > 12 * 60 ) /* greater than 12 hours */
+ {
+ /* 144 - 167: 12 hours + ( (TP-VP - 143) * 30 minutes ) */
+ v = (UINT8) ( ( i - ((12 * 60) + 29) ) / 30 + 143 );
+ }
+ else
+ {
+ /* 0 - 143: (TP-VP + 1) * 5 minutes */
+ v = (UINT8) ( ( i + 4 ) / 5 - 1 );
+ }
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_encode_relative_time");
+ }
+ /* done */
+ return v;
+
+} /* wms_ts_encode_relative_time() */
+
+
+UINT8 wms_ts_encode_gw_validity
+(
+ const wms_gw_validity_s_type *validity,
+ UINT8 *data
+)
+{
+ UINT8 i, pos = 0;
+
+ switch( validity->format )
+ {
+ case WMS_GW_VALIDITY_NONE:
+ break;
+
+ case WMS_GW_VALIDITY_RELATIVE:
+ data[pos] = wms_ts_encode_relative_time( & validity->u.time );
+ pos ++;
+ break;
+
+ case WMS_GW_VALIDITY_ABSOLUTE:
+ i = wms_ts_encode_timestamp( & validity->u.time, data+pos );
+ if( i == 0 )
+ {
+ at_print(LOG_DEBUG,"Error while Decoding Absolute Validity Timestamp");
+ }
+ pos += i;
+ break;
+
+ case WMS_GW_VALIDITY_ENHANCED:
+ // TBD
+ break;
+
+ default:
+ break;
+ } /* switch */
+
+ return pos;
+
+} /* wms_ts_encode_gw_validity() */
+
+
+wms_status_e_type wms_ts_encode_submit
+(
+ const wms_gw_submit_s_type *submit,
+ T_zUfiSms_RawTsData *raw_ts_data_ptr
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ UINT8 *data;
+ UINT8 pos = 0, i;
+
+ if( submit == NULL || raw_ts_data_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"Null pointer in wms_ts_encode_submit!");
+ return WMS_NULL_PTR_S;
+ }
+
+ data = raw_ts_data_ptr->data;
+
+ /* Setting Data to 0 */
+ (void)memset(data, 0, WMS_MAX_LEN);
+
+ /* TP-MTI, TP-RD, TP-VPF, TP-SRR, TP_UDHI, TP-RP:
+ */
+ data[pos] = 0x01; /* SUBMIT: bits 0, 1 */
+ data[pos] |= submit->reject_duplicates ? 0x04 : 0; /* bit 2 */
+
+ if (submit->validity.format > 3 )
+ {
+ return st = WMS_INVALID_VALIDITY_FORMAT_S;
+ }
+ data[pos] |= submit->validity.format << 3; /* bits 3, 4 */
+
+ data[pos] |= submit->status_report_enabled ? 0x20 : 0; /* bit 5 */
+ data[pos] |= submit->user_data_header_present ? 0x40 : 0; /* bit 6 */
+ data[pos] |= submit->reply_path_present ? 0x80 : 0; /* bit 7 */
+ pos ++;
+
+ /* TP-MR
+ */
+ data[pos] = (UINT8) submit->message_reference;
+ pos ++;
+
+ /* TP-DA
+ */
+ i = wms_ts_encode_address( & submit->address, & data[pos] );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+ pos += i;
+
+
+ /* TP-PID
+ */
+ data[pos] = submit->pid;
+ pos ++;
+
+ /* TP-DCS
+ */
+ pos += wms_ts_encode_dcs( & submit->dcs, data+pos );
+
+ /* TP-VP
+ */
+ pos += wms_ts_encode_gw_validity( & submit->validity, data+pos );
+
+ /* TP-UDL
+ */
+ /*data[pos] =(UINT8) submit->user_data.sm_len;
+ pos ++;*/
+
+ /*TP_UDL is filled in encode_gw_user_data function*/
+
+ /* TP-UD
+ */
+
+ if (wms_ts_compute_gw_user_data_length( &submit->dcs, &submit->user_data) > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ at_print(LOG_DEBUG,"User Data Length has exceeded capacity");
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+ else
+ {
+ i = wms_ts_encode_gw_user_data( & submit->dcs,
+ & submit->user_data,
+ data+pos );
+ pos += i;
+ }
+
+ raw_ts_data_ptr->tpdu_type = WMS_TPDU_SUBMIT;
+ raw_ts_data_ptr->len = pos;
+
+ return st;
+
+} /* wms_ts_encode_submit() */
+
+wms_status_e_type wms_ts_encode_status_report
+(
+ const wms_gw_status_report_s_type *status_report,
+ T_zUfiSms_RawTsData *raw_ts_data_ptr
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ UINT8 *data;
+ UINT8 pos = 0, i;
+
+ if( status_report == NULL || raw_ts_data_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"Null pointer in wms_ts_encode_status_report!");
+ return WMS_NULL_PTR_S;
+ }
+
+ data = raw_ts_data_ptr->data;
+
+ /* Setting Data to 0 */
+ (void)memset(data, 0, WMS_MAX_LEN);
+
+ /* TP-MTI, TP_UDHI:
+ */
+ data[pos] = 0x10; /* Status Report bits 0, 1 */
+ data[pos] |= status_report->more ? 0 : 0x04;/*bit 2*/
+ data[pos] |= status_report->status_report_qualifier ? 0x20 : 0; /*bit 5*/
+ data[pos] |= status_report->user_data_header_present ? 0x40 : 0;
+ /* bit 6 */
+ pos ++;
+
+ /* TP-MR
+ */
+ data[pos] = (UINT8) status_report->message_reference;
+ pos ++;
+
+ /* TP-RA
+ */
+ i = wms_ts_encode_address( & status_report->address, & data[pos] );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+ pos += i;
+
+
+ /* TP-SCTS
+ */
+ i = wms_ts_encode_timestamp( & status_report->timestamp, data+pos );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+ /* TP-DT*/
+ i = wms_ts_encode_timestamp( & status_report->discharge_time, data+pos );
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+ /*TP-ST*/
+ data[pos] = status_report->tp_status;
+ pos++;
+
+ /*TP-PI*/
+ data[pos] = (UINT8) status_report->mask;
+ pos ++;
+
+ /*TP-PID*/
+ if( status_report->mask & WMS_TPDU_MASK_PID )
+ {
+ data[pos] = status_report->pid;
+ pos ++;
+ }
+
+ /* TP-DCS
+ */
+ if( status_report->mask & WMS_TPDU_MASK_DCS )
+ {
+ pos += wms_ts_encode_dcs( & status_report->dcs, data+pos );
+ }
+
+ if( status_report->mask & WMS_TPDU_MASK_USER_DATA)
+ {
+ /* TP-UDL
+ */
+ /*data[pos] =(UINT8) deliver_report_error->user_data.sm_len;
+ pos ++;*/
+
+ /*TP_UDL is filled in encode_gw_user_data function*/
+
+ /* TP-UD
+ */
+ if (wms_ts_compute_gw_user_data_length( &status_report->dcs, &status_report->user_data) > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ at_print(LOG_DEBUG,"User Data Length has exceeded capacity");
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+ else
+ {
+ i = wms_ts_encode_gw_user_data( & status_report->dcs,
+ & status_report->user_data,
+ data+pos );
+ pos += i;
+ }
+ }
+
+ raw_ts_data_ptr->tpdu_type = WMS_TPDU_STATUS_REPORT;
+ raw_ts_data_ptr->len = pos;
+
+ return st;
+
+} /* wms_ts_encode_status_report() */
+
+wms_status_e_type wms_ts_encode
+(
+ const T_zUfiSms_ClientTsData * ptClientTsData,
+ T_zUfiSms_RawTsData * ptRawTsData
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ const wms_gw_pp_ts_data_s_type *msg;
+
+ if( ptClientTsData == NULL || ptRawTsData == NULL )
+ {
+ return WMS_NULL_PTR_S;
+ }
+
+ msg = & ptClientTsData->u.gw_pp;
+ //pthread_mutex_lock( &wmsts_mutex );
+
+ switch( ptClientTsData->format )
+ {
+ #if 0
+ case WMS_FORMAT_CDMA:
+ case WMS_FORMAT_ANALOG_AWISMS:
+ case WMS_FORMAT_ANALOG_CLI:
+ case WMS_FORMAT_ANALOG_VOICE_MAIL:
+ case WMS_FORMAT_ANALOG_SMS:
+ case WMS_FORMAT_MWI:
+ st = wms_ts_encode_bearer_data( & ptClientTsData->u.cdma,
+ ptRawTsData );
+ break;
+ #endif
+ case WMS_FORMAT_GW_PP:
+ /* ---------- Start encoding --------- */
+
+ ptRawTsData->tpdu_type = msg->tpdu_type;
+
+ switch( msg->tpdu_type )
+ {
+ case WMS_TPDU_DELIVER:
+ st = wms_ts_encode_deliver( & msg->u.deliver, ptRawTsData );
+ break;
+
+ case WMS_TPDU_SUBMIT:
+ st = wms_ts_encode_submit( & msg->u.submit, ptRawTsData );
+ break;
+
+ case WMS_TPDU_STATUS_REPORT:
+ st = wms_ts_encode_status_report( & msg->u.status_report,
+ ptRawTsData );
+ break;
+#if 0
+ case WMS_TPDU_SUBMIT_REPORT_ACK:
+ st = wms_ts_encode_submit_report_ack( & msg->u.submit_report_ack,
+ ptRawTsData );
+ break;
+
+
+ case WMS_TPDU_SUBMIT_REPORT_ERROR:
+ st = wms_ts_encode_submit_report_error( & msg->u.submit_report_error,
+ ptRawTsData );
+ break;
+
+ case WMS_TPDU_COMMAND:
+ st = wms_ts_encode_command( & msg->u.command,
+ ptRawTsData );
+ break;
+
+ case WMS_TPDU_DELIVER_REPORT_ACK:
+ st = wms_ts_encode_deliver_report_ack( & msg->u.deliver_report_ack,
+ ptRawTsData );
+ break;
+
+ case WMS_TPDU_DELIVER_REPORT_ERROR:
+ st = wms_ts_encode_deliver_report_error( & msg->u.deliver_report_error,
+ ptRawTsData );
+ break;
+
#endif
-if(nLength<(0xe8d+6031-0x261b)||nLength>=sizeof(tmpSCA))return-
-(0x612+5402-0x1b2b);nDstLength=Bytes2String(buf,pDst,(0x96d+7346-0x261d));
-nDstLength+=InvertNumbers(tmpSCA,&pDst[nDstLength],nLength);
-#if (0x1185+5264-0x2614)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x70\x64\x73\x74\x33\x3a\x25\x73" "\n",
-pDst);
-#endif
-if(pSrc->TPA[(0xf3+6647-0x1aea)]==((char)(0xc43+4906-0x1f42))){nLength=strlen(&(
-pSrc->TPA[(0x526+8259-0x2568)]));}else{nLength=strlen(pSrc->TPA);}if(pSrc->
-TP_UDHI==(0x2292+988-0x266e)){if(pSrc->TP_SRR==(0x62b+7850-0x24d5)){buf[
-(0xa2a+3806-0x1908)]=(0x105f+1439-0x15ed);}if(pSrc->TP_SRR==(0x14c2+3547-0x229c)
-){buf[(0x9b7+5193-0x1e00)]=(0x988+2155-0x11c2);}}if(pSrc->TP_UDHI==
-(0x6c9+7306-0x2352)){if(pSrc->TP_SRR==(0xd68+3913-0x1cb1)){buf[
-(0x210+1822-0x92e)]=(0x81b+5232-0x1c3a);}if(pSrc->TP_SRR==(0xa83+6670-0x2490)){
-buf[(0x1fa+4579-0x13dd)]=(0x976+3952-0x1875);}}buf[(0x1811+1398-0x1d86)]=
-(0x463+8081-0x23f4);buf[(0x98d+6871-0x2462)]=(char)nLength;if(pSrc->TPA[
-(0xbb8+1098-0x1002)]==((char)(0x13aa+1663-0x19fe))){buf[(0xae2+3431-0x1846)]=
-(0xae8+5333-0x1f2c);nDstLength+=Bytes2String(buf,&pDst[nDstLength],
-(0xfc4+4788-0x2274));nDstLength+=InvertNumbers(&(pSrc->TPA[(0x4a4+6728-0x1eeb)])
-,&pDst[nDstLength],nLength);}else if(!(strncmp(pSrc->TPA,"\x30\x30\x38\x36",
-(0xa2a+1460-0xfda)))){buf[(0xa34+151-0xac9)]=(char)nLength-(0xa16+3536-0x17e4);
-buf[(0x124c+214-0x131f)]=(0xf87+1266-0x13e8);nDstLength+=Bytes2String(buf,&pDst[
-nDstLength],(0x1e9f+1711-0x254a));nDstLength+=InvertNumbers(&(pSrc->TPA[
-(0xc53+3594-0x1a5b)]),&pDst[nDstLength],nLength-(0x255f+116-0x25d1));}else{buf[
-(0xe9+2917-0xc4b)]=(0x879+4114-0x180a);nDstLength+=Bytes2String(buf,&pDst[
-nDstLength],(0x2b0+3037-0xe89));nDstLength+=InvertNumbers(pSrc->TPA,&pDst[
-nDstLength],nLength);}
-#if (0x1556+889-0x18ce)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x70\x64\x73\x74\x34\x3a\x25\x73" "\n",
-pDst);
-#endif
-nLength=(int)pSrc->TP_UDLength;buf[(0xfcb+5526-0x2561)]=pSrc->TP_PID;buf[
-(0x1479+2226-0x1d2a)]=pSrc->TP_DCS;buf[(0x48c+5977-0x1be3)]=pSrc->TP_VP;if(pSrc
-->TP_DCS==CODE_GSM7){nLength=code_is_gsm7(pSrc,buf,nLength);}else if(pSrc->
-TP_DCS==CODE_UCS2){nLength=code_is_ucs2(pSrc,buf,nLength);}else{nLength=strlen(
-pSrc->TP_UD);if(pSrc->TP_UDHI==(0xa65+3462-0x17ea)){buf[(0xbda+3579-0x19d2)]=(
-unsigned char)nLength;buf[(0x7a5+4766-0x1a3f)]=(unsigned char)pSrc->TP_UD[
-(0xda5+1398-0x131b)];buf[(0x1800+1468-0x1db7)]=(0x1c05+529-0x1e16);buf[
-(0xd67+4174-0x1daf)]=(unsigned char)pSrc->TP_UD[(0x3a8+1494-0x97c)];buf[
-(0x1b4f+2665-0x25b1)]=(unsigned char)pSrc->TP_UD[(0x13d9+803-0x16f9)];buf[
-(0x1786+457-0x1947)]=(unsigned char)pSrc->TP_UD[(0x1b0d+1556-0x211d)];buf[
-(0x19a7+1338-0x1ed8)]=(unsigned char)pSrc->TP_UD[(0x2a9+458-0x46e)];if(nLength-
-(0x29c+3173-0xefb)<=(0xb3d+7027-0x26b0)||nLength-(0x1454+2345-0x1d77)>=sizeof(
-buf)-(0x153+7652-0x1f2d))return-(0xf81+5502-0x24fe);buf[(0xe7+3152-0xd34)]=(
-unsigned char)(Encode8bit(&(pSrc->TP_UD[(0x7d9+4068-0x17b7)]),&buf[
-(0x1675+398-0x17f9)],(unsigned short)(nLength-(0x8f7+4169-0x193a)))+
-(0x9fd+7062-0x258d));nLength=buf[(0x12ac+8-0x12b1)]+(0xb7f+5098-0x1f65);}else{if
-(nLength<=(0x19d+3530-0xf67)||nLength>=sizeof(buf)-(0x13bc+4660-0x25ec))return-
-(0x1aeb+2758-0x25b0);buf[(0x93a+682-0xbe1)]=Encode8bit(pSrc->TP_UD,&buf[
-(0x391+7281-0x1ffe)],nLength);nLength=buf[(0x1ed6+397-0x2060)]+
-(0xc37+2843-0x174e);}}check_udl=nLength-(0x736+358-0x898);nDstLength+=
-Bytes2String(buf,&pDst[nDstLength],nLength);sc_cfg_set(NV_CHECK_UDL,"");if(
-check_udl>(0x999+3899-0x1848)){sc_cfg_set(NV_CHECK_UDL,"\x65\x72\x72\x6f\x72");}
-#if (0x5c2+374-0x737)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x20\x45\x6e\x63\x6f\x64\x65\x50\x64\x75\x5f\x53\x75\x62\x6d\x69\x74\x20\x65\x6e\x64\x20\x6d\x61\x6b\x65\x20\x70\x64\x75\x20\x64\x61\x74\x61" "\n"
-);printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x6c\x65\x6e\x3a\x25\x64\x2c\x20\x74\x70\x75\x64\x3a\x25\x73" "\n"
-,nDstLength,pSrc->TP_UD);
-#endif
-#if (0x538+6694-0x1f5d)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x70\x64\x73\x74\x35\x3a\x25\x73" "\n",
-pDst);
-#endif
-return nDstLength;}int Decode7bit(const unsigned char*pSrc,char*pDst,int
-nSrcLength){int nSrc;int nDst;int nByte;unsigned char nLeft;if(pSrc==NULL||pDst
-==NULL||nSrcLength<(0xf87+3793-0x1e58)){return-(0xf99+3794-0x1e6a);}nSrc=
-(0xcb+9528-0x2603);nDst=(0x53+7348-0x1d07);nByte=(0xd7d+3775-0x1c3c);nLeft=
-(0x598+2497-0xf59);while(nSrc<nSrcLength){*pDst=((*pSrc<<nByte)|nLeft)&
-(0x1bb8+347-0x1c94);nLeft=*pSrc>>((0x1cd1+2105-0x2503)-nByte);pDst++;nDst++;
-nByte++;if(nByte==(0x834+5856-0x1f0d)){*pDst=nLeft;pDst++;nDst++;nByte=
-(0xa82+3269-0x1747);nLeft=(0x1a27+330-0x1b71);}pSrc++;nSrc++;}*pDst='\0';return
-nDst;}int DecodePushPdu(const char*pSrcPdu,SMS_PARAM*pDst){int nDstLength=
-(0x21+75-0x6c);unsigned char tmp=(0x585+73-0x5ce);int ud_length=
-(0x3e8+1640-0xa50);unsigned char buf[(0x11c1+4981-0x2436)]={(0x1784+469-0x1959)}
-;char temp_num[(0x1b49+1844-0x2219)]={(0x2f2+651-0x57d)};unsigned char
-first_octet=(0xe64+2067-0x1677);unsigned char udhl=(0xc3b+2204-0x14d7);unsigned
-int halftmp=(0xa4c+3910-0x1992);char tp_ra[(0x484+555-0x6ac)]={
-(0x1b4a+1220-0x200e)};int tmplen=(0x59+6469-0x199e);unsigned char IEIDL;int
-pushType=(0x192+349-0x2ef);const char*pSrc=pSrcPdu;if(pSrcPdu==NULL||pDst==NULL)
-{printf(
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x70\x61\x72\x61\x20\x6e\x75\x6c\x6c\x2e\x20" "\n"
-);return-(0xe36+4961-0x2196);}String2Bytes(pSrc,&tmp,(0x4d0+8314-0x2548));
-at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x74\x6d\x70\x20\x3d\x20\x25\x64\x2e" "\n"
-,tmp);if(tmp==(0x121+1095-0x568)){pSrc+=(0x16f3+2113-0x1f32);}else{tmp=(tmp-
-(0x56f+8058-0x24e8))*(0x51f+2548-0xf11);pSrc+=(0x488+400-0x614);if(tmp>
-(0x7e4+7561-0x254d)){SerializeNumbers_sms(pSrc,pDst->SCA,(0xcaa+2524-0x1666));
-tmp=(0xabb+2800-0x158b);}else{SerializeNumbers_sms(pSrc,pDst->SCA,tmp);}pSrc+=
-tmp;}String2Bytes(pSrc,&tmp,(0x418+3428-0x117a));first_octet=tmp;pSrc+=
-(0xc41+1705-0x12e8);String2Bytes(pSrc,&tmp,(0x3f6+6384-0x1ce4));halftmp=tmp;if(
-tmp&(0x70+454-0x235))tmp+=(0x42+5628-0x163d);pSrc+=(0xf3+7415-0x1de8);memset(
-tp_ra,(0x139a+4980-0x270e),sizeof(tp_ra));String2Bytes(pSrc,tp_ra,
-(0x1387+3435-0x20f0));pSrc+=(0x1136+333-0x1281);if((tp_ra[(0x30a+7401-0x1ff3)]&
-(0x1254+2928-0x1d74))==(0x75c+1781-0xe01)){char tempra[(0xc5f+5736-0x2247)];char
- acAsc[(0x2d8+918-0x5ee)];if(halftmp>=(0x8a4+4862-0x1b94)){halftmp=(tmp/
-(0x1f13+1593-0x254a))/(0x38a+7388-0x205f)+(tmp/(0x140f+4105-0x2416));}else{
-halftmp=tmp/(0x733+2436-0x10b5);}memset(tempra,(0x891+1277-0xd8e),sizeof(tempra)
-);memcpy(tempra,pSrc,tmp);memset(acAsc,(0x857+1352-0xd9f),sizeof(acAsc));
-nDstLength=String2Bytes(tempra,buf,halftmp&(0xa+1248-0x4e3)?(int)halftmp*
-(0xb0d+1363-0x1059)/(0x85b+1065-0xc80)+(0x348+5341-0x1823):(int)halftmp*
-(0xe6f+5884-0x2564)/(0x104+9021-0x243d));halftmp=Decode7bit(buf,acAsc,nDstLength
-);memset(pDst->TPA,(0x8eb+6697-0x2314),sizeof(pDst->TPA));if(halftmp>
-(0x12b+7923-0x1ffe)){memcpy(pDst->TPA,acAsc,(0x301+5192-0x1729));tmp=
-(0x113a+2854-0x1c40);}else{memcpy(pDst->TPA,acAsc,halftmp);}}else{if(tmp>
-(0x124+1239-0x5db)){SerializeNumbers_sms(pSrc,pDst->TPA,(0x1d4a+2079-0x2549));}
-else{SerializeNumbers_sms(pSrc,pDst->TPA,tmp);}if((tp_ra[(0x68f+4039-0x1656)]&
-(0xa01+616-0xbd8))==(0x1329+2029-0x1a85)){memset(temp_num,(0x212a+1196-0x25d6),
-sizeof(temp_num));if(pDst->TPA[(0x3e3+771-0x6e6)]!=((char)(0x13d2+4628-0x25bb)))
-{snprintf(temp_num,sizeof(temp_num),"\x25\x73\x25\x73","\x2b",pDst->TPA);if(
-strlen(temp_num)>(0x155f+4263-0x25e6)){snprintf(pDst->TPA,sizeof(pDst->TPA),
-"\x25\x33\x32\x73",temp_num);}else{snprintf(pDst->TPA,sizeof(pDst->TPA),
-"\x25\x73",temp_num);}}}}pSrc+=tmp;String2Bytes(pSrc,(unsigned char*)&pDst->
-TP_PID,(0x5e2+7739-0x241b));pSrc+=(0xccc+399-0xe59);String2Bytes(pSrc,(unsigned
-char*)&pDst->TP_DCS,(0x10c6+3883-0x1fef));pSrc+=(0x97+5472-0x15f5);
-SerializeNumbers_sms(pSrc,pDst->TP_SCTS,(0xcd0+5322-0x218c));pSrc+=
-(0xb37+3856-0x1a39);String2Bytes(pSrc,&tmp,(0xe22+1076-0x1254));pSrc+=
-(0x1933+635-0x1bac);memset(pDst->TP_UD,(0x500+7719-0x2327),sizeof(pDst->TP_UD));
-at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x66\x69\x72\x73\x74\x5f\x6f\x63\x74\x65\x74\x20\x3d\x20\x30\x78\x25\x30\x32\x78\x2e" "\n"
-,first_octet);if(first_octet&(0x1ee9+1299-0x23bc)){const char*temp=pSrc;unsigned
- char pduType;unsigned char wspLen;unsigned char udhLen;unsigned char DestPort1;
-unsigned char DestPort2;unsigned char RefNum1;unsigned char RefNum2;pushType=
-SMS_NO_PUSH;String2Bytes(temp,&udhl,(0x7fd+3690-0x1665));temp+=
-(0xca2+5609-0x2289);tmplen=String2Bytes(temp,&pDst->TP_IEI,(0xc6f+2050-0x146f));
-at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x54\x50\x5f\x49\x45\x49\x20\x3d\x20\x30\x78\x25\x30\x32\x78\x2e" "\n"
-,pDst->TP_IEI);if(pDst->TP_IEI==(0x142+1832-0x865)){temp+=(0x433+6001-0x1ba2)*
-tmplen+(0x2f4+7377-0x1fc3);tmplen=String2Bytes(temp,&DestPort1,
-(0x78a+4803-0x1a4b));at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x44\x65\x73\x74\x50\x6f\x72\x74\x31\x20\x3d\x20\x30\x78\x25\x30\x32\x78\x2e" "\n"
-,DestPort1);temp+=(0x1972+1081-0x1da9)*tmplen;tmplen=String2Bytes(temp,&
-DestPort2,(0xb44+808-0xe6a));at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x44\x65\x73\x74\x50\x6f\x72\x74\x32\x20\x3d\x20\x30\x78\x25\x30\x32\x78\x2e" "\n"
-,DestPort2);if((DestPort1==(0x19d+9104-0x2522))&&((DestPort2==
-(0xcd6+2216-0x14fa))||(DestPort2==(0xa47+3109-0x15e7)))){pushType=SMS_PUSH;}}if(
-SMS_PUSH!=pushType){return pushType;}temp=pSrc+udhl*(0x7c4+3735-0x1659)+
-(0x7cb+7401-0x24b0);tmplen=String2Bytes(temp,&pduType,(0x7ef+6939-0x2308));if(
-pduType==(0x923+68-0x961)){pushType=SMS_PUSH;temp+=(0x9c5+6684-0x23dd);tmplen=
-String2Bytes(temp,&pduType,(0x717+5457-0x1c66));if(pduType==(0x1570+4429-0x25f9)
-){pushType=SMS_NOTIFICATION;}else{temp+=(0x1f6+6602-0x1bbc);tmplen=String2Bytes(
-temp,&pduType,(0x1e70+1696-0x250e));if((pduType==(0xd01+22-0xc55))||(pduType==
-(0x2e7+6699-0x1c5c))){pushType=SMS_BOOTSTRAP;}}}if((pDst->TP_IEI==
-(0x1476+1908-0x1be6))||(pDst->TP_IEI==(0x10a6+5685-0x26d6))||(pDst->TP_IEI==
-(0x1439+2686-0x1eaf))){temp=pSrc+(0x1675+2357-0x1fa6);tmplen=String2Bytes(temp,&
-IEIDL,(0x1611+2754-0x20d1));if(IEIDL==(udhl-(0x95c+44-0x986))){}else{temp+=
-(0x1489+638-0x1705)*(0x1473+877-0x17da);tmplen=String2Bytes(temp,&udhLen,
-(0x497+5543-0x1a3c));if(udhLen==(0x6a0+1564-0xcb9)){temp+=(0x2158+1387-0x26c1)*
-tmplen;tmplen=String2Bytes(temp,&RefNum1,(0x2241+970-0x2609));pDst->TP_ReferNum=
-RefNum1;temp+=(0x15e8+2948-0x216a)*tmplen;tmplen=String2Bytes(temp,&pDst->
-TP_AllPieceNum,(0x617+980-0x9e9));temp+=(0xca6+1366-0x11fa)*tmplen;tmplen=
-String2Bytes(temp,&pDst->TP_CurrentPieceNum,(0x13c6+1879-0x1b1b));temp+=
-(0x1171+690-0x1421)*tmplen;}else if(udhLen==(0x7d7+1199-0xc82)){temp+=
-(0xd57+5715-0x23a8)*tmplen;tmplen=String2Bytes(temp,&RefNum1,(0x540+6403-0x1e41)
-);temp+=(0x2f4+1000-0x6da)*tmplen;tmplen=String2Bytes(temp,&RefNum2,
-(0x5da+6443-0x1f03));int ReferNum=RefNum2+RefNum1*(0x2108+1155-0x248b);pDst->
-TP_ReferNum=ReferNum;temp+=(0x733+7883-0x25fc)*tmplen;tmplen=String2Bytes(temp,&
-pDst->TP_AllPieceNum,(0xdb1+3157-0x1a04));temp+=(0xb50+5213-0x1fab)*tmplen;
-tmplen=String2Bytes(temp,&pDst->TP_CurrentPieceNum,(0x1b2d+2349-0x2458));temp+=
-(0x946+5224-0x1dac)*tmplen;}}}at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x52\x65\x66\x65\x72\x4e\x75\x6d\x20\x3d\x20\x25\x64\x2c\x41\x6c\x6c\x4e\x75\x6d\x20\x3d\x25\x64\x2c\x43\x75\x72\x4e\x75\x6d\x20\x3d\x25\x64\x2e" "\n"
-,pDst->TP_ReferNum,pDst->TP_AllPieceNum,pDst->TP_CurrentPieceNum);if(
-SMS_NOTIFICATION==pushType){temp=pSrc+udhl*(0x1a87+2156-0x22f1)+
-(0x1b28+2958-0x26b0);tmplen=String2Bytes(temp,&wspLen,(0xc7b+5527-0x2210));temp=
-temp+wspLen*(0x931+2733-0x13dc)+(0x200f+1174-0x24a3);}else{temp=pSrc+udhl*
-(0x252+253-0x34d)+(0xe79+5671-0x249e);}nDstLength=((strlen(temp)<sizeof(pDst->
-TP_UD))?strlen(temp):(sizeof(pDst->TP_UD)-(0x742+28-0x75d)));memcpy(pDst->TP_UD,
-temp,nDstLength);at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x70\x44\x73\x74\x2d\x3e\x54\x50\x5f\x55\x44\x20\x3d\x20\x25\x73\x2e" "\n"
-,pDst->TP_UD);}at_print(LOG_DEBUG,
-"\x44\x65\x63\x6f\x64\x65\x50\x75\x73\x68\x50\x64\x75\x20\x70\x75\x73\x68\x54\x79\x70\x65\x20\x3d\x20\x25\x64\x2e" "\n"
-,pushType);return pushType;}static int SerializeNumbers_sms(const char*pSrc,char
-*pDst,int nSrcLength){int nDstLength;char ch;int i=(0x526+4460-0x1692);if(pSrc==
-NULL||pDst==NULL||nSrcLength<(0xee1+3666-0x1d33)){return-(0x70b+4277-0x17bf);}
-nDstLength=nSrcLength;for(i=(0x5b2+8155-0x258d);i<nSrcLength;i+=
-(0x758+3085-0x1363)){ch=*pSrc++;*pDst++=*pSrc++;*pDst++=ch;}if(*(pDst-
-(0xbd4+2261-0x14a8))==((char)(0x39d+2095-0xb86))){pDst--;nDstLength--;}*pDst=
-'\0';return nDstLength;}UINT16 wms_ts_pack_gw_7_bit_chars(const UINT8*in,UINT16
-in_len,UINT16 shift,UINT16 out_len_max,UINT8*out){UINT16 i=(0xd4b+1232-0x121b);
-UINT16 pos=(0xe7f+3339-0x1b8a);if(in==NULL||out==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x70\x61\x63\x6b\x5f\x67\x77\x5f\x37\x5f\x62\x69\x74\x5f\x63\x68\x61\x72\x73"
-);return(0xd64+3344-0x1a74);}shift%=(0x6b3+4386-0x17ce);if(shift!=
-(0x3c0+4322-0x14a2)){out[pos]|=(UINT8)(in[i]<<shift);shift=((0x1568+4097-0x2562)
--shift)+(0x502+4340-0x15f5);if(shift==(0x1748+634-0x19bb)){shift=
-(0xe3+7829-0x1f78);i++;}pos++;}for(;pos<out_len_max&&i<in_len;pos++,i++){out[pos
-]=in[i]>>shift;if(i+(0x632+4586-0x181b)<in_len){out[pos]|=(UINT8)(in[i+
-(0xf5c+2189-0x17e8)]<<((0x230c+903-0x268c)-shift));shift++;if(shift==
-(0x11e9+227-0x12c5)){shift=(0x1220+364-0x138c);i++;}}}return pos;}UINT8
-wms_ts_encode_address(const wms_address_s_type*addr,UINT8*data){UINT8 i,pos=
-(0xcab+6737-0x26fc);if(addr->number_of_digits>WMS_GW_ADDRESS_MAX){at_print(
-LOG_DEBUG,
-"\x41\x64\x64\x72\x20\x6c\x65\x6e\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x20\x25\x64"
-,addr->number_of_digits);return(0x2086+1547-0x2691);}if(addr->number_type==
-WMS_NUMBER_ALPHANUMERIC){data[pos]=(UINT8)((addr->number_of_digits*
-(0x7c5+659-0xa51)+(0x2389+29-0x23a3))/(0x5ad+1655-0xc20));}else{data[pos]=addr->
-number_of_digits;}pos++;data[pos]=(0xbbd+4333-0x1c2a);data[pos]|=(UINT8)((UINT8)
-addr->number_type<<(0x46b+3337-0x1170));data[pos]|=(UINT8)addr->number_plan;pos
-++;if(addr->number_type==WMS_NUMBER_ALPHANUMERIC){pos+=(UINT8)
-wms_ts_pack_gw_7_bit_chars(addr->digits,addr->number_of_digits,
-(0x11b8+4814-0x2486),WMS_GW_ADDRESS_MAX,&data[pos]);}else{for(i=
-(0x108a+5447-0x25d1);i<addr->number_of_digits;i++){data[pos]=(UINT8)(addr->
-digits[i++]&(0xb3b+4672-0x1d6c));{data[pos]|=(UINT8)(addr->digits[i]<<
-(0x420+7162-0x2016));}pos++;}}return pos;}UINT8 wms_ts_encode_dcs(const
-wms_gw_dcs_s_type*dcs,UINT8*data){UINT8 pos=(0x1f12+903-0x2299);if(dcs->
-msg_waiting==WMS_GW_MSG_WAITING_NONE){data[pos]=dcs->is_compressed?
-(0x1c83+108-0x1ccf):(0xe52+4845-0x213f);data[pos]|=(dcs->msg_class!=
-WMS_MESSAGE_CLASS_NONE)?(0xfac+4296-0x2064):(0xbe7+5838-0x22b5);data[pos]|=dcs->
-alphabet<<(0x55c+7109-0x211f);data[pos]|=dcs->msg_class&(0xb15+2869-0x1647);}
-else if(dcs->msg_waiting==WMS_GW_MSG_WAITING_NONE_1111){data[pos]=
-(0x115b+2697-0x1af4);if(dcs->alphabet==WMS_GW_ALPHABET_8_BIT)data[pos]|=
-(0x1c72+568-0x1ea6);data[pos]|=dcs->msg_class&(0xb00+6529-0x247e);}else{if(dcs->
-msg_waiting==WMS_GW_MSG_WAITING_DISCARD){data[pos]=(0x24af+164-0x2493);}else if(
-dcs->msg_waiting==WMS_GW_MSG_WAITING_STORE&&dcs->alphabet==
-WMS_GW_ALPHABET_7_BIT_DEFAULT){data[pos]=(0xd1d+5802-0x22f7);}else{data[pos]=
-(0x11a6+791-0x13dd);}data[pos]|=(dcs->msg_waiting_active==TRUE)?
-(0xf88+1004-0x136c):(0x138b+1854-0x1ac9);data[pos]|=dcs->msg_waiting_kind&
-(0x145a+3806-0x2335);}pos++;return pos;}UINT8 wms_ts_bcd_to_int(const UINT8 bcd,
-UINT8*result){unsigned char low_bit=(bcd&(0xc78+6771-0x26dc));unsigned char
-high_bit=((bcd&(0x119a+2573-0x1ab7))>>(0xbc6+1874-0x1314));if(low_bit>
-(0x3f2+7944-0x22f1)||high_bit>(0xb0+4798-0x1365)){at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x64\x69\x67\x69\x74\x21");*
-result=(0x769+7779-0x25cc);return FALSE;}else{*result=((bcd&(0x101f+583-0x1257))
-+(((bcd&(0xa2c+4534-0x1af2))>>(0x13c7+3825-0x22b4))*(0x61+4124-0x1073)));return
-TRUE;}}UINT8 wms_ts_encode_timestamp(const wms_timestamp_s_type*timestamp,UINT8*
-data){sint7 i;UINT8 pos=(0x996+6965-0x24cb),j;if(!wms_ts_bcd_to_int(timestamp->
-year,&j)){return(0x47f+5846-0x1b55);}data[pos]=((timestamp->year&
-(0x38b+8962-0x267e))<<(0xa2a+2990-0x15d4))+((timestamp->year&
-(0x11ca+5600-0x26ba))>>(0x36c+2055-0xb6f));pos++;if(wms_ts_bcd_to_int(timestamp
-->month,&j)){if(j>(0x675+7274-0x22d3)||j<(0x529+3937-0x1489)){at_print(LOG_DEBUG
-,
-"\x4d\x6f\x6e\x74\x68\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);return(0x68a+4922-0x19c4);}}else{return(0x1a5+5656-0x17bd);}data[pos]=((
-timestamp->month&(0x7e6+2138-0x1031))<<(0x13fd+2818-0x1efb))+((timestamp->month&
-(0x110+2214-0x8c6))>>(0x498+2781-0xf71));pos++;if(wms_ts_bcd_to_int(timestamp->
-day,&j)){if(j>(0x70f+5715-0x1d43)||j<(0xd63+4978-0x20d4)){at_print(LOG_DEBUG,
-"\x44\x61\x79\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j);
-return(0x379+6551-0x1d10);}}else{return(0xe8a+523-0x1095);}data[pos]=((timestamp
-->day&(0xb8f+1456-0x1130))<<(0xbf+356-0x21f))+((timestamp->day&
-(0x1ebf+1959-0x2576))>>(0x1022+1733-0x16e3));pos++;if(wms_ts_bcd_to_int(
-timestamp->hour,&j)){if(j>(0x1c00+648-0x1e71)){at_print(LOG_DEBUG,
-"\x48\x6f\x75\x72\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j
-);return(0x777+5795-0x1e1a);}}else{return(0x1578+2788-0x205c);}data[pos]=((
-timestamp->hour&(0xd7+4436-0x121c))<<(0x1a62+413-0x1bfb))+((timestamp->hour&
-(0x179d+128-0x172d))>>(0x1c9d+2497-0x265a));pos++;if(wms_ts_bcd_to_int(timestamp
-->minute,&j)){if(j>(0x1c3+3872-0x10a8)){at_print(LOG_DEBUG,
-"\x4d\x69\x6e\x75\x74\x65\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);return(0x1061+3381-0x1d96);}}else{return(0x1c0c+1166-0x209a);}data[pos]=((
-timestamp->minute&(0x67a+2367-0xfaa))<<(0x379+4244-0x1409))+((timestamp->minute&
-(0x79d+6289-0x1f3e))>>(0x1b+6799-0x1aa6));pos++;if(wms_ts_bcd_to_int(timestamp->
-second,&j)){if(j>(0xe0a+3979-0x1d5a)){at_print(LOG_DEBUG,
-"\x53\x65\x63\x6f\x6e\x64\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);return(0x18bf+2570-0x22c9);}}else{return(0x36f+6748-0x1dcb);}data[pos]=((
-timestamp->second&(0x1b53+2750-0x2602))<<(0x8f3+1096-0xd37))+((timestamp->second
-&(0x540+1727-0xb0f))>>(0x1889+1559-0x1e9c));pos++;i=(sint7)timestamp->timezone;
-if(i>(0x7f3+2527-0x11a2)||i<-(0x1c51+1475-0x21e4)){at_print(LOG_DEBUG,
-"\x54\x69\x6d\x65\x7a\x6f\x6e\x65\x20\x69\x73\x20\x6f\x75\x74\x20\x6f\x66\x20\x62\x6f\x75\x6e\x64\x3a\x20\x25\x64"
-,i);return(0x12ab+25-0x12c4);}if(i>=(0x70b+4104-0x1713)){data[pos]=(UINT8)(((
-UINT8)(i%(0x21c5+434-0x236d)))<<(0x75a+2138-0xfb0));data[pos]|=(i/
-(0x81f+3089-0x1426));}else{i*=(-(0x1170+561-0x13a0));data[pos]=(UINT8)(((UINT8)(
-i%(0x39f+3408-0x10e5)))<<(0x4ba+6922-0x1fc0));data[pos]|=(i/(0x316+4390-0x1432))
-;data[pos]|=(0x173f+12-0x1743);}pos++;return pos;}UINT8 wms_ts_get_udh_length(
-const wms_udh_s_type*udh){UINT8 length=(0x1314+2353-0x1c45);if(udh!=NULL){switch
-(udh->header_id){case WMS_UDH_CONCAT_8:length=(0x4a3+8252-0x24de)+
-(0x892+4358-0x1997)+WMS_UDH_OCTETS_CONCAT8;break;case WMS_UDH_CONCAT_16:length=
-(0x7e8+2407-0x114e)+(0x67+8779-0x22b1)+WMS_UDH_OCTETS_CONCAT16;break;case
-WMS_UDH_SPECIAL_SM:length=(0x14c+4601-0x1344)+(0x1c32+1484-0x21fd)+
-WMS_UDH_OCTETS_SPECIAL_SM;break;case WMS_UDH_PORT_8:length=(0x309+6812-0x1da4)+
-(0x1682+2997-0x2236)+WMS_UDH_OCTETS_PORT8;break;case WMS_UDH_PORT_16:length=
-(0x36a+4770-0x160b)+(0xf83+2759-0x1a49)+WMS_UDH_OCTETS_PORT16;break;case
-WMS_UDH_SMSC_CONTROL:length=(0x182f+3059-0x2421)+(0x97+6410-0x19a0)+udh->u.other
-.header_length;break;case WMS_UDH_SOURCE:length=(0x460+8814-0x26cd)+
-(0x1064+3174-0x1cc9)+udh->u.other.header_length;break;case WMS_UDH_WCMP:length=
-(0x18df+3084-0x24ea)+(0x14+3601-0xe24)+udh->u.other.header_length;break;case
-WMS_UDH_TEXT_FORMATING:if(!udh->u.text_formating.is_color_present){length=
-(0x16b7+2395-0x2011)+(0x1104+2247-0x19ca)+WMS_UDH_OCTETS_TEXT_FORMATTING;}else{
-length=(0x6f5+3028-0x12c8)+(0x85f+2632-0x12a6)+WMS_UDH_OCTETS_TEXT_FORMATTING+
-(0x2e9+6476-0x1c34);}break;case WMS_UDH_PRE_DEF_SOUND:length=(0x620+4005-0x15c4)
-+(0xca2+4135-0x1cc8)+WMS_UDH_OCTETS_PRE_DEF;break;case WMS_UDH_USER_DEF_SOUND:
-length=(0x15c+4537-0x1314)+(0x561+1309-0xa7d)+udh->u.user_def_sound.data_length+
-(0x7f8+746-0xae1);break;case WMS_UDH_PRE_DEF_ANIM:length=(0x152c+2669-0x1f98)+
-(0x11ea+2246-0x1aaf)+WMS_UDH_OCTETS_PRE_DEF;break;case WMS_UDH_LARGE_ANIM:length
-=(0x81+6225-0x18d1)+(0x138+9074-0x24a9)+WMS_UDH_LARGE_BITMAP_SIZE*
-WMS_UDH_ANIM_NUM_BITMAPS+(0x2a+8788-0x227d);break;case WMS_UDH_SMALL_ANIM:length
-=(0x920+5031-0x1cc6)+(0x64+1396-0x5d7)+WMS_UDH_SMALL_BITMAP_SIZE*
-WMS_UDH_ANIM_NUM_BITMAPS+(0x2e2+2559-0xce0);break;case WMS_UDH_LARGE_PICTURE:
-length=(0x78c+2222-0x1039)+(0xa49+4751-0x1cd7)+WMS_UDH_LARGE_PIC_SIZE+
-(0x1ca4+1229-0x2170);break;case WMS_UDH_SMALL_PICTURE:length=
-(0x1d6c+1282-0x226d)+(0x82d+2616-0x1264)+WMS_UDH_SMALL_PIC_SIZE+
-(0x9a+7755-0x1ee4);break;case WMS_UDH_VAR_PICTURE:length=(0xa6a+2094-0x1297)+
-(0x1fb+49-0x22b)+(UINT8)(udh->u.var_picture.height*udh->u.var_picture.width/
-(0xffa+4295-0x20b9))+(0x1625+2826-0x212c);break;case WMS_UDH_RFC822:length=
-(0x251f+268-0x262a)+(0x10f2+3152-0x1d41)+WMS_UDH_OCTETS_RFC822;break;case
-WMS_UDH_NAT_LANG_SS:length=(0xddb+5503-0x2359)+(0x12c+2089-0x954)+
-WMS_UDH_OCTETS_NAT_LANG_SS;break;case WMS_UDH_NAT_LANG_LS:length=
-(0x4e7+1277-0x9e3)+(0x407+8744-0x262e)+WMS_UDH_OCTETS_NAT_LANG_LS;break;case
-WMS_UDH_USER_PROMPT:length=(0x592+5502-0x1b0f)+(0x16ba+40-0x16e1)+
-WMS_UDH_OCTETS_USER_PROMPT;break;case WMS_UDH_EXTENDED_OBJECT:length=
-(0xc9b+4250-0x1d34)+(0x1d5+436-0x388)+udh->u.eo.content.length;if(udh->u.eo.
-first_segment==TRUE){length+=WMS_UDH_OCTETS_EO_HEADER;}break;default:length=
-(0x18b4+2793-0x239c)+(0x71d+2209-0xfbd)+udh->u.other.header_length;break;}}
-return length;}uint32 wms_ts_compute_user_data_header_length(const UINT8
-num_headers,const wms_udh_s_type*headers){uint32 length=(0x134c+3895-0x2283);
-uint32 i;if(headers==NULL){at_print(LOG_DEBUG,
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x63\x6f\x6d\x70\x75\x74\x65\x5f\x75\x73\x65\x72\x5f\x64\x61\x74\x61\x5f\x68\x65\x61\x64\x65\x72\x5f\x6c\x65\x6e\x67\x74\x68\x21"
-);return(0x1772+2699-0x21fd);}if(num_headers>(0xa44+4176-0x1a94)){length+=
-(0x942+2684-0x13bd);for(i=(0x1d9c+80-0x1dec);i<num_headers&&i<WMS_MAX_UD_HEADERS
-;i++){length+=(uint32)wms_ts_get_udh_length(&headers[i]);}}return length;}uint32
- wms_ts_compute_gw_user_data_length(const wms_gw_dcs_s_type*dcs,const
-wms_gw_user_data_s_type*user_data){uint32 length=(0xa93+3328-0x1793);if(dcs==
-NULL||user_data==NULL){at_print(LOG_DEBUG,
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x63\x6f\x6d\x70\x75\x74\x65\x5f\x67\x77\x5f\x75\x73\x65\x72\x5f\x64\x61\x74\x61\x5f\x6c\x65\x6e\x67\x74\x68\x21"
-);return(0x14d6+3737-0x236f);}length+=wms_ts_compute_user_data_header_length(
-user_data->num_headers,user_data->headers);if(dcs->alphabet==
-WMS_GW_ALPHABET_7_BIT_DEFAULT){length+=((user_data->sm_len*(0x321+7300-0x1f9e))+
-(0x1203+3095-0x1e13))/(0x1323+858-0x1675);}else{length+=user_data->sm_len;}
-return length;}static int wms_ts_encode_udh_concat_8(UINT8*udh){int pos=
-(0x48f+3960-0x1407);if(const_header->u.concat_8.total_sm==(0xd4c+2862-0x187a)||
-const_header->u.concat_8.seq_num==(0x557+2904-0x10af)||const_header->u.concat_8.
-seq_num>const_header->u.concat_8.total_sm){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x69\x64\x20\x25\x64\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x6e\x6f\x20\x44\x61\x74\x61"
-,const_header->header_id);return(0xe05+5799-0x24ac);}udh[pos++]=(UINT8)
-WMS_UDH_CONCAT_8;udh[pos++]=(UINT8)WMS_UDH_OCTETS_CONCAT8;udh[pos++]=
-const_header->u.concat_8.msg_ref;udh[pos++]=const_header->u.concat_8.total_sm;
-udh[pos++]=const_header->u.concat_8.seq_num;return pos;}static int
-wms_ts_encode_udh_concat16(UINT8*udh){int pos=(0x35+9534-0x2573);if(const_header
-->u.concat_16.total_sm==(0xb1c+2875-0x1657)||const_header->u.concat_16.seq_num==
-(0x1e11+1177-0x22aa)||const_header->u.concat_16.seq_num>const_header->u.
-concat_16.total_sm){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x69\x64\x20\x25\x64\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x6e\x6f\x20\x44\x61\x74\x61"
-,const_header->header_id);return(0x10e0+15-0x10ef);}udh[pos++]=(UINT8)
-WMS_UDH_CONCAT_16;udh[pos++]=(UINT8)WMS_UDH_OCTETS_CONCAT16;udh[pos++]=(UINT8)((
-const_header->u.concat_16.msg_ref&65280)>>(0x1ed5+442-0x2087));udh[pos++]=(UINT8
-)(const_header->u.concat_16.msg_ref&(0xe6d+5618-0x2360));udh[pos++]=const_header
-->u.concat_16.total_sm;udh[pos++]=const_header->u.concat_16.seq_num;return pos;}
-int wms_ts_encode_udh_nat_lang_ss(UINT8*udh){int pos=(0xc21+3012-0x17e5);udh[pos
-++]=(UINT8)WMS_UDH_NAT_LANG_SS;udh[pos++]=(UINT8)WMS_UDH_OCTETS_NAT_LANG_SS;udh[
-pos++]=(UINT8)const_header->u.nat_lang_ss.nat_lang_id;return pos;}int
-wms_ts_encode_udh_nat_lang_ls(UINT8*udh){int pos=(0x7d5+7237-0x241a);udh[pos++]=
-(UINT8)WMS_UDH_NAT_LANG_LS;udh[pos++]=(UINT8)WMS_UDH_OCTETS_NAT_LANG_LS;udh[pos
-++]=(UINT8)const_header->u.nat_lang_ls.nat_lang_id;return pos;}int
-wms_ts_encode_udh_other(UINT8*udh,wms_udh_id_e_type header_id){int i=
-(0x1f6+3051-0xde1);int pos=(0xccf+4933-0x2014);udh[pos++]=(UINT8)const_header->u
-.other.header_id;udh[pos++]=const_header->u.other.header_length;for(i=
-(0x9a+8609-0x223b);i<const_header->u.other.header_length;i++){udh[pos++]=
-const_header->u.other.data[i];}return pos;}UINT8 wms_ts_encode_user_data_header(
-UINT8 num_headers,const wms_udh_s_type*headers,UINT8*data){int i,pos=
-(0xc06+265-0xd0f);if(num_headers==(0x23d4+717-0x26a1))return(0x88+487-0x26f);++
-pos;for(i=(0xef6+3740-0x1d92);i<WMS_MAX_UD_HEADERS&&i<num_headers;i++){
-const_header=&headers[i];switch(const_header->header_id){case WMS_UDH_CONCAT_8:
-pos+=wms_ts_encode_udh_concat_8(data+pos);break;case WMS_UDH_CONCAT_16:pos+=
-wms_ts_encode_udh_concat16(data+pos);break;
-#if (0x10af+3011-0x1c72)
-case WMS_UDH_SPECIAL_SM:pos+=wms_ts_encode_udh_special_sm(data+pos);break;case
-WMS_UDH_PORT_8:pos+=wms_ts_encode_udh_port_8(data+pos);break;case
-WMS_UDH_PORT_16:pos+=wms_ts_encode_udh_port16(data+pos);break;case
-WMS_UDH_TEXT_FORMATING:pos+=wms_ts_encode_udh_text_formatting(data+pos);break;
-case WMS_UDH_PRE_DEF_SOUND:pos+=wms_ts_encode_udh_pre_def_sound(data+pos);break;
-case WMS_UDH_USER_DEF_SOUND:pos+=wms_ts_encode_udh_user_def_sound(data+pos);
-break;case WMS_UDH_PRE_DEF_ANIM:pos+=wms_ts_encode_udh_pre_def_anim(data+pos);
-break;case WMS_UDH_LARGE_ANIM:pos+=wms_ts_encode_udh_large_anim(data+pos);break;
-case WMS_UDH_SMALL_ANIM:pos+=wms_ts_encode_udh_small_anim(data+pos);break;case
-WMS_UDH_LARGE_PICTURE:pos+=wms_ts_encode_udh_large_picture(data+pos);break;case
-WMS_UDH_SMALL_PICTURE:pos+=wms_ts_encode_udh_small_picture(data+pos);break;case
-WMS_UDH_VAR_PICTURE:pos+=wms_ts_encode_udh_var_picture(data+pos);break;case
-WMS_UDH_USER_PROMPT:pos+=wms_ts_encode_udh_user_prompt(data+pos);break;case
-WMS_UDH_EXTENDED_OBJECT:pos+=wms_ts_encode_udh_eo(data+pos);break;case
-WMS_UDH_RFC822:pos+=wms_ts_encode_udh_rfc822(data+pos);break;
-#endif
-case WMS_UDH_NAT_LANG_SS:pos+=wms_ts_encode_udh_nat_lang_ss(data+pos);break;case
- WMS_UDH_NAT_LANG_LS:pos+=wms_ts_encode_udh_nat_lang_ls(data+pos);break;default:
-pos+=wms_ts_encode_udh_other(data+pos,const_header->header_id);}}data[
-(0x3a9+8753-0x25da)]=(UINT8)(pos-(0x10d5+294-0x11fa));return((UINT8)(pos-
-(0xf6f+383-0x10ed)));}UINT8 wms_ts_encode_gw_user_data(const wms_gw_dcs_s_type*
-dcs,const wms_gw_user_data_s_type*user_data,UINT8*data){UINT16 i,pos=
-(0x3df+1777-0xad0);UINT8 fill_bits=(0x18ab+2714-0x2345);UINT16
-total_bits_occupied;UINT8 user_data_header_length;UINT16 user_data_length;data[
-pos]=(UINT8)user_data->sm_len;pos++;if(dcs->alphabet==
-WMS_GW_ALPHABET_7_BIT_DEFAULT){if(user_data->num_headers>(0x2cc+4061-0x12a9)){if
-(wms_ts_compute_user_data_header_length(user_data->num_headers,user_data->
-headers)<=WMS_SMS_UDL_MAX_8_BIT){user_data_header_length=
-wms_ts_encode_user_data_header(user_data->num_headers,user_data->headers,data+
-pos);pos+=user_data_header_length+(0x559+3426-0x12ba);total_bits_occupied=(
-user_data_header_length+(0x1900+1001-0x1ce8))*(0xae9+3708-0x195d);fill_bits=(
-total_bits_occupied%(0x114+3590-0xf13));if(fill_bits!=(0xea4+513-0x10a5)){
-fill_bits=(0x37f+5344-0x1858)-fill_bits;}user_data_length=(total_bits_occupied+
-fill_bits+(user_data->sm_len*(0x5d0+7436-0x22d5)))/(0x7f+556-0x2a4);data[
-(0x5d9+3405-0x1326)]=(UINT8)user_data_length;data[(0x6e9+3075-0x12eb)]=
-user_data_header_length;}else{at_print(LOG_DEBUG,
-"\x45\x6e\x63\x6f\x64\x65\x20\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x48\x65\x61\x64\x65\x72\x20\x45\x78\x63\x65\x65\x64\x73\x20\x43\x61\x70\x61\x63\x69\x74\x79\x20\x2d\x20\x53\x6b\x69\x70\x70\x69\x6e\x67\x20\x55\x44\x48"
-);}}i=wms_ts_pack_gw_7_bit_chars(user_data->sm_data,user_data->sm_len,fill_bits,
-(UINT16)(WMS_MAX_LEN-pos),&data[pos]);pos+=i;}else{if(user_data->num_headers>
-(0xb1c+6061-0x22c9)){if(wms_ts_compute_user_data_header_length(user_data->
-num_headers,user_data->headers)<=WMS_SMS_UDL_MAX_8_BIT){user_data_header_length=
-wms_ts_encode_user_data_header(user_data->num_headers,user_data->headers,data+
-pos);data[(0x5b7+5933-0x1ce4)]=(UINT8)(user_data->sm_len+user_data_header_length
-+(0xf77+4243-0x2009));pos+=user_data_header_length+(0x8a1+2716-0x133c);}else{
-at_print(LOG_DEBUG,
-"\x45\x6e\x63\x6f\x64\x65\x20\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x48\x65\x61\x64\x65\x72\x20\x45\x78\x63\x65\x65\x64\x73\x20\x43\x61\x70\x61\x63\x69\x74\x79\x20\x2d\x20\x53\x6b\x69\x70\x70\x69\x6e\x67\x20\x55\x44\x48"
-);}}memcpy(&data[pos],user_data->sm_data,user_data->sm_len);pos+=user_data->
-sm_len;}return(UINT8)pos;}wms_status_e_type wms_ts_encode_deliver(const
-wms_gw_deliver_s_type*deliver,T_zUfiSms_RawTsData*raw_ts_data_ptr){
-wms_status_e_type st=WMS_OK_S;UINT8*data;UINT8 pos=(0x1291+2870-0x1dc7),i;if(
-deliver==NULL||raw_ts_data_ptr==NULL){at_print(LOG_DEBUG,
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x65\x6e\x63\x6f\x64\x65\x5f\x64\x65\x6c\x69\x76\x65\x72\x21"
-);return WMS_NULL_PTR_S;}data=raw_ts_data_ptr->data;(void)memset(data,
-(0x4f9+3474-0x128b),WMS_MAX_LEN);data[pos]=(0x1bfd+2593-0x261e);data[pos]|=
-deliver->more?(0x1109+5500-0x2685):(0xed5+2017-0x16b2);data[pos]|=deliver->
-status_report_enabled?(0xf87+5971-0x26ba):(0x1c1f+2053-0x2424);data[pos]|=
-deliver->user_data_header_present?(0x1f4d+173-0x1fba):(0xcda+1156-0x115e);data[
-pos]|=deliver->reply_path_present?(0x680+7724-0x242c):(0x1afd+1876-0x2251);pos++
-;i=wms_ts_encode_address(&deliver->address,&data[pos]);if(i==
-(0x19c2+1320-0x1eea)){return WMS_INVALID_PARM_SIZE_S;}pos+=i;data[pos]=deliver->
-pid;pos++;pos+=wms_ts_encode_dcs(&deliver->dcs,data+pos);i=
-wms_ts_encode_timestamp(&deliver->timestamp,data+pos);if(i==(0x14cf+1132-0x193b)
-){return WMS_INVALID_PARM_VALUE_S;}pos+=i;if(wms_ts_compute_gw_user_data_length(
-&deliver->dcs,&deliver->user_data)>WMS_SMS_UDL_MAX_8_BIT){at_print(LOG_DEBUG,
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79"
-);st=WMS_INVALID_USER_DATA_SIZE_S;}else{i=wms_ts_encode_gw_user_data(&deliver->
-dcs,&deliver->user_data,data+pos);pos+=i;}raw_ts_data_ptr->tpdu_type=
-WMS_TPDU_DELIVER;raw_ts_data_ptr->len=pos;return st;}UINT8
-wms_ts_encode_relative_time(const wms_timestamp_s_type*timestamp){uint32 i;UINT8
- v=(0x1f11+165-0x1fb6),j;if(timestamp!=NULL){if(!wms_ts_bcd_to_int(timestamp->
-year,&j)){at_print(LOG_DEBUG,
-"\x59\x65\x61\x72\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j
-);}i=j*(0x18d3+2076-0x1f82);if(!wms_ts_bcd_to_int(timestamp->month,&j)){at_print
-(LOG_DEBUG,
-"\x4d\x6f\x6e\x74\x68\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);}i=i+j*(0x409+5138-0x17fd);if(!wms_ts_bcd_to_int(timestamp->day,&j)){
-at_print(LOG_DEBUG,
-"\x44\x61\x79\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j);}i
-+=j;if(i>(0x842+1486-0xdf2)){v=(UINT8)((i+(0xc55+4003-0x1bf2))/
-(0x446+2700-0xecb)+(0x13d+5436-0x15b9));}else if(i>=(0xb19+5619-0x210b)){v=(
-UINT8)(i+(0x15b1+1991-0x1cd2));}else{if(!wms_ts_bcd_to_int(timestamp->day,&j)){
-at_print(LOG_DEBUG,
-"\x44\x61\x79\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j);}i
-=j*(0x4ad+1745-0xb66)*(0x10e3+2926-0x1c15);if(!wms_ts_bcd_to_int(timestamp->hour
-,&j)){at_print(LOG_DEBUG,
-"\x48\x6f\x75\x72\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j
-);}i=i+j*(0xa0c+986-0xdaa);if(!wms_ts_bcd_to_int(timestamp->minute,&j)){at_print
-(LOG_DEBUG,
-"\x4d\x69\x6e\x75\x74\x65\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);}i+=j;if(i>(0x15d5+1505-0x1baa)*(0x622+7507-0x2339)){v=(UINT8)((i-((
-(0x24d6+354-0x262c)*(0x1190+4226-0x21d6))+(0xe89+2838-0x1982)))/
-(0x2e8+4063-0x12a9)+(0x40f+173-0x42d));}else{v=(UINT8)((i+(0x6c9+4002-0x1667))/
-(0x138d+4457-0x24f1)-(0xc15+3062-0x180a));}}}else{at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x65\x6e\x63\x6f\x64\x65\x5f\x72\x65\x6c\x61\x74\x69\x76\x65\x5f\x74\x69\x6d\x65"
-);}return v;}UINT8 wms_ts_encode_gw_validity(const wms_gw_validity_s_type*
-validity,UINT8*data){UINT8 i,pos=(0xa07+6199-0x223e);switch(validity->format){
-case WMS_GW_VALIDITY_NONE:break;case WMS_GW_VALIDITY_RELATIVE:data[pos]=
-wms_ts_encode_relative_time(&validity->u.time);pos++;break;case
-WMS_GW_VALIDITY_ABSOLUTE:i=wms_ts_encode_timestamp(&validity->u.time,data+pos);
-if(i==(0x1bc6+2051-0x23c9)){at_print(LOG_DEBUG,
-"\x45\x72\x72\x6f\x72\x20\x77\x68\x69\x6c\x65\x20\x44\x65\x63\x6f\x64\x69\x6e\x67\x20\x41\x62\x73\x6f\x6c\x75\x74\x65\x20\x56\x61\x6c\x69\x64\x69\x74\x79\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70"
-);}pos+=i;break;case WMS_GW_VALIDITY_ENHANCED:break;default:break;}return pos;}
-wms_status_e_type wms_ts_encode_submit(const wms_gw_submit_s_type*submit,
-T_zUfiSms_RawTsData*raw_ts_data_ptr){wms_status_e_type st=WMS_OK_S;UINT8*data;
-UINT8 pos=(0x41d+6021-0x1ba2),i;if(submit==NULL||raw_ts_data_ptr==NULL){at_print
-(LOG_DEBUG,
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x65\x6e\x63\x6f\x64\x65\x5f\x73\x75\x62\x6d\x69\x74\x21"
-);return WMS_NULL_PTR_S;}data=raw_ts_data_ptr->data;(void)memset(data,
-(0x1327+2136-0x1b7f),WMS_MAX_LEN);data[pos]=(0x1f0c+168-0x1fb3);data[pos]|=
-submit->reject_duplicates?(0x14ac+623-0x1717):(0x43a+2156-0xca6);if(submit->
-validity.format>(0x508+1340-0xa41)){return st=WMS_INVALID_VALIDITY_FORMAT_S;}
-data[pos]|=submit->validity.format<<(0x833+5152-0x1c50);data[pos]|=submit->
-status_report_enabled?(0xa7+884-0x3fb):(0xce3+4276-0x1d97);data[pos]|=submit->
-user_data_header_present?(0x160b+1249-0x1aac):(0x1634+4127-0x2653);data[pos]|=
-submit->reply_path_present?(0xf19+4873-0x21a2):(0x49f+4131-0x14c2);pos++;data[
-pos]=(UINT8)submit->message_reference;pos++;i=wms_ts_encode_address(&submit->
-address,&data[pos]);if(i==(0x16b6+2457-0x204f)){return WMS_INVALID_PARM_SIZE_S;}
-pos+=i;data[pos]=submit->pid;pos++;pos+=wms_ts_encode_dcs(&submit->dcs,data+pos)
-;pos+=wms_ts_encode_gw_validity(&submit->validity,data+pos);if(
-wms_ts_compute_gw_user_data_length(&submit->dcs,&submit->user_data)>
-WMS_SMS_UDL_MAX_8_BIT){at_print(LOG_DEBUG,
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79"
-);st=WMS_INVALID_USER_DATA_SIZE_S;}else{i=wms_ts_encode_gw_user_data(&submit->
-dcs,&submit->user_data,data+pos);pos+=i;}raw_ts_data_ptr->tpdu_type=
-WMS_TPDU_SUBMIT;raw_ts_data_ptr->len=pos;return st;}wms_status_e_type
-wms_ts_encode_status_report(const wms_gw_status_report_s_type*status_report,
-T_zUfiSms_RawTsData*raw_ts_data_ptr){wms_status_e_type st=WMS_OK_S;UINT8*data;
-UINT8 pos=(0x181b+1363-0x1d6e),i;if(status_report==NULL||raw_ts_data_ptr==NULL){
-at_print(LOG_DEBUG,
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x65\x6e\x63\x6f\x64\x65\x5f\x73\x74\x61\x74\x75\x73\x5f\x72\x65\x70\x6f\x72\x74\x21"
-);return WMS_NULL_PTR_S;}data=raw_ts_data_ptr->data;(void)memset(data,
-(0x111f+4978-0x2491),WMS_MAX_LEN);data[pos]=(0x884+3445-0x15e9);data[pos]|=
-status_report->more?(0x74+8634-0x222e):(0x25b+1363-0x7aa);data[pos]|=
-status_report->status_report_qualifier?(0x1b01+261-0x1be6):(0x387+3770-0x1241);
-data[pos]|=status_report->user_data_header_present?(0x1a3c+2262-0x22d2):
-(0x987+2872-0x14bf);pos++;data[pos]=(UINT8)status_report->message_reference;pos
-++;i=wms_ts_encode_address(&status_report->address,&data[pos]);if(i==
-(0x3a+4874-0x1344)){return WMS_INVALID_PARM_SIZE_S;}pos+=i;i=
-wms_ts_encode_timestamp(&status_report->timestamp,data+pos);if(i==
-(0x1477+3155-0x20ca)){return WMS_INVALID_PARM_VALUE_S;}pos+=i;i=
-wms_ts_encode_timestamp(&status_report->discharge_time,data+pos);if(i==
-(0x3a+8229-0x205f)){return WMS_INVALID_PARM_VALUE_S;}pos+=i;data[pos]=
-status_report->tp_status;pos++;data[pos]=(UINT8)status_report->mask;pos++;if(
-status_report->mask&WMS_TPDU_MASK_PID){data[pos]=status_report->pid;pos++;}if(
-status_report->mask&WMS_TPDU_MASK_DCS){pos+=wms_ts_encode_dcs(&status_report->
-dcs,data+pos);}if(status_report->mask&WMS_TPDU_MASK_USER_DATA){if(
-wms_ts_compute_gw_user_data_length(&status_report->dcs,&status_report->user_data
-)>WMS_SMS_UDL_MAX_8_BIT){at_print(LOG_DEBUG,
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79"
-);st=WMS_INVALID_USER_DATA_SIZE_S;}else{i=wms_ts_encode_gw_user_data(&
-status_report->dcs,&status_report->user_data,data+pos);pos+=i;}}raw_ts_data_ptr
-->tpdu_type=WMS_TPDU_STATUS_REPORT;raw_ts_data_ptr->len=pos;return st;}
-wms_status_e_type wms_ts_encode(const T_zUfiSms_ClientTsData*ptClientTsData,
-T_zUfiSms_RawTsData*ptRawTsData){wms_status_e_type st=WMS_OK_S;const
-wms_gw_pp_ts_data_s_type*msg;if(ptClientTsData==NULL||ptRawTsData==NULL){return
-WMS_NULL_PTR_S;}msg=&ptClientTsData->u.gw_pp;switch(ptClientTsData->format){
-#if (0xb0f+6737-0x2560)
-case WMS_FORMAT_CDMA:case WMS_FORMAT_ANALOG_AWISMS:case WMS_FORMAT_ANALOG_CLI:
-case WMS_FORMAT_ANALOG_VOICE_MAIL:case WMS_FORMAT_ANALOG_SMS:case WMS_FORMAT_MWI
-:st=wms_ts_encode_bearer_data(&ptClientTsData->u.cdma,ptRawTsData);break;
-#endif
-case WMS_FORMAT_GW_PP:ptRawTsData->tpdu_type=msg->tpdu_type;switch(msg->
-tpdu_type){case WMS_TPDU_DELIVER:st=wms_ts_encode_deliver(&msg->u.deliver,
-ptRawTsData);break;case WMS_TPDU_SUBMIT:st=wms_ts_encode_submit(&msg->u.submit,
-ptRawTsData);break;case WMS_TPDU_STATUS_REPORT:st=wms_ts_encode_status_report(&
-msg->u.status_report,ptRawTsData);break;
-#if (0x583+507-0x77e)
-case WMS_TPDU_SUBMIT_REPORT_ACK:st=wms_ts_encode_submit_report_ack(&msg->u.
-submit_report_ack,ptRawTsData);break;case WMS_TPDU_SUBMIT_REPORT_ERROR:st=
-wms_ts_encode_submit_report_error(&msg->u.submit_report_error,ptRawTsData);break
-;case WMS_TPDU_COMMAND:st=wms_ts_encode_command(&msg->u.command,ptRawTsData);
-break;case WMS_TPDU_DELIVER_REPORT_ACK:st=wms_ts_encode_deliver_report_ack(&msg
-->u.deliver_report_ack,ptRawTsData);break;case WMS_TPDU_DELIVER_REPORT_ERROR:st=
-wms_ts_encode_deliver_report_error(&msg->u.deliver_report_error,ptRawTsData);
-break;
-#endif
-default:at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x54\x50\x44\x55\x20\x74\x79\x70\x65\x20\x25\x64"
-,msg->tpdu_type);st=WMS_INVALID_TPDU_TYPE_S;break;}break;default:st=
-WMS_INVALID_FORMAT_S;at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x66\x6f\x72\x6d\x61\x74\x3a\x20\x25\x64",
-ptClientTsData->format);break;}ptRawTsData->format=ptClientTsData->format;return
- st;}UINT8 wms_ts_unpack_gw_7_bit_chars(const UINT8*in,UINT8 in_len,UINT8
-out_len_max,UINT16 shift,UINT8*out){int i=(0x609+1968-0xdb9);UINT16 pos=
-(0xb07+3233-0x17a8);if(in==NULL||out==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x75\x6e\x70\x61\x63\x6b\x5f\x67\x77\x5f\x37\x5f\x62\x69\x74\x5f\x63\x68\x61\x72\x73"
-);return(0x5a0+3902-0x14de);}if(shift!=(0x14b+3153-0xd9c))pos=pos+
-(0xd01+4248-0x1d98);if(shift==(0x15cf+2452-0x1f5c)){out[(0x1dad+254-0x1eab)]=in[
-(0x9f3+5666-0x2015)]>>(0xb34+4572-0x1d0f);shift=(0x9e3+5428-0x1f17);i=
-(0xd8c+6501-0x26f0);}for(i=i;i<out_len_max&&i<in_len;i++,pos++){out[i]=(in[pos]
-<<shift)&(0x5c0+2271-0xe20);if(pos!=(0x18a0+949-0x1c55)){
-#if (0x681+503-0x877)
-if(shift==(0x677+4373-0x178c)){out[i]|=(0x1565+4356-0x2669);}else{out[i]|=in[pos
--(0xc2a+4683-0x1e74)]>>((0xbf4+582-0xe32)-shift);}
+
+ default:
+ at_print(LOG_DEBUG,"Invalid TPDU type %d", msg->tpdu_type);
+ st = WMS_INVALID_TPDU_TYPE_S;
+ break;
+ }
+
+ /* ---------- End of encoding --------- */
+ break;
+/*
+ case WMS_FORMAT_GW_CB:
+ st = wms_ts_encode_gw_cb(&ptClientTsData->u.gw_cb,
+ ptRawTsData);
+ break;
+*/
+ default:
+ st = WMS_INVALID_FORMAT_S;
+ at_print(LOG_DEBUG,"Invalid format: %d", ptClientTsData->format);
+ break;
+ }
+
+ ptRawTsData->format = ptClientTsData->format;
+
+ //printf(">>>>>>>>>> pthread_mutex_unlock() : wmsts_mutex >>>>>>>>>>\n" );
+ //pthread_mutex_unlock( &wmsts_mutex );
+
+ return st;
+
+} /* wms_ts_encode() */
+
+UINT8 wms_ts_unpack_gw_7_bit_chars
+(
+ const UINT8 * in,
+ UINT8 in_len, /* Number of 7-bit characters */
+ UINT8 out_len_max, /* Number of maximum 7-bit characters after unpacking */
+ UINT16 shift,
+ UINT8 * out
+)
+{
+ int i=0;
+ UINT16 pos=0;
+
+ if (in == NULL || out == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_unpack_gw_7_bit_chars");
+ return 0;
+ }
+
+ /*If the number of fill bits != 0, then it would cause an additional shift*/
+ if (shift != 0)
+ pos = pos+1;
+
+ if (shift ==7)
+ {
+ out[0] = in[0] >> 1; /*7 fillbits*/
+ shift =0; /*First Byte is a special case*/
+ i=1;
+ }
+
+ for( i=i;
+ i < out_len_max && i< in_len;
+ i++, pos++ )
+ {
+ out[i] = ( in[pos] << shift ) & 0x7F;
+
+ if( pos != 0 )
+ {
+ /* except the first UINT8, a character contains some bits
+ ** from the previous UINT8.
+ */
+#if 1 // cov M
+ if(shift == 0)
+ {
+ out[i] |= 0;
+ }
+ else
+ {
+ out[i] |= in[pos-1] >> (8-shift);
+ }
#else
-out[i]|=in[pos-(0x1287+4793-0x253f)]>>((0xab6+6124-0x229a)-shift);
+ out[i] |= in[pos-1] >> (8-shift);
#endif
-}shift++;if(shift==(0x15b0+2336-0x1ec9)){shift=(0x1655+2161-0x1ec6);i++;if(i>=
-out_len_max){at_print(LOG_DEBUG,
-"\x4e\x6f\x74\x20\x65\x6e\x6f\x75\x67\x68\x20\x6f\x75\x74\x70\x75\x74\x20\x62\x75\x66\x66\x65\x72\x20\x66\x6f\x72\x20\x75\x6e\x70\x61\x63\x6b\x69\x6e\x67\x21"
-);break;}out[i]=in[pos]>>(0xbba+6797-0x2646);}}return(UINT8)(pos);}UINT8
-wms_ts_decode_address(const UINT8*data,wms_address_s_type*addr){UINT8 i,pos=
-(0x934+4905-0x1c5d);i=data[pos];if(i>WMS_GW_ADDRESS_MAX){at_print(LOG_DEBUG,
-"\x41\x64\x64\x72\x20\x6c\x65\x6e\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x20\x25\x64"
-,i);return(0x110d+5296-0x25bd);}addr->number_of_digits=i;pos++;addr->digit_mode=
-WMS_DIGIT_MODE_4_BIT;addr->number_type=(wms_number_type_e_type)((data[pos]&
-(0x5ff+1238-0xa65))>>(0xe9c+162-0xf3a));addr->number_plan=(
-wms_number_plan_e_type)(data[pos]&(0x2150+224-0x2221));pos++;if(addr->
-number_type==WMS_NUMBER_ALPHANUMERIC){UINT8 bytes_increment=(0x90a+6702-0x2338);
-addr->digit_mode=WMS_DIGIT_MODE_8_BIT;bytes_increment=(addr->number_of_digits+
-(0x16fb+1669-0x1d7f))/(0x8d6+6327-0x218b);addr->number_of_digits=(UINT8)(addr->
-number_of_digits*(0x6cd+4063-0x16a8)/(0x1751+323-0x188d));(void)
-wms_ts_unpack_gw_7_bit_chars(&data[pos],addr->number_of_digits,
-WMS_GW_ADDRESS_MAX,(0x155+84-0x1a9),addr->digits);pos+=bytes_increment;}else{for
-(i=(0x1c09+1198-0x20b7);i<addr->number_of_digits;i++){addr->digits[i++]=data[pos
-]&(0xe05+4053-0x1dcb);addr->digits[i]=(data[pos]&(0x1e9+8610-0x229b))>>
-(0xcbc+5618-0x22aa);pos++;}}return pos;}UINT8 wms_ts_decode_dcs(const UINT8*data
-,wms_gw_dcs_s_type*dcs){UINT8 pos=(0x4ca+4776-0x1772);UINT8 i;if(data==NULL||dcs
-==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x64\x63\x73"
-);return(0x4db+2561-0xedc);}dcs->msg_class=WMS_MESSAGE_CLASS_NONE;dcs->
-msg_waiting=WMS_GW_MSG_WAITING_NONE;dcs->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;
-dcs->is_compressed=FALSE;i=(data[pos]&(0x337+7398-0x1f5d))>>(0x519+4505-0x16ac);
-switch(i){case(0x16+5237-0x148b):dcs->is_compressed=data[pos]&
-(0xb30+1876-0x1264);if(data[pos]&(0xb75+1455-0x1114)){dcs->msg_class=(
-wms_message_class_e_type)(data[pos]&(0x1203+3038-0x1dde));}else{dcs->msg_class=
-WMS_MESSAGE_CLASS_NONE;}dcs->alphabet=(wms_gw_alphabet_e_type)((data[pos]&
-(0x13f8+2494-0x1daa))>>(0x293+8806-0x24f7));break;case(0x393+8583-0x2517):if((
-data[pos]&(0x17c9+482-0x197b))==(0x1fac+930-0x231e)){dcs->alphabet=(data[pos]&
-(0x2a8+2293-0xb99))?WMS_GW_ALPHABET_8_BIT:WMS_GW_ALPHABET_7_BIT_DEFAULT;dcs->
-msg_class=(wms_message_class_e_type)(data[pos]&(0x44c+3013-0x100e));dcs->
-is_compressed=FALSE;dcs->msg_waiting=WMS_GW_MSG_WAITING_NONE_1111;}else{dcs->
-is_compressed=FALSE;dcs->msg_class=WMS_MESSAGE_CLASS_NONE;if((data[pos]&
-(0x16a+1506-0x71c))==(0x766+1398-0xcdc)){dcs->msg_waiting=
-WMS_GW_MSG_WAITING_DISCARD;dcs->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;}else if(
-(data[pos]&(0x375+4674-0x1587))==(0x173d+3418-0x2487)){dcs->msg_waiting=
-WMS_GW_MSG_WAITING_STORE;dcs->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;}else{dcs->
-msg_waiting=WMS_GW_MSG_WAITING_STORE;dcs->alphabet=WMS_GW_ALPHABET_UCS2;}dcs->
-msg_waiting_active=(data[pos]&(0xe94+4536-0x2044))?TRUE:FALSE;dcs->
-msg_waiting_kind=(wms_gw_msg_waiting_kind_e_type)(data[pos]&(0x1570+569-0x17a6))
-;}break;default:at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x44\x43\x53\x3a\x20\x25\x78",data[pos]);dcs->
-alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;dcs->is_compressed=FALSE;dcs->msg_waiting
-=WMS_GW_MSG_WAITING_NONE;dcs->msg_class=WMS_MESSAGE_CLASS_NONE;break;}if(dcs->
-alphabet>WMS_GW_ALPHABET_UCS2){dcs->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;}dcs
-->raw_dcs_data=data[pos];pos++;return pos;}UINT8 wms_ts_decode_timestamp(const
-UINT8*data,wms_timestamp_s_type*timestamp){UINT8 pos=(0x657+3769-0x1510),i,j;if(
-data==NULL||timestamp==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x74\x69\x6d\x65\x73\x74\x61\x6d\x70"
-);return(0x12c4+2443-0x1c4f);}i=((data[pos]&(0x1148+1957-0x18de))<<
-(0x1187+51-0x11b6))+((data[pos]&(0x1861+2399-0x20d0))>>(0x587+674-0x825));if(!
-wms_ts_bcd_to_int(i,&j)){at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x59\x65\x61\x72\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0xba6+4078-0x1b94);}timestamp->year=i;pos++;i=((data[pos]&
-(0x2103+1414-0x267a))<<(0x1623+2191-0x1eae))+((data[pos]&(0x1ef4+1891-0x2567))>>
-(0x13ff+2926-0x1f69));if(wms_ts_bcd_to_int(i,&j)){if(j>(0x368+1390-0x8ca)||j<
-(0xb6d+5999-0x22db)){at_print(LOG_DEBUG,
-"\x4d\x6f\x6e\x74\x68\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64"
-,j);i=(0xd51+4775-0x1ff7);}}else{at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x4d\x6f\x6e\x74\x68\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0x5fa+7577-0x2392);}timestamp->month=i;pos++;i=((data[pos]&
-(0x1046+5439-0x2576))<<(0x317+2673-0xd84))+((data[pos]&(0x462+8101-0x2317))>>
-(0x1c4+1118-0x61e));if(wms_ts_bcd_to_int(i,&j)){if(j>(0x58b+4830-0x184a)||j<
-(0x584+7797-0x23f8)){at_print(LOG_DEBUG,
-"\x44\x61\x79\x20\x69\x73\x20\x69\x6e\x76\x61\x6c\x69\x64\x3a\x20\x25\x64",j);i=
-(0xcf3+3326-0x19f0);}}else{at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x44\x61\x79\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0x618+1903-0xd86);}timestamp->day=i;pos++;i=((data[pos]&
-(0x418+104-0x471))<<(0x5c+3899-0xf93))+((data[pos]&(0x433+1171-0x7d6))>>
-(0x641+3223-0x12d4));if(wms_ts_bcd_to_int(i,&j)){if(j>(0x3e2+1769-0xab4)){
-at_print(LOG_DEBUG,
-"\x48\x6f\x75\x72\x20\x69\x73\x20\x74\x6f\x6f\x20\x6c\x61\x72\x67\x65\x3a\x20\x25\x64"
-,j);i=(0xd58+4057-0x1d31);}}else{at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x48\x6f\x75\x72\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0xd0+7516-0x1e2c);}timestamp->hour=i;pos++;i=((data[pos]&
-(0x132f+4556-0x24ec))<<(0x2bc+6234-0x1b12))+((data[pos]&(0x123d+1518-0x173b))>>
-(0x15dc+2286-0x1ec6));if(wms_ts_bcd_to_int(i,&j)){if(j>(0x3e9+8969-0x26b7)){
-at_print(LOG_DEBUG,
-"\x4d\x69\x6e\x75\x74\x65\x20\x69\x73\x20\x74\x6f\x6f\x20\x6c\x61\x72\x67\x65\x3a\x20\x25\x64"
-,j);i=(0x1425+2084-0x1c49);}}else{at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x4d\x69\x6e\x75\x74\x65\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0x868+1485-0xe35);}timestamp->minute=i;pos++;i=((data[pos]&
-(0x10e1+722-0x13a4))<<(0x16af+535-0x18c2))+((data[pos]&(0xc1a+3565-0x1917))>>
-(0x603+4710-0x1865));if(wms_ts_bcd_to_int(i,&j)){if(j>(0x1012+1344-0x1517)){
-at_print(LOG_DEBUG,
-"\x53\x65\x63\x6f\x6e\x64\x20\x69\x73\x20\x74\x6f\x6f\x20\x6c\x61\x72\x67\x65\x3a\x20\x25\x64"
-,i);i=(0x222+6039-0x19b9);}}else{at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x42\x43\x44\x20\x44\x69\x67\x69\x74\x73\x20\x69\x6e\x20\x45\x6e\x63\x6f\x64\x65\x64\x20\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x20\x53\x65\x63\x6f\x6e\x64\x20\x3a\x20\x25\x64"
-,data[pos]);i=(0x8f4+5200-0x1d44);}timestamp->second=i;pos++;if(data[pos]&
-(0xfb5+1738-0x1677)){timestamp->timezone=(data[pos]&(0xedc+2532-0x18b9))*
-(0x1687+786-0x198f)+((data[pos]&(0xb87+5134-0x1ea5))>>(0xff+5283-0x159e));
-timestamp->timezone*=(-(0x14d9+3277-0x21a5));}else{timestamp->timezone=(sint7)((
-data[pos]&(0x59d+2230-0xe44))*(0x2222+1229-0x26e5)+((data[pos]&
-(0xa36+6618-0x2320))>>(0x103a+3180-0x1ca2)));}if(timestamp->timezone>
-(0x8b9+4215-0x1900)||timestamp->timezone<-(0x947+4618-0x1b21)){at_print(
-LOG_DEBUG,
-"\x54\x69\x6d\x65\x7a\x6f\x6e\x65\x20\x69\x73\x20\x6f\x75\x74\x20\x6f\x66\x20\x62\x6f\x75\x6e\x64\x3a\x20\x25\x64"
-,timestamp->timezone);timestamp->timezone=(0x2a0+6188-0x1acc);}pos++;return pos;
-}static UINT8 wms_ts_decode_udh_concat_8(const UINT8*udh,wms_udh_s_type*
-header_ptr){UINT8 pos=(0x19+8136-0x1fe1);if(udh==NULL||header_ptr==NULL){
-at_print(LOG_DEBUG,"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return
-(0x1aa+5520-0x173a);}if(udh[pos]<(0xc02+299-0xd2a)){at_print(LOG_DEBUG,
-"\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x43\x6f\x6e\x63\x61\x74\x20\x38\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x15a0+3768-0x2458);}if(udh[pos+(0xbdb+3312-0x18c9)]==
-(0x1823+1325-0x1d50)||udh[pos+(0x503+3300-0x11e4)]>udh[pos+(0x33b+1860-0xa7d)]){
-at_print(LOG_DEBUG,
-"\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x43\x6f\x6e\x74\x61\x63\x74\x20\x38\x20\x77\x69\x74\x68\x20\x6f\x75\x74\x20\x6f\x66\x20\x62\x6f\x75\x6e\x64\x20\x6d\x61\x78\x20\x6d\x65\x73\x73\x61\x67\x65\x73"
-);return(0x9b5+6452-0x22e9);}pos++;header_ptr->header_id=WMS_UDH_CONCAT_8;
-header_ptr->u.concat_8.msg_ref=udh[pos++];header_ptr->u.concat_8.total_sm=udh[
-pos++];header_ptr->u.concat_8.seq_num=udh[pos++];return(udh[(0x899+5690-0x1ed3)]
-+(0x82c+49-0x85c));}static UINT8 wms_ts_decode_udh_concat16(const UINT8*udh,
-wms_udh_s_type*header_ptr){UINT8 pos=(0x14e9+3327-0x21e8);if(udh==NULL||
-header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x1519+3301-0x21fe);}if(
-udh[pos]<(0x1c50+2245-0x2511)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x43\x6f\x6e\x63\x61\x74\x31\x36\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x120d+1894-0x1973);}if(udh[pos+(0x1426+1609-0x1a6c)]==
-(0x1196+3195-0x1e11)||udh[pos+(0x147b+4196-0x24db)]==(0xfc+5227-0x1567)||udh[pos
-+(0x683+4951-0x19d6)]>udh[pos+(0x296+51-0x2c6)])return(0x11d+263-0x224);
-header_ptr->header_id=WMS_UDH_CONCAT_16;pos++;header_ptr->u.concat_16.msg_ref=
-udh[pos++];header_ptr->u.concat_16.msg_ref=(UINT16)(header_ptr->u.concat_16.
-msg_ref<<(0xf1c+4265-0x1fbd))|udh[pos++];header_ptr->u.concat_16.total_sm=udh[
-pos++];header_ptr->u.concat_16.seq_num=udh[pos++];return(udh[
-(0x187a+1877-0x1fcf)]+(0x23bb+762-0x26b4));}static UINT8
-wms_ts_udh_decode_first_seg_check(const UINT8 len,const UINT8*data,UINT8*
-is_first_segment_ptr){UINT8 pos=(0xd66+5460-0x22ba);UINT8 num_headers=
-(0x1356+408-0x14ee);UINT8 udhl=(0x1317+3381-0x204c);UINT8 iedl=
-(0x7dc+1287-0xce3);UINT8 iei=(0x16a5+181-0x175a);*is_first_segment_ptr=TRUE;if(
-data==NULL||data[pos]==(0x5c1+1177-0xa5a)||len==(0x52c+2858-0x1056)){at_print(
-LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x75\x64\x68\x5f\x64\x65\x63\x6f\x64\x65\x5f\x66\x69\x72\x73\x74\x5f\x73\x65\x67\x5f\x63\x68\x65\x63\x6b"
-);return FALSE;}udhl=data[pos];pos++;while((pos<udhl)&&(num_headers<
-WMS_MAX_UD_HEADERS)){iei=data[pos];iedl=data[pos+(0x13b4+2640-0x1e03)];if(iei==
-WMS_UDH_CONCAT_16){if(data[pos+(0x13e0+2920-0x1f43)]!=(0x3fa+8413-0x24d6)){
-at_print(LOG_DEBUG,
-"\x57\x4d\x53\x5f\x55\x44\x48\x5f\x43\x4f\x4e\x43\x41\x54\x5f\x31\x36\x20\x6e\x6f\x74\x20\x66\x69\x72\x73\x74\x20\x73\x65\x67\x6d\x65\x6e\x74\x21"
-);*is_first_segment_ptr=FALSE;return TRUE;}else{return TRUE;}}else{num_headers++
-;pos+=((0xf5c+4677-0x219f)+iedl);}}return TRUE;}static UINT8
-wms_ts_decode_udh_special_sm(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8
-pos=(0x15e8+690-0x189a);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x745+6048-0x1ee5);}if(
-udh[pos]<(0x6+5970-0x1756)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x53\x70\x65\x63\x69\x61\x6c\x20\x53\x4d\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x1195+2588-0x1bb1);}pos++;header_ptr->header_id=
-WMS_UDH_SPECIAL_SM;header_ptr->u.special_sm.msg_waiting=(
-wms_gw_msg_waiting_e_type)((udh[pos]>>(0x254a+50-0x2575)==(0x264+8689-0x2455))?
-WMS_GW_MSG_WAITING_DISCARD:WMS_GW_MSG_WAITING_STORE);header_ptr->u.special_sm.
-msg_waiting_kind=(wms_gw_msg_waiting_kind_e_type)(udh[pos++]&(0x99c+1971-0x10d0)
-);header_ptr->u.special_sm.message_count=udh[pos++];return(udh[
-(0x231a+582-0x2560)]+(0xcd1+910-0x105e));}static UINT8 wms_ts_decode_udh_port_8(
-const UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x6b8+5814-0x1d6e);if(udh
-==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x1a7b+2997-0x2630);}if(
-udh[pos]<(0x1e77+1444-0x2419)){at_print(LOG_DEBUG,
-"\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x50\x6f\x72\x74\x20\x38\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x8d1+723-0xba4);}pos++;header_ptr->header_id=WMS_UDH_PORT_8;
-header_ptr->u.wap_8.dest_port=udh[pos++];header_ptr->u.wap_8.orig_port=udh[pos++
-];return(udh[(0xc50+3059-0x1843)]+(0x121b+185-0x12d3));}static UINT8
-wms_ts_decode_udh_port16(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=
-(0x128c+1717-0x1941);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x675+8227-0x2698);}if(
-udh[pos]<(0xbc6+6464-0x2502)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x50\x6f\x72\x74\x31\x36\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x93d+2621-0x137a);}header_ptr->header_id=WMS_UDH_PORT_16;pos
-++;header_ptr->u.wap_16.dest_port=udh[pos++];header_ptr->u.wap_16.dest_port=(
-UINT16)(header_ptr->u.wap_16.dest_port<<(0xb0+1919-0x827))|udh[pos++];header_ptr
-->u.wap_16.orig_port=udh[pos++];header_ptr->u.wap_16.orig_port=(UINT16)(
-header_ptr->u.wap_16.orig_port<<(0x1384+213-0x1451))|udh[pos++];return(udh[
-(0x1925+1915-0x20a0)]+(0x943+1069-0xd6f));}static UINT8
-wms_ts_decode_udh_text_formatting(const UINT8*udh,wms_udh_s_type*header_ptr){
-UINT8 pos=(0x711+5456-0x1c61);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG
-,"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x208+3968-0x1188);}if(
-udh[pos]<(0x1a5d+2780-0x2536)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x54\x65\x78\x74\x20\x46\x6f\x72\x6d\x61\x74\x74\x69\x6e\x67\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0xf82+4755-0x2215);}if(udh[pos]>=(0xca4+3196-0x191c)){
-header_ptr->u.text_formating.is_color_present=TRUE;}else{header_ptr->u.
-text_formating.is_color_present=FALSE;}pos++;header_ptr->header_id=
-WMS_UDH_TEXT_FORMATING;header_ptr->u.text_formating.start_position=udh[pos++];
-header_ptr->u.text_formating.text_formatting_length=udh[pos++];header_ptr->u.
-text_formating.alignment_type=(wms_udh_alignment_e_type)(udh[pos]&
-(0x2108+981-0x24da));header_ptr->u.text_formating.font_size=(
-wms_udh_font_size_e_type)((udh[pos]&(0x389+5012-0x1711))>>(0x586+6904-0x207c));
-header_ptr->u.text_formating.style_bold=(udh[pos]&(0x7a4+7232-0x23d4))>>
-(0xd24+2585-0x1739);header_ptr->u.text_formating.style_italic=(udh[pos]&
-(0xc4f+1526-0x1225))>>(0x19a+3571-0xf88);header_ptr->u.text_formating.
-style_underlined=(udh[pos]&(0x705+7973-0x25ea))>>(0x71c+2259-0xfe9);header_ptr->
-u.text_formating.style_strikethrough=(udh[pos]&(0x36f+1644-0x95b))>>
-(0x7c1+2808-0x12b2);pos++;if(header_ptr->u.text_formating.is_color_present){
-header_ptr->u.text_formating.text_color_foreground=(wms_udh_text_color_e_type)(
-udh[pos]&(0x1668+3580-0x2455));header_ptr->u.text_formating.
-text_color_background=(wms_udh_text_color_e_type)((udh[pos]&(0x407+6989-0x1e64))
->>(0xb17+5844-0x21e7));pos++;}return(udh[(0x5d8+5002-0x1962)]+
-(0x5bc+7250-0x220d));}static UINT8 wms_ts_decode_udh_pre_def_sound(const UINT8*
-udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x1706+4084-0x26fa);if(udh==NULL||
-header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x670+7932-0x256c);}if(
-udh[pos]<(0xad8+2484-0x148a)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x50\x72\x65\x20\x44\x65\x66\x69\x6e\x65\x64\x20\x53\x6f\x75\x6e\x64\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x3c0+7104-0x1f80);}pos++;header_ptr->header_id=
-WMS_UDH_PRE_DEF_SOUND;header_ptr->u.pre_def_sound.position=udh[pos++];header_ptr
-->u.pre_def_sound.snd_number=udh[pos++];return(udh[(0x181a+219-0x18f5)]+
-(0x5cd+6410-0x1ed6));}static UINT8 wms_ts_decode_udh_user_def_sound(const UINT8*
-udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x142b+4344-0x2523),j;if(udh==NULL||
-header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x56+3050-0xc40);}if(udh[
-pos]==(0x4da+6941-0x1ff7)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x55\x73\x65\x72\x20\x44\x65\x66\x69\x6e\x65\x64\x20\x53\x6f\x75\x6e\x64\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x6e\x6f\x20\x44\x61\x74\x61"
-);return(0x465+2388-0xdb9);}header_ptr->header_id=WMS_UDH_USER_DEF_SOUND;
-header_ptr->u.user_def_sound.data_length=udh[pos++]-(0xf86+772-0x1289);
-header_ptr->u.user_def_sound.position=udh[pos++];if(header_ptr->u.user_def_sound
-.data_length>WMS_UDH_MAX_SND_SIZE){at_print(LOG_DEBUG,
-"\x4d\x61\x78\x20\x53\x69\x7a\x65\x20\x45\x78\x63\x65\x65\x64\x20\x48\x65\x61\x64\x65\x72\x20\x69\x64\x20\x25\x64\x20"
-,header_ptr->header_id);return(0xc86+3896-0x1bbe);}memset(header_ptr->u.
-user_def_sound.user_def_sound,(0x6aa+3253-0x1260),WMS_UDH_MAX_SND_SIZE);for(j=
-(0x866+656-0xaf6);j<header_ptr->u.user_def_sound.data_length;j++)header_ptr->u.
-user_def_sound.user_def_sound[j]=udh[pos++];return pos;}static UINT8
-wms_ts_decode_udh_pre_def_anim(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8
-pos=(0x410+888-0x788);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x214+3174-0xe7a);}if(udh
-[pos]!=(0x14a7+1409-0x1a26)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x50\x72\x65\x20\x44\x65\x66\x69\x6e\x65\x64\x20\x41\x6e\x69\x6d\x61\x74\x69\x6f\x6e\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x489+6891-0x1f74);}pos++;header_ptr->header_id=
-WMS_UDH_PRE_DEF_ANIM;header_ptr->u.pre_def_anim.position=udh[pos++];header_ptr->
-u.pre_def_anim.animation_number=udh[pos++];return pos;}static UINT8
-wms_ts_decode_udh_large_anim(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8
-pos=(0x994+6156-0x21a0),j,k;if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x745+3239-0x13ec);}if(
-udh[pos]!=(WMS_UDH_ANIM_NUM_BITMAPS*WMS_UDH_LARGE_BITMAP_SIZE+
-(0x533+7042-0x20b4))){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x4c\x61\x72\x67\x65\x20\x44\x65\x66\x69\x6e\x65\x64\x20\x41\x6e\x69\x6d\x61\x74\x69\x6f\x6e\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x14a6+3061-0x209b);}header_ptr->header_id=WMS_UDH_LARGE_ANIM;
-pos++;header_ptr->u.large_anim.position=udh[pos++];for(j=(0xa1c+3755-0x18c7);j<
-WMS_UDH_ANIM_NUM_BITMAPS;j++)for(k=(0xc91+4647-0x1eb8);k<
-WMS_UDH_LARGE_BITMAP_SIZE;k++)header_ptr->u.large_anim.data[j][k]=udh[pos++];
-return pos;}static UINT8 wms_ts_decode_udh_small_anim(const UINT8*udh,
-wms_udh_s_type*header_ptr){UINT8 pos=(0x1ccf+940-0x207b),j,k;if(udh==NULL||
-header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0xa29+2840-0x1541);}if(
-udh[pos]!=(WMS_UDH_ANIM_NUM_BITMAPS*WMS_UDH_SMALL_BITMAP_SIZE+
-(0x2312+266-0x241b))){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x4c\x61\x72\x67\x65\x20\x44\x65\x66\x69\x6e\x65\x64\x20\x41\x6e\x69\x6d\x61\x74\x69\x6f\x6e\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x1b8f+74-0x1bd9);}header_ptr->header_id=WMS_UDH_SMALL_ANIM;
-pos++;header_ptr->u.small_anim.position=udh[pos++];for(j=(0x76d+3732-0x1601);j<
-WMS_UDH_ANIM_NUM_BITMAPS;j++)for(k=(0x87+8262-0x20cd);k<
-WMS_UDH_SMALL_BITMAP_SIZE;k++)header_ptr->u.small_anim.data[j][k]=udh[pos++];
-return pos;}static UINT8 wms_ts_decode_udh_large_picture(const UINT8*udh,
-wms_udh_s_type*header_ptr){UINT8 pos=(0x1b02+64-0x1b42),j;if(udh==NULL||
-header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x499+80-0x4e9);}if(udh[
-pos]!=WMS_UDH_LARGE_PIC_SIZE+(0x643+3583-0x1441)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x4c\x61\x72\x67\x65\x20\x50\x69\x63\x74\x75\x72\x65\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x50b+4095-0x150a);}header_ptr->header_id=
-WMS_UDH_LARGE_PICTURE;pos++;header_ptr->u.large_picture.position=udh[pos++];for(
-j=(0x1be5+1947-0x2380);j<WMS_UDH_LARGE_PIC_SIZE;j++)header_ptr->u.large_picture.
-data[j]=udh[pos++];return pos;}static UINT8 wms_ts_decode_udh_small_picture(
-const UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x593+5973-0x1ce8),j;if(
-udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x19f+3845-0x10a4);}if(
-udh[pos]!=WMS_UDH_SMALL_PIC_SIZE+(0xfbc+216-0x1093)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x53\x6d\x61\x6c\x6c\x20\x50\x69\x63\x74\x75\x72\x65\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x67\x6e\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x10af+1169-0x1540);}header_ptr->header_id=
-WMS_UDH_SMALL_PICTURE;pos++;header_ptr->u.small_picture.position=udh[pos++];for(
-j=(0x848+3704-0x16c0);j<WMS_UDH_SMALL_PIC_SIZE;j++)header_ptr->u.small_picture.
-data[j]=udh[pos++];return pos;}static UINT8 wms_ts_decode_udh_var_picture(const
-UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x1824+1280-0x1d24),j,pic_size;
-if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x317+836-0x65b);}if(udh[
-pos]>WMS_UDH_VAR_PIC_SIZE+(0x217+7076-0x1db8)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x56\x61\x72\x20\x50\x69\x63\x74\x75\x72\x65\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x182+2366-0xac0);}if((udh[pos]-(0x352+8735-0x256e))!=(udh[pos
-+(0x5da+1584-0xc08)]*udh[pos+(0x1a1f+1301-0x1f31)])){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x56\x61\x72\x20\x50\x69\x63\x74\x75\x72\x65\x2c\x20\x70\x69\x63\x20\x73\x69\x7a\x65\x20\x76\x61\x6c\x75\x65\x20\x6d\x69\x73\x6d\x61\x74\x63\x68\x20\x77\x69\x74\x68\x20\x68\x65\x69\x67\x74\x20\x61\x6e\x64\x20\x77\x65\x69\x67\x68\x74"
-);return(0x3db+8691-0x25ce);}pic_size=udh[pos++]-(0x10e8+3176-0x1d4d);header_ptr
-->header_id=WMS_UDH_VAR_PICTURE;header_ptr->u.var_picture.position=udh[pos++];
-header_ptr->u.var_picture.width=(UINT8)(udh[pos++]*(0x869+6322-0x2113));
-header_ptr->u.var_picture.height=udh[pos++];for(j=(0x53b+2288-0xe2b);j<pic_size
-&&j<WMS_UDH_VAR_PIC_SIZE;j++)header_ptr->u.var_picture.data[j]=udh[pos++];return
- pos;}static UINT8 wms_ts_decode_udh_user_prompt(const UINT8*udh,wms_udh_s_type*
-header_ptr){UINT8 pos=(0x922+215-0x9f9);if(udh==NULL||header_ptr==NULL){at_print
-(LOG_DEBUG,"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return
-(0x1516+1946-0x1cb0);}if(udh[pos]<(0x23a7+51-0x23d9)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x55\x73\x65\x72\x20\x50\x72\x6f\x6d\x70\x74\x20\x70\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0xe94+5797-0x2539);}pos++;header_ptr->header_id=
-WMS_UDH_USER_PROMPT;header_ptr->u.user_prompt.number_of_objects=udh[pos++];
-return(udh[(0xb21+6513-0x2492)]+(0x931+3398-0x1676));}static UINT8
-wms_ts_decode_udh_eo(const UINT8*udh,UINT8 first_segment,wms_udh_s_type*
-header_ptr){UINT8 pos=(0xb15+5548-0x20c1),udh_length;if(udh==NULL||header_ptr==
-NULL){at_print(LOG_DEBUG,"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return
-(0xa14+1000-0xdfc);}if(udh[pos]==(0xc3d+465-0xe0e)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x45\x78\x74\x65\x6e\x64\x65\x64\x20\x4f\x62\x6a\x65\x63\x74\x20\x70\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x6e\x6f\x20\x44\x61\x74\x61"
-);return(0x2389+9-0x2392);}udh_length=udh[pos++];header_ptr->header_id=
-WMS_UDH_EXTENDED_OBJECT;header_ptr->u.eo.first_segment=first_segment;if(
-first_segment==TRUE){if(udh_length<WMS_UDH_OCTETS_EO_HEADER){return
-(0x168d+1978-0x1e47);}header_ptr->u.eo.reference=udh[pos++];header_ptr->u.eo.
-length=udh[pos++]<<(0xf+9467-0x2502);header_ptr->u.eo.length|=udh[pos++];
-header_ptr->u.eo.control=udh[pos++];header_ptr->u.eo.type=(wms_udh_eo_id_e_type)
-udh[pos++];header_ptr->u.eo.position=udh[pos++]<<(0x498+982-0x866);header_ptr->u
-.eo.position|=udh[pos++];}header_ptr->u.eo.content.length=(udh_length-pos)+
-(0x1427+2727-0x1ecd);memcpy(header_ptr->u.eo.content.data,udh+pos,header_ptr->u.
-eo.content.length);pos+=header_ptr->u.eo.content.length;return pos;}static UINT8
- wms_ts_decode_udh_rfc822(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=
-(0x1de7+495-0x1fd6);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x7b2+4335-0x18a1);}if(
-udh[pos]<(0x1413+2109-0x1c4f)){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x52\x66\x63\x38\x32\x32\x20\x50\x72\x65\x73\x65\x6e\x74\x20\x77\x69\x74\x68\x20\x69\x6e\x76\x61\x6c\x69\x64\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3d\x20\x25\x64"
-,udh[pos]);return(0x1454+2243-0x1d17);}pos++;header_ptr->header_id=
-WMS_UDH_RFC822;header_ptr->u.rfc822.header_length=udh[pos++];return(udh[
-(0x961+4483-0x1ae4)]+(0x18fc+1393-0x1e6c));}static UINT8
-wms_ts_decode_udh_nat_lang_ss(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8
-pos=(0x7+8231-0x202e);if(udh==NULL||header_ptr==NULL){return(0x5ba+3025-0x118b);
-}if(udh[pos]!=WMS_UDH_OCTETS_NAT_LANG_SS){return(0x71b+1881-0xe74);}pos++;
-header_ptr->header_id=WMS_UDH_NAT_LANG_SS;if((WMS_UDH_NAT_LANG_TURKISH>udh[pos])
-||(WMS_UDH_NAT_LANG_PORTUGUESE<udh[pos])){return(0xe93+1350-0x13d9);}header_ptr
-->u.nat_lang_ss.nat_lang_id=(wms_udh_nat_lang_id_e_type)udh[pos++];return(udh[
-(0xb72+5913-0x228b)]+(0xc6a+2247-0x1530));}static UINT8
-wms_ts_decode_udh_nat_lang_ls(const UINT8*udh,wms_udh_s_type*header_ptr){UINT8
-pos=(0x12e9+3566-0x20d7);if(udh==NULL||header_ptr==NULL){return(0x100+515-0x303)
-;}if(udh[pos]!=WMS_UDH_OCTETS_NAT_LANG_LS){return(0x8ba+80-0x90a);}pos++;
-header_ptr->header_id=WMS_UDH_NAT_LANG_LS;if((WMS_UDH_NAT_LANG_TURKISH>udh[pos])
-||(WMS_UDH_NAT_LANG_PORTUGUESE<udh[pos])){return(0xe3b+6147-0x263e);}header_ptr
-->u.nat_lang_ls.nat_lang_id=(wms_udh_nat_lang_id_e_type)udh[pos++];return(udh[
-(0x801+455-0x9c8)]+(0x13bc+3634-0x21ed));}static UINT8 wms_ts_decode_udh_other(
-const UINT8*udh,wms_udh_s_type*header_ptr){UINT8 pos=(0x79+7147-0x1c64),i=
-(0x3b5+5715-0x1a08);if(udh==NULL||header_ptr==NULL){at_print(LOG_DEBUG,
-"\x75\x64\x68\x20\x69\x73\x20\x4e\x55\x4c\x4c");return(0x1cfb+2222-0x25a9);}if(
-udh[pos+(0x995+3000-0x154c)]>WMS_UDH_OTHER_SIZE){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x48\x65\x61\x64\x65\x72\x20\x4f\x74\x68\x65\x72\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x65\x78\x63\x65\x65\x64\x69\x6e\x67\x20\x32\x32\x36"
-);return(0x288+6066-0x1a3a);}header_ptr->header_id=(wms_udh_id_e_type)udh[pos];
-header_ptr->u.other.header_id=(wms_udh_id_e_type)udh[pos++];header_ptr->u.other.
-header_length=udh[pos++];for(i=(0x2084+537-0x229d);i<header_ptr->u.other.
-header_length;i++){header_ptr->u.other.data[i]=udh[pos++];}return pos;}UINT8
-wms_ts_decode_user_data_header(const UINT8 len,const UINT8*data,UINT8*
-num_headers_ptr,wms_udh_s_type*udh_ptr){UINT8 pos=(0x2067+142-0x20f5);UINT8
-header_length=(0x11d3+5349-0x26b8),num_headers=(0x101d+4669-0x225a);UINT8 udhl;
-UINT8 first_segment=TRUE;if(data==NULL||len==(0x46d+6918-0x1f73)||data[pos]==
-(0x769+1334-0xc9f)||num_headers_ptr==NULL||udh_ptr==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x75\x73\x65\x72\x5f\x64\x61\x74\x61\x5f\x68\x65\x61\x64\x65\x72"
-);return(0x1886+2744-0x233e);}udhl=data[pos];pos++;while((pos<udhl)&&(
-num_headers<WMS_MAX_UD_HEADERS)){switch(data[pos++]){case WMS_UDH_CONCAT_8:
-header_length=wms_ts_decode_udh_concat_8(data+pos,&udh_ptr[num_headers]);break;
-case WMS_UDH_CONCAT_16:header_length=wms_ts_decode_udh_concat16(data+pos,&
-udh_ptr[num_headers]);break;case WMS_UDH_SPECIAL_SM:header_length=
-wms_ts_decode_udh_special_sm(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_PORT_8:header_length=wms_ts_decode_udh_port_8(data+pos,&udh_ptr[
-num_headers]);break;case WMS_UDH_PORT_16:header_length=wms_ts_decode_udh_port16(
-data+pos,&udh_ptr[num_headers]);break;case WMS_UDH_TEXT_FORMATING:header_length=
-wms_ts_decode_udh_text_formatting(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_PRE_DEF_SOUND:header_length=wms_ts_decode_udh_pre_def_sound(data+pos,&
-udh_ptr[num_headers]);break;case WMS_UDH_USER_DEF_SOUND:header_length=
-wms_ts_decode_udh_user_def_sound(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_PRE_DEF_ANIM:header_length=wms_ts_decode_udh_pre_def_anim(data+pos,&
-udh_ptr[num_headers]);break;case WMS_UDH_LARGE_ANIM:header_length=
-wms_ts_decode_udh_large_anim(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_SMALL_ANIM:header_length=wms_ts_decode_udh_small_anim(data+pos,&udh_ptr[
-num_headers]);break;case WMS_UDH_LARGE_PICTURE:header_length=
-wms_ts_decode_udh_large_picture(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_SMALL_PICTURE:header_length=wms_ts_decode_udh_small_picture(data+pos,&
-udh_ptr[num_headers]);break;case WMS_UDH_VAR_PICTURE:header_length=
-wms_ts_decode_udh_var_picture(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_USER_PROMPT:header_length=wms_ts_decode_udh_user_prompt(data+pos,&
-udh_ptr[num_headers]);break;case WMS_UDH_EXTENDED_OBJECT:
-wms_ts_udh_decode_first_seg_check(len,data,&first_segment);header_length=
-wms_ts_decode_udh_eo(data+pos,first_segment,&udh_ptr[num_headers]);break;case
-WMS_UDH_RFC822:header_length=wms_ts_decode_udh_rfc822(data+pos,&udh_ptr[
-num_headers]);break;case WMS_UDH_NAT_LANG_SS:header_length=
-wms_ts_decode_udh_nat_lang_ss(data+pos,&udh_ptr[num_headers]);break;case
-WMS_UDH_NAT_LANG_LS:header_length=wms_ts_decode_udh_nat_lang_ls(data+pos,&
-udh_ptr[num_headers]);break;default:pos--;header_length=wms_ts_decode_udh_other(
-data+pos,&udh_ptr[num_headers]);break;}if((UINT16)pos+(UINT16)header_length>
-WMS_MAX_LEN){at_print(LOG_DEBUG,
-"\x6e\x75\x6d\x62\x65\x72\x20\x6f\x66\x20\x62\x79\x74\x65\x73\x20\x64\x65\x63\x6f\x64\x65\x64\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x55\x44\x48\x4c\x20\x76\x61\x6c\x75\x65\x20\x6f\x66\x20\x25\x64"
-,udhl);return(0x1c49+1301-0x215e);}else if(header_length!=(0x167b+1049-0x1a94)){
-pos+=header_length;num_headers++;}else{at_print(LOG_DEBUG,
-"\x42\x61\x64\x20\x55\x44\x48\x3a\x20\x70\x6f\x73\x3d\x25\x64\x2c\x20\x64\x61\x74\x61\x5b\x70\x6f\x73\x5d\x3d\x25\x64"
-,pos,data[pos]);*num_headers_ptr=(0xa10+7339-0x26bb);return(0xb10+5684-0x2144);}
-}if(num_headers>=WMS_MAX_UD_HEADERS){at_print(LOG_DEBUG,
-"\x64\x65\x63\x6f\x64\x65\x5f\x75\x64\x68\x3a\x20\x4e\x75\x6d\x20\x48\x65\x61\x64\x65\x72\x73\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x57\x4d\x53\x5f\x4d\x41\x58\x5f\x55\x44\x5f\x48\x45\x41\x44\x45\x52\x53"
-);pos=udhl+(0x77a+3631-0x15a8);}if(pos!=(udhl+(0xa7d+1878-0x11d2))){at_print(
-LOG_DEBUG,
-"\x53\x4d\x53\x20\x55\x44\x48\x20\x63\x6f\x75\x6c\x64\x20\x6e\x6f\x74\x20\x62\x65\x20\x64\x65\x63\x6f\x64\x65\x64"
-);num_headers=(0x680+7310-0x230e);udhl=(0x18f8+1214-0x1db6);}if(num_headers>
-(0xa84+2012-0x1260)){*num_headers_ptr=num_headers;}return udhl;}UINT8
-wms_ts_decode_gw_user_data(const wms_gw_dcs_s_type*dcs,const UINT8 len,const
-UINT8*data,const UINT8 user_data_header_present,wms_gw_user_data_s_type*
-user_data){UINT8 i,pos=(0x1410+3367-0x2137);UINT8 fill_bits=(0x1123+551-0x134a);
-UINT8 user_data_length;UINT8 user_data_header_length=(0x1227+2069-0x1a3c);if(dcs
-==NULL||data==NULL||user_data==NULL){at_print(LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x67\x77\x5f\x75\x73\x65\x72\x5f\x64\x61\x74\x61"
-);return(0x8fb+6283-0x2186);}(void)memset(user_data,(0x10a1+3823-0x1f90),sizeof(
-wms_gw_user_data_s_type));if(len==(0x417+5122-0x1819)){return(0xbea+5965-0x2337)
-;}if(dcs->alphabet==WMS_GW_ALPHABET_7_BIT_DEFAULT){if(len>WMS_SMS_UDL_MAX_7_BIT)
-{at_print(LOG_DEBUG,
-"\x75\x73\x65\x72\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3e\x20\x6d\x61\x78\x20\x76\x61\x6c\x75\x65\x20\x66\x6f\x72\x20\x67\x77\x20\x37\x2d\x62\x69\x74\x20\x61\x6c\x70\x68\x61\x62\x65\x74"
-);return(0x2168+604-0x23c4);}user_data_length=len;if(user_data_header_present){
-user_data_header_length=wms_ts_decode_user_data_header(data[pos],data+pos,&
-user_data->num_headers,user_data->headers);}if(user_data_header_length>len){
-at_print(LOG_DEBUG,
-"\x75\x73\x65\x72\x20\x64\x61\x74\x61\x20\x68\x65\x61\x64\x65\x72\x20\x6c\x65\x6e\x67\x74\x68\x20\x3e\x20\x74\x6f\x74\x61\x6c\x20\x6c\x65\x6e\x67\x74\x68"
-);return(0x8b+3344-0xd9b);}if(user_data_header_length>(0x11e4+4622-0x23f2)){
-fill_bits=((len*(0xfe0+2894-0x1b27))-((user_data_header_length+(0x80+2060-0x88b)
-)*(0x786+6484-0x20d2)))%(0xbf6+2428-0x156b);user_data_length=(UINT8)(((len*
-(0xee5+3383-0x1c15))-((user_data_header_length+(0x632+5206-0x1a87))*
-(0x1b30+1070-0x1f56)))/(0xbdd+183-0xc8d));pos=user_data_header_length+
-(0x1301+3026-0x1ed2);if(fill_bits!=(0xd4+3687-0xf3b)){fill_bits=
-(0x2d4+4960-0x162c)-fill_bits;}}i=wms_ts_unpack_gw_7_bit_chars(&data[pos],
-user_data_length,WMS_MAX_LEN,fill_bits,user_data->sm_data);user_data->sm_len=
-user_data_length;}else{if(len>WMS_SMS_UDL_MAX_8_BIT){at_print(LOG_DEBUG,
-"\x75\x73\x65\x72\x20\x64\x61\x74\x61\x20\x6c\x65\x6e\x67\x74\x68\x20\x3e\x20\x6d\x61\x78\x20\x76\x61\x6c\x75\x65\x20\x66\x6f\x72\x20\x38\x2d\x62\x69\x74\x20\x63\x68\x61\x72\x61\x72\x61\x63\x74\x65\x72\x73"
-);return(0x3aa+1471-0x969);}user_data_length=len;if(user_data_header_present){
-user_data_header_length=wms_ts_decode_user_data_header(data[pos],data+pos,&
-user_data->num_headers,user_data->headers);if(user_data_header_length>len){
-at_print(LOG_DEBUG,
-"\x75\x73\x65\x72\x20\x64\x61\x74\x61\x20\x68\x65\x61\x64\x65\x72\x20\x6c\x65\x6e\x67\x74\x68\x20\x3e\x20\x74\x6f\x74\x61\x6c\x20\x6c\x65\x6e\x67\x74\x68"
-);return(0xa37+3620-0x185b);}pos+=user_data_header_length+(0x6b+1927-0x7f1);
-user_data_length=(len-user_data_header_length)-(0x662+8204-0x266d);}memcpy(
-user_data->sm_data,data+pos,user_data_length);user_data->sm_len=user_data_length
-;i=(UINT8)user_data->sm_len;}pos+=i;return pos;}wms_status_e_type
-wms_ts_decode_deliver(const T_zUfiSms_RawTsData*ptRawTsData,
-wms_gw_deliver_s_type*deliver){wms_status_e_type st=WMS_OK_S;uint32 pos=
-(0x529+3604-0x133d),i;const UINT8*data=ptRawTsData->data;if(ptRawTsData==NULL||
-deliver==NULL){printf(
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x64\x65\x6c\x69\x76\x65\x72"
-);return WMS_NULL_PTR_S;}else if((data[pos]&(0x129d+2459-0x1c35))!=
-(0x4e3+6314-0x1d8d)){printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x74\x70\x64\x75\x20\x74\x79\x70\x65\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x64\x65\x6c\x69\x76\x65\x72"
-);return WMS_INVALID_TPDU_TYPE_S;}else{deliver->more=(data[pos]&
-(0x6c2+6864-0x218e))?FALSE:TRUE;deliver->status_report_enabled=(data[pos]&
-(0x44f+5779-0x1ac2))?TRUE:FALSE;deliver->user_data_header_present=(data[pos]&
-(0xe81+599-0x1098))?TRUE:FALSE;deliver->reply_path_present=(data[pos]&
-(0x85f+6405-0x20e4))?TRUE:FALSE;pos++;i=wms_ts_decode_address(&data[pos],&
-deliver->address);if(i==(0xdf1+2227-0x16a4)){printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x72\x61\x6d\x20\x73\x69\x7a\x65\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x64\x65\x6c\x69\x76\x65\x72"
-);return WMS_INVALID_PARM_SIZE_S;}pos+=i;deliver->pid=(wms_pid_e_type)data[pos];
-pos++;pos+=wms_ts_decode_dcs(data+pos,&deliver->dcs);if(deliver->dcs.
-msg_waiting_kind!=WMS_GW_MSG_WAITING_VOICEMAIL){if(deliver->pid==
-WMS_PID_RETURN_CALL){deliver->dcs.msg_waiting=WMS_GW_MSG_WAITING_STORE;deliver->
-dcs.msg_waiting_active=TRUE;deliver->dcs.msg_waiting_kind=
-WMS_GW_MSG_WAITING_VOICEMAIL;}}i=wms_ts_decode_timestamp(data+pos,&deliver->
-timestamp);if(i==(0x636+7768-0x248e)){printf(
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x70\x61\x72\x61\x6d\x20\x76\x61\x6c\x75\x65\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x64\x65\x6c\x69\x76\x65\x72"
-);return WMS_INVALID_PARM_VALUE_S;}pos+=i;pos++;i=wms_ts_decode_gw_user_data(&
-deliver->dcs,data[pos-(0x110b+1114-0x1564)],data+pos,deliver->
-user_data_header_present,&deliver->user_data);if(i>WMS_SMS_UDL_MAX_8_BIT){printf
-(
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79\x3a\x20\x55\x44\x4c\x20\x3d\x20\x25\x6c\x75"
-,i);st=WMS_INVALID_USER_DATA_SIZE_S;}pos+=i;return st;}}UINT8
-wms_ts_decode_gw_validity(const UINT8*data,wms_gw_validity_s_type*validity){
-UINT8 i,pos=(0x1ba0+2079-0x23bf);if(data==NULL||validity==NULL){at_print(
-LOG_DEBUG,
-"\x6e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x67\x77\x5f\x76\x61\x6c\x69\x64\x69\x74\x79"
-);return(0x9cd+3879-0x18f4);}else{switch(validity->format){case
-WMS_GW_VALIDITY_NONE:memset(validity,(0x553+3393-0x1294),sizeof(
-wms_gw_validity_s_type));break;case WMS_GW_VALIDITY_RELATIVE:
-zUfiSms_DecodeRelativeTime(data[pos],&validity->u.time);pos++;break;case
-WMS_GW_VALIDITY_ABSOLUTE:i=wms_ts_decode_timestamp(data+pos,&validity->u.time);
-pos+=i;break;case WMS_GW_VALIDITY_ENHANCED:break;default:break;}return pos;}}
-wms_status_e_type wms_ts_decode_submit(const T_zUfiSms_RawTsData*ptRawTsData,
-wms_gw_submit_s_type*submit){wms_status_e_type st=WMS_OK_S;uint32 pos=
-(0x4da+6667-0x1ee5),i;const UINT8*data;if(ptRawTsData==NULL||submit==NULL){
-printf(
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x73\x75\x62\x6d\x69\x74\x21"
-);return WMS_NULL_PTR_S;}data=ptRawTsData->data;submit->reject_duplicates=(data[
-pos]&(0xb94+2481-0x1541))?TRUE:FALSE;submit->validity.format=(
-wms_gw_validity_format_e_type)((data[pos]&(0x120f+5068-0x25c3))>>
-(0x2077+664-0x230c));submit->status_report_enabled=(data[pos]&
-(0x2b7+5713-0x18e8))?TRUE:FALSE;submit->user_data_header_present=(data[pos]&
-(0x1f37+249-0x1ff0))?TRUE:FALSE;submit->reply_path_present=(data[pos]&
-(0x169+4510-0x1287))?TRUE:FALSE;pos++;submit->message_reference=data[pos];pos++;
-i=wms_ts_decode_address(&data[pos],&submit->address);if(i==(0x342+542-0x560)){
-return WMS_INVALID_PARM_SIZE_S;}pos+=i;submit->pid=(wms_pid_e_type)data[pos];pos
-++;pos+=wms_ts_decode_dcs(data+pos,&submit->dcs);i=wms_ts_decode_gw_validity(
-data+pos,&submit->validity);if((submit->validity.format!=WMS_GW_VALIDITY_NONE)&&
-(i==(0xcb+7077-0x1c70))){return WMS_INVALID_PARM_VALUE_S;}pos+=i;pos++;i=
-wms_ts_decode_gw_user_data(&submit->dcs,data[pos-(0x223f+975-0x260d)],data+pos,
-submit->user_data_header_present,&submit->user_data);if(i>WMS_SMS_UDL_MAX_8_BIT)
-{printf(
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79\x3a\x20\x55\x44\x4c\x20\x3d\x20\x25\x6c\x75"
-,i);st=WMS_INVALID_USER_DATA_SIZE_S;}pos+=i;return st;}wms_status_e_type
-wms_ts_decode_status_report(const T_zUfiSms_RawTsData*ptRawTsData,
-wms_gw_status_report_s_type*status_report){wms_status_e_type st=WMS_OK_S;uint32
-pos=(0x1899+1889-0x1ffa),i;const UINT8*data;if(ptRawTsData==NULL||status_report
-==NULL){printf(
-"\x4e\x75\x6c\x6c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x69\x6e\x20\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x5f\x73\x74\x61\x74\x75\x73\x5f\x72\x65\x70\x6f\x72\x74\x21"
-);return WMS_NULL_PTR_S;}data=ptRawTsData->data;status_report->more=data[pos]&
-(0x151f+1575-0x1b42)?FALSE:TRUE;status_report->status_report_qualifier=data[pos]
-&(0x66f+3362-0x1371)?TRUE:FALSE;status_report->user_data_header_present=(data[
-pos]&(0x6ab+4738-0x18ed))?TRUE:FALSE;pos++;status_report->message_reference=data
-[pos];pos++;i=wms_ts_decode_address(&data[pos],&status_report->address);if(i==
-(0xa7d+1024-0xe7d)){return WMS_INVALID_PARM_SIZE_S;}pos+=i;i=
-wms_ts_decode_timestamp(data+pos,&status_report->timestamp);if(i==
-(0x55f+4889-0x1878)){return WMS_INVALID_PARM_VALUE_S;}pos+=i;i=
-wms_ts_decode_timestamp(data+pos,&status_report->discharge_time);if(i==
-(0x94f+5214-0x1dad)){return WMS_INVALID_PARM_VALUE_S;}pos+=i;status_report->
-tp_status=(wms_tp_status_e_type)data[pos];pos++;status_report->mask=data[pos];
-status_report->pid=(wms_pid_e_type)(0x28c+2568-0xc94);status_report->user_data.
-sm_len=(0x473+8802-0x26d5);status_report->mask&=(0x575+2862-0xfa4);if((
-status_report->mask!=(0x7ba+411-0x856))&&(status_report->mask!=
-(0xf0c+867-0x126f))){pos++;if(status_report->mask&WMS_TPDU_MASK_PID){
-status_report->pid=(wms_pid_e_type)data[pos];pos++;}if(status_report->mask&
-WMS_TPDU_MASK_DCS){pos+=wms_ts_decode_dcs(data+pos,&status_report->dcs);}if(
-status_report->mask&WMS_TPDU_MASK_USER_DATA){pos++;i=wms_ts_decode_gw_user_data(
-&status_report->dcs,data[pos-(0x19e4+2241-0x22a4)],data+pos,status_report->
-user_data_header_present,&status_report->user_data);if(i>WMS_SMS_UDL_MAX_8_BIT){
-printf(
-"\x55\x73\x65\x72\x20\x44\x61\x74\x61\x20\x4c\x65\x6e\x67\x74\x68\x20\x68\x61\x73\x20\x65\x78\x63\x65\x65\x64\x65\x64\x20\x63\x61\x70\x61\x63\x69\x74\x79\x3a\x20\x55\x44\x4c\x20\x3d\x20\x25\x6c\x75"
-,i);st=WMS_INVALID_USER_DATA_SIZE_S;}pos+=i;}}else{status_report->mask=
-(0xcaf+5880-0x23a7);}return st;}wms_status_e_type wms_ts_decode(const
-T_zUfiSms_RawTsData*ptRawTsData,T_zUfiSms_ClientTsData*ptClientTsData){
-wms_status_e_type st=WMS_OK_S;wms_gw_pp_ts_data_s_type*msg;if(ptRawTsData==NULL
-||ptClientTsData==NULL){return WMS_NULL_PTR_S;}msg=&ptClientTsData->u.gw_pp;
-switch(ptRawTsData->format){case WMS_FORMAT_CDMA:case WMS_FORMAT_ANALOG_AWISMS:
-case WMS_FORMAT_ANALOG_CLI:case WMS_FORMAT_ANALOG_VOICE_MAIL:case
-WMS_FORMAT_ANALOG_SMS:case WMS_FORMAT_MWI:at_print(AT_DEBUG,
-"\x21\x21\x21\x21\x21\x21\x21\x21\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x20\x45\x72\x72\x6f\x72\x3a\x20\x47\x65\x74\x20\x4f\x6d\x69\x74\x20\x66\x6f\x72\x6d\x61\x74\x21\x21\x21\x20\x46\x6f\x72\x6d\x61\x74\x5b\x25\x64\x5d" "\n"
-,ptRawTsData->format);break;case WMS_FORMAT_GW_PP:msg->tpdu_type=ptRawTsData->
-tpdu_type;switch(msg->tpdu_type){case WMS_TPDU_DELIVER:st=wms_ts_decode_deliver(
-ptRawTsData,&msg->u.deliver);break;case WMS_TPDU_SUBMIT:st=wms_ts_decode_submit(
-ptRawTsData,&msg->u.submit);break;case WMS_TPDU_STATUS_REPORT:st=
-wms_ts_decode_status_report(ptRawTsData,&msg->u.status_report);break;case
-WMS_TPDU_DELIVER_REPORT_ACK:case WMS_TPDU_DELIVER_REPORT_ERROR:case
-WMS_TPDU_SUBMIT_REPORT_ACK:case WMS_TPDU_SUBMIT_REPORT_ERROR:case
-WMS_TPDU_COMMAND:at_print(AT_DEBUG,
-"\x21\x21\x21\x21\x21\x21\x21\x21\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x20\x45\x72\x72\x6f\x72\x3a\x20\x47\x65\x74\x20\x4f\x6d\x69\x74\x20\x62\x72\x61\x6e\x63\x68\x21\x21\x21\x20\x74\x70\x64\x75\x5f\x74\x79\x70\x65\x5b\x25\x64\x5d" "\n"
-,msg->tpdu_type);break;default:at_print(LOG_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x54\x50\x44\x55\x20\x74\x79\x70\x65\x20\x25\x64"
-,msg->tpdu_type);st=WMS_INVALID_TPDU_TYPE_S;break;}break;case WMS_FORMAT_GW_CB:
-at_print(AT_DEBUG,
-"\x21\x21\x21\x21\x21\x21\x21\x21\x77\x6d\x73\x5f\x74\x73\x5f\x64\x65\x63\x6f\x64\x65\x20\x45\x72\x72\x6f\x72\x3a\x20\x47\x65\x74\x20\x4f\x6d\x69\x74\x20\x66\x6f\x72\x6d\x61\x74\x21\x21\x21\x20\x46\x6f\x72\x6d\x61\x74\x5b\x25\x64\x5d" "\n"
-,ptRawTsData->format);break;default:st=WMS_INVALID_FORMAT_S;at_print(AT_DEBUG,
-"\x49\x6e\x76\x61\x6c\x69\x64\x20\x66\x6f\x72\x6d\x61\x74\x3a\x20\x25\x64",
-ptRawTsData->format);break;}ptClientTsData->format=ptRawTsData->format;return st
-;}
+ }
+
+ shift ++;
+
+ if( shift == 7 )
+ {
+ shift = 0;
+
+ /* a possible extra complete character is available */
+ i ++;
+ if( i >= out_len_max )
+ {
+ at_print(LOG_DEBUG,"Not enough output buffer for unpacking!");
+ break;
+ }
+ out[i] = in[pos] >> 1;
+ }
+ }
+
+ return(UINT8)(pos);
+
+} /* wms_ts_unpack_gw_7_bit_chars() */
+
+UINT8 wms_ts_decode_address
+(
+ const UINT8 * data,
+ wms_address_s_type * addr
+)
+{
+ UINT8 i, pos = 0;
+
+ /* Len field: number of digits */
+ i = data[pos];
+
+ if( i > WMS_GW_ADDRESS_MAX )
+ {
+ /* Address is too long */
+ at_print(LOG_DEBUG,"Addr len too long: %d", i);
+ return 0;
+ }
+
+ addr->number_of_digits = i;
+
+ pos ++;
+
+ /* TON & NPI: */
+ addr->digit_mode = WMS_DIGIT_MODE_4_BIT;
+ addr->number_type = (wms_number_type_e_type) (( data[pos] & 0x70 ) >> 4);
+ addr->number_plan = (wms_number_plan_e_type) (data[pos] & 0x0F);
+ pos ++;
+
+ if (addr->number_type == WMS_NUMBER_ALPHANUMERIC )
+ {
+ UINT8 bytes_increment=0;
+ /* Alphanumberic Number Type */
+ addr->digit_mode = WMS_DIGIT_MODE_8_BIT;
+
+ /* length = number of BCD digits */
+ bytes_increment = (addr->number_of_digits+1)/2;
+
+ addr->number_of_digits = (UINT8)(addr->number_of_digits*4/7);
+
+ (void)wms_ts_unpack_gw_7_bit_chars
+ (
+ &data[pos],
+ addr->number_of_digits,
+ WMS_GW_ADDRESS_MAX,
+ 0,
+ addr->digits
+ );
+
+ pos += bytes_increment;
+ }
+ else
+ {
+ /* the digits: */
+ for( i=0; i<addr->number_of_digits; i++ )
+ {
+ /* unpack two digits each time */
+ addr->digits[i++] = data[pos] & 0x0F;
+ addr->digits[i] = ( data[pos] & 0xF0 ) >> 4;
+ pos ++;
+ }
+ }
+ return pos;
+} /* wms_ts_decode_address() */
+
+UINT8 wms_ts_decode_dcs
+(
+ const UINT8 *data,
+ wms_gw_dcs_s_type *dcs
+)
+{
+ UINT8 pos = 0;
+ UINT8 i;
+ /* initialize the values */
+
+ if (data == NULL || dcs == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_decode_dcs");
+ return 0;
+ }
+
+ dcs->msg_class = WMS_MESSAGE_CLASS_NONE;
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_NONE;
+ dcs->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ dcs->is_compressed = FALSE;
+
+
+ /* bits 7-6 */
+ i = ( data[pos] & 0xC0 ) >> 6;
+ switch( i )
+ {
+ case 0:
+ /* pattern 00xx xxxx */
+ dcs->is_compressed = data[pos] & 0x20;
+ if( data[pos] & 0x10 )
+ {
+ dcs->msg_class = (wms_message_class_e_type) (data[pos] & 0x03);
+ }
+ else
+ {
+ /* no class information */
+ dcs->msg_class = WMS_MESSAGE_CLASS_NONE;
+ }
+ dcs->alphabet = (wms_gw_alphabet_e_type) (( data[pos] & 0x0C ) >> 2);
+ break;
+
+ case 3:
+ /* bits 5-4 */
+ if( (data[pos] & 0x30) == 0x30 )
+ {
+ /* pattern 1111 xxxx */
+
+ /* bit 3 is reserved */
+
+ /* bit 2 */
+ dcs->alphabet = (data[pos] & 0x04 ) ? WMS_GW_ALPHABET_8_BIT:
+ WMS_GW_ALPHABET_7_BIT_DEFAULT;
+
+ /* bits 1-0 */
+ dcs->msg_class = (wms_message_class_e_type) (data[pos] & 0x03);
+
+ /* set remaining fields */
+ dcs->is_compressed = FALSE;
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_NONE_1111;
+ }
+ else
+ {
+ /* Message waiting groups
+ */
+ dcs->is_compressed = FALSE;
+ dcs->msg_class = WMS_MESSAGE_CLASS_NONE;
+
+ /* bits 5-4 */
+ if( (data[pos] & 0x30) == 0x00 )
+ {
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_DISCARD;
+ dcs->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ }
+ else if( (data[pos] & 0x30) == 0x10 )
+ {
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_STORE;
+ dcs->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ }
+ else
+ {
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_STORE;
+ dcs->alphabet = WMS_GW_ALPHABET_UCS2;
+ }
+
+ /* bit 3 */
+ dcs->msg_waiting_active = ( data[pos] & 0x08 ) ? TRUE : FALSE;
+
+ /* bit 2 is reserved */
+
+ /* bits 1-0 */
+ dcs->msg_waiting_kind = (wms_gw_msg_waiting_kind_e_type) (data[pos] & 0x03);
+ }
+ break;
+
+ default:
+ // reserved values
+ at_print(LOG_DEBUG,"Invalid DCS: %x", data[pos]);
+ dcs->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ dcs->is_compressed = FALSE;
+ dcs->msg_waiting = WMS_GW_MSG_WAITING_NONE;
+ dcs->msg_class = WMS_MESSAGE_CLASS_NONE;
+ break;
+ }
+
+ if ( dcs->alphabet > WMS_GW_ALPHABET_UCS2 )
+ {
+ dcs->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ }
+
+ dcs->raw_dcs_data = data[pos];
+
+ pos ++;
+
+ return pos;
+
+} /* wms_ts_decode_dcs() */
+
+UINT8 wms_ts_decode_timestamp
+(
+ const UINT8 *data,
+ wms_timestamp_s_type *timestamp
+)
+{
+ UINT8 pos = 0, i, j;
+
+ if (data == NULL || timestamp == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_decode_timestamp");
+ return 0;
+ }
+
+ /*year check*/
+
+ /* in GW, swap the order of LSB, MSB */
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( !wms_ts_bcd_to_int(i, &j) )
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Year : %d",data[pos]);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ timestamp->year = i;
+ pos ++;
+
+ /*month check*/
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( wms_ts_bcd_to_int(i, &j) )
+ {
+ if (j > 12 || j < 1)
+ {
+ at_print(LOG_DEBUG,"Month is invalid: %d", j);
+ i = 1; /* Modifying it to a Good Value */
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Month : %d",data[pos]);
+ i = 1; /* Modifying it to a Good Value */
+ }
+ timestamp->month = i;
+ pos ++;
+
+ /*day check*/
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( wms_ts_bcd_to_int(i, &j) )
+ {
+ if (j > 31 || j < 1)
+ {
+ at_print(LOG_DEBUG,"Day is invalid: %d", j);
+ i = 1; /* Modifying it to a Good Value */
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Day : %d",data[pos]);
+ i = 1; /* Modifying it to a Good Value */
+ }
+ timestamp->day = i;
+ pos ++;
+
+ /*hour check*/
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( wms_ts_bcd_to_int(i, &j) )
+ {
+ if (j > 23)
+ {
+ at_print(LOG_DEBUG,"Hour is too large: %d", j);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Hour : %d",data[pos]);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ timestamp->hour = i;
+ pos ++;
+
+ /*minute check*/
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( wms_ts_bcd_to_int(i, &j) )
+ {
+ if (j > 59)
+ {
+ at_print(LOG_DEBUG,"Minute is too large: %d", j);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Minute : %d",data[pos]);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ timestamp->minute = i;
+ pos ++;
+
+ /*seconds check*/
+ i = ((data[pos] & 0x0F) << 4) + ((data[pos] & 0xF0) >> 4);
+ if ( wms_ts_bcd_to_int(i, &j) )
+ {
+ if (j > 59)
+ {
+ at_print(LOG_DEBUG,"Second is too large: %d", i);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Invalid BCD Digits in Encoded Timestamp Second : %d",data[pos]);
+ i = 0; /* Modifying it to a Good Value */
+ }
+ timestamp->second = i;
+ pos ++;
+
+ /*timezone, special case where timestamp->timezone is an integer value*/
+ if (data[pos] & 0x08)
+ {
+ timestamp->timezone = (data[pos] & 0x07) * 10 + ((data[pos] & 0xF0)>>4);
+ timestamp->timezone *= (-1);
+ }
+ else
+ {
+ timestamp->timezone = (sint7)((data[pos] & 0x0F) * 10 + ((data[pos] & 0xF0) >> 4 ));
+ }
+
+ if (timestamp->timezone > 48 || timestamp->timezone < -48)
+ {
+ at_print(LOG_DEBUG,"Timezone is out of bound: %d", timestamp->timezone);
+ timestamp->timezone = 0; /* Modifying it to a Good Value */
+ }
+ pos ++;
+
+ return pos;
+
+} /* wms_ts_decode_timestamp() */
+
+
+static UINT8 wms_ts_decode_udh_concat_8
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr /* OUT */
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if (udh[pos] < 3) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"UDH Header Concat 8 Present with invalid data length = %d", udh[pos]);
+ return 0; /*Return 0*/
+ }
+
+
+ /* if the maximum number of messages is 0 Or*/
+ /* if the sequence number of the message is 0 Or*/
+ /* if the sequence number of the current message is greater than the max messages*/
+ if (udh[pos +2] == 0 ||
+ //udh[pos +3] == 0 ||
+ udh[pos +3] > udh[pos +2])
+ {
+ at_print(LOG_DEBUG,"UDH Header Contact 8 with out of bound max messages");
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_CONCAT_8;
+ header_ptr->u.concat_8.msg_ref = udh[pos++];
+ header_ptr->u.concat_8.total_sm= udh[pos++];
+ header_ptr->u.concat_8.seq_num = udh[pos++];
+
+ return (udh[0] + 1);
+
+}/*wms_ts_decode_udh_concat_8*/
+
+static UINT8 wms_ts_decode_udh_concat16
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 4) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Concat16 Present with invalid data length = %d", udh[pos]);
+ return 0;
+ }
+
+ /* if the maximum number of messages is 0 Or*/
+ /* if the sequence number of the message is 0 Or*/
+ /* if the sequence number of the current message is greater than the max messages*/
+ if (udh[pos +3] == 0 ||
+ udh[pos +4] == 0 ||
+ udh[pos +4] > udh[pos +3])
+ return 0;
+
+ header_ptr->header_id = WMS_UDH_CONCAT_16;
+ pos++;
+ header_ptr->u.concat_16.msg_ref = udh[pos++];
+ header_ptr->u.concat_16.msg_ref = (UINT16)(header_ptr->u.concat_16.msg_ref << 8) | udh[pos++];
+ header_ptr->u.concat_16.total_sm= udh[pos++];
+ header_ptr->u.concat_16.seq_num = udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_concat16*/
+
+
+/*=========================================================================
+FUNCTION
+ wms_ts_udh_decode_first_seg_check
+
+DESCRIPTION
+
+ Local helper function used during decoding to check if message segment
+ is first segment or not.
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ TRUE/FALSE depending on if function is successful or not.
+
+SIDE EFFECTS
+ Modifies is_first_segment_ptr with result
+=========================================================================*/
+static UINT8 wms_ts_udh_decode_first_seg_check
+(
+ const UINT8 len, /* user_data_length*/
+ const UINT8 *data, /* first UINT8 of user data */
+ UINT8 *is_first_segment_ptr /* OUT */
+)
+{
+ UINT8 pos = 0;
+ UINT8 num_headers = 0;
+ UINT8 udhl = 0;
+ UINT8 iedl = 0;
+ UINT8 iei = 0;
+
+ // Default to true - it might not have concat header present
+ *is_first_segment_ptr = TRUE;
+
+ if (data == NULL || data[pos] == 0 || len == 0 )
+ {
+ at_print(LOG_DEBUG,"null in wms_ts_udh_decode_first_seg_check");
+ return FALSE;
+ }
+
+ // First UINT8 is the UDH Length
+ udhl = data[pos];
+
+ // Move pos to first user data header
+ pos++;
+
+ while ((pos < udhl) && (num_headers < WMS_MAX_UD_HEADERS))
+ {
+ // First UINT8 is UDH, next UINT8 is length
+ iei = data[pos];
+ iedl = data[pos+1];
+
+ if ( iei == WMS_UDH_CONCAT_16 )
+ {
+ // For concat16 element, peek and see seq#
+ // -------------------------------------------
+ // || IEI | IEDL | Ref# | Ref# |Max# | Seq# ||
+ // -------------------------------------------
+ if ( data[pos+5] != 1 )
+ {
+ at_print(LOG_DEBUG,"WMS_UDH_CONCAT_16 not first segment!");
+ *is_first_segment_ptr = FALSE;
+ return TRUE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ // Not a concat header, so we dont care, skip over it's length
+ else
+ {
+ num_headers++;
+ pos += (2 + iedl); // IEI + IEDL + Actual Data Length
+ }
+ } // while
+
+ return TRUE;
+}
+
+
+static UINT8 wms_ts_decode_udh_special_sm
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 2) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Special SM Present with invalid data length = %d", udh[pos]);
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_SPECIAL_SM;
+
+ /* Bit 7 of octet 1 indicates if the message shall be stored or not.
+ Bit 6..0 of octet 1 indicate which indicator is to be updated.
+ 000 0000 = Voice Message Waiting
+ 000 0001 = Fax Message Waiting
+ 000 0010 = Email Message Waiting
+ 000 0011 = Other Message Waiting
+ Octet 2 represents the number of waiting messages
+ The number can range from 0 to 255 with the value of 255 meaning
+ that there are 255 or more messages waiting
+ */
+
+ header_ptr->u.special_sm.msg_waiting = (wms_gw_msg_waiting_e_type) ((udh[pos] >> 7 == 0) ? WMS_GW_MSG_WAITING_DISCARD : WMS_GW_MSG_WAITING_STORE);
+ header_ptr->u.special_sm.msg_waiting_kind = (wms_gw_msg_waiting_kind_e_type) (udh[pos++] & 0x7f);
+ header_ptr->u.special_sm.message_count = udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_special_sm*/
+
+static UINT8 wms_ts_decode_udh_port_8
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+
+ if (udh[pos] < 2) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"UDH Header Port 8 Present with invalid data length = %d", udh[pos]);
+ return 0; /*Return 0*/
+ }
+
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_PORT_8;
+ header_ptr->u.wap_8.dest_port = udh[pos++];
+ header_ptr->u.wap_8.orig_port = udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_port_8*/
+
+static UINT8 wms_ts_decode_udh_port16
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 4) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Port16 Present with invalid data length = %d", udh[pos]);
+ return 0;
+ }
+
+ header_ptr->header_id = WMS_UDH_PORT_16;
+ pos++;
+ header_ptr->u.wap_16.dest_port = udh[pos++];
+ header_ptr->u.wap_16.dest_port = (UINT16)(header_ptr->u.wap_16.dest_port << 8) | udh[pos++];
+ header_ptr->u.wap_16.orig_port = udh[pos++];
+ header_ptr->u.wap_16.orig_port = (UINT16)(header_ptr->u.wap_16.orig_port << 8) | udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_port16*/
+
+
+static UINT8 wms_ts_decode_udh_text_formatting
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 3 ) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Text Formatting Present with invalid data length = %d", udh[pos]);
+ return 0;
+ }
+
+ if(udh[pos] >= 4)
+ {
+ header_ptr->u.text_formating.is_color_present = TRUE;
+ }
+ else
+ {
+ header_ptr->u.text_formating.is_color_present = FALSE;
+ }
+ pos++;
+
+
+ header_ptr->header_id = WMS_UDH_TEXT_FORMATING;
+ header_ptr->u.text_formating.start_position = udh[pos++];
+ header_ptr->u.text_formating.text_formatting_length = udh[pos++];
+ header_ptr->u.text_formating.alignment_type = (wms_udh_alignment_e_type) (udh[pos] & 0x03 ); /*bit 0 and bit 1*/
+ header_ptr->u.text_formating.font_size = (wms_udh_font_size_e_type) ((udh[pos] & 0x0c) >> 2); /*bit 3 and bit 2*/
+
+ header_ptr->u.text_formating.style_bold = (udh[pos] & 0x10) >> 4; /*bit 4 */
+ header_ptr->u.text_formating.style_italic = (udh[pos] & 0x20) >> 5; /*bit 5 */
+ header_ptr->u.text_formating.style_underlined = (udh[pos] & 0x40) >> 6; /*bit 6 */
+ header_ptr->u.text_formating.style_strikethrough = (udh[pos] & 0x80) >> 7; /*bit 7 */
+ pos++;
+
+ if(header_ptr->u.text_formating.is_color_present)
+ {
+ header_ptr->u.text_formating.text_color_foreground = (wms_udh_text_color_e_type) (udh[pos] & 0x0F); /* bit 0-3 */
+ header_ptr->u.text_formating.text_color_background = (wms_udh_text_color_e_type) ((udh[pos] & 0xF0) >> 4); /* bit 4-7 */
+ pos++;
+ }
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_text_formatting*/
+
+static UINT8 wms_ts_decode_udh_pre_def_sound
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 2) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Pre Defined Sound Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_PRE_DEF_SOUND;
+ header_ptr->u.pre_def_sound.position = udh[pos++];
+ header_ptr->u.pre_def_sound.snd_number = udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_pre_def_sound*/
+
+static UINT8 wms_ts_decode_udh_user_def_sound
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] == 0) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header User Defined Sound Present with no Data");
+ return 0;
+ }
+
+ header_ptr->header_id = WMS_UDH_USER_DEF_SOUND;
+ header_ptr->u.user_def_sound.data_length = udh[pos++]-1;
+ header_ptr->u.user_def_sound.position = udh[pos++];
+
+
+ if (header_ptr->u.user_def_sound.data_length > WMS_UDH_MAX_SND_SIZE)
+ {
+ at_print(LOG_DEBUG,"Max Size Exceed Header id %d ", header_ptr->header_id);
+ //data[pos] += data[pos]; /*Skip the bytes*/
+ return 0;
+ }
+
+ //pos++;
+ memset (header_ptr->u.user_def_sound.user_def_sound, 0xff,WMS_UDH_MAX_SND_SIZE);
+
+ for(j=0; j<header_ptr->u.user_def_sound.data_length; j++)
+ header_ptr->u.user_def_sound.user_def_sound[j] = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_user_def_sound*/
+
+
+static UINT8 wms_ts_decode_udh_pre_def_anim
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] != 2) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Pre Defined Animation Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_PRE_DEF_ANIM;
+ header_ptr->u.pre_def_anim.position = udh[pos++];
+ header_ptr->u.pre_def_anim.animation_number = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_pre_def_anim*/
+
+static UINT8 wms_ts_decode_udh_large_anim
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j,k;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] != (WMS_UDH_ANIM_NUM_BITMAPS * WMS_UDH_LARGE_BITMAP_SIZE + 1) ) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Large Defined Animation Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ header_ptr->header_id = WMS_UDH_LARGE_ANIM;
+ pos++; /*Skip the Size*/
+ header_ptr->u.large_anim.position = udh[pos++];
+
+ for(j=0; j<WMS_UDH_ANIM_NUM_BITMAPS; j++)
+ for (k=0; k<WMS_UDH_LARGE_BITMAP_SIZE; k++)
+ header_ptr->u.large_anim.data[j][k] = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_large_anim*/
+
+
+static UINT8 wms_ts_decode_udh_small_anim
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j,k;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] != (WMS_UDH_ANIM_NUM_BITMAPS * WMS_UDH_SMALL_BITMAP_SIZE + 1) ) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Large Defined Animation Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ header_ptr->header_id = WMS_UDH_SMALL_ANIM;
+
+ pos++; /*Skip the Size*/
+ header_ptr->u.small_anim.position = udh[pos++];
+
+ for(j=0; j<WMS_UDH_ANIM_NUM_BITMAPS; j++)
+ for (k=0; k<WMS_UDH_SMALL_BITMAP_SIZE; k++)
+ header_ptr->u.small_anim.data[j][k] = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_small_anim*/
+
+static UINT8 wms_ts_decode_udh_large_picture
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] != WMS_UDH_LARGE_PIC_SIZE + 1) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Large Picture Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+
+ header_ptr->header_id = WMS_UDH_LARGE_PICTURE;
+ pos++; /*Skip the Size*/
+ header_ptr->u.large_picture.position = udh[pos++];
+
+ for(j=0; j<WMS_UDH_LARGE_PIC_SIZE; j++)
+ header_ptr->u.large_picture.data[j] = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_large_picture*/
+
+
+static UINT8 wms_ts_decode_udh_small_picture
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] != WMS_UDH_SMALL_PIC_SIZE + 1) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Small Picture Present with invalid data legnth = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ header_ptr->header_id = WMS_UDH_SMALL_PICTURE;
+ pos++; /*Skip the size*/
+ header_ptr->u.small_picture.position = udh[pos++];
+
+ for(j=0; j<WMS_UDH_SMALL_PIC_SIZE; j++)
+ header_ptr->u.small_picture.data[j] = udh[pos++];
+
+ return pos;
+}/*wms_ts_decode_udh_small_picture*/
+
+
+static UINT8 wms_ts_decode_udh_var_picture
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0,j,pic_size;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] > WMS_UDH_VAR_PIC_SIZE + 3) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Var Picture Present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ if ( (udh[pos] - 3) != (udh[pos+2] * udh[pos+3]) )
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Var Picture, pic size value mismatch with heigt and weight");
+ return 0;
+ }
+
+ pic_size = udh[pos++] -3;
+ header_ptr->header_id = WMS_UDH_VAR_PICTURE;
+ header_ptr->u.var_picture.position = udh[pos++];
+ header_ptr->u.var_picture.width = (UINT8) (udh[pos++] * 8);
+ header_ptr->u.var_picture.height = udh[pos++];
+
+ for(j=0; j<pic_size && j<WMS_UDH_VAR_PIC_SIZE; j++)
+ header_ptr->u.var_picture.data[j] = udh[pos++];
+
+
+ return pos;
+}/*wms_ts_decode_udh_var_picture*/
+
+
+static UINT8 wms_ts_decode_udh_user_prompt
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 1) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH User Prompt present with invalid data length = %d",
+ udh[pos]);
+ return 0;
+ }
+
+ pos ++; /* Skip udh length */
+
+ header_ptr->header_id = WMS_UDH_USER_PROMPT;
+ header_ptr->u.user_prompt.number_of_objects = udh[pos++];
+
+ return (udh[0] + 1);
+
+} /* wms_ts_decode_udh_user_prompt() */
+
+
+/* Decoding UDH Extended Object
+*/
+static UINT8 wms_ts_decode_udh_eo
+(
+ const UINT8 *udh,
+ UINT8 first_segment,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0, udh_length;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] == 0) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Extended Object present with no Data");
+ return 0;
+ }
+
+ /* Get the length of this UDH */
+ udh_length = udh[pos++];
+
+ header_ptr->header_id = WMS_UDH_EXTENDED_OBJECT;
+ header_ptr->u.eo.first_segment = first_segment;
+
+ if( first_segment == TRUE )
+ {
+ /* The following fields in the first segment occupy 7 bytes */
+ if( udh_length < WMS_UDH_OCTETS_EO_HEADER )
+ {
+ return 0;
+ }
+
+ header_ptr->u.eo.reference = udh[pos++];
+ header_ptr->u.eo.length = udh[pos++] << 8;
+ header_ptr->u.eo.length |= udh[pos++];
+ header_ptr->u.eo.control = udh[pos++];
+ header_ptr->u.eo.type = (wms_udh_eo_id_e_type) udh[pos++];
+ header_ptr->u.eo.position = udh[pos++] << 8;
+ header_ptr->u.eo.position |= udh[pos++];
+ }
+
+ /* Decode EO content */
+ header_ptr->u.eo.content.length = (udh_length - pos) + 1;
+ memcpy( header_ptr->u.eo.content.data,
+ udh + pos,
+ header_ptr->u.eo.content.length );
+
+ pos += header_ptr->u.eo.content.length;
+
+ return pos;
+
+} /* wms_ts_decode_udh_eo() */
+
+static UINT8 wms_ts_decode_udh_rfc822
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if(udh[pos] < 1) /*Length of information element*/
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Rfc822 Present with invalid data length = %d", udh[pos]);
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_RFC822;
+ header_ptr->u.rfc822.header_length = udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_rfc822*/
+
+static UINT8 wms_ts_decode_udh_nat_lang_ss
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ //QSR_MSG_ERROR( 3402803813ULL, "udh is NULL",0,0,0);//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+
+ if(udh[pos] != WMS_UDH_OCTETS_NAT_LANG_SS) /*Length of information element*/
+ {
+ //QSR_MSG_ERROR( 1901262068ULL, "SMS UDH National Lang Single Shift Present with invalid data length = %d",
+ // udh[pos], 0, 0 );//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_NAT_LANG_SS;
+ /* Validate national language id */
+ if ((WMS_UDH_NAT_LANG_TURKISH > udh[pos]) ||
+ (WMS_UDH_NAT_LANG_PORTUGUESE < udh[pos]))
+ {
+ //QSR_MSG_ERROR( 1506461877ULL, "SMS UDH National Lang Single Shift Present with invalid id = %d",
+ // udh[pos], 0, 0 );//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+ header_ptr->u.nat_lang_ss.nat_lang_id = (wms_udh_nat_lang_id_e_type)udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_nat_lang_ss*/
+
+static UINT8 wms_ts_decode_udh_nat_lang_ls
+(
+ const UINT8 *udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ //QSR_MSG_ERROR( 3402803813ULL, "udh is NULL",0,0,0);//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+
+ if(udh[pos] != WMS_UDH_OCTETS_NAT_LANG_LS) /*Length of information element*/
+ {
+ //QSR_MSG_ERROR( 1752724994ULL, "SMS UDH National Lang Locking Shift Present with invalid data length = %d", udh[pos], 0, 0 );//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+
+ pos++;
+ header_ptr->header_id = WMS_UDH_NAT_LANG_LS;
+ /* Validate national language id */
+ if ((WMS_UDH_NAT_LANG_TURKISH > udh[pos]) ||
+ (WMS_UDH_NAT_LANG_PORTUGUESE < udh[pos]))
+ {
+ //QSR_MSG_ERROR( 1843098272ULL, "SMS UDH National Lang Locking Shift Present with invalid id = %d", udh[pos], 0, 0 );//auto-gen, to change remove 'QSR_' and first param
+ return 0;
+ }
+ header_ptr->u.nat_lang_ls.nat_lang_id = (wms_udh_nat_lang_id_e_type)udh[pos++];
+
+ return (udh[0] + 1);
+}/*wms_ts_decode_udh_nat_lang_ls*/
+
+static UINT8 wms_ts_decode_udh_other
+(
+ const UINT8* udh,
+ wms_udh_s_type *header_ptr
+)
+{
+ UINT8 pos=0, i=0;
+
+ if (udh == NULL || header_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"udh is NULL");
+ return 0;
+ }
+
+ if (udh[pos+1] > WMS_UDH_OTHER_SIZE)
+ {
+ at_print(LOG_DEBUG,"SMS UDH Header Other data length exceeding 226");
+ return 0;
+ }
+
+ header_ptr->header_id = (wms_udh_id_e_type) udh[pos];
+ header_ptr->u.other.header_id = (wms_udh_id_e_type) udh[pos++];
+ header_ptr->u.other.header_length = udh[pos++];
+
+ for(i=0; i<header_ptr->u.other.header_length; i++)
+ {
+ header_ptr->u.other.data[i] = udh[pos++];
+ }
+
+ return pos;
+}
+
+
+UINT8 wms_ts_decode_user_data_header
+(
+ const UINT8 len, /* user_data_length*/
+ const UINT8 *data, /* first UINT8 of user data */
+ UINT8 * num_headers_ptr, /* OUT */
+ wms_udh_s_type * udh_ptr /* OUT */
+)
+{
+ UINT8 pos =0;
+ UINT8 header_length =0, num_headers=0;
+ UINT8 udhl;
+
+ UINT8 first_segment = TRUE; /* Used for Extended Object decoding */
+
+ if (data == NULL || len == 0 || data[pos] == 0 || num_headers_ptr == NULL || udh_ptr == NULL )
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_decode_user_data_header");
+ return 0;
+ }
+
+ udhl = data[pos];
+
+ pos++;
+
+ while ((pos < udhl)&&(num_headers<WMS_MAX_UD_HEADERS))
+ {
+ /*first UINT8 - header id*/
+ /*second UINT8 - header length*/
+ switch(data[pos++])
+ {
+ case WMS_UDH_CONCAT_8:
+ header_length = wms_ts_decode_udh_concat_8(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_CONCAT_16:
+ header_length = wms_ts_decode_udh_concat16(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_SPECIAL_SM:
+ header_length = wms_ts_decode_udh_special_sm(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_PORT_8:
+ header_length = wms_ts_decode_udh_port_8(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_PORT_16:
+ header_length = wms_ts_decode_udh_port16(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_TEXT_FORMATING:
+ header_length = wms_ts_decode_udh_text_formatting(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_PRE_DEF_SOUND:
+ header_length = wms_ts_decode_udh_pre_def_sound(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_USER_DEF_SOUND:
+ header_length = wms_ts_decode_udh_user_def_sound(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_PRE_DEF_ANIM:
+ header_length = wms_ts_decode_udh_pre_def_anim(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_LARGE_ANIM:
+ header_length = wms_ts_decode_udh_large_anim(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_SMALL_ANIM:
+ header_length = wms_ts_decode_udh_small_anim(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_LARGE_PICTURE:
+ header_length = wms_ts_decode_udh_large_picture(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_SMALL_PICTURE:
+ header_length = wms_ts_decode_udh_small_picture(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_VAR_PICTURE:
+ header_length = wms_ts_decode_udh_var_picture(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_USER_PROMPT:
+ header_length = wms_ts_decode_udh_user_prompt( data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_EXTENDED_OBJECT:
+ //kw 3
+ wms_ts_udh_decode_first_seg_check(len, data, &first_segment);
+ header_length = wms_ts_decode_udh_eo(data+pos, first_segment, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_RFC822:
+ header_length = wms_ts_decode_udh_rfc822(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_NAT_LANG_SS:
+ header_length = wms_ts_decode_udh_nat_lang_ss(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ case WMS_UDH_NAT_LANG_LS:
+ header_length = wms_ts_decode_udh_nat_lang_ls(data+pos, &udh_ptr[num_headers]);
+ break;
+
+ default:
+ pos --;
+ header_length = wms_ts_decode_udh_other(data+pos, &udh_ptr[num_headers]);
+ break;
+ } /* End of Switch */
+
+ if ( (UINT16)pos + (UINT16)header_length > WMS_MAX_LEN )
+ {
+ at_print(LOG_DEBUG,"number of bytes decoded has exceeded UDHL value of %d",udhl);
+ return 0;
+ }
+ else if(header_length != 0)
+ {
+ pos += header_length;
+ num_headers++;
+ }
+ else
+ {
+ at_print(LOG_DEBUG,"Bad UDH: pos=%d, data[pos]=%d", pos, data[pos]);
+ * num_headers_ptr = 0;
+ return 0; /* SHORT-RETURN */
+ }
+ } /* End of While loop */
+
+
+ if (num_headers >= WMS_MAX_UD_HEADERS)
+ {
+ /* Num Headers has Exceeded Max */
+ at_print(LOG_DEBUG,"decode_udh: Num Headers has exceeded WMS_MAX_UD_HEADERS");
+
+ /* Placing the correct value */
+ pos = udhl+1;
+ }
+
+ if (pos!= (udhl+1))
+ {
+ at_print(LOG_DEBUG,"SMS UDH could not be decoded");
+ num_headers =0;
+ udhl =0;
+ }
+
+ if (num_headers >0)
+ {
+ * num_headers_ptr = num_headers;
+ }
+
+ return udhl;
+}
+
+UINT8 wms_ts_decode_gw_user_data
+(
+ const wms_gw_dcs_s_type *dcs,
+ const UINT8 len, // user data length
+ const UINT8 *data,
+ const UINT8 user_data_header_present,
+ wms_gw_user_data_s_type *user_data
+)
+{
+ UINT8 i, pos=0;
+ UINT8 fill_bits =0;
+ UINT8 user_data_length;
+
+ UINT8 user_data_header_length = 0; /* only the user data header length*/
+
+ if (dcs == NULL || data == NULL || user_data == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_decode_gw_user_data");
+ return 0;
+ }
+
+ /* Defaulting to all zeroes */
+ (void)memset(user_data, 0, sizeof(wms_gw_user_data_s_type));
+
+ if (len == 0)
+ {
+ return 0;
+ }
+
+ if( dcs->alphabet == WMS_GW_ALPHABET_7_BIT_DEFAULT )
+ {
+ if (len > WMS_SMS_UDL_MAX_7_BIT)
+ {
+ at_print(LOG_DEBUG,"user data length > max value for gw 7-bit alphabet");
+ return 0;
+ }
+ user_data_length = len;
+
+ if(user_data_header_present)
+ {
+ user_data_header_length = wms_ts_decode_user_data_header( data[pos], data+pos,
+ & user_data->num_headers, user_data->headers );
+ }
+ if (user_data_header_length > len)
+ {
+ at_print(LOG_DEBUG,"user data header length > total length");
+ return 0;
+ }
+ /*len would be the number of septets*/
+ if(user_data_header_length > 0)
+ {
+ /*The number of fill bits required to make a septet boundary*/
+ fill_bits =( (len * 7) - ((user_data_header_length+1)*8) ) % 7;
+ user_data_length = (UINT8)(( (len * 7) - ((user_data_header_length+1)*8) ) / 7);
+ pos = user_data_header_length + 1;
+
+ if (fill_bits != 0)
+ {
+ fill_bits = 8-fill_bits;
+ }
+ }
+
+ i = wms_ts_unpack_gw_7_bit_chars
+ (
+ & data[pos],
+ user_data_length,
+ WMS_MAX_LEN,
+ fill_bits,
+ user_data->sm_data
+ );
+ user_data->sm_len = user_data_length;
+ }
+ else
+ {
+ if (len > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ at_print(LOG_DEBUG,"user data length > max value for 8-bit chararacters");
+ return 0;
+ }
+ user_data_length = len;
+ if(user_data_header_present)
+ {
+ user_data_header_length = wms_ts_decode_user_data_header( data[pos],
+ data+pos,
+ & user_data->num_headers,
+ user_data->headers );
+ if (user_data_header_length > len)
+ {
+ at_print(LOG_DEBUG,"user data header length > total length");
+ return 0;
+ }
+ pos += user_data_header_length +1;
+ user_data_length = (len - user_data_header_length) - 1;
+ }
+
+ memcpy( user_data->sm_data, data+pos, user_data_length );
+ user_data->sm_len = user_data_length;
+ i = (UINT8)user_data->sm_len;
+ }
+
+ pos += i;
+
+ return pos;
+
+} /* wms_ts_decode_gw_user_data() */
+
+wms_status_e_type wms_ts_decode_deliver
+(
+ const T_zUfiSms_RawTsData * ptRawTsData,
+ wms_gw_deliver_s_type * deliver
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ uint32 pos = 0, i;
+ const UINT8 *data = ptRawTsData->data;
+
+ /* TP-MTI, TP-MMS, TP-SRI, TP-UDHI, TP-RP
+ */
+ if (ptRawTsData == NULL || deliver == NULL)
+ {
+ printf("null pointer in wms_ts_decode_deliver");
+ return WMS_NULL_PTR_S;
+ }
+ else if ( (data[pos] & 0x03) != 0x00) /* check bit 0 and bit 1 for TP-MTI for deliver */
+ {
+ printf("invalid tpdu type in wms_ts_decode_deliver");
+ return WMS_INVALID_TPDU_TYPE_S;
+ }
+ else
+ {
+ deliver->more = (data[pos] & 0x04) ? FALSE : TRUE;
+ /* bit 2 */
+ /* bits 3, 4 are not used */
+ deliver->status_report_enabled = (data[pos] & 0x20) ? TRUE : FALSE;
+ /* bit 5 */
+ deliver->user_data_header_present = (data[pos] & 0x40) ? TRUE : FALSE;
+ /* bit 6 */
+ deliver->reply_path_present = (data[pos] & 0x80) ? TRUE : FALSE;
+ /* bit 7 */
+ pos ++;
+
+ /* TP-OA
+ */
+ i = wms_ts_decode_address( & data[pos], & deliver->address);
+ if( i==0 )
+ {
+ printf("invalid param size in wms_ts_decode_deliver");
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+ pos += i;
+
+ /* TP-PID
+ */
+ deliver->pid = (wms_pid_e_type) data[pos];
+ pos ++;
+
+ /* TP-DCS
+ */
+ pos += wms_ts_decode_dcs( data+pos, & deliver->dcs );
+
+ if (deliver->dcs.msg_waiting_kind != WMS_GW_MSG_WAITING_VOICEMAIL)
+ {
+ if (deliver->pid == WMS_PID_RETURN_CALL)
+ {
+ deliver->dcs.msg_waiting = WMS_GW_MSG_WAITING_STORE;
+ deliver->dcs.msg_waiting_active = TRUE;
+ deliver->dcs.msg_waiting_kind = WMS_GW_MSG_WAITING_VOICEMAIL;
+ }
+ }
+
+ /* TP-SCTS
+ */
+ i = wms_ts_decode_timestamp( data+pos, & deliver->timestamp );
+ if ( i==0 )
+ {
+ printf("invalid param value in wms_ts_decode_deliver");
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+
+ /* TP-UDL
+ */
+ // deliver->user_data_len = data[pos];
+ pos ++;
+
+ /* TP-UD
+ */
+ i = wms_ts_decode_gw_user_data( & deliver->dcs,
+ data[pos-1],
+ data+pos,
+ deliver->user_data_header_present,
+ & deliver->user_data );
+
+ if (i > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ printf("User Data Length has exceeded capacity: UDL = %lu", i);
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+
+ pos += i;
+
+ /* Set the global raw ts data len
+ */
+ //raw_ts_len = pos;
+
+ return st;
+ }
+} /* wms_ts_decode_deliver() */
+
+UINT8 wms_ts_decode_gw_validity
+(
+ const UINT8 * data,
+ wms_gw_validity_s_type * validity
+)
+{
+ UINT8 i, pos = 0;
+
+ if (data == NULL || validity == NULL)
+ {
+ at_print(LOG_DEBUG,"null pointer in wms_ts_decode_gw_validity");
+ return 0;
+ }
+ else
+ {
+ switch( validity->format )
+ {
+ case WMS_GW_VALIDITY_NONE:
+ memset( validity, 0, sizeof(wms_gw_validity_s_type) );
+ break;
+
+ case WMS_GW_VALIDITY_RELATIVE:
+ zUfiSms_DecodeRelativeTime( data[pos], & validity->u.time );
+ pos ++;
+ break;
+
+ case WMS_GW_VALIDITY_ABSOLUTE:
+ i = wms_ts_decode_timestamp( data+pos, & validity->u.time );
+ /* //kw 3
+ if( i == 0 )
+ {
+ at_print(LOG_DEBUG,"Error while Decoding Absolute Validity Timestamp");
+ }
+ */
+ pos += i;
+ break;
+
+ case WMS_GW_VALIDITY_ENHANCED:
+ // TBD
+ break;
+
+ default:
+ break;
+ } /* switch */
+ return pos;
+ }
+
+} /* wms_ts_decode_gw_validity() */
+
+
+wms_status_e_type wms_ts_decode_submit
+(
+ const T_zUfiSms_RawTsData * ptRawTsData,
+ wms_gw_submit_s_type * submit
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ uint32 pos = 0, i;
+ const UINT8 *data;
+
+ if( ptRawTsData == NULL || submit == NULL )
+ {
+ printf("Null pointer in wms_ts_decode_submit!");
+ return WMS_NULL_PTR_S;
+ }
+
+ data = ptRawTsData->data;
+
+ /* TP-MTI, TP-RD, TP-VPF, TP-SRR, TP_UDHI, TP-RP:
+ */
+ submit->reject_duplicates = (data[pos] & 0x04) ? TRUE : FALSE;
+ /* bit 2 */
+ submit->validity.format = (wms_gw_validity_format_e_type) (( data[pos] & 0x18 ) >> 3); /* bits 3, 4 */
+ submit->status_report_enabled = (data[pos] & 0x20) ? TRUE : FALSE;
+ /* bit 5 */
+ submit->user_data_header_present = (data[pos] & 0x40) ? TRUE : FALSE;
+ /* bit 6 */
+ submit->reply_path_present = (data[pos] & 0x80) ? TRUE : FALSE;
+ /* bit 7 */
+ pos ++;
+
+
+ /* TP-MR
+ */
+ submit->message_reference = data[pos];
+ pos ++;
+
+ /* TP-DA
+ */
+ i = wms_ts_decode_address( & data[pos], & submit->address );
+ if( i == 0 )
+ {
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+
+ pos += i;
+
+ /* TP-PID
+ */
+ submit->pid = (wms_pid_e_type) data[pos];
+ pos ++;
+
+ /* TP-DCS
+ */
+ pos += wms_ts_decode_dcs( data+pos, & submit->dcs );
+
+ /* TP-VP
+ */
+ i = wms_ts_decode_gw_validity( data+pos, & submit->validity );
+ if ((submit->validity.format != WMS_GW_VALIDITY_NONE) && ( i == 0 ))
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+
+ pos += i;
+
+ /* TP-UDL
+ */
+// submit->user_data_len = data[pos];
+ pos ++;
+
+ /* TP-UD
+ */
+ i = wms_ts_decode_gw_user_data( & submit->dcs,
+ data[pos-1],
+ data+pos,
+ submit->user_data_header_present,
+ & submit->user_data );
+
+ if (i > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ printf("User Data Length has exceeded capacity: UDL = %lu", i);
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+
+ pos += i;
+
+ /* Set the global raw ts data len
+ */
+ //raw_ts_len = pos;
+
+ return st;
+
+} /* wms_ts_decode_submit() */
+
+wms_status_e_type wms_ts_decode_status_report
+(
+ const T_zUfiSms_RawTsData * ptRawTsData,
+ wms_gw_status_report_s_type * status_report
+)
+{
+ wms_status_e_type st = WMS_OK_S;
+ uint32 pos = 0, i;
+ const UINT8 *data;
+
+ if( ptRawTsData == NULL || status_report == NULL )
+ {
+ printf("Null pointer in wms_ts_decode_status_report!");
+ return WMS_NULL_PTR_S;
+ }
+
+ data = ptRawTsData->data;
+
+ /* TP-MTI, TP_UDHI:
+ */
+ status_report->more = data[pos] & 0x04? FALSE:TRUE;/*bit 2*/
+ status_report->status_report_qualifier = data[pos] & 0x20 ? TRUE:FALSE;
+ /*bit 5*/
+ status_report->user_data_header_present =
+ (data[pos] & 0x40) ? TRUE : FALSE; /* bit 6 */
+ pos ++;
+
+ /* TP-MR
+ */
+ status_report->message_reference = data[pos];
+ pos ++;
+
+ /* TP-RA
+ */
+ i = wms_ts_decode_address( & data[pos], & status_report->address);
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_SIZE_S;
+ }
+ pos += i;
+
+ /* TP-SCTS
+ */
+ i = wms_ts_decode_timestamp( data+pos, & status_report->timestamp);
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+ /* TP-DT*/
+ i = wms_ts_decode_timestamp( data+pos, & status_report->discharge_time);
+ if( i==0 )
+ {
+ return WMS_INVALID_PARM_VALUE_S;
+ }
+ pos += i;
+
+ /*TP-ST*/
+ status_report->tp_status = (wms_tp_status_e_type) data[pos];
+ pos++;
+
+ /*TP-PI*/
+ status_report->mask = data[pos];
+
+ /*TP-PID*/
+ status_report->pid = (wms_pid_e_type) 0;
+
+ status_report->user_data.sm_len = 0;
+
+ /* to extract last UINT8 */
+ status_report->mask &= 0xFF;
+
+ /* to check for valid mask */
+ if ((status_report->mask != 0xFF)
+ && (status_report->mask != 0))
+ {
+ /* Increment only if mask is valid */
+ pos ++;
+
+ if( status_report->mask & WMS_TPDU_MASK_PID )
+ {
+ status_report->pid = (wms_pid_e_type) data[pos];
+ pos ++;
+ }
+
+ /* TP-DCS
+ */
+ if( status_report->mask & WMS_TPDU_MASK_DCS )
+ {
+ pos += wms_ts_decode_dcs( data+pos, & status_report->dcs );
+ }
+
+ if( status_report->mask & WMS_TPDU_MASK_USER_DATA )
+ {
+ /* TP-UDL
+ */
+ pos ++;
+ /* TP-UD
+ */
+ i = wms_ts_decode_gw_user_data( & status_report->dcs,
+ data[pos-1],
+ data+pos,
+ status_report->user_data_header_present,
+ & status_report->user_data );
+
+ if (i > WMS_SMS_UDL_MAX_8_BIT)
+ {
+ printf("User Data Length has exceeded capacity: UDL = %lu", i);
+ st = WMS_INVALID_USER_DATA_SIZE_S;
+ }
+
+ pos += i;
+ }
+ }
+ else
+ {
+ status_report->mask = 0;
+ }
+ /* Set the global raw ts data len
+ */
+ //raw_ts_len = pos;
+
+ return st;
+
+} /* wms_ts_decode_status_report() */
+
+wms_status_e_type wms_ts_decode
+(
+ const T_zUfiSms_RawTsData * ptRawTsData,
+ T_zUfiSms_ClientTsData* ptClientTsData
+)
+{
+ // TBD: GW format only
+ wms_status_e_type st = WMS_OK_S;
+ wms_gw_pp_ts_data_s_type *msg;
+
+ if( ptRawTsData == NULL || ptClientTsData == NULL )
+ {
+ return WMS_NULL_PTR_S;
+ }
+
+ msg = & ptClientTsData->u.gw_pp;
+
+ //pthread_mutex_lock( &wmsts_mutex );
+ switch( ptRawTsData->format )
+ {
+ case WMS_FORMAT_CDMA:
+ case WMS_FORMAT_ANALOG_AWISMS:
+ case WMS_FORMAT_ANALOG_CLI:
+ case WMS_FORMAT_ANALOG_VOICE_MAIL:
+ case WMS_FORMAT_ANALOG_SMS:
+ case WMS_FORMAT_MWI:
+ /*
+ st = wms_ts_decode_bearer_data( ptRawTsData,
+ & ptClientTsData->u.cdma );
+ */
+ at_print(AT_DEBUG,"!!!!!!!!wms_ts_decode Error: Get Omit format!!! Format[%d]\n",ptRawTsData->format);
+ break;
+
+ case WMS_FORMAT_GW_PP:
+ msg->tpdu_type = ptRawTsData->tpdu_type;
+
+ switch( msg->tpdu_type )
+ {
+ case WMS_TPDU_DELIVER:
+ st = wms_ts_decode_deliver( ptRawTsData, & msg->u.deliver );
+ break;
+
+ case WMS_TPDU_SUBMIT:
+ st = wms_ts_decode_submit( ptRawTsData, & msg->u.submit );
+ break;
+
+ case WMS_TPDU_STATUS_REPORT:
+ st = wms_ts_decode_status_report( ptRawTsData,
+ & msg->u.status_report);
+ break;
+
+ case WMS_TPDU_DELIVER_REPORT_ACK:
+ case WMS_TPDU_DELIVER_REPORT_ERROR:
+ case WMS_TPDU_SUBMIT_REPORT_ACK:
+ case WMS_TPDU_SUBMIT_REPORT_ERROR:
+ case WMS_TPDU_COMMAND:
+ at_print(AT_DEBUG,"!!!!!!!!wms_ts_decode Error: Get Omit branch!!! tpdu_type[%d]\n",msg->tpdu_type );
+ break;
+
+ default:
+ at_print(LOG_DEBUG,"Invalid TPDU type %d", msg->tpdu_type);
+ st = WMS_INVALID_TPDU_TYPE_S;
+ break;
+ }
+
+ break;
+
+ case WMS_FORMAT_GW_CB:
+ /*st = wms_ts_decode_gw_cb( ptRawTsData,
+ & ptClientTsData->u.gw_cb );
+ */
+ at_print(AT_DEBUG,"!!!!!!!!wms_ts_decode Error: Get Omit format!!! Format[%d]\n",ptRawTsData->format);
+ break;
+
+ default:
+ st = WMS_INVALID_FORMAT_S;
+ at_print(AT_DEBUG,"Invalid format: %d", ptRawTsData->format);
+ break;
+ }
+
+ ptClientTsData->format = ptRawTsData->format;
+ //pthread_mutex_unlock( &wmsts_mutex );
+
+ return st;
+
+} /* wms_ts_decode() */
+
diff --git a/ap/app/zte_comm/sms/src/sms_db.c b/ap/app/zte_comm/sms/src/sms_db.c
index b4b00e6..dcb67d4 100755
--- a/ap/app/zte_comm/sms/src/sms_db.c
+++ b/ap/app/zte_comm/sms/src/sms_db.c
@@ -1,551 +1,1183 @@
-
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2008, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+*
+* ÎļþÃû³Æ£º sms_db.c
+* Îļþ±êʶ£º
+* ÄÚÈÝÕªÒª£º SMSÄ£¿é²Ù×÷Êý¾Ý¿âÎļþ
+* ÆäËü˵Ã÷£º
+* µ±Ç°°æ±¾£º V0.1
+* ×÷ Õߣº G.F
+* Íê³ÉÈÕÆÚ£º 2008-12-13
+*
+* Ð޸ļǼ1£º
+* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
+************************************************************************/
#include <stdio.h>
#include <time.h>
#include <limits.h>
#include "sms_db.h"
#include "sms_code.h"
#include "cfg_nv_def.h"
-typedef sqlite3_callback zte_wms_db_callback;
-#define ZTE_WMS_CREATE_TABLE_SMS_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73"\
- \
- \
-"\x28\x69\x64\x20\x49\x4e\x54\x45\x47\x45\x52\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59\x20\x41\x55\x54\x4f\x49\x4e\x43\x52\x45\x4d\x45\x4e\x54"\
- \
- \
-"\x20\x4e\x4f\x54\x20\x4e\x55\x4c\x4c\x2c\x20\x69\x6e\x64\x20\x54\x45\x58\x54\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x20\x54\x45\x58\x54\x2c\x54\x61\x67"\
- \
- \
-"\x20\x54\x45\x58\x54\x2c\x4e\x75\x6d\x62\x65\x72\x20\x54\x45\x58\x54\x2c\x43\x63\x5f\x53\x6d\x73\x20\x54\x45\x58\x54\x2c\x43\x63\x5f\x52\x65\x66\x20"\
- \
- \
-"\x20\x54\x45\x58\x54\x2c\x43\x63\x5f\x54\x6f\x74\x61\x6c\x20\x54\x45\x58\x54\x2c\x20\x43\x63\x5f\x53\x65\x71\x20\x54\x45\x58\x54\x2c\x43\x63\x5f\x4e\x75\x6d"\
- \
- \
-"\x20\x54\x45\x58\x54\x2c\x43\x63\x5f\x43\x6f\x6e\x74\x65\x6e\x74\x20\x54\x45\x58\x54\x2c\x4c\x61\x6e\x67\x75\x61\x67\x65\x20\x54\x45\x58\x54\x2c\x54\x70\x5f\x44\x63\x73"\
- \
- \
-"\x20\x54\x45\x58\x54\x2c\x4d\x73\x67\x5f\x52\x65\x66\x20\x54\x45\x58\x54\x2c\x43\x6f\x6e\x74\x65\x6e\x74\x20\x54\x45\x58\x54\x2c\x20"\
- \
- \
-"\x20\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x5f\x52\x65\x63\x69\x76\x65\x64\x20\x54\x45\x58\x54\x2c\x44\x72\x61\x66\x74\x5f\x47\x72\x6f\x75\x70\x5f\x49\x64\x20\x54\x45\x58\x54\x2c\x59\x65\x61\x72\x20\x54\x45\x58\x54\x2c\x4d\x6f\x6e\x74\x68\x20\x54\x45\x58\x54\x2c"\
- \
- \
-"\x20\x44\x61\x79\x20\x54\x45\x58\x54\x2c\x48\x6f\x75\x72\x20\x54\x45\x58\x54\x2c\x4d\x69\x6e\x75\x74\x65\x20\x54\x45\x58\x54\x2c\x53\x65\x63\x6f\x6e\x64\x20\x54\x45\x58\x54\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x20\x54\x45\x58\x54\x2c\x4d\x6b\x74\x69\x6d\x65\x20\x49\x4e\x54\x45\x47\x45\x52\x2c\x44\x69\x73\x70\x6c\x61\x79\x4d\x6f\x64\x65\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_CMD_STATUS_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x63\x6d\x64\x5f\x73\x74\x61\x74\x75\x73\x28\x43\x6d\x64\x20\x54\x45\x58\x54\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59\x2c\x43\x6d\x64\x5f\x53\x74\x61\x74\x75\x73\x20\x54\x45\x58\x54\x2c"\
- \
- \
-"\x20\x45\x72\x72\x5f\x43\x6f\x64\x65\x20\x54\x45\x58\x54\x2c\x53\x65\x6e\x64\x5f\x46\x61\x69\x6c\x5f\x43\x6f\x75\x6e\x74\x20\x54\x45\x58\x54\x2c\x44\x65\x6c\x5f\x54\x79\x70\x65\x20\x54\x45\x58\x54\x2c"\
- \
- \
-"\x20\x44\x65\x6c\x5f\x43\x6f\x75\x6e\x74\x20\x54\x45\x58\x54\x2c\x44\x65\x6c\x5f\x69\x6e\x64\x65\x78\x20\x54\x45\x58\x54\x2c\x20\x46\x61\x69\x6c\x65\x64\x5f\x43\x6f\x75\x6e\x74\x20\x54\x45\x58\x54\x2c\x46\x61\x69\x6c\x65\x64\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_SMS_REP_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x72\x65\x70\x6f\x72\x74\x28\x69\x64\x20\x49\x4e\x54\x45\x47\x45\x52\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59"\
- \
- \
-"\x20\x41\x55\x54\x4f\x49\x4e\x43\x52\x45\x4d\x45\x4e\x54\x20\x4e\x4f\x54\x20\x4e\x55\x4c\x4c\x2c\x20\x20\x61\x64\x64\x72\x65\x73\x73\x20\x54\x45\x58\x54\x2c\x63\x6f\x6e\x74\x65\x6e\x74\x20\x54\x45\x58\x54\x2c\x59\x65\x61\x72\x20\x54\x45\x58\x54\x2c\x4d\x6f\x6e\x74\x68\x20\x54\x45\x58\x54\x2c"\
- \
- \
-"\x20\x44\x61\x79\x20\x54\x45\x58\x54\x2c\x48\x6f\x75\x72\x20\x54\x45\x58\x54\x2c\x4d\x69\x6e\x75\x74\x65\x20\x54\x45\x58\x54\x2c\x53\x65\x63\x6f\x6e\x64\x20\x54\x45\x58\x54\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_PAR_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x28\x69\x64\x20\x49\x4e\x54\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59\x2c\x20\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x20\x54\x45\x58\x54\x2c\x20\x53\x6d\x73\x5f\x53\x63\x61\x20\x54\x45\x58\x54\x2c\x20"\
- \
-"\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x20\x54\x45\x58\x54\x2c\x54\x70\x5f\x56\x61\x6c\x69\x64\x69\x74\x79\x20\x54\x45\x58\x54\x2c\x53\x65\x6e\x64\x5f\x52\x65\x74\x72\x79\x20\x54\x45\x58\x54\x2c\x4f\x75\x74\x64\x61\x74\x65\x5f\x44\x65\x6c\x65\x74\x65\x20\x54\x45\x58\x54\x2c\x44\x65\x66\x61\x75\x6c\x74\x5f\x53\x74\x6f\x72\x65\x20\x54\x45\x58\x54\x2c\x4d\x61\x78\x5f\x43\x63\x5f\x52\x65\x66\x20\x54\x45\x58\x54\x2c\x20"\
- \
- \
-"\x20\x4d\x61\x78\x5f\x53\x6d\x73\x5f\x52\x65\x66\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_INFO_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x69\x6e\x66\x6f\x28\x69\x64\x20\x49\x4e\x54\x45\x47\x45\x52\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59"\
- \
- \
-"\x20\x41\x55\x54\x4f\x49\x4e\x43\x52\x45\x4d\x45\x4e\x54\x20\x4e\x4f\x54\x20\x4e\x55\x4c\x4c\x2c\x20\x6e\x61\x6d\x65\x20\x54\x45\x58\x54\x2c\x20\x76\x61\x6c\x75\x65\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_CELL_BRO_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x63\x65\x6c\x6c\x5f\x62\x72\x6f\x20\x28\x69\x64\x20\x49\x4e\x54\x45\x47\x45\x52\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59"\
- \
- \
-"\x20\x41\x55\x54\x4f\x49\x4e\x43\x52\x45\x4d\x45\x4e\x54\x20\x4e\x4f\x54\x20\x4e\x55\x4c\x4c\x2c\x20\x6d\x73\x67\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_CREATE_SEND_CONTENT_SQL \
-"\x43\x52\x45\x41\x54\x45\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x4e\x4f\x54\x20\x45\x58\x49\x53\x54\x53\x20\x73\x65\x6e\x64\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x20\x28\x69\x64\x20\x49\x4e\x54\x45\x47\x45\x52\x20\x50\x52\x49\x4d\x41\x52\x59\x20\x4b\x45\x59"\
- \
- \
-"\x20\x41\x55\x54\x4f\x49\x4e\x43\x52\x45\x4d\x45\x4e\x54\x20\x4e\x4f\x54\x20\x4e\x55\x4c\x4c\x2c\x20\x6d\x73\x67\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x20\x54\x45\x58\x54\x29\x3b"
-#define ZTE_WMS_DROP_ALL_TABLE_SQL \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x63\x6d\x64\x5f\x73\x74\x61\x74\x75\x73\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x72\x65\x70\x6f\x72\x74\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x69\x6e\x66\x6f\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x63\x65\x6c\x6c\x5f\x62\x72\x6f\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x65\x6e\x64\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x3b"
-#define ZTE_WMS_DROP_TABLE_EXCEPTSMS_SQL \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x63\x6d\x64\x5f\x73\x74\x61\x74\x75\x73\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x72\x65\x70\x6f\x72\x74\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x6d\x73\x5f\x69\x6e\x66\x6f\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x63\x65\x6c\x6c\x5f\x62\x72\x6f\x3b"\
- \
-"\x44\x52\x4f\x50\x20\x54\x41\x42\x4c\x45\x20\x49\x46\x20\x45\x58\x49\x53\x54\x53\x20\x73\x65\x6e\x64\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x3b"
-#define ZTE_WMS_DEL_SIM_SQL \
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x68\x65\x72\x65\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x73\x69\x6d\x27\x3b"
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+
+/* ºê´¦Àí */
+typedef sqlite3_callback zte_wms_db_callback;
+
+#define ZTE_WMS_CREATE_TABLE_SMS_SQL "CREATE TABLE IF NOT EXISTS sms" \
+ "(id INTEGER PRIMARY KEY AUTOINCREMENT" \
+ " NOT NULL, ind TEXT,Mem_Store TEXT,Tag" \
+ " TEXT,Number TEXT,Cc_Sms TEXT,Cc_Ref " \
+ " TEXT,Cc_Total TEXT, Cc_Seq TEXT,Cc_Num" \
+ " TEXT,Cc_Content TEXT,Language TEXT,Tp_Dcs" \
+ " TEXT,Msg_Ref TEXT,Content TEXT, " \
+ " Sms_Report_Recived TEXT,Draft_Group_Id TEXT,Year TEXT,Month TEXT," \
+ " Day TEXT,Hour TEXT,Minute TEXT,Second TEXT,TimeZone TEXT,Mktime INTEGER,DisplayMode TEXT);"
+
+#define ZTE_WMS_CREATE_CMD_STATUS_SQL "CREATE TABLE IF NOT EXISTS cmd_status(Cmd TEXT PRIMARY KEY,Cmd_Status TEXT," \
+ " Err_Code TEXT,Send_Fail_Count TEXT,Del_Type TEXT," \
+ " Del_Count TEXT,Del_index TEXT, Failed_Count TEXT,Failed TEXT);"
+
+#define ZTE_WMS_CREATE_SMS_REP_SQL "CREATE TABLE IF NOT EXISTS sms_report(id INTEGER PRIMARY KEY" \
+ " AUTOINCREMENT NOT NULL, address TEXT,content TEXT,Year TEXT,Month TEXT," \
+ " Day TEXT,Hour TEXT,Minute TEXT,Second TEXT,TimeZone TEXT);"
+
+#define ZTE_WMS_CREATE_PAR_SQL "CREATE TABLE IF NOT EXISTS parameter(id INT PRIMARY KEY, Sms_Report TEXT, Sms_Sca TEXT, "\
+ " Mem_Store TEXT,Tp_Validity TEXT,Send_Retry TEXT,Outdate_Delete TEXT,Default_Store TEXT,Max_Cc_Ref TEXT, " \
+ " Max_Sms_Ref TEXT);"
+
+#define ZTE_WMS_CREATE_INFO_SQL "CREATE TABLE IF NOT EXISTS sms_info(id INTEGER PRIMARY KEY" \
+ " AUTOINCREMENT NOT NULL, name TEXT, value TEXT);"
+
+#define ZTE_WMS_CREATE_CELL_BRO_SQL "CREATE TABLE IF NOT EXISTS cell_bro (id INTEGER PRIMARY KEY" \
+ " AUTOINCREMENT NOT NULL, msg_content TEXT);"
+#define ZTE_WMS_CREATE_SEND_CONTENT_SQL "CREATE TABLE IF NOT EXISTS send_content (id INTEGER PRIMARY KEY" \
+ " AUTOINCREMENT NOT NULL, msg_content TEXT);"
+
+#define ZTE_WMS_DROP_ALL_TABLE_SQL "DROP TABLE IF EXISTS sms;"\
+ "DROP TABLE IF EXISTS cmd_status;"\
+ "DROP TABLE IF EXISTS sms_report;"\
+ "DROP TABLE IF EXISTS parameter;"\
+ "DROP TABLE IF EXISTS sms_info;"\
+ "DROP TABLE IF EXISTS cell_bro;"\
+ "DROP TABLE IF EXISTS send_content;"
+
+#define ZTE_WMS_DROP_TABLE_EXCEPTSMS_SQL "DROP TABLE IF EXISTS cmd_status;"\
+ "DROP TABLE IF EXISTS sms_report;"\
+ "DROP TABLE IF EXISTS parameter;"\
+ "DROP TABLE IF EXISTS sms_info;"\
+ "DROP TABLE IF EXISTS cell_bro;"\
+ "DROP TABLE IF EXISTS send_content;"
+
+
+#define ZTE_WMS_DEL_SIM_SQL "DELETE FROM sms Where Mem_Store='sim';"
+//#define ZTE_WMS_DEL_NV_SQL "DELETE FROM sms Where Mem_Store='nv'"
+
+//90*24*60*60s three month
#define OUTDATEINTERVAL 7776000
-typedef struct{char*buf_addr;int buf_len;}T_zUfiSms_BufInfo;typedef struct{int
-valid;char*strSQL;}T_zUfiSms_SQLMap;sqlite3*g_zUfiSms_DbPointer=
-(0xeb1+2241-0x1772);extern T_zUfiSms_ParaInfo g_zUfiSms_CurSmsPara;extern
-unsigned long g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_MAX];extern
-T_zUfiSms_DelSms g_zUfiSms_DelMsg;static int isSucess(T_zUfiSms_DbResult dbRst){
-return dbRst==ZTE_WMS_DB_OK?ZUFI_SUCC:ZUFI_FAIL;}time_t zte_getsecond(
-T_zUfiSms_Date date){time_t timet;struct tm tmtime={(0x1b5f+443-0x1d1a)};int
-tmp_i=(0x14e5+2500-0x1ea9);
-#if (0x522+422-0x6c8)
-if(atoi(date.year)>(0x2b5+270-0x360)||atoi(date.year)<(0x238c+400-0x251c)){
-printf("[SMS] getsecond error, year out of range: %d!!!",atoi(date.year));return
-(0x197d+2628-0x23c1);}
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef struct
+{
+ char *buf_addr;
+ int buf_len;
+}T_zUfiSms_BufInfo;
+typedef struct
+{
+ int valid;
+ char *strSQL;
+}T_zUfiSms_SQLMap;
+
+// Êý¾Ý¿âµÄÖ¸Õë
+sqlite3* g_zUfiSms_DbPointer = 0;
+
+extern T_zUfiSms_ParaInfo g_zUfiSms_CurSmsPara;
+extern unsigned long g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_MAX];
+extern T_zUfiSms_DelSms g_zUfiSms_DelMsg;
+
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+static int isSucess(T_zUfiSms_DbResult dbRst)
+{
+ return dbRst == ZTE_WMS_DB_OK ? ZUFI_SUCC : ZUFI_FAIL;
+}
+time_t zte_getsecond(T_zUfiSms_Date date)
+{
+ time_t timet;
+ struct tm tmtime = {0};//cov
+ int tmp_i = 0;
+#if 0
+ if(atoi(date.year) > 99 || atoi(date.year) < 0)
+ {
+ printf("[SMS] getsecond error, year out of range: %d!!!", atoi(date.year));
+ return 0;
+ }
#endif
-tmp_i=atoi(date.year);if(tmp_i<(0x37c+3735-0x1213)||tmp_i>INT_MAX-
-(0x8c4+6103-0x209a)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x79\x65\x61\x72\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x310+8950-0x2606);}tmtime.tm_year=tmp_i+(0x26bb+736-0x21cb)-
-(0xeeb+7383-0x2456);tmp_i=atoi(date.month);if(tmp_i<(0x145+26-0x15f)||tmp_i>
-INT_MAX-(0x1eb1+1873-0x2601)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x6d\x6f\x6e\x74\x68\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x348+1836-0xa74);}tmtime.tm_mon=tmp_i-(0x2260+750-0x254d);tmp_i=
-atoi(date.day);if(tmp_i<(0x17af+2149-0x2014)||tmp_i>INT_MAX-(0x37f+205-0x44b)){
-at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x64\x61\x79\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x2120+680-0x23c8);}tmtime.tm_mday=tmp_i;tmp_i=atoi(date.hour);if
-(tmp_i<(0x265+4153-0x129e)||tmp_i>INT_MAX-(0x2436+704-0x26f5)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x68\x6f\x75\x72\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x1546+4548-0x270a);}tmtime.tm_hour=tmp_i;tmp_i=atoi(date.min);if
-(tmp_i<(0x119c+1018-0x1596)||tmp_i>INT_MAX-(0x69b+7014-0x2200)){at_print(LOG_ERR
-,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x6d\x69\x6e\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x598+846-0x8e6);}tmtime.tm_min=tmp_i;tmp_i=atoi(date.sec);if(
-tmp_i<(0x1af7+827-0x1e32)||tmp_i>INT_MAX-(0xe35+2781-0x1911)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x64\x61\x74\x65\x2e\x73\x65\x63\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return(0x2ba+7020-0x1e26);}tmtime.tm_sec=tmp_i;timet=mktime(&tmtime);
-return timet;}T_zUfiSms_DbResult zUfiSms_OpenDb(void){int retry_times=
-(0x1084+4219-0x20ff);int open_rst=SQLITE_ERROR;if(g_zUfiSms_DbPointer!=NULL){
-sqlite3_close(g_zUfiSms_DbPointer);g_zUfiSms_DbPointer=NULL;}do{open_rst=
-sqlite3_open(ZTE_WMS_DB_PATH,&g_zUfiSms_DbPointer);}while(open_rst==
-SQLITE_CANTOPEN&&retry_times++<(0x966+6994-0x24ae));printf(
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4f\x70\x65\x6e\x44\x62\x3a\x20\x72\x65\x74\x72\x79\x5f\x74\x69\x6d\x65\x73\x20\x3d\x20\x25\x64\x2c\x20\x6f\x70\x65\x6e\x5f\x72\x73\x74\x20\x3d\x20\x25\x64" "\n"
-,retry_times,open_rst);return open_rst==SQLITE_OK?ZTE_WMS_DB_OK:
-ZTE_SMS_DB_ERROR_NOT_OPEN_DB;}T_zUfiSms_DbResult zUfiSms_CloseDb(void){if(
-sqlite3_close(g_zUfiSms_DbPointer)!=SQLITE_OK){return ZTE_SMS_DB_ERROR;}
-g_zUfiSms_DbPointer=NULL;return ZTE_WMS_DB_OK;}T_zUfiSms_DbResult
-zUfiSms_ExecSql(const char*exec_sql,zte_wms_db_callback callback,void*fvarg){int
- try_times=(0x149c+3937-0x23fd);int sqlRst=SQLITE_ERROR;while(try_times++<
-(0x91c+5930-0x203c)){sqlRst=sqlite3_exec(g_zUfiSms_DbPointer,exec_sql,callback,
-fvarg,NULL);if(sqlRst!=SQLITE_BUSY&&sqlRst!=SQLITE_LOCKED&&sqlRst!=SQLITE_IOERR)
-{break;}printf(
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x45\x78\x65\x63\x53\x71\x6c\x3a\x20\x74\x72\x79\x5f\x74\x69\x6d\x65\x73\x3d\x25\x64\x2c\x20\x53\x51\x4c\x3d\x25\x73\x2c\x20\x45\x72\x72\x6d\x73\x67\x3d\x25\x73" "\n"
-,try_times,exec_sql,sqlite3_errmsg(g_zUfiSms_DbPointer));sleep(
-(0x5c2+4116-0x15d5));}if(sqlRst!=SQLITE_OK){printf(
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x45\x78\x65\x63\x53\x71\x6c\x3a\x20\x74\x72\x79\x5f\x74\x69\x6d\x65\x73\x3d\x25\x64\x2c\x20\x53\x51\x4c\x3d\x25\x73\x2c\x20\x45\x72\x72\x6d\x73\x67\x3d\x25\x73" "\n"
-,try_times,exec_sql,sqlite3_errmsg(g_zUfiSms_DbPointer));return ZTE_SMS_DB_ERROR
-;}else{
+ tmp_i = atoi(date.year); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.year err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_year = tmp_i + 2000 - 1900;
+
+ tmp_i = atoi(date.month); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.month err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_mon = tmp_i - 1;
+
+ tmp_i = atoi(date.day); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.day err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_mday = tmp_i;
+
+ tmp_i = atoi(date.hour); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.hour err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_hour = tmp_i;
+
+ tmp_i = atoi(date.min); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.min err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_min = tmp_i;
+
+ tmp_i = atoi(date.sec); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]date.sec err:%d\n", tmp_i);
+ return 0;
+ }
+ tmtime.tm_sec = tmp_i;
+
+ timet = mktime(&tmtime);
+ //printf("--------start: %4d/%02d/%02d %02d:%02d:%02d------",1900 + tmtime.tm_year,1 + tmtime.tm_mon,tmtime.tm_mday,tmtime.tm_hour,tmtime.tm_min,tmtime.tm_sec);
+ //printf("--------second: %u,date: %s,l: %d,ll: %d ---------",(unsigned int)timet,ctime((time_t *)&timet),sizeof(long),sizeof(long long));
+ return timet;
+}
+//´ò¿ªsmsÊý¾Ý¿â£¬´æÈëg_zUfiSms_Db
+T_zUfiSms_DbResult zUfiSms_OpenDb(void)
+{
+ int retry_times = 0;
+ int open_rst = SQLITE_ERROR;
+
+ if(g_zUfiSms_DbPointer != NULL)
+ {
+ sqlite3_close(g_zUfiSms_DbPointer);
+ g_zUfiSms_DbPointer = NULL;
+ }
+
+ do
+ {
+ open_rst = sqlite3_open(ZTE_WMS_DB_PATH, &g_zUfiSms_DbPointer);
+
+ }while(open_rst == SQLITE_CANTOPEN && retry_times++ < 10);
+
+ printf("zUfiSms_OpenDb: retry_times = %d, open_rst = %d\n", retry_times, open_rst);
+
+ return open_rst == SQLITE_OK ? ZTE_WMS_DB_OK : ZTE_SMS_DB_ERROR_NOT_OPEN_DB;
+}
+T_zUfiSms_DbResult zUfiSms_CloseDb(void)
+{
+ if(sqlite3_close(g_zUfiSms_DbPointer) != SQLITE_OK)
+ {
+ return ZTE_SMS_DB_ERROR;
+ }
+ g_zUfiSms_DbPointer = NULL;
+ return ZTE_WMS_DB_OK;
+}
+
+/* Ö´ÐÐÒ»ÌõsqlÓï¾ä **/
+T_zUfiSms_DbResult zUfiSms_ExecSql(const char * exec_sql,zte_wms_db_callback callback,void *fvarg)
+{
+ int try_times = 0;
+ int sqlRst = SQLITE_ERROR;
+
+ while(try_times++ < 10)
+ {
+ sqlRst = sqlite3_exec(g_zUfiSms_DbPointer, exec_sql, callback, fvarg, NULL);
+ if(sqlRst != SQLITE_BUSY && sqlRst != SQLITE_LOCKED && sqlRst != SQLITE_IOERR)
+ {
+ break;
+ }
+ printf("zUfiSms_ExecSql: try_times=%d, SQL=%s, Errmsg=%s\n", try_times, exec_sql, sqlite3_errmsg(g_zUfiSms_DbPointer));
+ sleep(1);
+ }
+ if(sqlRst != SQLITE_OK)
+ {
+ printf("zUfiSms_ExecSql: try_times=%d, SQL=%s, Errmsg=%s\n", try_times, exec_sql, sqlite3_errmsg(g_zUfiSms_DbPointer));
+ return ZTE_SMS_DB_ERROR;
+ }
+ else
+ {
#ifdef WEBS_SECURITY
-if(access(ZTE_WMS_TMP1_PATH,F_OK)==(0x1175+995-0x1558)){slog(PB_PRINT,SLOG_ERR,
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x45\x78\x65\x63\x53\x71\x6c\x20\x64\x62\x20\x73\x74\x61\x79"
-);if(remove(ZTE_WMS_TMP1_PATH)!=(0x3a9+4726-0x161f)){slog(SMS_PRINT,SLOG_ERR,
-"\x72\x65\x6d\x6f\x76\x65\x20\x57\x4d\x53\x5f\x54\x4d\x50\x31\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}}{char rnum_buf[(0xea7+1240-0x1367)]={(0xa41+6939-0x255c)};char cmd[
-(0x1b3c+763-0x1db7)]={(0xe39+4745-0x20c2)};sc_cfg_get(
-"\x72\x6e\x75\x6d\x5f\x61\x74",rnum_buf,sizeof(rnum_buf));snprintf(cmd,sizeof(
-cmd),
-"\x2f\x62\x69\x6e\x2f\x6f\x70\x65\x6e\x73\x73\x6c\x20\x65\x6e\x63\x20\x2d\x65\x20\x2d\x61\x65\x73\x32\x35\x36\x20\x2d\x73\x61\x6c\x74\x20\x2d\x69\x6e\x20\x25\x73\x20\x2d\x6f\x75\x74\x20\x25\x73\x20\x2d\x70\x61\x73\x73\x20\x70\x61\x73\x73\x3a\x25\x73"
-,ZTE_WMS_DB_PATH,ZTE_WMS_TMP1_PATH,rnum_buf);zxic_system(cmd);if(access(
-ZTE_WMS_TMP1_PATH,F_OK)==(0x1b0b+2439-0x2492)){if(remove(ZTE_WMS_SEC_PATH)!=
-(0x77d+897-0xafe)){slog(SMS_PRINT,SLOG_ERR,
-"\x72\x65\x6d\x6f\x76\x65\x20\x57\x4d\x53\x5f\x53\x45\x43\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}if(rename(ZTE_WMS_TMP1_PATH,ZTE_WMS_SEC_PATH)!=(0x47b+7892-0x234f)){slog(
-SMS_PRINT,SLOG_ERR,
-"\x72\x65\x6e\x61\x6d\x65\x20\x57\x4d\x53\x5f\x54\x4d\x50\x31\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
-);}}}
+ if(access(ZTE_WMS_TMP1_PATH, F_OK) == 0)
+ {
+ slog(PB_PRINT,SLOG_ERR,"zUfiSms_ExecSql db stay");
+ if(remove(ZTE_WMS_TMP1_PATH) != 0)
+ {
+ slog(SMS_PRINT,SLOG_ERR,"remove WMS_TMP1_PATH fail");
+ }
+ }
+ {
+ char rnum_buf[24] = {0};
+ char cmd[128] = {0};
+
+ sc_cfg_get("rnum_at", rnum_buf, sizeof(rnum_buf));
+ snprintf(cmd, sizeof(cmd), "/bin/openssl enc -e -aes256 -salt -in %s -out %s -pass pass:%s", ZTE_WMS_DB_PATH, ZTE_WMS_TMP1_PATH, rnum_buf);
+ zxic_system(cmd);
+ if(access(ZTE_WMS_TMP1_PATH, F_OK) == 0)
+ {
+ if(remove(ZTE_WMS_SEC_PATH) != 0)
+ {
+ slog(SMS_PRINT,SLOG_ERR,"remove WMS_SEC_PATH fail");
+ }
+ if(rename(ZTE_WMS_TMP1_PATH, ZTE_WMS_SEC_PATH) != 0)
+ {
+ slog(SMS_PRINT,SLOG_ERR,"rename WMS_TMP1_PATH fail");
+ }
+ }
+ }
#endif
-return ZTE_WMS_DB_OK;}}int zUfiSms_GetFirstColumnInt(void*fvarg,int columns,char
-**zresult,char**lname){if(columns>=(0xddd+464-0xfac)){if(zresult[
-(0x1638+847-0x1987)]==NULL){*(int*)fvarg=(0x1893+688-0x1b43);}else{*(int*)fvarg=
-atoi(zresult[(0x15a6+1215-0x1a65)]);}return SQLITE_OK;}else{return SQLITE_ERROR;
-}}int zUfiSms_SetCmdStatus(T_zUfiSms_StatusInfo*ptSetStatus){T_zUfiSms_DbResult
-result=ZTE_WMS_DB_OK;char*strSQL=NULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x74\x43\x6d\x64\x53\x74\x61\x74\x75\x73\x20\x65\x6e\x74\x65\x72\x2e" "\n"
-);strSQL=sqlite3_mprintf(
-"\x49\x4e\x53\x45\x52\x54\x20\x4f\x52\x20\x52\x45\x50\x4c\x41\x43\x45\x20\x49\x4e\x54\x4f\x20\x25\x73\x28\x43\x6d\x64\x2c\x43\x6d\x64\x5f\x53\x74\x61\x74\x75\x73\x2c\x45\x72\x72\x5f\x43\x6f\x64\x65\x2c\x53\x65\x6e\x64\x5f\x46\x61\x69\x6c\x5f\x43\x6f\x75\x6e\x74\x2c\x44\x65\x6c\x5f\x43\x6f\x75\x6e\x74\x29\x20"
-"\x56\x41\x4c\x55\x45\x53\x28\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x29\x3b"
-,ZTE_WMS_DB_CMD_STATUS_TABLE,ptSetStatus->cmd,ptSetStatus->cmd_status,
-ptSetStatus->err_code,ptSetStatus->send_failed_count,ptSetStatus->
-delete_failed_count);result=zUfiSms_ExecSql(strSQL,NULL,NULL);sqlite3_free(
-strSQL);return isSucess(result);}void zUfiSms_SetParameterNv(T_zUfiSms_ParaInfo*
-para){if((0xfbd+4774-0x2263)==(int)para->status_report_on){sc_cfg_set(
-NV_REPORT_ENABLE,"\x30");}else{sc_cfg_set(NV_REPORT_ENABLE,"\x31");}if(
-(0x9e2+995-0xdc5)==(int)para->sendfail_retry_on){sc_cfg_set(NV_SENDFAIL_RETRY,
-"\x30");}else{sc_cfg_set(NV_SENDFAIL_RETRY,"\x31");}if((0x19c+4627-0x13af)==(int
-)para->outdate_delete_on){sc_cfg_set(NV_OUTDATE_DELETE,"\x30");}else{sc_cfg_set(
-NV_OUTDATE_DELETE,"\x31");}if(*(para->default_store)!='\0'){sc_cfg_set(
-NV_DEFAULT_STORE,(char*)para->default_store);}if((0x6db+1323-0xc06)==(int)para->
-mem_store){sc_cfg_set(NV_PRA_MEMSTORE,"\x30");}else{sc_cfg_set(NV_PRA_MEMSTORE,
-"\x31");}if((0x1738+1044-0x1a4d)==(int)para->tp_validity_period){sc_cfg_set(
-NV_SMS_VP,"\x6c\x6f\x6e\x67\x65\x73\x74");}else if((0x1482+3300-0x20b9)==(int)
-para->tp_validity_period){sc_cfg_set(NV_SMS_VP,"\x6f\x6e\x65\x77\x65\x65\x6b");}
-else if((0x416+785-0x680)==(int)para->tp_validity_period){sc_cfg_set(NV_SMS_VP,
-"\x6f\x6e\x65\x5f\x64\x61\x79");}else if((0x138b+2607-0x1d2b)==(int)para->
-tp_validity_period){sc_cfg_set(NV_SMS_VP,"\x74\x77\x65\x6c\x76\x65\x68");}printf
-(
-"\x77\x6d\x73\x5f\x64\x62\x5f\x73\x65\x74\x5f\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73\x20\x3a\x3a\x20\x73\x65\x74\x20\x74\x70\x5f\x76\x61\x6c\x69\x64\x69\x74\x79\x5f\x70\x65\x72\x69\x6f\x64\x20\x25\x64" "\n"
-,(int)para->tp_validity_period);}int zUfiSms_SetDbParameters(T_zUfiSms_ParaInfo*
-para){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;char*strSQL=NULL;int count=
-(0x15b+4865-0x145c);if(NULL==para){return-(0x1aa+2177-0xa2a);}zUfiSms_ExecSql(
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20"
- ZTE_WMS_DB_PARAMETER_TABLE"\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x31\x3b",
-zUfiSms_GetFirstColumnInt,&count);if(count>(0x140c+3365-0x2131)){strSQL=
-sqlite3_mprintf(
-"\x55\x50\x44\x41\x54\x45\x20\x25\x73\x20\x53\x45\x54\x20\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x3d\x27\x25\x64\x27\x2c\x53\x6d\x73\x5f\x53\x63\x61\x3d\x27\x25\x71\x27\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x64\x27\x2c\x54\x70\x5f\x56\x61\x6c\x69\x64\x69\x74\x79\x3d\x27\x25\x64\x27\x2c\x53\x65\x6e\x64\x5f\x52\x65\x74\x72\x79\x3d\x27\x25\x64\x27\x2c\x4f\x75\x74\x64\x61\x74\x65\x5f\x44\x65\x6c\x65\x74\x65\x3d\x27\x25\x64\x27\x2c\x44\x65\x66\x61\x75\x6c\x74\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x71\x27\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x31\x3b"
-,ZTE_WMS_DB_PARAMETER_TABLE,(int)para->status_report_on,para->sca,(int)para->
-mem_store,(int)para->tp_validity_period,(int)para->sendfail_retry_on,(int)para->
-outdate_delete_on,para->default_store,ZTE_WMS_DB_PARAMETER_TABLE);}else{strSQL=
-sqlite3_mprintf(
-"\x49\x4e\x53\x45\x52\x54\x20\x49\x4e\x54\x4f\x20\x25\x73\x28\x69\x64\x2c\x20\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x2c\x53\x6d\x73\x5f\x53\x63\x61\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x2c\x54\x70\x5f\x56\x61\x6c\x69\x64\x69\x74\x79\x2c\x53\x65\x6e\x64\x5f\x52\x65\x74\x72\x79\x2c\x4f\x75\x74\x64\x61\x74\x65\x5f\x44\x65\x6c\x65\x74\x65\x2c\x44\x65\x66\x61\x75\x6c\x74\x5f\x53\x74\x6f\x72\x65\x2c\x4d\x61\x78\x5f\x43\x63\x5f\x52\x65\x66\x2c\x4d\x61\x78\x5f\x53\x6d\x73\x5f\x52\x65\x66\x29\x20"
-"\x56\x41\x4c\x55\x45\x53\x28\x27\x31\x27\x2c\x20\x27\x25\x64\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x71\x27\x2c\x27\x30\x27\x2c\x27\x30\x27\x29\x3b"
-,ZTE_WMS_DB_PARAMETER_TABLE,(int)para->status_report_on,para->sca,(int)para->
-mem_store,(int)para->tp_validity_period,(int)para->sendfail_retry_on,(int)para->
-outdate_delete_on,para->default_store);}result=zUfiSms_ExecSql(strSQL,NULL,NULL)
-;sqlite3_free(strSQL);if(result==ZTE_WMS_DB_OK){zUfiSms_SetParameterNv(para);
-return(0xfd8+198-0x109e);}return-(0x17d+6657-0x1b7d);}int zUfiSms_GetTotalCount(
-const char*pDbTable,int*pTotalCount){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;
-char*strSQL=NULL;strSQL=sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x71\x27\x3b"
-,pDbTable);result=zUfiSms_ExecSql(strSQL,zUfiSms_GetFirstColumnInt,pTotalCount);
-sqlite3_free(strSQL);return isSucess(result);}int zUfiSms_GetSmsMaxReferInDb(
-void){int max_sms_ref=-(0x139a+4947-0x26ec);zUfiSms_ExecSql(
-"\x53\x45\x4c\x45\x43\x54\x20\x4d\x61\x78\x5f\x53\x6d\x73\x5f\x52\x65\x66\x20\x46\x52\x4f\x4d\x20"
- ZTE_WMS_DB_PARAMETER_TABLE
-"\x20\x57\x48\x45\x52\x45\x20\x69\x64\x20\x3d\x20\x31\x3b",
-zUfiSms_GetFirstColumnInt,&max_sms_ref);return max_sms_ref;}int
-zUfiSms_GetConcatInfo(char*mem_store,long id,T_zUfiSms_DbStoreStr*pac,char*
-content,int len){sqlite3_stmt*stmt=NULL;char*strSQL=sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x69\x6e\x64\x2c\x43\x63\x5f\x53\x65\x71\x2c\x43\x63\x5f\x43\x6f\x6e\x74\x65\x6e\x74\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x71\x27\x3b"
-,id,mem_store);(void)sqlite3_prepare(g_zUfiSms_DbPointer,strSQL,-
-(0x102+2933-0xc76),&stmt,(0xaf7+5571-0x20ba));while(SQLITE_ROW==sqlite3_step(
-stmt)){char*column_text=NULL;memset(pac->IndStr,(0x4ba+6692-0x1ede),sizeof(pac->
-IndStr));memset(pac->Seg_Seq,(0x13a7+4589-0x2594),sizeof(pac->Seg_Seq));if((
-column_text=sqlite3_column_text(stmt,(0x699+8114-0x264b)))!=NULL)strncpy(pac->
-IndStr,column_text,sizeof(pac->FormatInd)-(0x537+3345-0x1247));if((column_text=
-sqlite3_column_text(stmt,(0x8b7+6627-0x2299)))!=NULL)strncpy(pac->Seg_Seq,
-column_text,sizeof(pac->FormatSeq)-(0x6f3+2189-0xf7f));if((column_text=
-sqlite3_column_text(stmt,(0x184c+239-0x1939)))!=NULL)strncpy(content,column_text
-,len-(0x6b4+7554-0x2435));printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x43\x6f\x6e\x63\x61\x74\x49\x6e\x66\x6f\x3a\x25\x73\x2c\x25\x73" "\n"
-,pac->IndStr,pac->Seg_Seq);}(void)sqlite3_finalize(stmt);sqlite3_free(strSQL);
-return(0xcd0+1398-0x1246);}int zUfiSms_UpdateConcatSmsToDb(T_zUfiSms_DbStoreData
-*db_data,const char*mem_store,char*format_concat,char*content,
-T_zUfiSms_DbStoreStr*pac,int concat_num,long id){char*sql=NULL;
-T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;sql=sqlite3_mprintf(
-"\x55\x50\x44\x41\x54\x45\x20\x73\x6d\x73\x20\x53\x45\x54\x20\x69\x6e\x64\x3d\x27\x25\x73\x27\x2c\x54\x61\x67\x3d\x27\x25\x64\x27\x2c\x43\x63\x5f\x53\x65\x71\x3d\x27\x25\x73\x27\x2c\x43\x63\x5f\x4e\x75\x6d\x3d\x27\x25\x64\x27\x2c\x20"
-"\x43\x63\x5f\x43\x6f\x6e\x74\x65\x6e\x74\x3d\x27\x25\x71\x27\x2c\x43\x6f\x6e\x74\x65\x6e\x74\x3d\x27\x25\x71\x27\x2c\x59\x65\x61\x72\x3d\x27\x25\x71\x27\x2c\x4d\x6f\x6e\x74\x68\x3d\x27\x25\x71\x27\x2c\x20"
-"\x44\x61\x79\x3d\x27\x25\x71\x27\x2c\x48\x6f\x75\x72\x3d\x27\x25\x71\x27\x2c\x4d\x69\x6e\x75\x74\x65\x3d\x27\x25\x71\x27\x2c\x53\x65\x63\x6f\x6e\x64\x3d\x27\x25\x71\x27\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x3d\x27\x25\x71\x27\x20"
-"\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x71\x27\x3b"
-,pac->FormatInd,db_data->tag,pac->FormatSeq,concat_num,format_concat,content,
-db_data->julian_date.year,db_data->julian_date.month,db_data->julian_date.day,
-db_data->julian_date.hour,db_data->julian_date.min,db_data->julian_date.sec,
-db_data->julian_date.timezone,id,mem_store);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x55\x70\x64\x61\x74\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x3a\x25\x73\x2d\x2d\x25\x73" "\n"
-,sql,pac->FormatSeq);result=zUfiSms_ExecSql(sql,NULL,NULL);sqlite3_free(sql);
-return isSucess(result);}int zUfiSms_InsertConcatSmsToDb(T_zUfiSms_DbStoreData*
-db_data,const char*mem_store,char*format_concat,char*content,
-T_zUfiSms_DbStoreStr*pac,int concat_num){char*sql=NULL;T_zUfiSms_DbResult result
-=ZTE_WMS_DB_OK;sql=sqlite3_mprintf(
-"\x49\x4e\x53\x45\x52\x54\x20\x49\x4e\x54\x4f\x20\x73\x6d\x73\x28\x69\x6e\x64\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x2c\x54\x61\x67\x2c\x4e\x75\x6d\x62\x65\x72\x2c\x43\x63\x5f\x53\x6d\x73\x2c\x43\x63\x5f\x52\x65\x66\x2c\x43\x63\x5f\x54\x6f\x74\x61\x6c\x2c\x43\x63\x5f\x53\x65\x71\x2c\x43\x63\x5f\x4e\x75\x6d\x2c\x43\x63\x5f\x43\x6f\x6e\x74\x65\x6e\x74\x2c\x54\x70\x5f\x44\x63\x73\x2c\x20\x4d\x73\x67\x5f\x52\x65\x66\x2c"
-"\x43\x6f\x6e\x74\x65\x6e\x74\x2c\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x5f\x52\x65\x63\x69\x76\x65\x64\x2c\x44\x72\x61\x66\x74\x5f\x47\x72\x6f\x75\x70\x5f\x49\x64\x2c\x59\x65\x61\x72\x2c\x4d\x6f\x6e\x74\x68\x2c\x44\x61\x79\x2c\x48\x6f\x75\x72\x2c\x4d\x69\x6e\x75\x74\x65\x2c\x53\x65\x63\x6f\x6e\x64\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x2c\x4d\x6b\x74\x69\x6d\x65\x2c\x44\x69\x73\x70\x6c\x61\x79\x4d\x6f\x64\x65\x29\x20"
-"\x56\x41\x4c\x55\x45\x53\x28" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c\x20\x27\x25\x64\x27\x2c" "\'" "\x25\x71" "\'" "\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c" "\'" "\x25\x71" "\'" "\x2c\x27\x25\x64\x27\x2c" "\'" "\x25\x71" "\'" "\x2c\x27\x25\x64\x27\x2c\x20\x27\x25\x64\x27\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c\x20" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c" "\'" "\x25\x71" "\'" "\x2c\x27\x25\x64\x27\x2c\x20\x27\x25\x64\x27\x29\x3b"
-,pac->FormatInd,mem_store,db_data->tag,db_data->number,db_data->concat_sms,
-db_data->concat_info[(0x185+8310-0x21fb)],db_data->concat_info[
-(0x1184+2574-0x1b91)],pac->FormatSeq,concat_num,format_concat,db_data->tp_dcs,
-db_data->msg_ref,content,"\x30",db_data->draft_group_id,db_data->julian_date.
-year,db_data->julian_date.month,db_data->julian_date.day,db_data->julian_date.
-hour,db_data->julian_date.min,db_data->julian_date.sec,db_data->julian_date.
-timezone,(unsigned int)zte_getsecond(db_data->julian_date),db_data->
-msg_displaymode);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x49\x6e\x73\x65\x72\x74\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x20\x73\x71\x6c\x3d\x25\x73\x2e" "\n"
-,sql);result=zUfiSms_ExecSql(sql,NULL,NULL);sqlite3_free(sql);return isSucess(
-result);}int zUfiSms_GetConcatMaxReferInDb(void){int ConcatMaxRefer=
-(0x32d+745-0x616);int result=(0x171d+2111-0x1f5c);result=zUfiSms_ExecSql(
-"\x53\x45\x4c\x45\x43\x54\x20\x4d\x61\x78\x5f\x43\x63\x5f\x52\x65\x66\x20\x46\x52\x4f\x4d\x20"
- ZTE_WMS_DB_PARAMETER_TABLE
-"\x20\x57\x48\x45\x52\x45\x20\x69\x64\x20\x3d\x20\x31\x3b",
-zUfiSms_GetFirstColumnInt,&ConcatMaxRefer);if(ZTE_WMS_DB_OK!=result){return-
-(0x1754+3707-0x25ce);}return ConcatMaxRefer;}int zUfiSms_CreateTables(){int iMap
-=(0xfb8+839-0x12ff);const T_zUfiSms_SQLMap SQL_MAP[]={{(0xf2f+2256-0x17fe),
-ZTE_WMS_CREATE_TABLE_SMS_SQL},{(0xf0b+114-0xf7c),ZTE_WMS_DEL_SIM_SQL},{
-(0x160+721-0x430),ZTE_WMS_CREATE_CMD_STATUS_SQL},{(0xd7c+6088-0x2543),
-ZTE_WMS_CREATE_SMS_REP_SQL},{(0xe8+7962-0x2001),ZTE_WMS_CREATE_PAR_SQL},{
-(0x19+1232-0x4e8),ZTE_WMS_CREATE_INFO_SQL},{(0x10ba+4254-0x2157),
-ZTE_WMS_CREATE_CELL_BRO_SQL},{(0x57f+5789-0x1c1b),
-ZTE_WMS_CREATE_SEND_CONTENT_SQL},};for(iMap=(0x222+2184-0xaaa);iMap<sizeof(
-SQL_MAP)/sizeof(T_zUfiSms_SQLMap);iMap++){if(SQL_MAP[iMap].valid==
-(0x1dec+1626-0x2445)){if(zUfiSms_ExecSql(SQL_MAP[iMap].strSQL,NULL,NULL)!=
-ZTE_WMS_DB_OK){return ZUFI_FAIL;}}}return ZUFI_SUCC;}int zUfiSms_CreateAllTable(
-void){if(ZTE_WMS_DB_OK!=zUfiSms_OpenDb()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x61\x6e\x20\x6e\x6f\x74\x20\x6f\x70\x65\x6e\x20\x64\x61\x74\x61\x62\x61\x73\x65\x2e\x72\x65\x74\x75\x72\x6e\x2e" "\n"
-);return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;}return zUfiSms_CreateTables();}int
-zUfiSms_DropAllTable(void){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;if(
-ZTE_WMS_DB_OK!=zUfiSms_OpenDb()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x61\x6e\x20\x6e\x6f\x74\x20\x6f\x70\x65\x6e\x20\x64\x61\x74\x61\x62\x61\x73\x65\x2e\x72\x65\x74\x75\x72\x6e\x2e" "\n"
-);return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;}result=zUfiSms_ExecSql(
-ZTE_WMS_DROP_ALL_TABLE_SQL,NULL,NULL);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x72\x6f\x70\x41\x6c\x6c\x54\x61\x62\x6c\x65\x3a\x20\x73\x71\x6c\x20\x3d\x20\x25\x73\x2c\x20\x72\x65\x73\x75\x6c\x74\x20\x3d\x20\x25\x64\x21\x20" "\n"
-,ZTE_WMS_DROP_ALL_TABLE_SQL,result);return ZUFI_SUCC;}int
-zUfiSms_DropAllTableExceptSms(void){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;if(
-ZTE_WMS_DB_OK!=zUfiSms_OpenDb()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x61\x6e\x20\x6e\x6f\x74\x20\x6f\x70\x65\x6e\x20\x64\x61\x74\x61\x62\x61\x73\x65\x2e\x72\x65\x74\x75\x72\x6e\x2e" "\n"
-);return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;}result=zUfiSms_ExecSql(
-ZTE_WMS_DROP_TABLE_EXCEPTSMS_SQL,NULL,NULL);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x72\x6f\x70\x41\x6c\x6c\x54\x61\x62\x6c\x65\x3a\x20\x73\x71\x6c\x20\x3d\x20\x25\x73\x2c\x20\x72\x65\x73\x75\x6c\x74\x20\x3d\x20\x25\x64\x21\x20" "\n"
-,ZTE_WMS_DROP_ALL_TABLE_SQL,result);return ZUFI_SUCC;}int zUfiSms_IsDbEmpty(
-const char*tab,int*pCount){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;char*strSQL=
-sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20\x25\x73\x3b"
-,tab);result=zUfiSms_ExecSql(strSQL,zUfiSms_GetFirstColumnInt,pCount);
-sqlite3_free(strSQL);return isSucess(result);}int zUfiSms_InsertNormalSmsToDb(
-T_zUfiSms_DbStoreData*ptDbSaveData,const char*pStorePos,char*pContent){char*
-strSQL=NULL;T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;strSQL=sqlite3_mprintf(
-"\x49\x4e\x53\x45\x52\x54\x20\x49\x4e\x54\x4f\x20\x73\x6d\x73\x28\x69\x6e\x64\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x2c\x54\x61\x67\x2c\x4e\x75\x6d\x62\x65\x72\x2c\x43\x63\x5f\x53\x6d\x73\x2c\x43\x63\x5f\x52\x65\x66\x2c\x43\x63\x5f\x54\x6f\x74\x61\x6c\x2c\x43\x63\x5f\x53\x65\x71\x2c\x54\x70\x5f\x44\x63\x73\x2c\x20"
-"\x4d\x73\x67\x5f\x52\x65\x66\x2c\x43\x6f\x6e\x74\x65\x6e\x74\x2c\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x5f\x52\x65\x63\x69\x76\x65\x64\x2c\x44\x72\x61\x66\x74\x5f\x47\x72\x6f\x75\x70\x5f\x49\x64\x2c\x59\x65\x61\x72\x2c\x4d\x6f\x6e\x74\x68\x2c\x44\x61\x79\x2c\x48\x6f\x75\x72\x2c\x4d\x69\x6e\x75\x74\x65\x2c\x53\x65\x63\x6f\x6e\x64\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x2c\x4d\x6b\x74\x69\x6d\x65\x2c\x44\x69\x73\x70\x6c\x61\x79\x4d\x6f\x64\x65\x29\x20\x56\x41\x4c\x55\x45\x53\x28\x27\x25\x64\x27\x2c\x27\x25\x71\x27\x2c\x20"
-"\x27\x25\x64\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x20"
-"\x27\x25\x71\x27\x2c\x27\x25\x71\x27\x2c\x27\x25\x75\x27\x2c\x20\x27\x25\x64\x27\x29\x3b"
-,ptDbSaveData->index,pStorePos,ptDbSaveData->tag,ptDbSaveData->number,
-ptDbSaveData->concat_sms,ptDbSaveData->concat_info[(0x14e1+42-0x150b)],
-ptDbSaveData->concat_info[(0x1ab+2232-0xa62)],ptDbSaveData->concat_info[
-(0xcf8+3907-0x1c39)],ptDbSaveData->tp_dcs,ptDbSaveData->msg_ref,pContent,"\x30",
-ptDbSaveData->draft_group_id,ptDbSaveData->julian_date.year,ptDbSaveData->
-julian_date.month,ptDbSaveData->julian_date.day,ptDbSaveData->julian_date.hour,
-ptDbSaveData->julian_date.min,ptDbSaveData->julian_date.sec,ptDbSaveData->
-julian_date.timezone,(unsigned int)zte_getsecond(ptDbSaveData->julian_date),
-ptDbSaveData->msg_displaymode);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x49\x6e\x73\x65\x72\x74\x4e\x6f\x72\x6d\x61\x6c\x53\x6d\x73\x54\x6f\x44\x62\x20\x73\x71\x6c\x3d\x25\x73" "\n"
-,strSQL);result=zUfiSms_ExecSql(strSQL,NULL,NULL);sqlite3_free(strSQL);return
-isSucess(result);}int zUfiSms_UpdateNormalSmsToDb(T_zUfiSms_DbStoreData*
-ptDbSaveData,const char*pStorePos,char*pContent,long iSmsId){char*strSQL=NULL;
-T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;strSQL=sqlite3_mprintf(
-"\x55\x50\x44\x41\x54\x45\x20\x73\x6d\x73\x20\x53\x45\x54\x20\x4e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x2c\x43\x6f\x6e\x74\x65\x6e\x74\x3d\x27\x25\x71\x27\x2c\x59\x65\x61\x72\x3d\x27\x25\x71\x27\x2c\x4d\x6f\x6e\x74\x68\x3d\x27\x25\x71\x27\x2c\x20"
-"\x44\x61\x79\x3d\x27\x25\x71\x27\x2c\x48\x6f\x75\x72\x3d\x27\x25\x71\x27\x2c\x4d\x69\x6e\x75\x74\x65\x3d\x27\x25\x71\x27\x2c\x53\x65\x63\x6f\x6e\x64\x3d\x27\x25\x71\x27\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x3d\x27\x25\x71\x27\x20"
-"\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x20\x61\x6e\x64\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x71\x27\x3b"
-,ptDbSaveData->number,pContent,ptDbSaveData->julian_date.year,ptDbSaveData->
-julian_date.month,ptDbSaveData->julian_date.day,ptDbSaveData->julian_date.hour,
-ptDbSaveData->julian_date.min,ptDbSaveData->julian_date.sec,ptDbSaveData->
-julian_date.timezone,iSmsId,pStorePos);if(NULL==strSQL){return ZUFI_FAIL;}printf
-(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x55\x70\x64\x61\x74\x65\x4e\x6f\x72\x6d\x61\x6c\x53\x6d\x73\x54\x6f\x44\x62\x20\x73\x71\x6c\x3d\x25\x73" "\n"
-,strSQL);result=zUfiSms_ExecSql(strSQL,NULL,NULL);sqlite3_free(strSQL);return
-isSucess(result);}int zUfiSms_GetFirstColumnStr(void*fvarg,int columns,char**
-zresult,char**lname){if(columns>=(0x33d+8227-0x235f)&&fvarg!=NULL){if(zresult[
-(0x1d12+2318-0x2620)]!=NULL){T_zUfiSms_BufInfo*para=(T_zUfiSms_BufInfo*)fvarg;
-strncpy(para->buf_addr,zresult[(0xcaf+5297-0x2160)],para->buf_len-
-(0x77f+4026-0x1738));return SQLITE_OK;}}return SQLITE_ERROR;}int
-zUfiSms_GetStorePosById(char*item,char*item_data,int item_len,int id){
-T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;T_zUfiSms_BufInfo buf_info={
-(0x1d4a+769-0x204b)};char*strSQL=NULL;if(NULL==item||NULL==item_data){return
-ZUFI_FAIL;}buf_info.buf_addr=item_data;buf_info.buf_len=item_len;strSQL=
-sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x25\x71\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,item,id);result=zUfiSms_ExecSql(strSQL,zUfiSms_GetFirstColumnStr,&buf_info);
-sqlite3_free(strSQL);if((ZTE_WMS_DB_OK!=result)||((0x1d7a+1557-0x238f)==strcmp(
-item_data,""))){at_print(LOG_ERR,
-"\x67\x65\x74\x20\x74\x61\x62\x6c\x65\x5f\x6d\x65\x6d\x62\x65\x72\x20\x62\x79\x20\x69\x64\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);return ZUFI_FAIL;}return ZUFI_SUCC;}int zUfiSms_DeleteSmsInDb(void){char sql[
-(0x992+5310-0x1dd0)]={(0xe29+3733-0x1cbe)};snprintf(sql,sizeof(sql),
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x61\x6e\x64\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SIM_TABLE,g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_index-
-(0xdfc+5286-0x22a1)]);return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));}int
-zUfiSms_DeleteAllSimSmsInDb(void){return isSucess(zUfiSms_ExecSql(
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27"
- ZTE_WMS_DB_SIM_TABLE"\x27\x3b",NULL,NULL));}int zUfiSms_DeleteNvSms(void){if(
-g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_NV]==g_zUfiSms_DelMsg.nv_count){if(
-ZTE_WMS_DB_OK!=zUfiSms_ExecSql(
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27"
- ZTE_WMS_DB_NV_TABLE"\x27\x3b",NULL,NULL)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x4e\x76\x53\x6d\x73\x3a\x64\x65\x6c\x65\x74\x65\x20\x66\x61\x69\x6c" "\n"
-);return WMS_CMD_FAILED;}}else{int i=(0x10d4+557-0x1301);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x4e\x76\x53\x6d\x73\x3a\x64\x65\x6c\x65\x74\x65\x20\x6e\x76\x5f\x63\x6f\x75\x6e\x74\x3d\x25\x64" "\n"
-,g_zUfiSms_DelMsg.nv_count);for(i=(0x1141+3886-0x206f);i<g_zUfiSms_DelMsg.
-nv_count;i++){char sql[(0x136+5889-0x17b7)]={(0xbda+447-0xd99)};snprintf(sql,
-sizeof(sql),
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x61\x6e\x64\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_NV_TABLE,g_zUfiSms_DelMsg.nv_id[i]);if(ZTE_WMS_DB_OK!=
-zUfiSms_ExecSql(sql,NULL,NULL)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x65\x78\x65\x63\x20\x73\x71\x6c\x20\x66\x61\x69\x6c\x65\x64\x2c\x69\x3d\x25\x64" "\n"
-,i);return WMS_CMD_FAILED;}}}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x4e\x76\x53\x6d\x73\x3a\x64\x65\x6c\x65\x74\x65\x20\x73\x75\x63\x63\x65\x73\x73" "\n"
-);return WMS_CMD_SUCCESS;}int zUfiSms_GetSmsIndex(int id,T_zUfiSms_ModifyTag*
-ptModifyTag,int is_cc){char sql[(0x6e5+168-0x70d)]={(0x12b9+4884-0x25cd)};
-T_zUfiSms_BufInfo buf_info={(0x6fc+791-0xa13)};char str_index[(0x9d3+1512-0xfb9)
-*WMS_MESSAGE_LIST_MAX]={(0x5a1+7115-0x216c)};buf_info.buf_addr=str_index;
-buf_info.buf_len=sizeof(str_index);snprintf(sql,sizeof(sql),
-"\x53\x45\x4c\x45\x43\x54\x20\x69\x6e\x64\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,id);if(zUfiSms_ExecSql(sql,zUfiSms_GetFirstColumnStr,&buf_info)!=ZTE_WMS_DB_OK)
-{at_print(LOG_ERR,
-"\x6f\x70\x65\x6e\x20\x74\x61\x62\x6c\x65\x20\x73\x6d\x73\x20\x66\x61\x69\x6c\x65\x64"
-);return ZUFI_FAIL;}if((0x5e9+5112-0x19e0)==is_cc){int i=(0x466+7097-0x201f);int
- j=(0x10bc+3567-0x1eab);int count=(0x107+7533-0x1e74);char**out_result=NULL;
-count=zUfiSms_SplitString(str_index,&out_result,((char)(0x147d+2216-0x1cea)));
-for(i=(0x883+7539-0x25f6);i<count;i++){if((0x190b+2427-0x2286)!=strcmp(
-out_result[i],"")){ptModifyTag->indices[j++]=atoi(out_result[i]);}}ptModifyTag->
-num_of_indices=j;free(out_result);}else{ptModifyTag->indices[(0x21ba+330-0x2304)
-]=atoi(str_index);ptModifyTag->num_of_indices=(0x199+7151-0x1d87);}ptModifyTag->
-total_indices=ptModifyTag->num_of_indices;printf(
-"\x6d\x6f\x64\x69\x66\x79\x5f\x74\x61\x67\x5f\x70\x74\x72\x2d\x3e\x74\x6f\x74\x61\x6c\x5f\x69\x6e\x64\x69\x63\x65\x73\x3d\x25\x64" "\n"
-,ptModifyTag->total_indices);return ZUFI_SUCC;}int zUfiSms_IsConcatSms(int id){
-char sql[(0x268+4914-0x151a)]={(0x445+4138-0x146f)};int is_cc=
-(0x293+7365-0x1f58);T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;snprintf(sql,sizeof(
-sql),
-"\x53\x45\x4c\x45\x43\x54\x20\x43\x63\x5f\x53\x6d\x73\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,id);result=zUfiSms_ExecSql(sql,zUfiSms_GetFirstColumnInt,&
-is_cc);if(ZTE_WMS_DB_OK!=result){at_print(LOG_ERR,
-"\x6f\x70\x65\x6e\x20\x74\x61\x62\x6c\x65\x20\x25\x73\x20\x66\x61\x69\x6c\x65\x64"
-,ZTE_WMS_DB_SMS_TABLE);return-(0xcd0+3418-0x1a29);}return is_cc;}int
-zUfiSms_UpdateSmsTagInDb(unsigned long id,unsigned int tags){char sql[
-(0x2249+384-0x2349)]={(0xcea+3599-0x1af9)};snprintf(sql,sizeof(sql),
-"\x55\x50\x44\x41\x54\x45\x20\x25\x73\x20\x53\x45\x54\x20\x54\x61\x67\x3d\x27\x25\x64\x27\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,tags,id);return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));}
-int zUfiSms_GetTagCountInDb(T_zUfiSms_MemoryType mem_store,unsigned int tags,int
-*pTotalCount){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;char sql[
-(0xe89+2312-0x1711)]={(0x65f+1470-0xc1d)};if(pTotalCount==NULL){return ZUFI_FAIL
-;}if(mem_store==ZTE_WMS_MEMORY_MAX){snprintf(sql,sizeof(sql),
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x54\x61\x67\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,tags);}else if(mem_store==ZTE_WMS_MEMORY_NV){snprintf(sql,
-sizeof(sql),
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x41\x4e\x44\x20\x54\x61\x67\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,ZTE_WMS_DB_NV_TABLE,tags);}else{snprintf(sql,sizeof(sql),
-"\x53\x45\x4c\x45\x43\x54\x20\x63\x6f\x75\x6e\x74\x28\x2a\x29\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x41\x4e\x44\x20\x54\x61\x67\x3d\x27\x25\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,ZTE_WMS_DB_SIM_TABLE,tags);}result=zUfiSms_ExecSql(sql,(
-zte_wms_db_callback)zUfiSms_GetFirstColumnInt,pTotalCount);return isSucess(
-result);}int zUfiSms_DeleteDraftSms(long iSmsId){char sql[(0xcd4+6820-0x26f8)]={
-(0x8a+340-0x1de)};snprintf(sql,sizeof(sql),
-"\x44\x45\x4c\x45\x54\x45\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x27\x25\x6c\x64\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,iSmsId);return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));}
-int zUfiSms_SetConcatMaxRefer(int ref){char sql[(0x420+6292-0x1c34)]={
-(0x62f+6419-0x1f42)};if(ZTE_WMS_MAX_CONCAT_REF<ref){ref=(0xd61+841-0x10aa);}
-snprintf(sql,sizeof(sql),
-"\x55\x50\x44\x41\x54\x45\x20\x25\x73\x20\x53\x45\x54\x20\x4d\x61\x78\x5f\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x31\x3b"
-,ZTE_WMS_DB_PARAMETER_TABLE,ref);return isSucess(zUfiSms_ExecSql(sql,NULL,NULL))
-;}int zUfiSms_SetMaxReference(int ref){char sql[(0xd54+1123-0x1137)]={
-(0x2300+163-0x23a3)};if(ZTE_WMS_MAX_SMS_REF<ref){ref=(0x87b+4801-0x1b3c);}
-snprintf(sql,sizeof(sql),
-"\x55\x50\x44\x41\x54\x45\x20\x25\x73\x20\x53\x45\x54\x20\x4d\x61\x78\x5f\x53\x6d\x73\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x57\x48\x45\x52\x45\x20\x69\x64\x3d\x31\x3b"
-,ZTE_WMS_DB_PARAMETER_TABLE,ref);return isSucess(zUfiSms_ExecSql(sql,NULL,NULL))
-;}int zUfiSms_InsertReportStatusToDb(unsigned char*pNumber,T_zUfiSms_Date*
-ptSmsDate,int iReportStatus){char*strSQL=NULL;T_zUfiSms_DbResult result=
-ZTE_WMS_DB_OK;strSQL=sqlite3_mprintf(
-"\x49\x4e\x53\x45\x52\x54\x20\x49\x4e\x54\x4f\x20\x73\x6d\x73\x5f\x72\x65\x70\x6f\x72\x74\x28\x61\x64\x64\x72\x65\x73\x73\x2c\x63\x6f\x6e\x74\x65\x6e\x74\x2c\x59\x65\x61\x72\x2c\x4d\x6f\x6e\x74\x68\x2c\x44\x61\x79\x2c\x48\x6f\x75\x72\x2c\x4d\x69\x6e\x75\x74\x65\x2c\x53\x65\x63\x6f\x6e\x64\x2c\x54\x69\x6d\x65\x5a\x6f\x6e\x65\x29\x20"
-"\x56\x41\x4c\x55\x45\x53\x28\x27\x25\x73\x27\x2c\x27\x25\x64\x27\x2c\x27\x25\x73\x27\x2c\x27\x25\x73\x27\x2c\x27\x25\x73\x27\x2c\x27\x25\x73\x27\x2c\x20\x27\x25\x73\x27\x2c\x27\x25\x73\x27\x2c\x27\x25\x73\x27\x29\x3b"
-,pNumber,iReportStatus,ptSmsDate->year,ptSmsDate->month,ptSmsDate->day,ptSmsDate
-->hour,ptSmsDate->min,ptSmsDate->sec,ptSmsDate->timezone);result=zUfiSms_ExecSql
-(strSQL,NULL,NULL);sqlite3_free(strSQL);return isSucess(result);}int
-zUfiSms_GetFirstColumnParaInfo(void*fvarg,int columns,char**zresult,char**lname)
-{if(columns>=(0xaf6+5536-0x2095)&&fvarg!=NULL){if(zresult[(0x8b9+5235-0x1d2c)]!=
-NULL){T_zUfiSms_ParaInfo*para=(T_zUfiSms_ParaInfo*)fvarg;strncpy(para->sca,
-zresult[(0x1a9a+80-0x1aea)],sizeof(para->sca)-(0x863+1275-0xd5d));para->
-mem_store=atoi(zresult[(0xa8a+5390-0x1f97)]);para->tp_validity_period=atoi(
-zresult[(0x873+96-0x8d1)]);para->status_report_on=atoi(zresult[
-(0xa4f+4707-0x1caf)]);para->sendfail_retry_on=atoi(zresult[(0x5c6+4934-0x1908)])
-;para->outdate_delete_on=atoi(zresult[(0x1a73+1569-0x208f)]);(void)strncpy(para
-->default_store,zresult[(0xa1c+5676-0x2042)],sizeof(para->default_store)-
-(0x64f+7128-0x2226));return SQLITE_OK;}}return SQLITE_ERROR;}int
-zUfiSms_GetDbParameters(void){char*strSQL=
-"\x53\x45\x4c\x45\x43\x54\x20\x53\x6d\x73\x5f\x53\x63\x61\x2c\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x2c\x54\x70\x5f\x56\x61\x6c\x69\x64\x69\x74\x79\x2c\x53\x6d\x73\x5f\x52\x65\x70\x6f\x72\x74\x2c\x53\x65\x6e\x64\x5f\x52\x65\x74\x72\x79\x2c\x4f\x75\x74\x64\x61\x74\x65\x5f\x44\x65\x6c\x65\x74\x65\x2c\x44\x65\x66\x61\x75\x6c\x74\x5f\x53\x74\x6f\x72\x65\x20\x46\x52\x4f\x4d\x20"
- ZTE_WMS_DB_PARAMETER_TABLE"\x3b";memset(&g_zUfiSms_CurSmsPara,
-(0x12f9+4445-0x2456),sizeof(T_zUfiSms_ParaInfo));return isSucess(zUfiSms_ExecSql
-(strSQL,zUfiSms_GetFirstColumnParaInfo,&g_zUfiSms_CurSmsPara));}int
-zUfiSms_GetSendContent(void*fvarg,int column,char**zresult,char**lname){
-T_zUfiSms_BufInfo*para=(T_zUfiSms_BufInfo*)fvarg;if(column>=(0x219+7385-0x1ef1)
-&¶!=NULL)(void)strncpy(para->buf_addr,zresult[(0x2cf+313-0x408)],para->
-buf_len-(0x1b4d+2377-0x2495));return(0xbba+4265-0x1c63);}int
-zUfiSms_GetSmsContent(char*pSmsBuf,int len){T_zUfiSms_BufInfo buf_info={
-(0x1d01+1416-0x2289)};char*strSQL=
-"\x53\x45\x4c\x45\x43\x54\x20\x6d\x73\x67\x5f\x63\x6f\x6e\x74\x65\x6e\x74\x20\x46\x52\x4f\x4d\x20"
- ZTE_WMS_DB_SEND_CONTENT_TABLE"\x3b";buf_info.buf_addr=pSmsBuf;buf_info.buf_len=
-len;memset(buf_info.buf_addr,(0x7bd+973-0xb8a),len);return isSucess(
-zUfiSms_ExecSql(strSQL,zUfiSms_GetSendContent,&buf_info));}int
-zUfiSms_SearchConcatSmsInDb(T_zUfiSms_DbStoreData*ptDbSaveData,char*pMemStore){
-char*sql=NULL;sqlite3_stmt*stmt=NULL;int id=-(0x1552+3618-0x2373);switch(
-ptDbSaveData->tag){case WMS_TAG_TYPE_MO_SENT_V01:case
-WMS_TAG_TYPE_MO_NOT_SENT_V01:{sql=sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x43\x63\x5f\x53\x65\x71\x2c\x69\x64\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x54\x6f\x74\x61\x6c\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x41\x4e\x44\x20\x28\x54\x61\x67\x20\x3d\x20\x27\x25\x64\x27\x20\x4f\x52\x20\x54\x61\x67\x3d\x20\x27\x25\x64\x27\x29\x3b"
-,ptDbSaveData->number,ptDbSaveData->concat_info[(0x1155+4005-0x20fa)],
-ptDbSaveData->concat_info[(0x11eb+2345-0x1b13)],pMemStore,
-WMS_TAG_TYPE_MO_SENT_V01,WMS_TAG_TYPE_MO_NOT_SENT_V01);break;}case
-(0x1a7c+1586-0x20aa):{sql=sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x43\x63\x5f\x53\x65\x71\x2c\x69\x64\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x54\x6f\x74\x61\x6c\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x41\x4e\x44\x20\x54\x61\x67\x20\x3d\x20\x27\x25\x64\x27\x3b"
-,ptDbSaveData->number,ptDbSaveData->concat_info[(0xe07+2245-0x16cc)],
-ptDbSaveData->concat_info[(0x200+7307-0x1e8a)],pMemStore,(0x1413+711-0x16d6));
-break;}case WMS_TAG_TYPE_MT_READ_V01:case WMS_TAG_TYPE_MT_NOT_READ_V01:{sql=
-sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x43\x63\x5f\x53\x65\x71\x2c\x69\x64\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x54\x6f\x74\x61\x6c\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x20\x41\x4e\x44\x20\x28\x54\x61\x67\x20\x3d\x20\x27\x25\x64\x27\x20\x4f\x52\x20\x54\x61\x67\x3d\x20\x27\x25\x64\x27\x29\x3b"
-,ptDbSaveData->number,ptDbSaveData->concat_info[(0x9b0+4881-0x1cc1)],
-ptDbSaveData->concat_info[(0x618+31-0x636)],pMemStore,WMS_TAG_TYPE_MT_READ_V01,
-WMS_TAG_TYPE_MT_NOT_READ_V01);break;}default:{sql=sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x43\x63\x5f\x53\x65\x71\x2c\x69\x64\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x4e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x54\x6f\x74\x61\x6c\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x3b"
-,ptDbSaveData->number,ptDbSaveData->concat_info[(0x2b7+355-0x41a)],ptDbSaveData
-->concat_info[(0xcd9+2799-0x17c7)],pMemStore);at_print(LOG_ERR,
-"\x74\x61\x67\x20\x25\x64\x20\x69\x73\x20\x75\x6e\x6b\x6e\x6f\x77\x6e",
-ptDbSaveData->tag);break;}}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x3a\x25\x73" "\n",sql);if(
-sqlite3_prepare(g_zUfiSms_DbPointer,sql,-(0x13a1+2788-0x1e84),&stmt,
-(0xd53+3471-0x1ae2))!=SQLITE_OK){at_print(LOG_ERR,
-"\x63\x61\x6e\x20\x6e\x6f\x74\x20\x65\x78\x65\x63\x20\x73\x71\x6c\x2c\x73\x71\x6c\x69\x74\x65\x33\x5f\x65\x72\x72\x6d\x73\x67\x3a\x25\x73\x2e" "\n"
-,sqlite3_errmsg(g_zUfiSms_DbPointer));sqlite3_free(sql);return-
-(0x1607+1862-0x1d4c);}while(SQLITE_ROW==sqlite3_step(stmt)){int j=
-(0xa3b+1491-0x100e);char**out_result=NULL;char*column_text=sqlite3_column_text(
-stmt,(0x436+4562-0x1608));int count=-(0x306+4454-0x146b);if(column_text!=NULL)
-count=zUfiSms_SplitString(column_text,&out_result,((char)(0x928+2108-0x1129)));
-for(j=(0xdfb+2675-0x186e);j<count;j++){if((0xf1b+721-0x11ec)==strcmp(out_result[
-j],"")){if(j+(0x109f+4285-0x215b)==ptDbSaveData->concat_info[
-(0x1920+2864-0x244e)]){id=sqlite3_column_int(stmt,(0x1d98+2296-0x268f));break;}}
-}if(out_result!=NULL){free(out_result);out_result=NULL;}if(-(0x81d+458-0x9e6)!=
-id){break;}}(void)sqlite3_finalize(stmt);sqlite3_free(sql);return id;}int
-zUfiSms_CheckDbOutdateSms_Callback(void*fvarg,int columns,char**zresult,char**
-lname){if(fvarg!=NULL&&columns>=(0x8a5+218-0x97e)){if(zresult[
-(0x54f+6622-0x1f2d)]!=NULL){T_zUfiSms_DelReq*result=(T_zUfiSms_DelReq*)fvarg;
-result->id[result->all_or_count]=atoi(zresult[(0x1230+4965-0x2595)]);result->
-all_or_count++;return SQLITE_OK;}}return SQLITE_ERROR;}VOID
-zUfiSms_CheckDbOutdateSms(const char*pDbTable,T_zUfiSms_DelReq*pSmsDel){char
-acSql[(0x555+5846-0x1bab)]={(0x1422+3897-0x235b)};struct timeval tp;if(
-(0x144+7158-0x1d3a)!=gettimeofday(&tp,NULL)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x67\x65\x74\x74\x69\x6d\x65\x6f\x66\x64\x61\x79\x20\x65\x72\x72\x6f\x72\x21\x21\x21"
-);return;}if(tp.tv_sec<=OUTDATEINTERVAL){return;}snprintf(acSql,sizeof(acSql),
-"\x53\x45\x4c\x45\x43\x54\x20\x69\x64\x20\x46\x52\x4f\x4d\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x4d\x6b\x74\x69\x6d\x65\x3c\x27\x25\x75\x27\x20\x41\x4e\x44\x20\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65\x3d\x27\x25\x73\x27\x3b"
-,ZTE_WMS_DB_SMS_TABLE,(unsigned int)(tp.tv_sec-OUTDATEINTERVAL),pDbTable);if(
-ZTE_WMS_DB_OK!=zUfiSms_ExecSql(acSql,zUfiSms_CheckDbOutdateSms_Callback,pSmsDel)
-){at_print(LOG_ERR,
-"\x6f\x70\x65\x6e\x20\x74\x61\x62\x6c\x65\x20\x25\x73\x20\x66\x61\x69\x6c\x65\x64"
-,ZTE_WMS_DB_CMD_STATUS_TABLE);}return;}int
-zUfiSms_GetCurrentRecvTotalSeq_Callback(void*fvarg,int column,char**zresult,char
-**lname){if(fvarg!=NULL&&column>=(0xef2+4631-0x2107)){if(zresult[
-(0x11e8+4187-0x2243)]!=NULL&&zresult[(0x180f+143-0x189d)]!=NULL){SMS_MSG_INFO*
-msg=(SMS_MSG_INFO*)fvarg;memset(msg->id,(0x1beb+2115-0x242e),sizeof(msg->id));
-memset(msg->total_seq,(0x11d2+4763-0x246d),sizeof(msg->total_seq));strncpy(msg->
-id,zresult[(0x48c+4658-0x16be)],sizeof(msg->id)-(0x15cb+2018-0x1dac));strncpy(
-msg->total_seq,zresult[(0xc84+4466-0x1df5)],sizeof(msg->total_seq)-
-(0xf24+3865-0x1e3c));printf(
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x43\x75\x72\x72\x65\x6e\x74\x52\x65\x63\x76\x54\x6f\x74\x61\x6c\x53\x65\x71\x5f\x43\x61\x6c\x6c\x62\x61\x63\x6b\x20\x69\x64\x20\x3d\x20\x25\x73\x2c\x20\x74\x6f\x74\x61\x6c\x5f\x73\x65\x71\x20\x3d\x20\x25\x73" "\n"
-,msg->id,msg->total_seq);return SQLITE_OK;}}return SQLITE_ERROR;}int
-zUfiSms_GetCurrentRecvTotalSeq(T_zUfiSms_DbStoreData*ptDbSaveData,SMS_MSG_INFO*
-pmsg){T_zUfiSms_DbResult result=ZTE_WMS_DB_OK;char*strSQL=NULL;strSQL=
-sqlite3_mprintf(
-"\x53\x45\x4c\x45\x43\x54\x20\x69\x64\x2c\x20\x43\x63\x5f\x4e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x73\x6d\x73\x20\x57\x48\x45\x52\x45\x20\x20\x6e\x75\x6d\x62\x65\x72\x3d\x27\x25\x71\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x52\x65\x66\x3d\x27\x25\x64\x27\x20\x41\x4e\x44\x20\x43\x63\x5f\x54\x6f\x74\x61\x6c\x3d\x27\x25\x64\x27\x3b"
-,ptDbSaveData->number,ptDbSaveData->concat_info[(0x911+3339-0x161c)],
-ptDbSaveData->concat_info[(0x1cc3+1693-0x235f)]);printf(
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x43\x75\x72\x72\x65\x6e\x74\x52\x65\x63\x76\x54\x6f\x74\x61\x6c\x53\x65\x71\x20\x73\x71\x6c\x20\x3a\x20\x25\x73\x20" "\n"
-,strSQL);result=zUfiSms_ExecSql(strSQL,zUfiSms_GetCurrentRecvTotalSeq_Callback,
-pmsg);sqlite3_free(strSQL);return isSucess(result);}
+ return ZTE_WMS_DB_OK;
+ }
+}
+
+int zUfiSms_GetFirstColumnInt(void *fvarg, int columns, char **zresult, char **lname)
+{
+ if(columns >= 1)
+ {
+ if(zresult[0] == NULL)
+ {
+ *(int *)fvarg = 0;
+ }
+ else
+ {
+ *(int *)fvarg = atoi(zresult[0]);
+ }
+ return SQLITE_OK;
+ }
+ else
+ {
+ return SQLITE_ERROR;
+ }
+}
+
+int zUfiSms_SetCmdStatus(T_zUfiSms_StatusInfo *ptSetStatus)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char *strSQL = NULL;
+
+ printf("[SMS] zUfiSms_SetCmdStatus enter.\n");
+ strSQL = sqlite3_mprintf("INSERT OR REPLACE INTO %s(Cmd,Cmd_Status,Err_Code,Send_Fail_Count,Del_Count) " \
+ "VALUES('%d','%d','%d','%d','%d');",
+ ZTE_WMS_DB_CMD_STATUS_TABLE,
+ ptSetStatus->cmd, ptSetStatus->cmd_status, ptSetStatus->err_code,
+ ptSetStatus->send_failed_count, ptSetStatus->delete_failed_count);
+
+ result = zUfiSms_ExecSql(strSQL,NULL,NULL);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+
+void zUfiSms_SetParameterNv(T_zUfiSms_ParaInfo *para)
+{
+ if(0 == (int)para->status_report_on)
+ {
+ sc_cfg_set(NV_REPORT_ENABLE,"0");
+ }
+ else
+ {
+ sc_cfg_set(NV_REPORT_ENABLE,"1");
+ }
+ if(0 == (int)para->sendfail_retry_on)
+ {
+ sc_cfg_set(NV_SENDFAIL_RETRY,"0");
+ }
+ else
+ {
+ sc_cfg_set(NV_SENDFAIL_RETRY,"1");
+ }
+ if(0 == (int)para->outdate_delete_on)
+ {
+ sc_cfg_set(NV_OUTDATE_DELETE,"0");
+ }
+ else
+ {
+ sc_cfg_set(NV_OUTDATE_DELETE,"1");
+ }
+ if(*(para->default_store) != '\0')
+ {
+ sc_cfg_set(NV_DEFAULT_STORE,(char*)para->default_store);
+ }
+
+ if(0 == (int)para->mem_store)
+ {
+ sc_cfg_set(NV_PRA_MEMSTORE,"0");
+ }
+ else
+ {
+ sc_cfg_set(NV_PRA_MEMSTORE,"1");
+ }
+ if(0xFF == (int)para->tp_validity_period)
+ {
+ sc_cfg_set(NV_SMS_VP,"longest");
+ }
+ else if(0xAD == (int)para->tp_validity_period)
+ {
+ sc_cfg_set(NV_SMS_VP,"oneweek");
+ }
+ else if(0xA7 == (int)para->tp_validity_period)
+ {
+ sc_cfg_set(NV_SMS_VP,"one_day");
+ }
+ else if(0x8F == (int)para->tp_validity_period)
+ {
+ sc_cfg_set(NV_SMS_VP,"twelveh");
+ }
+ printf("wms_db_set_parameters :: set tp_validity_period %d\n",(int)para->tp_validity_period);
+}
+/* °Ñ²ÎÊý´æÈëÊý¾Ý¿â£¬Í¬²½¸üе½cfg µÄNVÖÐ **/
+int zUfiSms_SetDbParameters(T_zUfiSms_ParaInfo *para)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char *strSQL = NULL;
+ int count = 0;
+
+ if(NULL == para)
+ {
+ return -1;
+ }
+
+ zUfiSms_ExecSql("SELECT count(*) FROM " ZTE_WMS_DB_PARAMETER_TABLE " WHERE id=1;", zUfiSms_GetFirstColumnInt, &count);
+
+ if(count > 0) /*exist*/
+ {
+ strSQL = sqlite3_mprintf("UPDATE %s SET Sms_Report='%d',Sms_Sca='%q',Mem_Store='%d',Tp_Validity='%d',Send_Retry='%d',Outdate_Delete='%d',Default_Store='%q' WHERE id=1;",
+ ZTE_WMS_DB_PARAMETER_TABLE,
+ (int)para->status_report_on,
+ para->sca,
+ (int)para->mem_store,
+ (int)para->tp_validity_period,
+ (int)para->sendfail_retry_on,
+ (int)para->outdate_delete_on,
+ para->default_store,
+ ZTE_WMS_DB_PARAMETER_TABLE);
+ }
+ else
+ {
+ strSQL = sqlite3_mprintf("INSERT INTO %s(id, Sms_Report,Sms_Sca,Mem_Store,Tp_Validity,Send_Retry,Outdate_Delete,Default_Store,Max_Cc_Ref,Max_Sms_Ref) "
+ "VALUES('1', '%d','%q','%d','%d','%d','%d','%q','0','0');",
+ ZTE_WMS_DB_PARAMETER_TABLE,
+ (int)para->status_report_on,
+ para->sca,
+ (int)para->mem_store,
+ (int)para->tp_validity_period,
+ (int)para->sendfail_retry_on,
+ (int)para->outdate_delete_on,
+ para->default_store);
+ }
+ result = zUfiSms_ExecSql(strSQL,NULL,NULL);
+ sqlite3_free(strSQL);
+ if (result == ZTE_WMS_DB_OK)
+ {
+ zUfiSms_SetParameterNv(para);
+ return 0;
+ }
+ return -1;
+}
+
+/*»ñÈ¡´æ´¢ÓÚdb_tableÖ®´¦µÄ¶ÌÐÅ×ÜÊý*/
+int zUfiSms_GetTotalCount(const char *pDbTable,int *pTotalCount)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char *strSQL = NULL;
+
+ strSQL = sqlite3_mprintf("SELECT count(*) FROM sms WHERE Mem_Store='%q';", pDbTable);
+ result = zUfiSms_ExecSql(strSQL, zUfiSms_GetFirstColumnInt, pTotalCount);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+// »ñÈ¡Max_Sms_RefÐÅÔª£¬Í¨¹ý·µ»ØÖµ·µ»Ø
+int zUfiSms_GetSmsMaxReferInDb(void)
+{
+ int max_sms_ref = -1;
+
+ zUfiSms_ExecSql("SELECT Max_Sms_Ref FROM " ZTE_WMS_DB_PARAMETER_TABLE " WHERE id = 1;", zUfiSms_GetFirstColumnInt, &max_sms_ref);
+ return max_sms_ref;
+}
+/** ¸ù¾Ý´æ´¢Î»ÖúͶÌÐÅid»ñÈ¡index¡¢seq¡¢contentµÈÄÚÈÝ **/
+int zUfiSms_GetConcatInfo(char *mem_store,long id,T_zUfiSms_DbStoreStr *pac,char *content,int len)
+{
+ sqlite3_stmt *stmt = NULL;
+ char *strSQL = sqlite3_mprintf("SELECT ind,Cc_Seq,Cc_Content FROM sms WHERE id='%d' AND Mem_Store='%q';", id, mem_store);
+
+
+ (void)sqlite3_prepare(g_zUfiSms_DbPointer, strSQL,-1,&stmt,0);
+ while(SQLITE_ROW == sqlite3_step(stmt))
+ {
+ //klocwork
+ char * column_text = NULL;
+ memset(pac->IndStr, 0, sizeof(pac->IndStr));
+ memset(pac->Seg_Seq, 0, sizeof(pac->Seg_Seq));
+ if ((column_text = sqlite3_column_text(stmt,0)) != NULL)
+ strncpy(pac->IndStr, column_text, sizeof(pac->FormatInd)-1);
+ if ((column_text = sqlite3_column_text(stmt,1)) != NULL)
+ strncpy(pac->Seg_Seq, column_text, sizeof(pac->FormatSeq)-1);
+ if ((column_text = sqlite3_column_text(stmt,2)) != NULL)
+ strncpy(content, column_text, len-1);
+ printf("[SMS] teet zUfiSms_GetConcatInfo:%s,%s\n",pac->IndStr,pac->Seg_Seq);
+ }
+ (void)sqlite3_finalize(stmt);
+
+ sqlite3_free(strSQL);
+ return 0;
+}
+
+/** ¸üÐÂÒ»Ìõ¶ÌÐÅ */
+int zUfiSms_UpdateConcatSmsToDb
+(
+ T_zUfiSms_DbStoreData *db_data,
+ const char *mem_store,
+ char *format_concat,
+ char *content,
+ T_zUfiSms_DbStoreStr *pac,
+ int concat_num,
+ long id
+)
+{
+ char *sql = NULL;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ sql = sqlite3_mprintf("UPDATE sms SET ind='%s',Tag='%d',Cc_Seq='%s',Cc_Num='%d', "\
+ "Cc_Content='%q',Content='%q',Year='%q',Month='%q', "\
+ "Day='%q',Hour='%q',Minute='%q',Second='%q',TimeZone='%q' "\
+ "WHERE id='%d' AND Mem_Store='%q';",
+ pac->FormatInd, //index
+ db_data->tag, //ÒѶÁ£¬Î´¶Á»òÕ߯äËûÀàÐ͵Ä
+ pac->FormatSeq, //¼¶Áª¶ÌÐÅÖеڼ¸Ìõ
+ concat_num, //¼¶Áª¶ÌÐÅ×ܹ²¶àÉÙÌõ
+ format_concat, //ÓÃÀ´Æ´½Ó¼¶Áª¶ÌÐÅ
+ content, //×îÖյĶÌÐÅÄÚÈÝ
+ db_data->julian_date.year,
+ db_data->julian_date.month,
+ db_data->julian_date.day,
+ db_data->julian_date.hour,
+ db_data->julian_date.min,
+ db_data->julian_date.sec,
+ db_data->julian_date.timezone,
+ id,
+ mem_store);
+ printf("[SMS] teet zUfiSms_UpdateConcatSmsToDb:%s--%s\n",sql,pac->FormatSeq);
+ result = zUfiSms_ExecSql(sql, NULL, NULL);
+ sqlite3_free(sql);
+ return isSucess(result);
+}
+/*¼ÓÈëÒ»ÌõжÌÐÅ */
+int zUfiSms_InsertConcatSmsToDb
+(
+ T_zUfiSms_DbStoreData *db_data,
+ const char *mem_store,
+ char *format_concat,
+ char * content,
+ T_zUfiSms_DbStoreStr *pac,
+ int concat_num
+)
+{
+ char *sql = NULL;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ sql = sqlite3_mprintf("INSERT INTO sms(ind,Mem_Store,Tag,Number,Cc_Sms,Cc_Ref,Cc_Total,Cc_Seq,Cc_Num,Cc_Content,Tp_Dcs, Msg_Ref," \
+ "Content,Sms_Report_Recived,Draft_Group_Id,Year,Month,Day,Hour,Minute,Second,TimeZone,Mktime,DisplayMode) " \
+ "VALUES(\'%q\',\'%q\', '%d',\'%q\','%d','%d','%d',\'%q\','%d',\'%q\','%d', '%d',\'%q\',\'%q\',\'%q\',\'%q\',\'%q\',\'%q\',\'%q\', \'%q\',\'%q\',\'%q\','%d', '%d');",
+ pac->FormatInd,
+ mem_store,
+ db_data->tag,
+ db_data->number,
+ db_data->concat_sms,
+ db_data->concat_info[0],
+ db_data->concat_info[1],
+ pac->FormatSeq,
+ concat_num,
+ format_concat,
+ db_data->tp_dcs,
+ db_data->msg_ref,
+ content,
+ "0",
+ db_data->draft_group_id,
+ db_data->julian_date.year,
+ db_data->julian_date.month,
+ db_data->julian_date.day,
+ db_data->julian_date.hour,
+ db_data->julian_date.min,
+ db_data->julian_date.sec,
+ db_data->julian_date.timezone,
+ (unsigned int)zte_getsecond(db_data->julian_date),
+ db_data->msg_displaymode);
+
+ printf("[SMS] zUfiSms_InsertConcatSmsToDb sql=%s.\n",sql);
+ result = zUfiSms_ExecSql(sql,NULL,NULL);
+ sqlite3_free(sql);
+ return isSucess(result);
+}
+
+/*»ñÈ¡Max_Cc_Ref£¬Í¨¹ý·µ»ØÖµ·µ»Ø*/
+int zUfiSms_GetConcatMaxReferInDb(void)
+{
+ int ConcatMaxRefer = 0;
+ int result = 0;
+
+ result = zUfiSms_ExecSql("SELECT Max_Cc_Ref FROM " ZTE_WMS_DB_PARAMETER_TABLE " WHERE id = 1;", zUfiSms_GetFirstColumnInt, &ConcatMaxRefer);
+ if(ZTE_WMS_DB_OK != result)
+ {
+ return -1;
+ }
+ return ConcatMaxRefer;
+}
+
+
+int zUfiSms_CreateTables()
+{
+ int iMap = 0;
+ const T_zUfiSms_SQLMap SQL_MAP[] =
+ {
+ { 1, ZTE_WMS_CREATE_TABLE_SMS_SQL },
+ { 1, ZTE_WMS_DEL_SIM_SQL },
+ { 1, ZTE_WMS_CREATE_CMD_STATUS_SQL },
+ { 1, ZTE_WMS_CREATE_SMS_REP_SQL },
+ { 1, ZTE_WMS_CREATE_PAR_SQL },
+ { 1, ZTE_WMS_CREATE_INFO_SQL },
+ { 1, ZTE_WMS_CREATE_CELL_BRO_SQL },
+ { 1, ZTE_WMS_CREATE_SEND_CONTENT_SQL },
+ };
+
+ for(iMap =0; iMap < sizeof(SQL_MAP)/sizeof(T_zUfiSms_SQLMap); iMap++)
+ {
+ if(SQL_MAP[iMap].valid == 1)
+ {
+ if(zUfiSms_ExecSql(SQL_MAP[iMap].strSQL, NULL, NULL) != ZTE_WMS_DB_OK)
+ {
+ return ZUFI_FAIL;
+ }
+ }
+ }
+ return ZUFI_SUCC;
+}
+/*´´½¨ËùÓеÄÊý¾Ý¿âÖи÷±í*/
+int zUfiSms_CreateAllTable (void)
+{
+ if(ZTE_WMS_DB_OK != zUfiSms_OpenDb())
+ {
+ printf("[SMS] can not open database.return.\n");
+ return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;
+ }
+ return zUfiSms_CreateTables();
+}
+
+int zUfiSms_DropAllTable (void)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ if(ZTE_WMS_DB_OK != zUfiSms_OpenDb())
+ {
+ printf("[SMS] can not open database.return.\n");
+ return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;
+ }
+ result = zUfiSms_ExecSql(ZTE_WMS_DROP_ALL_TABLE_SQL,NULL,NULL);
+ printf("[SMS] zUfiSms_DropAllTable: sql = %s, result = %d! \n", ZTE_WMS_DROP_ALL_TABLE_SQL, result);
+ return ZUFI_SUCC;
+}
+
+int zUfiSms_DropAllTableExceptSms (void)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ if(ZTE_WMS_DB_OK != zUfiSms_OpenDb())
+ {
+ printf("[SMS] can not open database.return.\n");
+ return ZTE_SMS_DB_ERROR_NOT_OPEN_DB;
+ }
+ result = zUfiSms_ExecSql(ZTE_WMS_DROP_TABLE_EXCEPTSMS_SQL, NULL, NULL);
+ printf("[SMS] zUfiSms_DropAllTable: sql = %s, result = %d! \n", ZTE_WMS_DROP_ALL_TABLE_SQL, result);
+ return ZUFI_SUCC;
+}
+
+/* ¼ì²é±íÖÐÊÇ·ñÓÐÊý¾Ý 0:²»Îª¿Õ£¬1Ϊ¿Õ **/
+int zUfiSms_IsDbEmpty(const char *tab, int *pCount)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char *strSQL = sqlite3_mprintf("SELECT count(*) FROM %s;", tab);
+
+ result = zUfiSms_ExecSql(strSQL, zUfiSms_GetFirstColumnInt, pCount);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+/* ÔÚÊý¾Ý¿âµÄpStorePosÖмÓÈëÒ»Ìõмͼ */
+int zUfiSms_InsertNormalSmsToDb
+(
+ T_zUfiSms_DbStoreData *ptDbSaveData,
+ const char *pStorePos,
+ char *pContent
+)
+{
+ char *strSQL = NULL;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ strSQL = sqlite3_mprintf("INSERT INTO sms(ind,Mem_Store,Tag,Number,Cc_Sms,Cc_Ref,Cc_Total,Cc_Seq,Tp_Dcs, " \
+ "Msg_Ref,Content,Sms_Report_Recived,Draft_Group_Id,Year,Month,Day,Hour,Minute,Second,TimeZone,Mktime,DisplayMode) VALUES('%d','%q', " \
+ "'%d','%q','%d','%d','%d','%d','%d','%d','%q','%q','%q','%q','%q','%q','%q','%q', " \
+ "'%q','%q','%u', '%d');",
+ ptDbSaveData->index,
+ pStorePos,
+ ptDbSaveData->tag,
+ ptDbSaveData->number,
+ ptDbSaveData->concat_sms,
+ ptDbSaveData->concat_info[0],
+ ptDbSaveData->concat_info[1],
+ ptDbSaveData->concat_info[2],
+ ptDbSaveData->tp_dcs,
+ ptDbSaveData->msg_ref,
+ pContent,
+ "0",
+ ptDbSaveData->draft_group_id,
+ ptDbSaveData->julian_date.year,
+ ptDbSaveData->julian_date.month,
+ ptDbSaveData->julian_date.day,
+ ptDbSaveData->julian_date.hour,
+ ptDbSaveData->julian_date.min,
+ ptDbSaveData->julian_date.sec,
+ ptDbSaveData->julian_date.timezone,
+ (unsigned int)zte_getsecond(ptDbSaveData->julian_date),
+ ptDbSaveData->msg_displaymode);
+ printf("[SMS] zUfiSms_InsertNormalSmsToDb sql=%s\n", strSQL);
+ result = zUfiSms_ExecSql(strSQL,NULL,NULL);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+
+/* ¸üÐÂiSmsIdµÄ´æ´¢ÐÅÏ¢ */
+int zUfiSms_UpdateNormalSmsToDb
+(
+ T_zUfiSms_DbStoreData *ptDbSaveData,
+ const char *pStorePos,
+ char *pContent,
+ long iSmsId
+)
+{
+ char *strSQL = NULL;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ strSQL = sqlite3_mprintf("UPDATE sms SET Number='%q',Content='%q',Year='%q',Month='%q', "\
+ "Day='%q',Hour='%q',Minute='%q',Second='%q',TimeZone='%q' "\
+ "WHERE id='%d' and Mem_Store='%q';",
+ ptDbSaveData->number,
+ pContent,
+ ptDbSaveData->julian_date.year,
+ ptDbSaveData->julian_date.month,
+ ptDbSaveData->julian_date.day,
+ ptDbSaveData->julian_date.hour,
+ ptDbSaveData->julian_date.min,
+ ptDbSaveData->julian_date.sec,
+ ptDbSaveData->julian_date.timezone,
+ iSmsId,
+ pStorePos);
+ if(NULL == strSQL)
+ {
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] zUfiSms_UpdateNormalSmsToDb sql=%s\n",strSQL);
+ result = zUfiSms_ExecSql(strSQL,NULL,NULL);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+int zUfiSms_GetFirstColumnStr(void *fvarg,int columns, char **zresult,char **lname)
+{
+ if(columns >= 1 && fvarg != NULL)
+ {
+ if(zresult[0] != NULL)
+ {
+ T_zUfiSms_BufInfo *para = (T_zUfiSms_BufInfo *)fvarg;
+
+ strncpy(para->buf_addr, zresult[0], para->buf_len-1);
+ return SQLITE_OK;
+ }
+ }
+ return SQLITE_ERROR;
+}
+/* ¸ù¾Ýid»ñÈ¡¶ÌÐŵĴ洢λÖà */
+int zUfiSms_GetStorePosById(char *item,char *item_data,int item_len, int id)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ T_zUfiSms_BufInfo buf_info = { 0 };
+ char *strSQL = NULL;
+
+ if(NULL == item || NULL == item_data)
+ {
+ return ZUFI_FAIL;
+ }
+ buf_info.buf_addr = item_data;
+ buf_info.buf_len = item_len;
+
+ strSQL = sqlite3_mprintf("SELECT %q FROM sms WHERE id='%d';", item, id);
+ result = zUfiSms_ExecSql(strSQL, zUfiSms_GetFirstColumnStr, &buf_info);
+ sqlite3_free(strSQL);
+
+ if((ZTE_WMS_DB_OK != result) || (0 == strcmp(item_data,"")))
+ {
+ at_print(LOG_ERR,"get table_member by id failed.\n");
+ return ZUFI_FAIL;
+ }
+ return ZUFI_SUCC;
+}
+
+int zUfiSms_DeleteSmsInDb(void)
+{
+ char sql[128] = {0};
+
+ snprintf(sql,sizeof(sql),"DELETE FROM sms WHERE Mem_Store='%s' and id='%d';", ZTE_WMS_DB_SIM_TABLE, g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_index-1]);
+ return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));
+}
+
+int zUfiSms_DeleteAllSimSmsInDb(void)
+{
+ return isSucess(zUfiSms_ExecSql("DELETE FROM sms WHERE Mem_Store='" ZTE_WMS_DB_SIM_TABLE "';", NULL, NULL));
+}
+
+/** ɾ³ýNVÖеĶÌÐÅ **/
+int zUfiSms_DeleteNvSms(void)
+{
+ // ɾ³ýËùÓÐ
+ if(g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_NV] == g_zUfiSms_DelMsg.nv_count)
+ {
+ if(ZTE_WMS_DB_OK != zUfiSms_ExecSql("DELETE FROM sms WHERE Mem_Store='" ZTE_WMS_DB_NV_TABLE "';",NULL,NULL))
+ {
+ printf("[SMS] zUfiSms_DeleteNvSms:delete fail\n");
+ return WMS_CMD_FAILED;
+ }
+ }
+ else
+ {
+ int i = 0;
+ printf("[SMS] zUfiSms_DeleteNvSms:delete nv_count=%d\n",g_zUfiSms_DelMsg.nv_count);
+ // ɾ³ý²¿·Ö
+ for(i = 0; i < g_zUfiSms_DelMsg.nv_count; i++)
+ {
+ char sql[128] = { 0 };
+
+ snprintf(sql, sizeof(sql), "DELETE FROM sms WHERE Mem_Store='%s' and id='%d';", ZTE_WMS_DB_NV_TABLE, g_zUfiSms_DelMsg.nv_id[i]);
+ if(ZTE_WMS_DB_OK != zUfiSms_ExecSql(sql,NULL,NULL))
+ {
+ printf("[SMS] sms:exec sql failed,i=%d\n",i);
+ return WMS_CMD_FAILED;
+ }
+ }
+ }
+ printf("[SMS] zUfiSms_DeleteNvSms:delete success\n");
+ return WMS_CMD_SUCCESS;
+}
+
+/** »ñÈ¡¶ÌÐŵÄind×Ö¶Î,·ÅÈëptModifyTag */
+int zUfiSms_GetSmsIndex(int id,T_zUfiSms_ModifyTag *ptModifyTag,int is_cc)
+{
+ char sql[128] = { 0 };
+ T_zUfiSms_BufInfo buf_info = { 0 };
+ char str_index[2 * WMS_MESSAGE_LIST_MAX] = {0};
+
+ buf_info.buf_addr = str_index;
+ buf_info.buf_len = sizeof(str_index);
+
+ snprintf(sql, sizeof(sql), "SELECT ind FROM sms WHERE id='%d';", id);
+ if (zUfiSms_ExecSql(sql, zUfiSms_GetFirstColumnStr, &buf_info) != ZTE_WMS_DB_OK)
+ {
+ at_print(LOG_ERR,"open table sms failed");
+ return ZUFI_FAIL;
+ }
+
+ if(1 == is_cc)/*concat sms*/
+ {
+ int i = 0;
+ int j = 0;
+ int count = 0;
+ char **out_result = NULL;
+
+ count = zUfiSms_SplitString(str_index,&out_result, ';');
+ for(i = 0; i < count; i++)
+ {
+ if(0 != strcmp(out_result[i],""))
+ {
+ ptModifyTag->indices[j++] = atoi(out_result[i]);
+ }
+ }
+ ptModifyTag->num_of_indices = j;
+ free(out_result);
+ }
+ else /*normal sms*/
+ {
+ ptModifyTag->indices[0] = atoi(str_index);
+ ptModifyTag->num_of_indices = 1;
+ }
+
+ ptModifyTag->total_indices = ptModifyTag->num_of_indices;
+ printf("modify_tag_ptr->total_indices=%d\n", ptModifyTag->total_indices);
+ return ZUFI_SUCC;
+}
+
+/* ¼ì²éÊÇ·ñÊǼ¶Áª¶ÌÐÅ */
+int zUfiSms_IsConcatSms(int id)
+{
+ char sql[128] = { 0 };
+ int is_cc = 0;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ snprintf(sql, sizeof(sql), "SELECT Cc_Sms FROM %s WHERE id='%d';", ZTE_WMS_DB_SMS_TABLE, id);
+ result = zUfiSms_ExecSql(sql, zUfiSms_GetFirstColumnInt, &is_cc);
+ if(ZTE_WMS_DB_OK != result)
+ {
+ at_print(LOG_ERR,"open table %s failed", ZTE_WMS_DB_SMS_TABLE);
+ return -1;
+ }
+ return is_cc;
+}
+
+/** ½«¶ÌÐÅidµÄtag¸üР*/
+int zUfiSms_UpdateSmsTagInDb(unsigned long id,unsigned int tags)
+{
+ char sql[128] = { 0 };
+
+ snprintf(sql, sizeof(sql), "UPDATE %s SET Tag='%d' WHERE id='%d';", ZTE_WMS_DB_SMS_TABLE, tags, id);
+ return isSucess(zUfiSms_ExecSql(sql, NULL, NULL));
+}
+
+/** ²éѯ¶ÌÐÅidµÄtag */
+int zUfiSms_GetTagCountInDb(T_zUfiSms_MemoryType mem_store, unsigned int tags, int *pTotalCount)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char sql[128] = {0};
+
+ if(pTotalCount == NULL)
+ {
+ return ZUFI_FAIL;
+ }
+
+ if(mem_store == ZTE_WMS_MEMORY_MAX)
+ {
+ snprintf(sql,sizeof(sql),"SELECT count(*) FROM %s WHERE Tag='%d';", ZTE_WMS_DB_SMS_TABLE, tags);
+ }
+ else if(mem_store == ZTE_WMS_MEMORY_NV)
+ {
+ snprintf(sql,sizeof(sql),"SELECT count(*) FROM %s WHERE Mem_Store='%s' AND Tag='%d';", ZTE_WMS_DB_SMS_TABLE, ZTE_WMS_DB_NV_TABLE, tags);
+ }
+ else
+ {
+ snprintf(sql,sizeof(sql),"SELECT count(*) FROM %s WHERE Mem_Store='%s' AND Tag='%d';", ZTE_WMS_DB_SMS_TABLE, ZTE_WMS_DB_SIM_TABLE, tags);
+ }
+
+ result = zUfiSms_ExecSql(sql, (zte_wms_db_callback)zUfiSms_GetFirstColumnInt, pTotalCount);
+ return isSucess(result);
+
+}
+
+/* ´ÓÊý¾Ý¿âÖÐɾ³ýÒ»Ìõ¶ÌÐÅ */
+int zUfiSms_DeleteDraftSms(long iSmsId)
+{
+ char sql[128] = { 0 };
+
+ snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE id='%ld';",ZTE_WMS_DB_SMS_TABLE, iSmsId);
+ return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));
+}
+
+/* ´æ´¢¶ÌÐŵÄ×î´ó¶ÎºÅ */
+int zUfiSms_SetConcatMaxRefer(int ref)
+{
+ char sql[128] = { 0 };
+
+ if(ZTE_WMS_MAX_CONCAT_REF < ref)
+ {
+ ref = 0;
+ }
+
+ snprintf(sql,sizeof(sql),"UPDATE %s SET Max_Cc_Ref='%d' WHERE id=1;", ZTE_WMS_DB_PARAMETER_TABLE, ref);
+ return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));
+}
+
+/**±£´æ×î´ó·¢ËÍÊýÄ¿*/
+int zUfiSms_SetMaxReference(int ref)
+{
+ char sql[128] = { 0 };
+
+ if(ZTE_WMS_MAX_SMS_REF < ref)
+ {
+ ref = 0;
+ }
+
+ snprintf(sql,sizeof(sql),"UPDATE %s SET Max_Sms_Ref='%d' WHERE id=1;", ZTE_WMS_DB_PARAMETER_TABLE, ref);
+ return isSucess(zUfiSms_ExecSql(sql,NULL,NULL));
+}
+
+
+int zUfiSms_InsertReportStatusToDb(unsigned char *pNumber,T_zUfiSms_Date *ptSmsDate,int iReportStatus)
+{
+ char *strSQL = NULL;
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+
+ strSQL = sqlite3_mprintf("INSERT INTO sms_report(address,content,Year,Month,Day,Hour,Minute,Second,TimeZone) " \
+ "VALUES('%s','%d','%s','%s','%s','%s', '%s','%s','%s');",
+ pNumber,
+ iReportStatus,
+ ptSmsDate->year,
+ ptSmsDate->month,
+ ptSmsDate->day,
+ ptSmsDate->hour,
+ ptSmsDate->min,
+ ptSmsDate->sec,
+ ptSmsDate->timezone);
+
+ result = zUfiSms_ExecSql(strSQL, NULL, NULL);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+
+int zUfiSms_GetFirstColumnParaInfo(void *fvarg,int columns,char **zresult,char **lname)
+{
+
+ if(columns >= 1 && fvarg != NULL)
+ {
+ if(zresult[0] != NULL)
+ {
+ T_zUfiSms_ParaInfo *para = (T_zUfiSms_ParaInfo *)fvarg;
+
+ strncpy(para->sca, zresult[0], sizeof(para->sca) - 1);
+ para->mem_store = atoi(zresult[1]);
+ para->tp_validity_period = atoi(zresult[2]);
+ para->status_report_on = atoi(zresult[3]);
+ para->sendfail_retry_on = atoi(zresult[4]);
+ para->outdate_delete_on = atoi(zresult[5]);
+ (void)strncpy(para->default_store,zresult[6],sizeof(para->default_store)-1);
+ return SQLITE_OK;
+ }
+ }
+
+ return SQLITE_ERROR;
+}
+
+int zUfiSms_GetDbParameters(void)
+{
+ char *strSQL = "SELECT Sms_Sca,Mem_Store,Tp_Validity,Sms_Report,Send_Retry,Outdate_Delete,Default_Store FROM " ZTE_WMS_DB_PARAMETER_TABLE ";";
+
+ memset(&g_zUfiSms_CurSmsPara, 0, sizeof(T_zUfiSms_ParaInfo));
+ return isSucess(zUfiSms_ExecSql(strSQL,zUfiSms_GetFirstColumnParaInfo, &g_zUfiSms_CurSmsPara));
+}
+
+int zUfiSms_GetSendContent(void *fvarg,int column, char **zresult,char **lname)
+{
+ T_zUfiSms_BufInfo *para = (T_zUfiSms_BufInfo *)fvarg;
+
+ if(column >= 1 && para != NULL)
+
+ (void)strncpy(para->buf_addr,zresult[0],para->buf_len-1);
+ return 0;
+}
+
+// ´ÓSqlÖлñÈ¡¶ÌÐÅÄÚÈÝ£¬·ÅÓÚpSmsBufÖÐ
+int zUfiSms_GetSmsContent(char *pSmsBuf,int len)
+{
+ T_zUfiSms_BufInfo buf_info = { 0 };
+ char *strSQL = "SELECT msg_content FROM " ZTE_WMS_DB_SEND_CONTENT_TABLE ";";
+
+ buf_info.buf_addr = pSmsBuf;
+ buf_info.buf_len = len;
+ memset(buf_info.buf_addr, 0, len);
+
+ return isSucess(zUfiSms_ExecSql(strSQL, zUfiSms_GetSendContent, &buf_info));
+}
+
+/* ´ÓpMemStoreÖÐÕÒµ½ÓëptDbSaveDataÆ¥ÅäµÄ¶ÌÐÅ £¬·µ»ØÆäid */
+int zUfiSms_SearchConcatSmsInDb(T_zUfiSms_DbStoreData *ptDbSaveData,char *pMemStore)
+{
+ char *sql = NULL;
+ sqlite3_stmt *stmt = NULL;
+ int id = -1;
+
+ switch(ptDbSaveData->tag)
+ {
+ case WMS_TAG_TYPE_MO_SENT_V01:/*send box*/
+ case WMS_TAG_TYPE_MO_NOT_SENT_V01:/*draft box*/
+ {
+ sql = sqlite3_mprintf("SELECT Cc_Seq,id FROM sms WHERE Number='%q' AND Cc_Ref='%d' AND Cc_Total='%d' AND Mem_Store='%s' AND (Tag = '%d' OR Tag= '%d');",
+ ptDbSaveData->number,
+ ptDbSaveData->concat_info[0],
+ ptDbSaveData->concat_info[1],
+ pMemStore,
+ WMS_TAG_TYPE_MO_SENT_V01,
+ WMS_TAG_TYPE_MO_NOT_SENT_V01);
+ break;
+ }
+ case 4:/*saved box*/
+ {
+ sql = sqlite3_mprintf("SELECT Cc_Seq,id FROM sms WHERE Number='%q' AND Cc_Ref='%d' AND Cc_Total='%d' AND Mem_Store='%s' AND Tag = '%d';",
+ ptDbSaveData->number,
+ ptDbSaveData->concat_info[0],
+ ptDbSaveData->concat_info[1],
+ pMemStore,
+ 4);
+ break;
+ }
+ case WMS_TAG_TYPE_MT_READ_V01:/*receive box*/
+ case WMS_TAG_TYPE_MT_NOT_READ_V01:/*receive box*/
+ {
+ sql = sqlite3_mprintf("SELECT Cc_Seq,id FROM sms WHERE Number='%q' AND Cc_Ref='%d' AND Cc_Total='%d' AND Mem_Store='%s' AND (Tag = '%d' OR Tag= '%d');",
+ ptDbSaveData->number,
+ ptDbSaveData->concat_info[0],
+ ptDbSaveData->concat_info[1],
+ pMemStore,
+ WMS_TAG_TYPE_MT_READ_V01,
+ WMS_TAG_TYPE_MT_NOT_READ_V01);
+
+ break;
+ }
+ default:
+ {
+ sql = sqlite3_mprintf("SELECT Cc_Seq,id FROM sms WHERE Number='%q' AND Cc_Ref='%d' AND Cc_Total='%d' AND Mem_Store='%s';",
+ ptDbSaveData->number,
+ ptDbSaveData->concat_info[0],
+ ptDbSaveData->concat_info[1],
+ pMemStore);
+ at_print(LOG_ERR,"tag %d is unknown",ptDbSaveData->tag);
+ break;
+ }
+ }
+ printf("[SMS] teet:%s\n",sql);
+
+ if(sqlite3_prepare(g_zUfiSms_DbPointer,sql,-1,&stmt,0) != SQLITE_OK)
+ {
+ at_print(LOG_ERR,"can not exec sql,sqlite3_errmsg:%s.\n",sqlite3_errmsg(g_zUfiSms_DbPointer));
+ sqlite3_free(sql);
+ return -1;
+ }
+ while(SQLITE_ROW == sqlite3_step(stmt))
+ {
+ int j = 0;
+ char **out_result = NULL;
+ char * column_text = sqlite3_column_text(stmt, 0);
+ int count = -1;
+ if (column_text != NULL) //klocwork
+ count = zUfiSms_SplitString(column_text, &out_result, ';');
+
+ for(j = 0; j < count; j++)
+ {
+ if(0 == strcmp(out_result[j],""))
+ {
+ if(j+1 == ptDbSaveData->concat_info[2])
+ {
+ id = sqlite3_column_int(stmt,1);
+ break;
+ }
+ }
+ }
+
+ //if(count != -1)
+ if(out_result != NULL)//cov
+ {
+ free(out_result);
+ out_result = NULL;
+ }
+
+ if(-1 != id)
+ {
+ break;
+ }
+ }
+ (void)sqlite3_finalize(stmt);
+ sqlite3_free(sql);
+ return id;
+}
+
+int zUfiSms_CheckDbOutdateSms_Callback (void *fvarg, int columns, char **zresult,char **lname)
+{
+ if(fvarg != NULL && columns >= 1)
+ {
+ if(zresult[0] != NULL)
+ {
+ T_zUfiSms_DelReq *result = (T_zUfiSms_DelReq *)fvarg;
+
+ result->id[result->all_or_count] = atoi(zresult[0]);
+ result->all_or_count++;
+ return SQLITE_OK;
+ }
+ }
+ return SQLITE_ERROR;
+}
+
+VOID zUfiSms_CheckDbOutdateSms(const char *pDbTable, T_zUfiSms_DelReq *pSmsDel)
+{
+ char acSql[128] = {0};
+ struct timeval tp;
+
+ if (0 != gettimeofday(&tp,NULL))
+ {
+ printf("[SMS] gettimeofday error!!!");
+ return;
+ }
+ if(tp.tv_sec <= OUTDATEINTERVAL)
+ {
+ return;
+ }
+ snprintf(acSql, sizeof(acSql), "SELECT id FROM %s WHERE Mktime<'%u' AND Mem_Store='%s';" ,ZTE_WMS_DB_SMS_TABLE, (unsigned int)(tp.tv_sec -OUTDATEINTERVAL), pDbTable);
+ if (ZTE_WMS_DB_OK != zUfiSms_ExecSql(acSql,zUfiSms_CheckDbOutdateSms_Callback, pSmsDel))
+ {
+ at_print(LOG_ERR,"open table %s failed", ZTE_WMS_DB_CMD_STATUS_TABLE);
+ //return ZUFI_FAIL;
+ }
+
+ return;
+}
+
+int zUfiSms_GetCurrentRecvTotalSeq_Callback(void *fvarg,int column,char **zresult,char **lname)
+{
+ if(fvarg != NULL && column >= 2)
+ {
+ if(zresult[0] != NULL && zresult[1] != NULL)
+ {
+ SMS_MSG_INFO *msg = (SMS_MSG_INFO *)fvarg;
+
+ memset(msg->id, 0, sizeof(msg->id));
+ memset(msg->total_seq, 0, sizeof(msg->total_seq));
+ strncpy (msg->id, zresult[0], sizeof(msg->id)-1);
+ strncpy (msg->total_seq, zresult[1],sizeof(msg->total_seq)-1);
+ printf("[SMS][traffic] zUfiSms_GetCurrentRecvTotalSeq_Callback id = %s, total_seq = %s\n", msg->id, msg->total_seq);
+ return SQLITE_OK;
+ }
+ }
+ return SQLITE_ERROR;
+}
+
+int zUfiSms_GetCurrentRecvTotalSeq(T_zUfiSms_DbStoreData *ptDbSaveData,SMS_MSG_INFO *pmsg)
+{
+ T_zUfiSms_DbResult result = ZTE_WMS_DB_OK;
+ char *strSQL = NULL;
+
+ strSQL = sqlite3_mprintf("SELECT id, Cc_Num FROM sms WHERE number='%q' AND Cc_Ref='%d' AND Cc_Total='%d';",
+ ptDbSaveData->number, ptDbSaveData->concat_info[0], ptDbSaveData->concat_info[1]);
+ printf("[SMS][traffic] zUfiSms_GetCurrentRecvTotalSeq sql : %s \n", strSQL);
+ result = zUfiSms_ExecSql(strSQL,zUfiSms_GetCurrentRecvTotalSeq_Callback, pmsg);
+ sqlite3_free(strSQL);
+ return isSucess(result);
+}
+
diff --git a/ap/app/zte_comm/sms/src/sms_fnc.c b/ap/app/zte_comm/sms/src/sms_fnc.c
index ca36ccf..dd71cab 100755
--- a/ap/app/zte_comm/sms/src/sms_fnc.c
+++ b/ap/app/zte_comm/sms/src/sms_fnc.c
@@ -1,4 +1,42 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : AT_SERVER
+* ÎÄ ¼þ Ãû : SMS_fnc.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : AtServerÄ£¿ésms¹¦ÄÜÎļþ
+* ×÷ Õß : G.F
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-09-29
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ:
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : EC:617002775282, EC617002775301
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.5.30
+* ÐÞ¸ÄÄÚÈÝ : (´úÂë×ß²é)ÐÞ¸ÄÏà¹ØÄÚ´æ·ÃÎÊ´¦Àí²»µ±µÄÎÊÌâ
+**************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.24
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
+**************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.08.07
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÏòMMI·¢ËͶÌÐÅ״̬µÄ´úÂë
+**************************************************************************/
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
@@ -8,1186 +46,3020 @@
#include "sms_fnc.h"
#include "sms_db.h"
#include "sms_code.h"
-#define SMS_RETRY_COUNT (0x1724+3554-0x2503)
-#define SHORT_INT_LEN (0x1e1+7983-0x210a)
-SMS_LOCATION g_zUfiSms_CurLocation=SMS_LOCATION_SIM;int
-g_zUfiSms_ConcatSmsReference=(0x692+4359-0x1799);T_zUfiSms_ParaInfo
-g_zUfiSms_CurSmsPara={"",WMS_STORAGE_TYPE_UIM_V01,
-ZTE_WMS_SMS_DEFAULT_TP_VALIDITY_PERIOD_GW,(0x26b+8859-0x2506),
-(0x153b+2179-0x1dbe),(0x13f+6602-0x1b09),"\x6e\x76"};int g_zUfiSms_Language=
-NOT_DEFINE_LANGUAGE;int g_zUfiSms_Dcs=(0x157f+1090-0x19c1);unsigned long
-g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_MAX]={(0x93a+6807-0x236d),
-ZTE_WMS_DB_MSG_COUNT_MAX};T_zSms_SendSmsReq g_zUfiSms_FinalCmgsBuf;SMS_PARAM
-g_zUfiSms_SendingSms;UINT16 g_zUfiSms_IsLanguageShift=(0x9a2+6667-0x23ad);extern
- int g_zUfiSms_MsgRefer;extern T_zUfiSms_DelSms g_zUfiSms_DelMsg;extern
-T_zUfiSms_DelIndexInfo g_deleteIndex;extern T_zUfiSms_ModifyIndexInfo
-g_modifyIndex;extern T_zUfiSms_ModifySms g_zUfiSms_modifyMsg;extern UINT8
-g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX];extern int g_zUfiSms_ConcatTotalNum;
-extern T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;extern T_zUfiSms_GroupInfo
-g_zUfiSms_GroupSms;extern int g_zUfiSms_UnitLen;extern UINT8
-g_zUfiSms_IsConcatSendSuc;extern int g_zUfiSms_SendFailedCount;extern
-T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];extern
- int g_zUfiSms_SendFailedRetry;void zUfiSms_SetSmsLocation(SMS_LOCATION
-eLocation){switch(eLocation){case SMS_LOCATION_SIM:{g_zUfiSms_CurLocation=
-SMS_LOCATION_SIM;break;}case SMS_LOCATION_ME:{g_zUfiSms_CurLocation=
-SMS_LOCATION_ME;break;}default:{return;}}}int zUfiSms_SetDeleteInfo(
-T_zUfiSms_DelReq*ptDelMsg){char acStorePos[(0x19b9+895-0x1d06)];int i=
-(0xaaf+5336-0x1f87);g_zUfiSms_DelMsg.nv_count=(0x191b+2863-0x244a);
-g_zUfiSms_DelMsg.nv_index=(0x2dd+9023-0x261c);g_zUfiSms_DelMsg.sim_count=
-(0x1e2a+2009-0x2603);g_zUfiSms_DelMsg.sim_index=(0xa6b+4922-0x1da5);for(i=
-(0x3a6+1237-0x87b);i<ptDelMsg->all_or_count;i++){memset(acStorePos,
-(0x20ad+710-0x2373),sizeof(acStorePos));if(ZUFI_FAIL==zUfiSms_GetStorePosById(
-"Mem_Store",acStorePos,sizeof(acStorePos),ptDelMsg->id[i])){return ZUFI_FAIL;}if
-((0x3a+4474-0x11b4)==strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE)){g_zUfiSms_DelMsg.
-nv_id[g_zUfiSms_DelMsg.nv_count]=ptDelMsg->id[i];g_zUfiSms_DelMsg.nv_count++;
-g_zUfiSms_DelMsg.nv_index_count++;}else if((0x708+1891-0xe6b)==strcmp(acStorePos
-,ZTE_WMS_DB_SIM_TABLE)){g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_count]=
-ptDelMsg->id[i];g_zUfiSms_DelMsg.sim_count++;g_zUfiSms_DelMsg.sim_index_count++;
-}}return ZUFI_SUCC;}void zUfiSms_ChangeMainState(T_zUfiSms_MainState iNewState){
-char*ptStrSmsState[]={"\x73\x6d\x73\x5f\x69\x6e\x69\x74\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x69\x6e\x69\x74\x65\x64",
-"\x73\x6d\x73\x5f\x6c\x6f\x61\x64\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x6c\x6f\x61\x64\x65\x64",
-"\x73\x6d\x73\x5f\x73\x65\x6e\x64\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x73\x65\x6e\x64\x65\x64",
-"\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x64\x65\x6c\x65\x64",
-"\x73\x6d\x73\x5f\x72\x65\x63\x76\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x72\x65\x63\x76\x65\x64",
-"\x73\x6d\x73\x5f\x73\x61\x76\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x73\x61\x76\x65\x64",
-"\x73\x6d\x73\x5f\x64\x65\x6c\x73\x61\x76\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x64\x65\x6c\x73\x61\x76\x65\x64",
-"\x73\x6d\x73\x5f\x73\x69\x6d\x5f\x6c\x6f\x61\x64\x65\x64",
-"\x73\x6d\x73\x5f\x73\x65\x74\x74\x69\x6e\x67",
-"\x73\x6d\x73\x5f\x68\x61\x76\x65\x73\x65\x74",
-"\x73\x6d\x73\x5f\x63\x6f\x6e\x63\x61\x74\x73\x65\x6e\x64\x69\x6e\x67",};switch(
-iNewState){case SMS_STATE_INITING:case SMS_STATE_INITED:case SMS_STATE_LOADING:
-case SMS_STATE_LOADED:case SMS_STATE_SIM_LOADED:case SMS_STATE_SENDING:case
-SMS_STATE_SENDED:case SMS_STATE_DELING:case SMS_STATE_DELED:case
-SMS_STATE_RECVING:case SMS_STATE_RECVED:case SMS_STATE_DELSAVING:case
-SMS_STATE_DELSAVED:{break;}default:{return;}}sc_cfg_set(NV_SMS_STATE,
-ptStrSmsState[iNewState]);}int zUfiSms_CheckStoreDir(void){if(-
-(0x1f11+1232-0x23e0)==access(ZTE_WMS_DB_DIR,F_OK)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x25\x73\x20\x64\x6f\x65\x73\x20\x6e\x6f\x74\x20\x65\x78\x69\x73\x74\x2c\x73\x6f\x63\x72\x65\x61\x74\x65\x20\x69\x74\x2e" "\n"
-,ZTE_WMS_DB_DIR);if(-(0xc27+1129-0x108f)==mkdir(ZTE_WMS_DB_DIR,
-(0x5e3+5166-0x1812))){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x66\x61\x69\x6c\x65\x64\x20\x74\x6f\x20\x63\x72\x65\x61\x74\x65\x20\x64\x62\x20\x64\x69\x72\x2e" "\n"
-);return ZUFI_FAIL;}}return ZUFI_SUCC;}int zUfiSms_CheckSmsDb(void){if(-
-(0x16ec+2738-0x219d)==access(ZTE_WMS_DB_PATH,F_OK)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x25\x73\x20\x64\x6f\x65\x73\x20\x6e\x6f\x74\x20\x65\x78\x69\x73\x74\x2c\x73\x6f\x20\x67\x65\x74\x20\x64\x65\x66\x61\x75\x6c\x74\x20\x63\x6f\x6e\x66\x69\x67\x2e" "\n"
-,ZTE_WMS_DB_PATH);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x3d\x3d\x3d\x3d\x3d\x3d\x25\x73\x20\x65\x78\x69\x73\x74\x2e" "\n"
-,ZTE_WMS_DB_PATH);return ZUFI_SUCC;}void zUfiSms_GetDefaultCfgPara(void){
-unsigned char sts_flag=(0xb74+771-0xe77);unsigned char mem_store_flag=
-(0xfa6+3038-0x1b84);unsigned int tp_validity_period=(0xd53+2543-0x1742);char
-Temp_sms_vp[(0x1242+3892-0x216e)]={(0x1c6c+563-0x1e9f)};CHAR reportEnable[
-(0xa9b+2816-0x1569)]={(0x1633+2679-0x20aa)};CHAR smsLocation[(0x72+4280-0x10f8)]
-={(0x13b4+1090-0x17f6)};CHAR sendfailRetry[(0xf5a+873-0x1291)]={
-(0x37d+8203-0x2388)};CHAR outdateDelete[(0x1b6d+890-0x1eb5)]={(0x5d8+583-0x81f)}
-;CHAR defaultStore[(0xf4f+2795-0x1a08)]={(0x1658+2353-0x1f89)};sc_cfg_get(
-NV_REPORT_ENABLE,reportEnable,sizeof(reportEnable));sc_cfg_get(
-NV_SMS_LOCATION_SET,smsLocation,sizeof(smsLocation));sc_cfg_get(
-NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));sc_cfg_get(
-NV_OUTDATE_DELETE,outdateDelete,sizeof(outdateDelete));sc_cfg_get(
-NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));if((0x8e3+5065-0x1cac)==
-strcmp(reportEnable,"\x31")){sts_flag=(0x53b+6460-0x1e76);}g_zUfiSms_CurSmsPara.
-status_report_on=sts_flag;if((0x5df+3266-0x12a1)==strcmp(smsLocation,"\x4d\x45")
-){mem_store_flag=(0x64c+2947-0x11cf);}else{mem_store_flag=(0x926+7021-0x2492);}
-g_zUfiSms_CurSmsPara.mem_store=(unsigned int)((0x15b0+1099-0x19fb)==
-mem_store_flag?WMS_STORAGE_TYPE_NV_V01:WMS_STORAGE_TYPE_UIM_V01);sc_cfg_get(
-NV_SMS_VP,Temp_sms_vp,sizeof(Temp_sms_vp));tp_validity_period=
-(0x1f08+424-0x1fb1);if((0xb33+649-0xdbc)==strncmp(Temp_sms_vp,
-"\x6c\x6f\x6e\x67\x65\x73\x74",(0x12e7+688-0x1590))){tp_validity_period=
-(0x2592+411-0x262e);}if((0x19ef+741-0x1cd4)==strncmp(Temp_sms_vp,
-"\x6f\x6e\x65\x5f\x64\x61\x79",(0x18dd+2264-0x21ae))){tp_validity_period=
-(0x605+6972-0x209a);}if((0x12a1+64-0x12e1)==strncmp(Temp_sms_vp,
-"\x6f\x6e\x65\x77\x65\x65\x6b",(0x1724+2729-0x21c6))){tp_validity_period=
-(0x777+6585-0x2083);}if((0x579+2580-0xf8d)==strncmp(Temp_sms_vp,
-"\x74\x77\x65\x6c\x76\x65\x68",(0x1d09+1911-0x2479))){tp_validity_period=
-(0x181+8082-0x2084);}g_zUfiSms_CurSmsPara.tp_validity_period=tp_validity_period;
-if((0x66c+7869-0x2529)==strcmp(sendfailRetry,"\x31")){g_zUfiSms_CurSmsPara.
-sendfail_retry_on=(0x3c6+335-0x514);}else{g_zUfiSms_CurSmsPara.sendfail_retry_on
-=(0x871+1099-0xcbc);}if((0x1060+109-0x10cd)==strcmp(outdateDelete,"\x31")){
-g_zUfiSms_CurSmsPara.outdate_delete_on=(0x47c+2722-0xf1d);}else{
-g_zUfiSms_CurSmsPara.outdate_delete_on=(0x737+6363-0x2012);}if(
-(0x2bb+4231-0x1342)==strcmp(defaultStore,"\x73\x69\x6d")){strncpy(
-g_zUfiSms_CurSmsPara.default_store,"\x73\x69\x6d",sizeof(g_zUfiSms_CurSmsPara.
-default_store)-(0x38d+3933-0x12e9));}else{strncpy(g_zUfiSms_CurSmsPara.
-default_store,"\x6e\x76",sizeof(g_zUfiSms_CurSmsPara.default_store)-
-(0x5e8+6678-0x1ffd));}}void zUfiSms_GetDefaultPara(void){memset(&
-g_zUfiSms_CurSmsPara,(0x15e3+357-0x1748),sizeof(T_zUfiSms_ParaInfo));
-g_zUfiSms_CurSmsPara.status_report_on=(0x2a7+8614-0x244d);g_zUfiSms_CurSmsPara.
-mem_store=WMS_STORAGE_TYPE_NV_V01;g_zUfiSms_CurSmsPara.tp_validity_period=
-ZTE_WMS_SMS_DEFAULT_TP_VALIDITY_PERIOD_GW;g_zUfiSms_CurSmsPara.sendfail_retry_on
-=(0x7ea+2018-0xfcc);g_zUfiSms_CurSmsPara.outdate_delete_on=(0xd9f+364-0xf0b);
-strncpy(g_zUfiSms_CurSmsPara.default_store,"\x6e\x76",sizeof(
-g_zUfiSms_CurSmsPara.default_store)-(0x1c62+1280-0x2161));}
-#if (0x1903+2217-0x21ac)
-T_zUfiSms_CmdStatus zUfiSms_SetParameters(T_zUfiSms_CmdMsgBuff*ptSmsBuffer){
-T_zUfiSms_ParaInfo*ptSmsParameter=NULL;T_zUfiSms_ParaInfo tNewSmsParameter={
-(0x696+5609-0x1c7f)};if(NULL==ptSmsBuffer){return WMS_CMD_FAILED;}ptSmsParameter
-=(T_zUfiSms_ParaInfo*)(&(ptSmsBuffer->cmd_info.set_sms_para));memcpy((void*)&
-tNewSmsParameter,(void*)ptSmsParameter,sizeof(T_zUfiSms_ParaInfo));
+
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+#define SMS_RETRY_COUNT 3
+#define SHORT_INT_LEN 6
+
+/* ºê´¦Àí */
+
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+//¼Ç¼¶ÌÐŵĴ洢λÖÃ
+SMS_LOCATION g_zUfiSms_CurLocation = SMS_LOCATION_SIM;
+
+//²Î¿¼Êý£¬¼¶Áª¶ÌÐÅtpduÖеÄÒ»¸ö×ֶΣ¬Ï൱ÓÚ¶ÌÐŵÄID
+int g_zUfiSms_ConcatSmsReference = 0;
+
+/* ¼Ç¼µ±Ç°µÄһЩsms״̬ */
+T_zUfiSms_ParaInfo g_zUfiSms_CurSmsPara = {"",WMS_STORAGE_TYPE_UIM_V01,ZTE_WMS_SMS_DEFAULT_TP_VALIDITY_PERIOD_GW,0,0,0,"nv"};
+
+//¼Ç¼±àÂë¸ñʽÓëÓïÖÖ£¬±àÂëʱʹÓÃ
+int g_zUfiSms_Language = NOT_DEFINE_LANGUAGE;
+int g_zUfiSms_Dcs = 0;
+unsigned long g_zUfiSms_StoreCapablity[ZTE_WMS_MEMORY_MAX] = {100,ZTE_WMS_DB_MSG_COUNT_MAX};
+
+//×îÖÕÒª·¢Ë͸øAtµÄÄÚÈÝ
+T_zSms_SendSmsReq g_zUfiSms_FinalCmgsBuf;
+
+SMS_PARAM g_zUfiSms_SendingSms;
+UINT16 g_zUfiSms_IsLanguageShift = 0;
+
+extern int g_zUfiSms_MsgRefer;
+extern T_zUfiSms_DelSms g_zUfiSms_DelMsg;
+extern T_zUfiSms_DelIndexInfo g_deleteIndex;
+extern T_zUfiSms_ModifyIndexInfo g_modifyIndex;
+extern T_zUfiSms_ModifySms g_zUfiSms_modifyMsg;
+extern UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX];
+extern int g_zUfiSms_ConcatTotalNum;
+extern T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;
+extern T_zUfiSms_GroupInfo g_zUfiSms_GroupSms;
+extern int g_zUfiSms_UnitLen;
+extern UINT8 g_zUfiSms_IsConcatSendSuc;
+extern int g_zUfiSms_SendFailedCount;
+
+extern T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];
+extern int g_zUfiSms_SendFailedRetry;
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+
+/************************************
+ ÄÚ²¿¹¦Äܺ¯Êý
+************************************/
+void zUfiSms_SetSmsLocation(SMS_LOCATION eLocation)
+{
+ switch(eLocation)
+ {
+ case SMS_LOCATION_SIM:
+ {
+ g_zUfiSms_CurLocation = SMS_LOCATION_SIM;
+ break;
+ }
+ case SMS_LOCATION_ME:
+ {
+ g_zUfiSms_CurLocation = SMS_LOCATION_ME;
+ break;
+ }
+ default:
+ {
+ return;
+ }
+ }
+}
+
+
+
+/* »ñÈ¡ptDelMsgÖи÷idµÄ´æ´¢Î»Ö㬴æÈëg_zUfiSms_DelMsgÖÐ */
+int zUfiSms_SetDeleteInfo(T_zUfiSms_DelReq *ptDelMsg)
+{
+ char acStorePos[50];
+ int i = 0;
+
+ g_zUfiSms_DelMsg.nv_count = 0;
+ g_zUfiSms_DelMsg.nv_index = 0;
+ g_zUfiSms_DelMsg.sim_count = 0;
+ g_zUfiSms_DelMsg.sim_index = 0;
+ for(i = 0; i < ptDelMsg->all_or_count; i++)
+ {
+ memset(acStorePos,0,sizeof(acStorePos));
+ if(ZUFI_FAIL == zUfiSms_GetStorePosById("Mem_Store",acStorePos,sizeof(acStorePos),ptDelMsg->id[i]))
+ {
+ return ZUFI_FAIL;
+ }
+
+ if(0 == strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE))/*nv sms*/
+ {
+ g_zUfiSms_DelMsg.nv_id[g_zUfiSms_DelMsg.nv_count] = ptDelMsg->id[i];
+ g_zUfiSms_DelMsg.nv_count++;
+ g_zUfiSms_DelMsg.nv_index_count++;
+ }
+ else if(0 == strcmp(acStorePos,ZTE_WMS_DB_SIM_TABLE))/*sim sms*/
+ {
+ g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_count] = ptDelMsg->id[i];
+ g_zUfiSms_DelMsg.sim_count++;
+ g_zUfiSms_DelMsg.sim_index_count++;
+ }
+ }
+ return ZUFI_SUCC;
+}
+
+void zUfiSms_ChangeMainState(T_zUfiSms_MainState iNewState)
+{
+ char *ptStrSmsState[] =
+ { "sms_initing",
+ "sms_inited",
+ "sms_loading",
+ "sms_loaded",
+ "sms_sending",
+ "sms_sended",
+ "sms_deling",
+ "sms_deled",
+ "sms_recving",
+ "sms_recved",
+ "sms_saving",
+ "sms_saved",
+ "sms_delsaving",
+ "sms_delsaved",
+ "sms_sim_loaded",
+ "sms_setting",
+ "sms_haveset",
+ "sms_concatsending",
+ };
+
+ switch(iNewState)
+ {
+ case SMS_STATE_INITING:
+ case SMS_STATE_INITED:
+ case SMS_STATE_LOADING:
+ case SMS_STATE_LOADED:
+ case SMS_STATE_SIM_LOADED:
+ case SMS_STATE_SENDING:
+ case SMS_STATE_SENDED:
+ case SMS_STATE_DELING:
+ case SMS_STATE_DELED:
+ case SMS_STATE_RECVING:
+ case SMS_STATE_RECVED:
+ case SMS_STATE_DELSAVING:
+ case SMS_STATE_DELSAVED:
+ {
+ break;
+ }
+ default:
+ {
+ return;
+ }
+ }
+
+
+ sc_cfg_set(NV_SMS_STATE, ptStrSmsState[iNewState]);
+ //Èç¹û¼ÓÔØÁËsimÖеĶÌÐÅ£¬ÔÙ°ÑmeÖеĶÌÐżÓÔØÒ»´Î
+ /* if(SMS_STATE_SIM_LOADED == iNewState)
+ {
+ zUfiSms_LoadSmsFromMe();
+ }*/
+}
+
+int zUfiSms_CheckStoreDir(void)
+{
+ if (-1 == access(ZTE_WMS_DB_DIR,F_OK))
+ {
+ printf("[SMS] sms:%s does not exist,socreate it.\n",ZTE_WMS_DB_DIR);
+ if (-1 == mkdir(ZTE_WMS_DB_DIR, 0777))
+ {
+ printf("[SMS] sms:failed to create db dir.\n");
+ return ZUFI_FAIL;
+ }
+ }
+ return ZUFI_SUCC;
+}
+
+int zUfiSms_CheckSmsDb(void)
+{
+ if (-1 == access(ZTE_WMS_DB_PATH,F_OK))
+ {
+ printf("[SMS] sms:%s does not exist,so get default config.\n",ZTE_WMS_DB_PATH);
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] ======%s exist.\n",ZTE_WMS_DB_PATH);
+ return ZUFI_SUCC;
+}
+
+
+
+
+// if(-1 == unlink(ZTE_WMS_DB_FLAG))//ɾ³ýÎļþ
+
+/**´ÓcfgÖлñÈ¡µ±Ç°ÉèÖ㬴æÈëg_zUfiSms_CurSmsParaÖÐ */
+void zUfiSms_GetDefaultCfgPara(void)
+{
+ unsigned char sts_flag = 0;
+ unsigned char mem_store_flag = 0;
+ unsigned int tp_validity_period = 0;
+ char Temp_sms_vp[8] = {0};
+ CHAR reportEnable[50]={0};
+ CHAR smsLocation[50]={0};
+ CHAR sendfailRetry[50]={0};
+ CHAR outdateDelete[50]={0};
+ CHAR defaultStore[50]={0};
+
+ sc_cfg_get(NV_REPORT_ENABLE,reportEnable,sizeof(reportEnable));
+ sc_cfg_get(NV_SMS_LOCATION_SET,smsLocation,sizeof(smsLocation));
+ sc_cfg_get(NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));
+ sc_cfg_get(NV_OUTDATE_DELETE,outdateDelete,sizeof(outdateDelete));
+ sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
+
+ if(0 == strcmp(reportEnable, "1"))
+ {
+ sts_flag = 1;
+ }
+ g_zUfiSms_CurSmsPara.status_report_on = sts_flag;
+
+ if(0== strcmp(smsLocation, "ME"))
+ {
+ mem_store_flag = 0;
+ }
+ else
+ {
+ mem_store_flag = 1;
+ }
+
+ g_zUfiSms_CurSmsPara.mem_store = (unsigned int)(0 == mem_store_flag ? WMS_STORAGE_TYPE_NV_V01 : WMS_STORAGE_TYPE_UIM_V01);
+
+ sc_cfg_get(NV_SMS_VP,Temp_sms_vp,sizeof(Temp_sms_vp));
+ tp_validity_period = 0xFF;
+
+ if( 0 == strncmp(Temp_sms_vp,"longest",7))
+ {
+ tp_validity_period = 0xFF;
+ }
+ if(0 == strncmp(Temp_sms_vp,"one_day",7))
+ {
+ tp_validity_period = 0xA7;
+ }
+ if(0 == strncmp(Temp_sms_vp,"oneweek",7))
+ {
+ tp_validity_period = 0xAD;
+ }
+ if(0 == strncmp(Temp_sms_vp,"twelveh",7))
+ {
+ tp_validity_period = 0x8F;
+ }
+ g_zUfiSms_CurSmsPara.tp_validity_period = tp_validity_period;
+
+ if(0 == strcmp(sendfailRetry, "1"))
+ {
+ g_zUfiSms_CurSmsPara.sendfail_retry_on = 1;
+ }
+ else
+ {
+ g_zUfiSms_CurSmsPara.sendfail_retry_on = 0;
+ }
+ if(0 == strcmp(outdateDelete, "1"))
+ {
+ g_zUfiSms_CurSmsPara.outdate_delete_on= 1;
+ }
+ else
+ {
+ g_zUfiSms_CurSmsPara.outdate_delete_on= 0;
+ }
+ if(0 == strcmp(defaultStore, "sim"))
+ {
+ strncpy(g_zUfiSms_CurSmsPara.default_store,"sim",sizeof(g_zUfiSms_CurSmsPara.default_store)-1);
+ }
+ else
+ {
+ strncpy(g_zUfiSms_CurSmsPara.default_store,"nv",sizeof(g_zUfiSms_CurSmsPara.default_store)-1);
+ }
+}
+
+/* *»ñȡĬÈϲÎÊý */
+void zUfiSms_GetDefaultPara(void)
+{
+ memset(&g_zUfiSms_CurSmsPara,0,sizeof(T_zUfiSms_ParaInfo));
+
+ g_zUfiSms_CurSmsPara.status_report_on = 0;
+ g_zUfiSms_CurSmsPara.mem_store = WMS_STORAGE_TYPE_NV_V01;
+ g_zUfiSms_CurSmsPara.tp_validity_period = ZTE_WMS_SMS_DEFAULT_TP_VALIDITY_PERIOD_GW;
+ g_zUfiSms_CurSmsPara.sendfail_retry_on = 0;
+ g_zUfiSms_CurSmsPara.outdate_delete_on = 0;
+ strncpy(g_zUfiSms_CurSmsPara.default_store, "nv",sizeof(g_zUfiSms_CurSmsPara.default_store)-1);
+}
+
+#if 0
+T_zUfiSms_CmdStatus zUfiSms_SetParameters(T_zUfiSms_CmdMsgBuff *ptSmsBuffer)
+{
+ T_zUfiSms_ParaInfo *ptSmsParameter = NULL;
+ T_zUfiSms_ParaInfo tNewSmsParameter ={0};
+
+ if(NULL == ptSmsBuffer)
+ {
+ return WMS_CMD_FAILED;
+ }
+ ptSmsParameter = (T_zUfiSms_ParaInfo*)(&(ptSmsBuffer->cmd_info.set_sms_para));
+
+ memcpy((void*)&tNewSmsParameter,(void*)ptSmsParameter,sizeof(T_zUfiSms_ParaInfo));
+
#ifndef TSP_MODEL
-if((g_zUfiSms_CurSmsPara.mem_store!=ptSmsParameter->mem_store)){if(
-ZUFI_SMS_FAILURE==zUfiSms_SetCpms(ptSmsParameter)){at_print(LOG_ERR,
-"\x73\x65\x74\x20\x63\x66\x67\x20\x72\x6f\x75\x74\x65\x73\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return WMS_CMD_FAILED;}}
+ //ͨ¹ýCPMSÀ´ÉèÖöÌÐŵĴ洢λÖÃ
+ if ((g_zUfiSms_CurSmsPara.mem_store != ptSmsParameter->mem_store) )
+ {
+ if (ZUFI_SMS_FAILURE == zUfiSms_SetCpms(ptSmsParameter))
+ {
+ at_print(LOG_ERR,"set cfg routes failed.");
+ return WMS_CMD_FAILED;
+ }
+ }
#endif
-if(strlen(ptSmsParameter->sca)!=(0x123f+2364-0x1b7b)){if(ZUFI_SMS_FAILURE==
-zUfiSms_SetCsca(ptSmsParameter)){return WMS_CMD_FAILED;}}if(ZUFI_SMS_FAILURE==
-zUfiSms_SetDbParameters(ptSmsParameter)){return WMS_CMD_FAILED;}else{sc_cfg_set(
-"\x73\x6d\x73\x5f\x63\x65\x6e\x74\x65\x72\x5f\x6e\x75\x6d",ptSmsParameter->sca);
-}memcpy((void*)&g_zUfiSms_CurSmsPara,(void*)&tNewSmsParameter,sizeof(
-T_zUfiSms_ParaInfo));return WMS_CMD_SUCCESS;}
+
+ if (strlen(ptSmsParameter->sca) != 0)
+ {
+ if (ZUFI_SMS_FAILURE == zUfiSms_SetCsca(ptSmsParameter))
+ {
+ return WMS_CMD_FAILED;
+ }
+ }
+
+ /* ²ÎÊý´æÈëÊý¾Ý¿â */
+ if(ZUFI_SMS_FAILURE == zUfiSms_SetDbParameters(ptSmsParameter))
+ {
+ return WMS_CMD_FAILED;
+ }
+ else
+ {
+ sc_cfg_set("sms_center_num",ptSmsParameter->sca);
+ }
+
+ memcpy((void*)&g_zUfiSms_CurSmsPara,(void*)&tNewSmsParameter,sizeof(T_zUfiSms_ParaInfo));
+ return WMS_CMD_SUCCESS;
+}
#endif
-int zUfiSms_LoadSmsPara(){int count=(0x509+8303-0x2578);if(ZUFI_SUCC!=
-zUfiSms_IsDbEmpty(ZTE_WMS_DB_PARAMETER_TABLE,&count)){return ZUFI_FAIL;}if(count
-==(0x206+767-0x505)){zUfiSms_GetDefaultCfgPara();if((0x2e7+5231-0x1756)!=
-zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara)){return ZUFI_FAIL;}}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x68\x61\x76\x65\x20\x64\x65\x66\x61\x75\x6c\x74\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x20\x69\x6e\x20\x64\x61\x74\x61\x62\x61\x73\x65\x2e" "\n"
-);if(ZUFI_SUCC!=zUfiSms_GetDbParameters()){return ZUFI_FAIL;}if(
-WMS_STORAGE_TYPE_NV_V01!=g_zUfiSms_CurSmsPara.mem_store&&
-WMS_STORAGE_TYPE_UIM_V01!=g_zUfiSms_CurSmsPara.mem_store){zUfiSms_GetDefaultPara
-();if((0x1ec+3612-0x1008)!=zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara)){
-printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x74\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73\x20\x66\x61\x69\x6c\x73\x20\x32\x2e" "\n"
-);return ZUFI_FAIL;}}}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4c\x6f\x61\x64\x53\x6d\x73\x50\x61\x72\x61\x20\x73\x75\x63\x63\x2e" "\n"
-);return ZUFI_SUCC;}int zUfiSms_CheckMemoryFull(T_zUfiSms_MemoryType mem_store){
-int total_count=(0x8f1+6933-0x2406);if((ZTE_WMS_MEMORY_SIM==mem_store)||(
-ZTE_WMS_MEMORY_MAX==mem_store)){if(ZUFI_FAIL==zUfiSms_GetTotalCount(
-ZTE_WMS_DB_SIM_TABLE,&total_count)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x67\x65\x74\x20\x74\x61\x62\x6c\x65\x20\x74\x6f\x74\x61\x6c\x20\x63\x6f\x75\x6e\x74\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x68\x65\x63\x6b\x4d\x65\x6d\x6f\x72\x79\x46\x75\x6c\x6c\x20\x67\x65\x74\x20\x73\x69\x6d\x20\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2e" "\n"
-,total_count);if(total_count>=(int)g_zUfiSms_StoreCapablity[
-WMS_STORAGE_TYPE_UIM_V01]){g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01]=TRUE;
-}else{g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01]=FALSE;}}if((
-ZTE_WMS_MEMORY_NV==mem_store)||(ZTE_WMS_MEMORY_MAX==mem_store)){if(ZUFI_FAIL==
-zUfiSms_GetTotalCount(ZTE_WMS_DB_NV_TABLE,&total_count)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x3a\x67\x65\x74\x20\x74\x61\x62\x6c\x65\x20\x74\x6f\x74\x61\x6c\x20\x63\x6f\x75\x6e\x74\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x68\x65\x63\x6b\x4d\x65\x6d\x6f\x72\x79\x46\x75\x6c\x6c\x20\x67\x65\x74\x20\x4d\x45\x20\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2e" "\n"
-,total_count);if(total_count>=(int)g_zUfiSms_StoreCapablity[
-WMS_STORAGE_TYPE_NV_V01]){g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]=TRUE;}
-else{g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]=FALSE;}}return ZUFI_SUCC;}
-int zUfiSms_SetStorePara(char*mem_store){if((0x495+3868-0x13b1)==strcmp(
-mem_store,"\x53\x4d")){g_zUfiSms_CurSmsPara.mem_store=(unsigned int)
-WMS_STORAGE_TYPE_UIM_V01;(void)sc_cfg_set(NV_SMS_LOCATION_SET,"\x30");}else if(
-(0x1810+1680-0x1ea0)==strcmp(mem_store,"\x4d\x45")){g_zUfiSms_CurSmsPara.
-mem_store=(unsigned int)WMS_STORAGE_TYPE_NV_V01;(void)sc_cfg_set(
-NV_SMS_LOCATION_SET,"\x31");}else if((0x434+2254-0xd02)==strcmp(mem_store,
-"\x53\x52")){g_zUfiSms_CurSmsPara.mem_store=(unsigned int)(0x180b+1106-0x1c5b);(
-void)sc_cfg_set(NV_SMS_LOCATION_SET,"\x32");}else{g_zUfiSms_CurSmsPara.mem_store
-=(unsigned int)WMS_STORAGE_TYPE_NONE_V01;(void)sc_cfg_set(NV_SMS_LOCATION_SET,
-"\x2d\x31");}if(ZUFI_FAIL==zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara)){
-at_print(LOG_ERR,
-"\x63\x61\x6e\x20\x6e\x6f\x74\x20\x73\x65\x74\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73\x2e" "\n"
-);return ZUFI_FAIL;}return ZUFI_SUCC;}int zUfiSms_SetScaPara(char*sca){strncpy(
-g_zUfiSms_CurSmsPara.sca,sca,sizeof(g_zUfiSms_CurSmsPara.sca)-
-(0xa53+3152-0x16a2));if(ZUFI_FAIL==zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara
-)){at_print(LOG_ERR,
-"\x63\x61\x6e\x20\x6e\x6f\x74\x20\x73\x65\x74\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73\x2e" "\n"
-);return ZUFI_FAIL;}return ZUFI_SUCC;}void zUfiSms_SetGlobalDcsLang(unsigned
-char cDcs){if(cDcs==(0x3+2938-0xb7c)){g_zUfiSms_Dcs=DCS_ASC;g_zUfiSms_Language=
-NOT_DEFINE_LANGUAGE;}else if(cDcs==(0x8cf+7468-0x25f9)){g_zUfiSms_Dcs=DCS_USC;
-g_zUfiSms_Language=NOT_DEFINE_LANGUAGE;}else if(cDcs==(0x2d8+8657-0x24a6)){
-g_zUfiSms_Dcs=DCS_ASC;g_zUfiSms_Language=DCS_GSM7_SPANISH;}else if(cDcs==
-(0x1388+197-0x1448)){g_zUfiSms_Dcs=DCS_ASC;g_zUfiSms_Language=
-DCS_GSM7_PORTUGUESE;}else{g_zUfiSms_Dcs=DCS_ASC;g_zUfiSms_Language=
-DCS_GSM7_DEFAULT;}}int zUfiSms_FillGroupSms(T_zUfiSms_SendReq*ptSendMsg,
-T_zUfiSms_GroupInfo*ptGroupSms){int i;if(NULL==ptSendMsg||NULL==ptGroupSms||
-ZTE_WMS_SEND_NUM_MAX<ptSendMsg->receiver_count){return ZUFI_FAIL;}ptGroupSms->
-total_receiver=ptSendMsg->receiver_count;for(i=(0xbfd+928-0xf9d);i<ptGroupSms->
-total_receiver;i++){strncpy(ptGroupSms->receivers[i],ptSendMsg->dest_num[i],
-ZTE_WMS_ADDRESS_LEN_MAX);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x46\x69\x6c\x6c\x47\x72\x6f\x75\x70\x53\x6d\x73\x20\x72\x65\x63\x65\x69\x76\x65\x72\x73\x5b\x25\x64\x5d\x3d\x25\x73" "\n"
-,i,ptGroupSms->receivers[i]);}ptGroupSms->current_receiver=(0x43+1780-0x737);
-return ZUFI_SUCC;}int zUfiSms_FillConcatSms(T_zUfiSms_SendReq*pSendSrcMsg,
-T_zUfiSms_ConcatInfo*pDestConcatMsg){int iTotalLen=(0xf12+1020-0x130e);int
-iUnitlen=(0x293+9207-0x268a);int iSegNo=(0x1b9f+969-0x1f68);unsigned char*
-pSmsConverted=NULL;unsigned char acConvertContent[
-ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX*
-(0x1612+1696-0x1cae)+(0x65+8665-0x223a)]={(0xa2+4202-0x110c)};unsigned char
-acTmpContent[ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX*
-(0xcf7+2077-0x1510)+(0x3a2+6293-0x1c33)]={(0x171f+857-0x1a78)};int iTimeZone=
-(0x1b39+724-0x1e0d);int tmp_i=(0x778+4629-0x198d);if(NULL==pSendSrcMsg||NULL==
-pDestConcatMsg){return-(0x117f+4781-0x242b);}iTotalLen=pSendSrcMsg->msg_len;if(
-ZUFI_FAIL==zUfiSms_GetSmsContent(acTmpContent,sizeof(acTmpContent))){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x53\x6d\x73\x43\x6f\x6e\x74\x65\x6e\x74\x20\x46\x61\x69\x6c\x2e" "\n"
-);return-(0x9eb+1499-0xfc5);}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x53\x6d\x73\x43\x6f\x6e\x74\x65\x6e\x74\x3a\x25\x73\x2e" "\n"
-,acTmpContent);(void)String2Bytes(acTmpContent,acConvertContent,(int)strlen(
-acTmpContent));memset(acTmpContent,(0x2a8+835-0x5eb),sizeof(acTmpContent));if(
-DCS_USC==g_zUfiSms_Dcs){pSmsConverted=acConvertContent;}else{if(
-NOT_DEFINE_LANGUAGE==g_zUfiSms_Language){iTotalLen=
-zUfiSms_ConvertAsciiToGsmDefault(acConvertContent,acTmpContent,pSendSrcMsg->
-msg_len);}else if(DCS_GSM7_SPANISH==g_zUfiSms_Language){iTotalLen=
-zUfiSms_ConvertUcs2ToSpanish(acConvertContent,acTmpContent,pSendSrcMsg->msg_len)
-;}else if(DCS_GSM7_PORTUGUESE==g_zUfiSms_Language){iTotalLen=
-zUfiSms_ConvertUcs2ToPortuguese(acConvertContent,acTmpContent,pSendSrcMsg->
-msg_len);}else{iTotalLen=zUfiSms_ConvertUcs2ToGsmDefault(acConvertContent,
-acTmpContent,pSendSrcMsg->msg_len);}pSendSrcMsg->msg_len=iTotalLen;pSmsConverted
-=acTmpContent;}if(iTotalLen>(sizeof(acConvertContent)-(0x2b6+8739-0x24d8))){
-iTotalLen=sizeof(acConvertContent)-(0xf2a+647-0x11b0);}pDestConcatMsg->sms_len=
-iTotalLen;if((iTotalLen>ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX)||(g_zUfiSms_Language==
-DCS_PORTUGUESE&&iTotalLen>(0xbe8+5765-0x21d2))||((g_zUfiSms_Dcs==DCS_USC)&&
-iTotalLen>ZTE_WMS_SMS_MSG_CHAR_MAX)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x3d\x3d\x3d\x3d\x3d\x73\x65\x6e\x64\x20\x63\x6f\x6e\x74\x61\x63\x74\x20\x73\x6d\x73\x2e" "\n"
-);if(g_zUfiSms_Dcs==DCS_USC){iUnitlen=ZTE_WMS_SMS_CONCAT_ELEMNT_UCS_LEN*
-(0x1ff+5872-0x18ed);}else{if(g_zUfiSms_Language==NOT_DEFINE_LANGUAGE||
-g_zUfiSms_Language==DCS_GSM7_DEFAULT){iUnitlen=ZTE_WMS_SMS_CONCAT_ELEMNT_ASC_LEN
-;}else{iUnitlen=ZTE_WMS_SMS_CONCAT_ELEMNT_LANGUAGE_LEN;}}while(iTotalLen>
-(0x1ae6+2389-0x243b)&&iSegNo<ZTE_WMS_CONCAT_SMS_COUNT_MAX){memcpy(pDestConcatMsg
-->msg_contents[iSegNo],pSmsConverted,iUnitlen);iTotalLen-=iUnitlen;pSmsConverted
-+=iUnitlen;iSegNo++;}pDestConcatMsg->total_msg=iSegNo;}else{iUnitlen=iTotalLen;
-pDestConcatMsg->total_msg=(0x446+7745-0x2286);memcpy(pDestConcatMsg->
-msg_contents[(0x1877+1845-0x1fac)],pSmsConverted,iTotalLen);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x3d\x3d\x3d\x3d\x3d\x73\x65\x6e\x64\x20\x6e\x6f\x72\x6d\x61\x6c\x20\x73\x6d\x73\x2e\x6c\x65\x6e\x3a\x25\x64\x2e\x63\x6f\x6e\x74\x65\x6e\x74\x3a\x25\x73\x2e" "\n"
-,iUnitlen,pDestConcatMsg->msg_contents[(0x1238+1816-0x1950)]);}
-g_zUfiSms_ConcatTotalNum=pDestConcatMsg->total_msg;pDestConcatMsg->
-current_sending=(0x18a5+3672-0x26fd);memcpy(&(pDestConcatMsg->date),&(
-pSendSrcMsg->date),sizeof(T_zUfiSms_Date));tmp_i=atoi(pDestConcatMsg->date.
-timezone);if(tmp_i<INT_MIN+(0x6d8+5810-0x1d89)||tmp_i>INT_MAX-
-(0x1935+426-0x1ade)){printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x70\x44\x65\x73\x74\x43\x6f\x6e\x63\x61\x74\x4d\x73\x67\x20\x74\x69\x6d\x65\x7a\x6f\x6e\x65\x3a\x25\x64\x2e" "\n"
-,tmp_i);return ZUFI_FAIL;}iTimeZone=tmp_i*(0xf73+1127-0x13d6);memset(
-pDestConcatMsg->date.timezone,(0x821+1718-0xed7),sizeof(pDestConcatMsg->date.
-timezone));if(iTimeZone>(0x95a+4216-0x19d2)){snprintf(pDestConcatMsg->date.
-timezone,sizeof(pDestConcatMsg->date.timezone),"\x2b\x25\x64",iTimeZone);}else{
-snprintf(pDestConcatMsg->date.timezone,sizeof(pDestConcatMsg->date.timezone),
-"\x25\x64",iTimeZone);}pSmsConverted=NULL;return iUnitlen;}void
-zUfiSms_FillDateheader(T_zUfiSms_SubmitTpdu*ptSubmit,T_zUfiSms_ConcatInfo*
-ptConcatSms,T_zUfiSms_DbStoreData*ptDbSaveData){unsigned char iHeaderNum=
-(0xe98+1927-0x161f);iHeaderNum=ptSubmit->user_data.num_headers;ptSubmit->
-user_data_header_present=TRUE;if((0x2fa+4772-0x159e)==ptConcatSms->
-current_sending){g_zUfiSms_ConcatSmsReference++;(void)zUfiSms_SetConcatMaxRefer(
-g_zUfiSms_ConcatSmsReference);}ptSubmit->user_data.headers[iHeaderNum].header_id
-=WMS_UDH_CONCAT_8;ptSubmit->user_data.headers[iHeaderNum].u.concat_8.total_sm=
-ptConcatSms->total_msg;ptSubmit->user_data.headers[iHeaderNum].u.concat_8.
-seq_num=ptConcatSms->current_sending+(0xd25+1183-0x11c3);ptSubmit->user_data.
-headers[iHeaderNum].u.concat_8.msg_ref=g_zUfiSms_ConcatSmsReference%
-(0xba9+3165-0x1707);ptSubmit->user_data.num_headers++;ptDbSaveData->concat_sms=
-(0xbbd+5008-0x1f4c);ptDbSaveData->concat_info[(0x1331+1560-0x1949)]=
-g_zUfiSms_ConcatSmsReference;}int zUfiSms_MakeFinalCmgsBuf(){SMS_PARAM tSmsData;
-int iPduLength=(0xbbf+1639-0x1226);int nSmscLength=(0x1867+3565-0x2654);char
-Tempstrr[(0x1a88+1527-0x207d)]={(0xfe9+3657-0x1e32)};char Temp_sms_vp[
-(0x926+4924-0x1c5a)]={(0x1e96+1802-0x25a0)};char tmpBuf1[(0x1ab7+1863-0x21fb)]={
-(0x1b9c+2078-0x23ba)};char tmpBuf2[(0x19a4+2671-0x240d)]={(0x456+4576-0x1636)};
-CHAR smsCenter[(0x623+8436-0x26e5)]={(0x1871+2186-0x20fb)};memset(&tSmsData,
-(0x438+4399-0x1567),sizeof(SMS_PARAM));memset(&g_zUfiSms_FinalCmgsBuf,
-(0x161b+1818-0x1d35),sizeof(T_zSms_SendSmsReq));if(CODE_GSM7==
-g_zUfiSms_SendingSms.TP_DCS){int i=(0x10e0+3475-0x1e73);for(;i<
-g_zUfiSms_SendingSms.TP_UDLength;i++){tSmsData.TP_UD[i]=g_zUfiSms_SendingSms.
-TP_UD[i];}tSmsData.TP_UDLength=g_zUfiSms_SendingSms.TP_UDLength;}else{snprintf(
-tSmsData.TP_UD,sizeof(tSmsData.TP_UD),"\x25\x73",g_zUfiSms_SendingSms.TP_UD);
-tSmsData.TP_UDLength=strlen(tSmsData.TP_UD);}sc_cfg_get(NV_SMS_CENTER_NUM,
-smsCenter,sizeof(smsCenter));snprintf(tSmsData.SCA,sizeof(tSmsData.SCA),
-"\x25\x73",smsCenter);snprintf(tSmsData.TPA,sizeof(tSmsData.TPA),"\x25\x73",
-g_zUfiSms_SendingSms.TPA);tSmsData.TP_DCS=g_zUfiSms_SendingSms.TP_DCS;sc_cfg_get
-(NV_REPORT_ENABLE,Tempstrr,sizeof(Tempstrr));if(((0xdd1+2444-0x175d)==strncmp(
-Tempstrr,"\x31",(0x16f4+2721-0x2194)))&&(g_zUfiSms_ConcatSms.current_sending==
-g_zUfiSms_ConcatSms.total_msg-(0x11e5+1031-0x15eb))){tSmsData.TP_SRR=
-(0x1238+597-0x148c);}else{tSmsData.TP_SRR=(0x2fd+6767-0x1d6c);}tSmsData.TP_UDHI=
-g_zUfiSms_SendingSms.TP_UDHI;tSmsData.TP_VP=(0xb41+4294-0x1b08);sc_cfg_get(
-NV_SMS_VP,Temp_sms_vp,sizeof(Temp_sms_vp));if((0x304+8858-0x259e)==strncmp(
-Temp_sms_vp,"\x6c\x6f\x6e\x67\x65\x73\x74",(0x1fd2+1519-0x25ba))){tSmsData.TP_VP
-=(0x1205+4361-0x220f);}else if((0x1e49+1888-0x25a9)==strncmp(Temp_sms_vp,
-"\x6f\x6e\x65\x5f\x64\x61\x79",(0x1b1+5187-0x15ed))){tSmsData.TP_VP=
-(0x191b+2426-0x21ee);}else if((0xb2b+6214-0x2371)==strncmp(Temp_sms_vp,
-"\x6f\x6e\x65\x77\x65\x65\x6b",(0x1532+1845-0x1c60))){tSmsData.TP_VP=
-(0xd8d+4747-0x1f6b);}else if((0x370+1356-0x8bc)==strncmp(Temp_sms_vp,
-"\x74\x77\x65\x6c\x76\x65\x68",(0x1b9b+991-0x1f73))){tSmsData.TP_VP=
-(0x9af+3209-0x15a9);}tSmsData.TP_PID=(0x174a+1574-0x1d70);
-#if (0x466+5982-0x1bc3)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x62\x65\x67\x69\x6e\x3a\x25\x73" "\n",
-g_zUfiSms_FinalCmgsBuf.pdu);
-#endif
-iPduLength=EncodePdu_Submit(&tSmsData,g_zUfiSms_FinalCmgsBuf.pdu);
-#if (0x18ac+2157-0x2118)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4d\x61\x6b\x65\x46\x69\x6e\x61\x6c\x43\x6d\x67\x73\x42\x75\x66\x20\x6d\x61\x6b\x65\x20\x70\x64\x75\x20\x64\x61\x74\x61" "\n"
-);printf("\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x25\x73" "\n",
-g_zUfiSms_FinalCmgsBuf.pdu);
+
+
+/***/
+int zUfiSms_LoadSmsPara()
+{
+ int count = 0;
+ if(ZUFI_SUCC != zUfiSms_IsDbEmpty(ZTE_WMS_DB_PARAMETER_TABLE, &count))
+ {
+ return ZUFI_FAIL;
+ }
+
+ if(count == 0)
+ {
+ // Êý¾Ý¿âΪ¿Õ£¬´ÓÉèÖõÄNVÖлñÈ¡Êý¾ÝÀ´ÉèÖÃ
+ zUfiSms_GetDefaultCfgPara();
+ if(0 != zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara))
+ {
+ return ZUFI_FAIL;
+ }
+ }
+ else
+ {
+ printf("[SMS] have default parameter in database.\n");
+ if(ZUFI_SUCC != zUfiSms_GetDbParameters())
+ {
+ return ZUFI_FAIL;
+ }
+ if(WMS_STORAGE_TYPE_NV_V01 != g_zUfiSms_CurSmsPara.mem_store &&
+ WMS_STORAGE_TYPE_UIM_V01 != g_zUfiSms_CurSmsPara.mem_store)
+ {
+ //Êý¾ÝÒÑ´æÔÚ£¬µ«³ö´í£¬Ç¿ÖÆÊ¹ÓÃĬÈÏÖµ
+ zUfiSms_GetDefaultPara();
+ if(0 != zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara))
+ {
+ printf("[SMS] set parameters fails 2.\n");
+ return ZUFI_FAIL;
+ }
+ }
+ }
+ printf("[SMS] zUfiSms_LoadSmsPara succ.\n");
+ return ZUFI_SUCC;
+}
+
+/*ÉèÖÃsimºÍnvÊÇ·ñÒÑÂú±ê¼Ç **/
+int zUfiSms_CheckMemoryFull(T_zUfiSms_MemoryType mem_store)
+{
+ int total_count = 0;
+ /* check sim WMS_STORAGE_TYPE_UIM_V01*/
+ if ((ZTE_WMS_MEMORY_SIM == mem_store)||(ZTE_WMS_MEMORY_MAX == mem_store))
+ {
+ if(ZUFI_FAIL == zUfiSms_GetTotalCount(ZTE_WMS_DB_SIM_TABLE,&total_count))
+ {
+ printf("[SMS] sms:get table total count failed.\n");
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] zUfiSms_CheckMemoryFull get sim count:%d.\n",total_count);
+ if(total_count >= (int)g_zUfiSms_StoreCapablity[WMS_STORAGE_TYPE_UIM_V01])
+ {
+ g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01] = TRUE;
+ }
+ else
+ {
+ g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01] = FALSE;
+ }
+ }
+ /* check nv WMS_STORAGE_TYPE_NV_V01*/
+ if((ZTE_WMS_MEMORY_NV == mem_store ) ||(ZTE_WMS_MEMORY_MAX == mem_store ))
+ {
+ if(ZUFI_FAIL == zUfiSms_GetTotalCount(ZTE_WMS_DB_NV_TABLE,&total_count))
+ {
+ printf("[SMS] sms:get table total count failed.\n");
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] zUfiSms_CheckMemoryFull get ME count:%d.\n",total_count);
+ if(total_count >= (int)g_zUfiSms_StoreCapablity[WMS_STORAGE_TYPE_NV_V01])
+ {
+ g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01] = TRUE;
+ }
+ else
+ {
+ g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01] = FALSE;
+ }
+ }
+
+ return ZUFI_SUCC;
+}
+
+int zUfiSms_SetStorePara(char *mem_store)
+{
+ if(0 == strcmp(mem_store,"SM"))
+ {
+ g_zUfiSms_CurSmsPara.mem_store = (unsigned int)WMS_STORAGE_TYPE_UIM_V01;
+ (void)sc_cfg_set(NV_SMS_LOCATION_SET, "0");
+ }
+ else if(0 == strcmp(mem_store,"ME"))
+ {
+ g_zUfiSms_CurSmsPara.mem_store = (unsigned int)WMS_STORAGE_TYPE_NV_V01;
+ (void)sc_cfg_set(NV_SMS_LOCATION_SET, "1");
+ }
+ else if(0 == strcmp(mem_store,"SR"))
+ {
+ g_zUfiSms_CurSmsPara.mem_store = (unsigned int)2;
+ (void)sc_cfg_set(NV_SMS_LOCATION_SET, "2"); // ´ú±íSR
+ }
+ else
+ {
+ g_zUfiSms_CurSmsPara.mem_store = (unsigned int)WMS_STORAGE_TYPE_NONE_V01;
+ (void)sc_cfg_set(NV_SMS_LOCATION_SET, "-1");
+ }
+
+ if(ZUFI_FAIL == zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara))
+ {
+ at_print(LOG_ERR,"can not set parameters.\n");
+ return ZUFI_FAIL;
+ }
+ return ZUFI_SUCC;
+
+}
+int zUfiSms_SetScaPara(char *sca)
+{
+ strncpy(g_zUfiSms_CurSmsPara.sca,sca,sizeof(g_zUfiSms_CurSmsPara.sca)-1);
+
+ if(ZUFI_FAIL == zUfiSms_SetDbParameters(&g_zUfiSms_CurSmsPara))
+ {
+ at_print(LOG_ERR,"can not set parameters.\n");
+ return ZUFI_FAIL;
+ }
+ return ZUFI_SUCC;
+
+}
+
+/* ¸ù¾Ý±àÂ뷽ʽÉèÖÃÈ«¾ÖÊý¾Ý
+ cDcs 1-->ASCII, 2-->UNICODE, 3-->GSM7 SPANISH, 4-->GSM7 DEFAULT, 5-->GSM7 PORTUGUESE */
+void zUfiSms_SetGlobalDcsLang(unsigned char cDcs)
+{
+ if (cDcs == 1)
+ {
+ g_zUfiSms_Dcs = DCS_ASC;
+ g_zUfiSms_Language = NOT_DEFINE_LANGUAGE;
+ }
+ else if (cDcs == 2)
+ {
+ g_zUfiSms_Dcs = DCS_USC;
+ g_zUfiSms_Language = NOT_DEFINE_LANGUAGE ;
+ }
+ else if (cDcs == 3)
+ {
+ g_zUfiSms_Dcs = DCS_ASC;
+ g_zUfiSms_Language = DCS_GSM7_SPANISH;
+ }
+ else if (cDcs == 5)
+ {
+ g_zUfiSms_Dcs = DCS_ASC;
+ g_zUfiSms_Language = DCS_GSM7_PORTUGUESE;
+ }
+ else
+ {
+ g_zUfiSms_Dcs = DCS_ASC;
+ g_zUfiSms_Language = DCS_GSM7_DEFAULT;
+ }
+}
+
+/* Ìî³äҪȺ·¢¶ÌÐŵĺÅÂëÊýÁ¿ºÍ¸÷ºÅÂ룬·ÅÔÚgroup_smsÖÐ */
+int zUfiSms_FillGroupSms(T_zUfiSms_SendReq *ptSendMsg, T_zUfiSms_GroupInfo *ptGroupSms)
+{
+ int i;
+
+ if(NULL == ptSendMsg || NULL == ptGroupSms || ZTE_WMS_SEND_NUM_MAX < ptSendMsg->receiver_count)
+ {
+ return ZUFI_FAIL;
+ }
+
+ ptGroupSms->total_receiver = ptSendMsg->receiver_count;
+ for(i = 0; i < ptGroupSms->total_receiver; i++)
+ {
+ strncpy(ptGroupSms->receivers[i],ptSendMsg->dest_num[i],ZTE_WMS_ADDRESS_LEN_MAX);
+ printf("[SMS] zUfiSms_FillGroupSms receivers[%d]=%s\n",i,ptGroupSms->receivers[i]);
+ }
+ ptGroupSms->current_receiver = 0;
+
+ return ZUFI_SUCC;
+}
+
+/* ½«³¤¶ÌÐÅpSendSrcMsg²ð·Ö³É¼¶Áª¶ÌÐÅpDestConcatMsg,·µ»Ø×ܳ¤¶È */
+int zUfiSms_FillConcatSms (T_zUfiSms_SendReq *pSendSrcMsg, T_zUfiSms_ConcatInfo *pDestConcatMsg )
+{
+ int iTotalLen = 0;
+ int iUnitlen = 0;
+ int iSegNo = 0;
+ unsigned char *pSmsConverted = NULL; //Ö¸ÏòÒª¿½±´µÄ×Ö·û´®
+ unsigned char acConvertContent[ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX * ZTE_WMS_CONCAT_SMS_COUNT_MAX *4+4]={0};
+ unsigned char acTmpContent[ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX * ZTE_WMS_CONCAT_SMS_COUNT_MAX *4+4]={0};
+ int iTimeZone = 0;
+ int tmp_i = 0;
+
+ if(NULL == pSendSrcMsg || NULL == pDestConcatMsg)
+ {
+ return -1;
+ }
+
+ // ´ÓÊý¾Ý¿âÖлñȡҪ·¢Ë͵ĶÌÐÅÄÚÈÝÖÃÓÚacTmpContent£¬²¢×ª»»ÓÚacConvertContent
+ iTotalLen = pSendSrcMsg->msg_len;
+ if(ZUFI_FAIL == zUfiSms_GetSmsContent(acTmpContent,sizeof(acTmpContent)))
+ {
+ printf("[SMS] zUfiSms_GetSmsContent Fail.\n");
+ return -1;
+ }
+ printf("[SMS] zUfiSms_GetSmsContent:%s.\n",acTmpContent);
+ (void)String2Bytes(acTmpContent, acConvertContent, (int)strlen(acTmpContent));
+
+ //ת»»ÄÚÈÝ,µ÷Õû³¤¶È
+ memset(acTmpContent,0,sizeof(acTmpContent));
+ if (DCS_USC == g_zUfiSms_Dcs)
+ {
+ // ²»ÐèҪת»»
+ pSmsConverted = acConvertContent;
+ }
+ else
+ {
+ // asc¸ñʽ£¬ÐèÒª¸ù¾ÝÓïÖÖÀཫacConvertContentÔÙ´Îת»»£¬²¢´æÓÚacTmpContent£¬³¤¶ÈÒàͬ²½µ÷Õû
+ if(NOT_DEFINE_LANGUAGE == g_zUfiSms_Language)
+ {
+ iTotalLen = zUfiSms_ConvertAsciiToGsmDefault(acConvertContent,acTmpContent,pSendSrcMsg->msg_len);
+
+ }
+ else if(DCS_GSM7_SPANISH == g_zUfiSms_Language)
+ {
+ iTotalLen = zUfiSms_ConvertUcs2ToSpanish(acConvertContent,acTmpContent,pSendSrcMsg->msg_len);
+ }
+ else if(DCS_GSM7_PORTUGUESE == g_zUfiSms_Language)
+ {
+ iTotalLen = zUfiSms_ConvertUcs2ToPortuguese(acConvertContent,acTmpContent,pSendSrcMsg->msg_len);
+ }
+ else
+ {
+ iTotalLen = zUfiSms_ConvertUcs2ToGsmDefault(acConvertContent,acTmpContent,pSendSrcMsg->msg_len);
+ }
+ pSendSrcMsg->msg_len = iTotalLen;
+ pSmsConverted = acTmpContent;
+ }
+
+
+ // µ÷Õû²¢ÉèÖöÌÐÅ×îÖÕ³¤¶È
+ if(iTotalLen > (sizeof(acConvertContent) - 1))
+ {
+ iTotalLen = sizeof(acConvertContent) - 1;
+ }
+ pDestConcatMsg->sms_len = iTotalLen;
+
+ // ¼ÆË㳤¶ÌÐŵĵ¥Î»·Ö¶Î³¤¶È
+ if ((iTotalLen > ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX)||
+ (g_zUfiSms_Language == DCS_PORTUGUESE && iTotalLen > 155)||
+ ((g_zUfiSms_Dcs == DCS_USC) && iTotalLen > ZTE_WMS_SMS_MSG_CHAR_MAX))
+ {
+ printf("[SMS] =====send contact sms.\n");
+
+ if(g_zUfiSms_Dcs == DCS_USC)
+ {
+ iUnitlen = ZTE_WMS_SMS_CONCAT_ELEMNT_UCS_LEN * 2;
+ }
+ else //if(g_zUfiSms_Dcs == DCS_ASC)
+ {
+ if(g_zUfiSms_Language == NOT_DEFINE_LANGUAGE || g_zUfiSms_Language == DCS_GSM7_DEFAULT)
+ {
+ iUnitlen = ZTE_WMS_SMS_CONCAT_ELEMNT_ASC_LEN;
+ }
+ else
+ {
+ iUnitlen = ZTE_WMS_SMS_CONCAT_ELEMNT_LANGUAGE_LEN;
+ }
+ }
+ //°´ÕÕiUnitlen¿ªÊ¼ÇзֶÌÐÅ
+ while (iTotalLen > 0 && iSegNo < ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ //cov m
+ memcpy(pDestConcatMsg->msg_contents[iSegNo], pSmsConverted, iUnitlen);
+
+ iTotalLen -= iUnitlen;
+ pSmsConverted += iUnitlen;
+ iSegNo++;
+ }
+ pDestConcatMsg->total_msg = iSegNo;
+ }
+ else
+ {
+ // ¶Ì¶ÌÐÅ
+ iUnitlen = iTotalLen;
+ pDestConcatMsg->total_msg = 1;
+ memcpy(pDestConcatMsg->msg_contents[0], pSmsConverted, iTotalLen);
+ printf("[SMS] =====send normal sms.len:%d.content:%s.\n",iUnitlen,pDestConcatMsg->msg_contents[0]);
+ }
+
+ g_zUfiSms_ConcatTotalNum = pDestConcatMsg->total_msg;
+ pDestConcatMsg->current_sending = 0;
+
+ // ÉèÖöÌÐÅ·¢ËÍʱ¼ä
+ memcpy(&(pDestConcatMsg->date),&(pSendSrcMsg->date),sizeof(T_zUfiSms_Date));
+ tmp_i = atoi(pDestConcatMsg->date.timezone);
+ if(tmp_i < INT_MIN+1 || tmp_i > INT_MAX-1) { //kw 3
+ printf("unknown pDestConcatMsg timezone:%d.\n", tmp_i);
+ return ZUFI_FAIL;
+ }
+ iTimeZone = tmp_i * 4;
+
+ memset(pDestConcatMsg->date.timezone,0,sizeof(pDestConcatMsg->date.timezone));
+ if(iTimeZone > 0)
+ {
+ snprintf(pDestConcatMsg->date.timezone,sizeof(pDestConcatMsg->date.timezone),"+%d",iTimeZone);
+ }
+ else
+ {
+ snprintf(pDestConcatMsg->date.timezone,sizeof(pDestConcatMsg->date.timezone),"%d",iTimeZone);
+ }
+
+ pSmsConverted = NULL;
+ return iUnitlen;
+}
+
+void zUfiSms_FillDateheader
+(
+ T_zUfiSms_SubmitTpdu *ptSubmit,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ unsigned char iHeaderNum = 0;
+
+ iHeaderNum = ptSubmit->user_data.num_headers;
+ ptSubmit->user_data_header_present = TRUE;
+ // µ÷Õû²¢¼Ç¼ msg_ref
+ if (0 == ptConcatSms->current_sending)
+ {
+ g_zUfiSms_ConcatSmsReference++;
+ (void)zUfiSms_SetConcatMaxRefer(g_zUfiSms_ConcatSmsReference);
+ }
+
+ // ÌîдUD
+ ptSubmit->user_data.headers[iHeaderNum].header_id = WMS_UDH_CONCAT_8;
+ ptSubmit->user_data.headers[iHeaderNum].u.concat_8.total_sm = ptConcatSms->total_msg;
+ ptSubmit->user_data.headers[iHeaderNum].u.concat_8.seq_num = ptConcatSms->current_sending + 1;
+ ptSubmit->user_data.headers[iHeaderNum].u.concat_8.msg_ref = g_zUfiSms_ConcatSmsReference % 0xff;
+ ptSubmit->user_data.num_headers++;
+
+ ptDbSaveData->concat_sms = 1;
+ ptDbSaveData->concat_info[0] = g_zUfiSms_ConcatSmsReference;
+}
+
+//¶ÌÐÅ·¢ËÍÊý¾Ý´Óg_zUfiSms_SendingSmsÖдæÈëg_zUfiSms_FinalCmgsBuf£¬
+int zUfiSms_MakeFinalCmgsBuf()
+{
+ SMS_PARAM tSmsData;
+ int iPduLength = 0;
+ int nSmscLength = 0;
+ char Tempstrr[2] = {0};
+ char Temp_sms_vp[8] = {0};
+ char tmpBuf1[3]={0};
+ char tmpBuf2[6]={0};//klocwork
+ CHAR smsCenter[50]={0};
+
+ memset(&tSmsData, 0, sizeof(SMS_PARAM));
+ memset(&g_zUfiSms_FinalCmgsBuf, 0, sizeof(T_zSms_SendSmsReq));
+
+ //¿½±´TPUD
+ if (CODE_GSM7 == g_zUfiSms_SendingSms.TP_DCS)
+ {
+ int i = 0;
+ for(; i < g_zUfiSms_SendingSms.TP_UDLength; i++)
+ {
+ tSmsData.TP_UD[i] = g_zUfiSms_SendingSms.TP_UD[i] ;
+ }
+ tSmsData.TP_UDLength = g_zUfiSms_SendingSms.TP_UDLength;
+ }
+ else
+ {
+ //¿½±´Ôʼ¶ÌÐÅÄÚÈÝ
+ snprintf(tSmsData.TP_UD,sizeof(tSmsData.TP_UD),"%s", g_zUfiSms_SendingSms.TP_UD);
+ tSmsData.TP_UDLength = strlen(tSmsData.TP_UD);
+
+ }
+
+ /*Ìî³ä·þÎñÖÐÐĺÅÂëºÍÄ¿±êºÅÂë*/
+ sc_cfg_get(NV_SMS_CENTER_NUM,smsCenter,sizeof(smsCenter));
+ snprintf(tSmsData.SCA, sizeof(tSmsData.SCA),"%s", smsCenter);
+ snprintf(tSmsData.TPA, sizeof(tSmsData.TPA),"%s", g_zUfiSms_SendingSms.TPA);
+ tSmsData.TP_DCS = g_zUfiSms_SendingSms.TP_DCS;
+
+ sc_cfg_get(NV_REPORT_ENABLE,Tempstrr,sizeof(Tempstrr));
+ if((0 == strncmp(Tempstrr,"1",1)) && (g_zUfiSms_ConcatSms.current_sending == g_zUfiSms_ConcatSms.total_msg-1))
+ {
+ // ÐèÒª·¢ËÍ״̬±¨¸æ
+ tSmsData.TP_SRR = 1;
+ }
+ else
+ {
+ tSmsData.TP_SRR = 0;
+ }
+ tSmsData.TP_UDHI= g_zUfiSms_SendingSms.TP_UDHI;
+ tSmsData.TP_VP = 0xFF;
+
+ //¶ÌÐÅÔÚ¶ÌÏûÏ¢ÖÐÐĵĴ洢ʱ¼ä
+ sc_cfg_get(NV_SMS_VP,Temp_sms_vp,sizeof(Temp_sms_vp));
+ if( 0 == strncmp(Temp_sms_vp,"longest",7))
+ {
+ tSmsData.TP_VP = 0xFF;
+ }
+ else if(0 == strncmp(Temp_sms_vp,"one_day",7))
+ {
+ tSmsData.TP_VP = 0xA7;
+ }
+ else if(0 == strncmp(Temp_sms_vp,"oneweek",7))
+ {
+ tSmsData.TP_VP = 0xAD;
+ }
+ else if(0 == strncmp(Temp_sms_vp,"twelveh",7))
+ {
+ tSmsData.TP_VP = 0x8F;
+ }
+
+ tSmsData.TP_PID = 0;
+
+ #if 1//corem for debug
+ printf("[SMScorem]begin:%s\n",g_zUfiSms_FinalCmgsBuf.pdu);
+ #endif // ½«tSmsData ´æÈëg_zUfiSms_FinalCmgsBuf.pduÖÐ
+ iPduLength = EncodePdu_Submit(&tSmsData, g_zUfiSms_FinalCmgsBuf.pdu); /*±àÂë*/
+ #if 1//corem for debug
+ printf("[SMScorem] zUfiSms_MakeFinalCmgsBuf make pdu data\n");
+ printf("[SMScorem]%s\n",g_zUfiSms_FinalCmgsBuf.pdu);
+ #endif
+ //!!!!!!!!Èç´Ëµ÷Ó㬾ÓȻû³öÎÊÌ⣬Î÷°²ÉñÁË
+ (void)String2Bytes(g_zUfiSms_FinalCmgsBuf.pdu, tmpBuf1, 2);
+ Bytes2String(tmpBuf1, tmpBuf2, strlen(tmpBuf1));
+ nSmscLength = atoi(tmpBuf2);
+ if(nSmscLength < 0 || nSmscLength > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]nSmscLength err:%d\n", nSmscLength);
+ nSmscLength = 0;;
+ }
+ nSmscLength++;
+ g_zUfiSms_FinalCmgsBuf.length = iPduLength / 2 - nSmscLength;
+ #if 1//corem for debug
+ printf("[SMScorem] zUfiSms_MakeFinalCmgsBuf make end pdu data\n");
+ printf("[SMScorem]len:%d, %s\n",g_zUfiSms_FinalCmgsBuf.length, g_zUfiSms_FinalCmgsBuf.pdu);
+ #endif
+ return ZUFI_SUCC;
+}
+
+/* ¸ù¾ÝptConcatSmsºÍptGroupSmsÌî³äptSubmit×Ö¶Î,·ÅÔÚg_SMS_Sending_SmsºÍptDbSaveDataÖÐ */
+int zUfiSms_FillSubmitTpdu(
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_GroupInfo *ptGroupSms,
+ int iSmsLen,
+ T_zUfiSms_SubmitTpdu *ptSubmit,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ if(NULL == ptSubmit || NULL == ptConcatSms || NULL == ptGroupSms || NULL == ptDbSaveData)
+ {
+ return -1;
+ }
+ ptSubmit->reject_duplicates = FALSE;
+ ptSubmit->reply_path_present = FALSE;
+ ptSubmit->user_data_header_present = FALSE;
+ //ÊÇ·ñÆô¶¯×´Ì¬±¨¸æ
+ ptSubmit->status_report_enabled = g_zUfiSms_CurSmsPara.status_report_on;
+
+ /* ³¤¶ÌÐÅ£¬Ö»Óз¢ËÍ×îºóÒ»½Úʱ²ÅÆô¶¯×´Ì¬±¨¸æ */
+ if((1 < ptConcatSms->total_msg) && (ptConcatSms->current_sending + 1 < ptConcatSms->total_msg))
+ {
+ ptSubmit->status_report_enabled = 0;
+ }
+
+ ptSubmit->message_reference = g_zUfiSms_MsgRefer;
+ ptSubmit->pid = WMS_PID_DEFAULT;
+ ptSubmit->dcs.msg_class = (wms_message_class_e_type)4;
+ ptSubmit->dcs.is_compressed = 0;
+ ptSubmit->dcs.alphabet = (g_zUfiSms_Dcs == DCS_ASC)? WMS_GW_ALPHABET_7_BIT_DEFAULT : WMS_GW_ALPHABET_UCS2;
+ ptSubmit->validity.format = WMS_GW_VALIDITY_RELATIVE;
+
+ // ½«µ±Ç°Ê±¼äдÈëptSubmitʱ¼ä´Á
+ zUfiSms_DecodeRelativeTime(g_zUfiSms_CurSmsPara.tp_validity_period, &ptSubmit->validity.u.time);
+ ptSubmit->user_data.num_headers = 0;
+
+ //Ìî³ä¼¶Áª¶ÌÐŵÄÍ·²¿¼Ç¼
+ if (ptConcatSms->total_msg > 1)
+ {
+ zUfiSms_FillDateheader(ptSubmit,ptConcatSms,ptDbSaveData);
+ ptDbSaveData->concat_info[2] = ptConcatSms->current_sending + 1;
+ ptDbSaveData->concat_info[1] = ptConcatSms->total_msg;
+ }
+
+ // ÆÏÌÑÑÀÓÐèÒªÔÚ×îºóÒ»¸öheaderÖÐÌí¼Ó˵Ã÷
+ if (g_zUfiSms_Language == DCS_PORTUGUESE)
+ {
+ UINT8 i = ptSubmit->user_data.num_headers;
+ ptSubmit->user_data_header_present = TRUE;
+ ptSubmit->user_data.headers[i].header_id = WMS_UDH_NAT_LANG_SS;
+
+ ptSubmit->user_data.headers[ptSubmit->user_data.num_headers].u.nat_lang_ss.nat_lang_id
+ = WMS_UDH_NAT_LANG_PORTUGUESE;
+ ptSubmit->user_data.num_headers++;
+ g_zUfiSms_IsLanguageShift = WMS_UDH_NAT_LANG_SS;
+ }
+
+ // ½«µ±Ç°¼´½«·¢Ë͵ĶÌÐÅsegÄÚÈÝ´æÈësubmit
+ ptSubmit->user_data.sm_len = iSmsLen;
+ memcpy(ptSubmit->user_data.sm_data,ptConcatSms->msg_contents[ptConcatSms->current_sending], iSmsLen);
+
+ //µ÷Õû¶ÌÐŽÓÊÕÕߵĺÅÂëºÍ³¤¶È,È¥µô+ºÍ00
+ if (ptGroupSms->receivers[ptGroupSms->current_receiver][0] == '+')
+ {
+ (void)zUfiSms_CharToInt(ptGroupSms->receivers[ptGroupSms->current_receiver] + 1,
+ strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]) - 1, ptSubmit->address.digits);
+ ptSubmit->address.number_type = WMS_NUMBER_INTERNATIONAL;
+ ptSubmit->address.number_of_digits = strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]) - 1;
+ }
+ else if (ptGroupSms->receivers[ptGroupSms->current_receiver][0] == '0' &&ptGroupSms->receivers[ptGroupSms->current_receiver][1] == '0')
+ {
+ (void)zUfiSms_CharToInt(ptGroupSms->receivers[ptGroupSms->current_receiver] + 2,
+ strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]) - 2, ptSubmit->address.digits);
+ ptSubmit->address.number_type = WMS_NUMBER_INTERNATIONAL;
+ ptSubmit->address.number_of_digits = strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]) - 2;
+ }
+ else
+ {
+ (void)zUfiSms_CharToInt(ptGroupSms->receivers[ptGroupSms->current_receiver], strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]), ptSubmit->address.digits);
+ ptSubmit->address.number_type = WMS_NUMBER_UNKNOWN;
+ ptSubmit->address.number_of_digits = strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]);
+ }
+ ptSubmit->address.digit_mode = (wms_digit_mode_e_type)0;
+ ptSubmit->address.number_mode = (wms_number_mode_e_type)0;
+ ptSubmit->address.number_plan = WMS_NUMBER_PLAN_TELEPHONY;//93d µ½´ËΪֹ
+ memset(&g_zUfiSms_SendingSms,0, sizeof(SMS_PARAM));
+ //ÉèÖõ±Ç°¶ÌÐŵĽÓÊÕÕß
+ snprintf(g_zUfiSms_SendingSms.TPA, sizeof(g_zUfiSms_SendingSms.TPA),"%s", ptGroupSms->receivers[ptGroupSms->current_receiver]);
+
+ //°ÑÊý¾ÝͳͳдÈëg_zUfiSms_SendingSmsÖÐÈ¥
+ if(g_zUfiSms_Language != NOT_DEFINE_LANGUAGE)
+ {
+ g_zUfiSms_SendingSms.TP_DCS = CODE_GSM7;
+ }
+ else
+ {
+ if(g_zUfiSms_Dcs == DCS_USC)
+ {
+ g_zUfiSms_SendingSms.TP_DCS = CODE_UCS2;
+ }
+ else
+ {
+ g_zUfiSms_SendingSms.TP_DCS = CODE_GSM8;
+ }
+ }
+ if(g_zUfiSms_SendingSms.TP_DCS == CODE_GSM7)
+ {
+ zUfiSms_FillGlobalTpudGsm7(ptSubmit,ptConcatSms,ptDbSaveData);
+ }
+ else
+ {
+ zUfiSms_FillGlobalTpudUcs2(ptSubmit,ptConcatSms,ptDbSaveData);
+ }
+
+ //½«×îÖÕ¶ÌÐÅÄÚÈÝ´æÈëg_zUfiSms_FinalCmgsBuf
+ (void)zUfiSms_MakeFinalCmgsBuf();
+ return ZUFI_SUCC;
+}
+
+// ÉèÖöÌÐÅÖÐÐÄ
+void zUfiSms_FillSca(T_zUfiSms_ClientMsg *ptClientMsg)
+{
+ char sca[ZTE_WMS_SCA_LEN_MAX] = {0};
+ int i = 0;
+
+ if(NULL == ptClientMsg)
+ {
+ return ;
+ }
+
+ memcpy((void*)sca,(void*)(g_zUfiSms_CurSmsPara.sca),sizeof(g_zUfiSms_CurSmsPara.sca));
+ // ¹ú¼ÊºÅÂë
+ if (sca[0] == '+')
+ {
+ ptClientMsg->u.gw_message.sc_address.number_type = WMS_NUMBER_INTERNATIONAL;
+ }
+
+ ptClientMsg->u.gw_message.sc_address.digit_mode = WMS_DIGIT_MODE_8_BIT;
+ ptClientMsg->u.gw_message.sc_address.number_plan = WMS_NUMBER_PLAN_TELEPHONY;
+ ptClientMsg->u.gw_message.sc_address.number_of_digits = strlen(sca);
+ if (sca[0] == '+')
+ {
+ // ¼õÈ¥+
+ ptClientMsg->u.gw_message.sc_address.number_of_digits--;
+ for (i = 0;i < ptClientMsg->u.gw_message.sc_address.number_of_digits;i++)
+ {
+ sca[i] = sca[i + 1];
+ }
+ }
+ else if (sca[0] == '0' && sca[1] == '0')
+ {
+ // ¼õÈ¥00
+ ptClientMsg->u.gw_message.sc_address.number_of_digits -= 2;
+ for (i = 0;i < ptClientMsg->u.gw_message.sc_address.number_of_digits;i++)
+ {
+ sca[i] = sca[i + 2];
+ }
+ }
+ //½«scaÖеĺÅÂëÓÉ×Ö·û±äΪÊý×Ö£¬´æÈëptClientMsg
+ (void)zUfiSms_CharToInt(sca, ptClientMsg->u.gw_message.sc_address.number_of_digits,
+ ptClientMsg->u.gw_message.sc_address.digits);
+}
+
+// °ÑÊý¾Ýͳͳ×é×°µ½ptDbSaveDataÖÐÈ¥£¬ÎªÐ´Êý¾Ý¿â×ö×¼±¸
+void zUfiSms_FillDbSaveData
+(
+ T_zUfiSms_ClientMsg *ptClientMsg,
+ T_zUfiSms_ClientTsData *ptClientData,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_GroupInfo *ptGroupSms,
+ int iSmsLen,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ if(NULL == ptClientMsg || NULL == ptClientData ||
+ NULL == ptConcatSms || NULL == ptGroupSms || NULL == ptDbSaveData)
+ {
+ at_print(LOG_ERR,"invalid inputs\n");
+ return ;
+ }
+
+ ptDbSaveData->mem_store = ptClientMsg->msg_hdr.mem_store;
+ ptDbSaveData->index = ptClientMsg->msg_hdr.index;
+ ptDbSaveData->mode = ptClientMsg->msg_hdr.message_mode;
+ ptDbSaveData->tag = ptClientMsg->msg_hdr.tag;
+
+ memset(ptDbSaveData->number, 0, ZTE_WMS_ADDRESS_LEN_MAX + 1);
+ memcpy(ptDbSaveData->number, ptGroupSms->receivers[ptGroupSms->current_receiver],
+ strlen(ptGroupSms->receivers[ptGroupSms->current_receiver]));
+ ptDbSaveData->tp_dcs = DCS_USC;
+ ptDbSaveData->tp_pid = ptClientData->u.gw_pp.u.submit.pid;
+ ptDbSaveData->msg_ref = ptClientData->u.gw_pp.u.submit.message_reference;
+ memset(ptDbSaveData->sms_content, 0, sizeof(ptDbSaveData->sms_content));
+
+ if(g_zUfiSms_Dcs == DCS_USC)
+ {
+ ptDbSaveData->alphabet = WMS_GW_ALPHABET_UCS2;
+ }
+ else if(g_zUfiSms_Dcs == DCS_ASC)
+ {
+ ptDbSaveData->alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ }
+ (void)zUfiSms_DispatchWtoi(ptConcatSms->msg_contents[ptConcatSms->current_sending],
+ iSmsLen, (UINT8*)ptDbSaveData->sms_content);
+ memcpy(&(ptDbSaveData->julian_date),&(ptConcatSms->date),sizeof(T_zUfiSms_Date));
+ memcpy(&g_zUfiSms_DbStoreData[ptConcatSms->current_sending],ptDbSaveData,sizeof(zte_wms_db_sms_data_s_type));
+}
+
+
+// °ÑÆäËûÈ«¾ÖÊý¾Ýͳͳдµ½db_write_dataºÍclient_message_ptrÖÐ !!!!!µÚÒ»¸öÈë²Î¸ÄΪÄÚ²¿¾Ö²¿±äÁ¿
+void zUfiSms_SetPduData(T_zUfiSms_ClientMsg *ptClientMsg,T_zUfiSms_DbStoreData *ptDbSaveData)
+{
+ T_zUfiSms_ClientTsData tClientTsData;
+
+ ptClientMsg->msg_hdr.mem_store = WMS_MEMORY_STORE_NV_GW;
+ ptClientMsg->msg_hdr.tag = WMS_TAG_MO_NOT_SENT;
+ ptClientMsg->msg_hdr.message_mode = WMS_MESSAGE_MODE_GW;
+ ptClientMsg->u.gw_message.is_broadcast = FALSE;
+
+ //Ìî³ätClientTsDataÊý¾Ý£¬±àÂëºó´æÈëptClientMsg
+ memset((void*)&tClientTsData, 0, sizeof(wms_client_ts_data_s_type));
+ tClientTsData.format = WMS_FORMAT_GW_PP;
+ tClientTsData.u.gw_pp.tpdu_type = WMS_TPDU_SUBMIT;
+ (void)zUfiSms_FillSubmitTpdu(&g_zUfiSms_ConcatSms,&g_zUfiSms_GroupSms,g_zUfiSms_UnitLen,&tClientTsData.u.gw_pp.u.submit,ptDbSaveData);
+ (void)wms_ts_encode(&tClientTsData, &ptClientMsg->u.gw_message.raw_ts_data);
+ zUfiSms_FillSca(ptClientMsg);
+
+ // °ÑÊý¾Ýͳͳ×é×°µ½ptDbSaveDataÖÐÈ¥£¬ÎªÐ´Êý¾Ý¿â×ö×¼±¸
+ zUfiSms_FillDbSaveData(ptClientMsg,&tClientTsData,&g_zUfiSms_ConcatSms,&g_zUfiSms_GroupSms,g_zUfiSms_UnitLen,ptDbSaveData);
+}
+
+/*´æ´¢»ò¸üÐÂÆÕͨ¶ÌÐÅ */
+int zUfiSms_StoreNormalSmsToDb(T_zUfiSms_DbStoreData *ptDbSaveData, const char *pMemStore, long iSmsId)
+{
+ int result = ZUFI_SUCC;
+ char *pContent = NULL;
+ int iTotalCount = 0;
+
+ pContent = (char*)malloc(4 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX);
+ if (pContent == NULL)
+ {
+ return ZUFI_FAIL;
+ }
+
+ //±àÂëµ÷Õû
+ memset(pContent,0,4 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX);
+ if( WMS_GW_ALPHABET_7_BIT_DEFAULT == ptDbSaveData->alphabet)
+ {
+ static char data[4*ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX + 1] = {0};
+ memset(data,0,4*ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX+1);
+
+ (void)zUfiSms_DecodeContent((char*) ptDbSaveData->sms_content, strlen(ptDbSaveData->sms_content),FALSE, data);
+ strncpy(pContent,data,4 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX-1);
+ }
+ else
+ {
+ strncpy(pContent,ptDbSaveData->sms_content,4 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX-1);
+ }
+
+ ptDbSaveData->tp_dcs = (unsigned char)2;
+ if(-1 == iSmsId) /*insert new normal sms*/
+ {
+ if(ZUFI_FAIL == zUfiSms_GetTotalCount(pMemStore,&iTotalCount))//kw 3
+ {
+ free(pContent);
+ pContent = NULL;
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] zUfiSms_StoreNormalSmsToDb iTotalCount=%d\n",iTotalCount);
+ if(iTotalCount >= g_zUfiSms_StoreCapablity[(strcmp(pMemStore,"nv") ? ZTE_WMS_MEMORY_SIM : ZTE_WMS_MEMORY_NV)])
+ {
+ free(pContent);
+ pContent = NULL;
+ return -1;
+ }
+
+ if(ZUFI_FAIL == zUfiSms_InsertNormalSmsToDb(ptDbSaveData,pMemStore,pContent))
+ {
+ result = ZUFI_FAIL;
+ }
+ }
+ else /*update exist sms*/
+ {
+ if(ZUFI_FAIL == zUfiSms_UpdateNormalSmsToDb(ptDbSaveData,pMemStore,pContent,iSmsId))
+ {
+ result = ZUFI_FAIL;
+ }
+ }
+
+ free(pContent);
+ pContent = NULL;
+ return result;
+}
+
+static int zUfiSms_ConcatDataFree(T_zUfiSms_DbStoreData *ptDbSaveData,int count,char ** out_result)
+{
+ int i = 0;
+ for(i = 0; i < count; i++)
+ {
+ //db_data->concat_info[2]´æ´¢µ±Ç°Êǵڼ¸Ìõ
+ if(ptDbSaveData->concat_info[2] == i+1)
+ {
+ free(out_result[i]);
+ out_result[i] = NULL;
+ break;
+ }
+ }
+ return 0;
+}
+/** ½«ÒÑÓеĴ洢¶ÌÐÅÖеÄcontent¡¢ind/CcSeqµÈ¼ÓÈëеÄptDbSaveDataÊý¾Ý£¬¸ñʽ»¯ºóÊä³ö */
+int zUfiSms_AddNewSmsToConcatData
+(
+ T_zUfiSms_DbStoreData *ptDbSaveData,
+ char *pOldContent,
+ char *pFormatNewContent,
+ char *pRealNewContent,
+ T_zUfiSms_DbStoreStr *pac,
+ int *pConcatTotalNum,
+ int len
+)
+{
+ int count = 0;
+ char ** out_result = NULL;
+ char cSegChar = ';';
+ int i = 0;
+ int iTotalSegNum = 0;
+ char acContentSeg[2 * ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX * ZTE_WMS_SMS_COUNT_MAX] = {0};
+ //µ±Ç°µÄ´æ´¢Î»ÖÃ
+ char *pCurConPos = acContentSeg;
+ boolean isEsc = FALSE;
+
+ if(NULL == pOldContent)//kw 3
+ {
+ return -1;
+ }
+
+ /* È¡³öÏÖÓеļ¶Áª¶ÌÐÅS1;S2;S3µÄ¸÷½ÚÄÚÈÝ£¬´æÈëout_result£¬ */
+ count = zUfiSms_SplitString(pOldContent, &out_result, cSegChar);
+ for(i = 0; i < count; i++)
+ {
+ //db_data->concat_info[2]´æ´¢µ±Ç°Êǵڼ¸Ìõ
+ if(ptDbSaveData->concat_info[2] == i+1)
+ {
+ //ÕÒµ½¶ÔÓ¦µÄ¶ÌÐÅseg£¬°ÑжÌÐżÓÈë¼¶Áª
+ out_result[i] = (char*)malloc(sizeof(ptDbSaveData->sms_content));
+ memset(out_result[i], 0, sizeof(ptDbSaveData->sms_content));
+ if(WMS_GW_ALPHABET_7_BIT_DEFAULT == ptDbSaveData->alphabet)
+ {
+ isEsc = zUfiSms_DecodeContent(ptDbSaveData->sms_content, strlen(ptDbSaveData->sms_content), isEsc, out_result[i]);
+ }
+ else
+ {
+ strncpy(out_result[i],ptDbSaveData->sms_content,sizeof(ptDbSaveData->sms_content)-1);
+ }
+ break;
+ }
+ }
+ //°Ñ¸÷¸öFormatºóµÄsegÁ¬×ºÆðÀ´,´æÈëpFormat_concatMsgºÍpContent_outÖУ¬Ò»¸öFormat,Ò»¸öÕæÊµÄÚÈÝ
+ for(i = 0; i < count; i++)
+ {
+ //strcat(acContentSeg,out_result[i]);//klocwork
+ snprintf(acContentSeg+strlen(acContentSeg), sizeof(acContentSeg)-strlen(acContentSeg), "%s", out_result[i]);
+ strcat(pFormatNewContent,out_result[i]);
+ if(i != count -1)
+ {
+ strcat(pFormatNewContent,";");
+ }
+ }
+ strncpy(pRealNewContent,acContentSeg,len);
+ zUfiSms_ConcatDataFree(ptDbSaveData,count,out_result);
+ free(out_result);
+ out_result = NULL;
+
+ /* Ind£¬½«concat_indÖеÄÄÚÈÝ·Ö¸îºó´æÈëformat_ind */
+ count = zUfiSms_SplitString(pac->IndStr, &out_result, cSegChar);
+ for(i = 0; i < count; i++)
+ {
+ if(ptDbSaveData->concat_info[2] == i+1)
+ {
+ out_result[i] = (char*)malloc(SHORT_INT_LEN);//sizeof(ptDbSaveData->index)
+ memset(out_result[i],0,SHORT_INT_LEN);
+ snprintf(out_result[i],SHORT_INT_LEN,"%d",ptDbSaveData->index);
+ break;
+ }
+ }
+ for(i = 0; i < count; i++)
+ {
+ //strcat(pac->FormatInd,out_result[i]);
+ snprintf(pac->FormatInd+strlen(pac->FormatInd), sizeof(pac->FormatInd)-strlen(pac->FormatInd), "%s", out_result[i]);
+ if(i != count -1)
+ {
+ //strcat(pac->FormatInd,";");
+ snprintf(pac->FormatInd+strlen(pac->FormatInd), sizeof(pac->FormatInd)-strlen(pac->FormatInd), ";");
+ }
+ }
+ zUfiSms_ConcatDataFree(ptDbSaveData,count,out_result);
+ free(out_result);
+ out_result = NULL;
+
+ /*cc seq ½«cancat_seqÖеÄÄÚÈÝ·Ö¸îºó´æÈëformat_seq*/
+ count = zUfiSms_SplitString(pac->Seg_Seq, &out_result, cSegChar);
+ for(i = 0; i < count; i++)
+ {
+ if(ptDbSaveData->concat_info[2] == i+1)
+ {
+ out_result[i] = (char*)malloc(SHORT_INT_LEN);//sizeof(ptDbSaveData->concat_info[2])
+ memset(out_result[i],0,SHORT_INT_LEN);
+ snprintf(out_result[i],SHORT_INT_LEN,"%d",ptDbSaveData->concat_info[2]);
+ break;
+ }
+ }
+ for(i = 0; i < count; i++)
+ {
+ //strcat(pac->FormatSeq,out_result[i]);
+ snprintf(pac->FormatSeq+strlen(pac->FormatSeq), sizeof(pac->FormatSeq)-strlen(pac->FormatSeq), "%s", out_result[i]);
+ if(i != count -1)
+ {
+ //strcat(pac->FormatSeq,";");
+ snprintf(pac->FormatSeq+strlen(pac->FormatSeq), sizeof(pac->FormatSeq)-strlen(pac->FormatSeq), ";");
+ }
+ // Ò»ÌõÓÐЧseg¼Ç¼
+ if(0 != strcmp(out_result[i],""))
+ {
+ iTotalSegNum++;
+ }
+ }
+ *pConcatTotalNum = iTotalSegNum;
+ zUfiSms_ConcatDataFree(ptDbSaveData,count,out_result);
+ free(out_result);
+ out_result = NULL;
+
+ return 0;
+}
+
+int zUfiSms_UpdateConcatSms(T_zUfiSms_DbStoreData *ptDbSaveData, const char *pStorePos, long iSmsId)
+{
+ T_zUfiSms_DbStoreStr ac = {0};
+ char *pOldContent = NULL;
+ char *pFormatNewContent = NULL;
+ char *pRealNewContent = NULL;
+ int iTotalNum = 0;
+ int result = ZUFI_SUCC;
+ int spaceLen = 4* ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX+4;//(ZTE_WMS_CONCAT_SMS_COUNT_MAX+1)*1024;
+ // ·ÖÅä¿Õ¼ä
+ pOldContent = (char*)malloc(spaceLen);
+ pFormatNewContent = (char*)malloc(spaceLen);
+ pRealNewContent = (char*)malloc(spaceLen);
+ if (pOldContent == NULL || pFormatNewContent == NULL || pRealNewContent == NULL)
+ {
+ if (pOldContent) free(pOldContent);
+ if (pFormatNewContent) free(pFormatNewContent);
+ if (pRealNewContent) free(pRealNewContent);
+ return ZUFI_FAIL;
+ }
+
+ memset(pRealNewContent,0,spaceLen);
+ memset(pOldContent,0,spaceLen);
+ memset(pFormatNewContent,0,spaceLen);
+
+ (void)zUfiSms_GetConcatInfo(pStorePos,iSmsId,&ac,pOldContent,spaceLen);
+ printf("[SMS] teet -0 IndStr:%s,Seg_Seq:%s,FormatInd:%s,FormatSeq:%s\n",ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);
+ if(-1 == zUfiSms_AddNewSmsToConcatData(ptDbSaveData,pOldContent,pFormatNewContent,pRealNewContent,&ac,&iTotalNum,spaceLen))
+ {
+ result = ZUFI_FAIL;
+ }
+ printf("[SMS] teet 0 IndStr:%s,Seg_Seq:%s,FormatInd:%s,FormatSeq:%s\n",ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);
+ ptDbSaveData->tp_dcs = 2;
+ if(ZUFI_FAIL == zUfiSms_UpdateConcatSmsToDb(ptDbSaveData,pStorePos,pFormatNewContent,pRealNewContent,&ac,iTotalNum,iSmsId))//kw 3
+ {
+ result = ZUFI_FAIL;
+ }
+ printf("[SMS] teet 1 IndStr:%s,Seg_Seq:%s,FormatInd:%s,FormatSeq:%s\n",ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);
+ free(pRealNewContent);
+ free(pOldContent);
+ free(pFormatNewContent);
+ pRealNewContent = NULL;
+ pOldContent = NULL;
+ pFormatNewContent = NULL;
+ printf("[SMS] zUfiSms_UpdateConcatSms success.\n");
+ return result;
+}
+
+int zUfiSms_InsertConcatSms(T_zUfiSms_DbStoreData *ptDbSaveData, const char *pStorePos)
+{
+ T_zUfiSms_DbStoreStr ac = {0};
+ int iSms_TotalCount = 0;
+ int i = 0;
+ char acTmpContent[256];
+ int iConcatNum = 0;
+ char *pFormatConcat = NULL;
+ char *pContent = NULL;
+ int spaceLen = 4* ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX+4;
+
+ if(NULL == ptDbSaveData || NULL == pStorePos )
+ {
+ return ZUFI_FAIL;
+ }
+
+ printf("[SMS] enter InsertConcatSms.\n");
+ memset(acTmpContent,0,sizeof(acTmpContent));
+
+ // ÏÈÉèÖöÌÐŶÎÖ®¼äµÄ·Ö¸ô·û,×îÖÕ¸ñʽΪ S1;S2;S3
+ iSms_TotalCount = ptDbSaveData->concat_info[1];
+ for(i = 1; i < iSms_TotalCount; i++)
+ {
+ strcat(ac.IndStr,";");
+ strcat(ac.Seg_Seq,";");
+ strcat(acTmpContent,";");
+ }
+
+ //·ÖÅ䳤¶ÌÐŵÄ×¿Õ¼ä5*160
+ pFormatConcat = (char *)malloc(spaceLen);
+ if(NULL == pFormatConcat)
+ {
+ return ZUFI_FAIL;
+ }
+ memset(pFormatConcat,0,spaceLen);
+
+ pContent = (char *)malloc(spaceLen);
+ if (pContent == NULL)
+ {
+ free(pFormatConcat);
+ return ZUFI_FAIL;
+ }
+ memset(pContent,0,spaceLen);
+
+ // ¸üÐÂÔÓм¶Áª¶ÌÐŵĸñʽ£¬´Ódb_dataÖзÅÈëtmp_content¡¢content¡¢format_ind¡£format_seq
+ if(-1 == zUfiSms_AddNewSmsToConcatData(ptDbSaveData, acTmpContent, pFormatConcat, pContent,
+ &ac,&iConcatNum,spaceLen))
+ {
+ free(pFormatConcat);
+ free(pContent);
+ pFormatConcat = NULL;
+ pContent = NULL;
+ return ZUFI_FAIL;
+ }
+
+ // Ìí¼ÓÐÂÊÕµ½µÄ¶ÌÐÅ
+ ptDbSaveData->tp_dcs = 2;
+ if(ZUFI_FAIL == zUfiSms_InsertConcatSmsToDb(ptDbSaveData,pStorePos,pFormatConcat,pContent,&ac,iConcatNum))//kw 3
+ {
+ free(pFormatConcat);
+ free(pContent);
+ pFormatConcat = NULL;
+ pContent = NULL;
+ return ZUFI_FAIL;
+ }
+
+ free(pFormatConcat);
+ free(pContent);
+ pFormatConcat = NULL;
+ pContent = NULL;
+ printf("[SMS] zUfiSms_InsertConcatSms success.\n");
+ return ZUFI_SUCC;
+}
+
+/* ½«ptDbSaveData´æ´¢µ½pMemStoreÖÐ */
+int zUfiSms_StoreConcatSmsToDb(T_zUfiSms_DbStoreData *ptDbSaveData, char *pMemStore)
+{
+ long iSmsId = 0;
+ int total_count = 0;
+
+ if(NULL == ptDbSaveData || NULL == pMemStore)
+ {
+ return ZUFI_FAIL;
+ }
+
+ iSmsId = zUfiSms_SearchConcatSmsInDb(ptDbSaveData,pMemStore);
+ if(-1 != iSmsId) /*concat sms has exist,so update this sms by id*/
+ {
+ printf("[SMS] zUfiSms_StoreConcatSmsToDb Enter UpdateConcatSms SmsId:%d.\n",iSmsId);
+ return zUfiSms_UpdateConcatSms(ptDbSaveData,pMemStore,iSmsId);
+ }
+ else /*insert a new concat sms if possible */
+ {
+ if(ZUFI_FAIL == zUfiSms_GetTotalCount(pMemStore,&total_count))//kw 3
+ {
+ printf("[SMS] zUfiSms_StoreConcatSmsToDb GetTotalCount Failed.\n");
+ return ZUFI_FAIL;
+ }
+
+ printf("[SMS] zUfiSms_StoreConcatSmsToDb pMemStore=%s,total_count=%d.\n",pMemStore,total_count);
+ if(total_count >= g_zUfiSms_StoreCapablity[(strcmp(pMemStore,"nv") ? ZTE_WMS_MEMORY_SIM : ZTE_WMS_MEMORY_NV)])
+ {
+ printf("[SMS] zUfiSms_StoreConcatSmsToDb Sms memory is Full.\n");
+ return ZUFI_FAIL;
+ }
+
+ return zUfiSms_InsertConcatSms(ptDbSaveData,pMemStore);
+ }
+}
+
+/**½«ptDbSaveDataдÈëiMemStoreÖУ¬¶ÔÓ¦idΪiSmsId,ÈôΪ-1£¬±íʾжÌÐÅ */
+int zUfiSms_WriteSmsToDb
+(T_zUfiSms_DbStoreData *ptDbSaveData, zUfiSms_StoreType iMemStore, long iSmsId)
+{
+ char acDbMemStore[10];
+ int iTotalCount = 0;
+ int id = 0;
+ UINT8 needCheckMemory = 1;
+ if(NULL == ptDbSaveData)
+ {
+ return ZUFI_FAIL;
+ }
+
+ //´æ´¢Î»ÖÃ
+ memset(acDbMemStore,0,sizeof(acDbMemStore));
+ if(WMS_STORAGE_TYPE_UIM_V01 == iMemStore)
+ {
+ strncpy(acDbMemStore,ZTE_WMS_DB_SIM_TABLE,sizeof(acDbMemStore)-1);
+ }
+ else
+ {
+ strncpy(acDbMemStore,ZTE_WMS_DB_NV_TABLE,sizeof(acDbMemStore)-1);
+ }
+
+ if (1 == ptDbSaveData->concat_sms)
+ {
+ id = zUfiSms_SearchConcatSmsInDb(ptDbSaveData,&acDbMemStore);
+ if(-1 != id) /*concat sms has exist*/
+ {
+ needCheckMemory = 0;
+ }
+ }
+
+ if(needCheckMemory == 1)
+ {
+ //µ±Ç°ÒÑ´æ´¢ÊýÁ¿
+ if(ZUFI_FAIL == zUfiSms_GetTotalCount(acDbMemStore,&iTotalCount))
+ {
+ return ZUFI_FAIL;
+ }
+ printf("[SMS] zUfiSms_WriteSmsToDb iTotalCount=%d(needCheckMemory==1)\n",iTotalCount);
+ if(iTotalCount >= g_zUfiSms_StoreCapablity[(strcmp(acDbMemStore,"nv") ? ZTE_WMS_MEMORY_SIM : ZTE_WMS_MEMORY_NV)])
+ {
+ // ÒÑÂú£¬ÎÞ·¨Ð´Èë
+ printf("[SMS] zUfiSms_WriteSmsToDb memory full, error\n");
+ return ZTE_WMS_NV_MEMORY_FULL;
+ }
+ }
+ if(ptDbSaveData->concat_info[2] == 0 || ptDbSaveData->concat_info[2] > ptDbSaveData->concat_info[1])
+ {
+ ptDbSaveData->concat_sms = 0;
+ }
+
+ printf("[SMS] zUfiSms_WriteSmsToDb TotalCount:%d.concat_sms:%d.concat_info[1]:%d\n",iTotalCount,ptDbSaveData->concat_sms,ptDbSaveData->concat_info[1]);
+
+ /*concat sms*/
+ if (1 == ptDbSaveData->concat_sms)
+ {
+ // µÚ¶þλÊǵ±Ç°¶ÎºÅ
+ if(ZTE_WMS_CONCAT_SMS_COUNT_MAX < ptDbSaveData->concat_info[1])
+ {
+ return ZUFI_FAIL;
+ }
+ else
+ {
+ return zUfiSms_StoreConcatSmsToDb(ptDbSaveData,acDbMemStore);
+ }
+ }
+ else /*normal sms*/
+ {
+ return zUfiSms_StoreNormalSmsToDb(ptDbSaveData,acDbMemStore,iSmsId);
+ }
+}
+
+T_zUfiSms_CmdStatus zUfiSms_SendOutSms(T_zUfiSms_DbStoreData *ptDbSaveData, int cid)
+{
+ //CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+
+ if(NULL == ptDbSaveData)
+ {
+ return WMS_CMD_FAILED;
+ }
+ // Ç°ÃæÓÐʧ°ÜµÄseg
+ if(!g_zUfiSms_IsConcatSendSuc)
+ {
+ //·¢ËÍʧ°Ü, ±£´æÆðÀ´
+ ptDbSaveData->tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ if(ZUFI_SUCC == zUfiSms_WriteSmsToDb(ptDbSaveData,WMS_STORAGE_TYPE_NV_V01,-1))
+ {
+ g_zUfiSms_MsgRefer++;
+ ptDbSaveData->msg_ref = g_zUfiSms_MsgRefer;
+ (void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);
+ }
+ }
+ else
+ {
+ CHAR sendfailRetry[50]={0};
+ sc_cfg_get(NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));
+ if(0 == strcmp("1", sendfailRetry))
+ {
+ g_zUfiSms_SendFailedRetry = 3;
+ }
+ //atBase_SendMsgToSelf(ZAT_CMGS_CMD, NULL, 0);
+ atRes = zSms_SendCmgsReq();
+ if(atRes != ZSMS_RESULT_OK)
+ {
+ zSms_RecvCmgsErr();
+ }
+ else
+ {
+ zSms_RecvCmgsOk();
+ }
+ }
+ return WMS_CMD_SUCCESS;
+}
+
+// ·¢Ëͼ¶Áª¶ÌÐÅ£¬·¢ÍêÒ»½Ú£¬µÈ´ýOK£¬ÔÙÑ»·½øÈë¸Ãº¯Êý±àÂë·¢ËÍÏÂÒ»½Ú
+int zUfiSms_SendConcatSms(int cid)
+{
+ int atRes = 0;
+
+ T_zUfiSms_ClientMsg tClientMsg;
+ T_zUfiSms_DbStoreData tDbSaveData;
+ int result = ZUFI_FAIL;
+
+ if(g_zUfiSms_ConcatSms.current_sending >= g_zUfiSms_ConcatSms.total_msg)
+ {
+ return ZUFI_FAIL;
+ }
+
+ // ´ÓÈ«¾ÖÊý¾ÝÖй¹Ôì·¢ËÍÊý¾Ý£¬´æÈëtClientMsg/tDbSaveData
+ memset((void*)&tClientMsg,0, sizeof(T_zUfiSms_ClientMsg));
+ memset((void*)&tDbSaveData, 0, sizeof(tDbSaveData));
+ zUfiSms_SetPduData(&tClientMsg,&tDbSaveData);
+
+ /*if the first concat sms failed,then the left concat sms will not be send*/
+ if(!g_zUfiSms_IsConcatSendSuc)
+ {
+ tDbSaveData.tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ (void)zUfiSms_WriteSmsToDb(&tDbSaveData,WMS_STORAGE_TYPE_NV_V01,-1);
+ g_zUfiSms_SendFailedCount++;
+ }
+ else
+ {
+ CHAR sendfailRetry[50]={0};
+ sc_cfg_get(NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));
+ if(0 == strcmp("1", sendfailRetry))
+ {
+ g_zUfiSms_SendFailedRetry = 3;
+ }
+ //atBase_SendMsgToSelf(ZAT_CMGS_CMD, NULL, 0);
+ atRes = zSms_SendCmgsReq();
+ if(atRes != ZSMS_RESULT_OK)
+ {
+ zSms_RecvCmgsErr();
+ }
+ else
+ {
+ zSms_RecvCmgsOk();
+ }
+
+ }
+
+ //µ÷Õû·¢ËͼÆÊýÆ÷
+ g_zUfiSms_ConcatSms.current_sending++;
+ if (g_zUfiSms_ConcatSms.current_sending < g_zUfiSms_ConcatSms.total_msg)
+ {
+ //»¹Ê£ÏÂ×îºóÒ»¸ö·Ö¶Î´ý·¢ËÍ
+ if (g_zUfiSms_ConcatSms.sms_len < g_zUfiSms_UnitLen * (g_zUfiSms_ConcatSms.current_sending +1))
+ {
+ g_zUfiSms_UnitLen = g_zUfiSms_ConcatSms.sms_len - g_zUfiSms_UnitLen * g_zUfiSms_ConcatSms.current_sending ;
+ }
+ }
+
+ //·¢ËͽáÊø£¬³öÏÖ´íÎó
+ if( g_zUfiSms_ConcatSms.current_sending == g_zUfiSms_ConcatSms.total_msg && !g_zUfiSms_IsConcatSendSuc )
+ {
+ T_zUfiSms_StatusInfo tSendStatus;
+
+ memset((void*)&tSendStatus,0,sizeof(T_zUfiSms_StatusInfo));
+ tSendStatus.err_code = ZTE_SMS_CMS_NONE;
+ tSendStatus.send_failed_count = g_zUfiSms_SendFailedCount;
+ tSendStatus.delete_failed_count = 0;
+ tSendStatus.cmd_status = WMS_CMD_FAILED;
+ tSendStatus.cmd = WMS_SMS_CMD_MSG_SEND;
+ (void)zUfiSms_SetCmdStatus(&tSendStatus);
+
+ sc_cfg_set(NV_SMS_SEND_RESULT, "fail");
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+ return ZUFI_FAIL;
+ }
+ // ·¢ËÍʧ°Ü£¬µÝ¹éµ÷Ó㬶ÌÐÅ´æ´¢£¬Éϱ¨×´Ì¬¡£
+ if( !g_zUfiSms_IsConcatSendSuc)
+ {
+ zUfiSms_SendConcatSms(cid);
+ }
+
+ return result;
+}
+int zSvr_sendCmgs(VOID)
+{
+ int atRes = 0;
+ int i = 0;
+
+ atRes = zSms_SendCmgsReq();
+ if(atRes != ZSMS_RESULT_OK)
+ {
+ CHAR sendfailRetry[50]={0};
+ sc_cfg_get(NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));
+ if(0 == strcmp("1", sendfailRetry))
+ {
+ for(i=0;i<SMS_RETRY_COUNT;i++)
+ {
+ atRes = zSms_SendCmgsReq();
+ if(atRes == ZSMS_RESULT_OK)
+ {
+ break;
+ }
+ }
+ }
+ }
+ return atRes;
+}
+/*½«ÄÚÈÝconcat_sms°´ÕÕ·¢ËÍÈËgroup_smsÖð´Î·¢ËÍ */
+T_zUfiSms_CmdStatus zUfiSms_SendSms(VOID)
+{
+ T_zUfiSms_ClientMsg tClientMsg;
+ T_zUfiSms_DbStoreData tDbSaveData;
+ int res = 0;
+
+ if(-1 == g_zUfiSms_UnitLen)
+ {
+ // ÎÞÄÚÈÝ·¢ËÍ
+ printf("[SMS] !!!zUfiSms_SendSms: No content!.\n");
+ return WMS_CMD_FAILED;
+ }
+ while(g_zUfiSms_ConcatSms.current_sending < g_zUfiSms_ConcatSms.total_msg)
+ {
+ // ´ÓÈ«¾ÖÊý¾ÝÖй¹Ôì·¢ËÍÊý¾Ý£¬´æÈëtClientMsg/tDbSaveData
+ memset((void*)&tClientMsg,0, sizeof(T_zUfiSms_ClientMsg));
+ memset((void*)&tDbSaveData, 0, sizeof(tDbSaveData));
+ zUfiSms_SetPduData(&tClientMsg,&tDbSaveData);
+
+ /*if the first concat sms failed,then the left concat sms will not be send*/
+ if(!g_zUfiSms_IsConcatSendSuc)
+ {
+ tDbSaveData.tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ (void)zUfiSms_WriteSmsToDb(&tDbSaveData,WMS_STORAGE_TYPE_NV_V01,-1);//loop or only tag
+ g_zUfiSms_SendFailedCount++;
+ }
+ else
+ {
+ //atBase_SendMsgToSelf(ZAT_CMGS_CMD, NULL, 0);
+ res = zSvr_sendCmgs();
+ if(res != ZSMS_RESULT_OK)
+ {
+ zSms_RecvCmgsErr();
+ }
+ else
+ {
+ zSms_RecvCmgsOk();
+ }
+
+ }
+
+ //µ÷Õû·¢ËͼÆÊýÆ÷
+ g_zUfiSms_ConcatSms.current_sending++;
+ if (g_zUfiSms_ConcatSms.current_sending < g_zUfiSms_ConcatSms.total_msg)
+ {
+ //»¹Ê£ÏÂ×îºóÒ»¸ö·Ö¶Î´ý·¢ËÍ
+ if (g_zUfiSms_ConcatSms.sms_len < g_zUfiSms_UnitLen * (g_zUfiSms_ConcatSms.current_sending +1))
+ {
+ g_zUfiSms_UnitLen = g_zUfiSms_ConcatSms.sms_len - g_zUfiSms_UnitLen * g_zUfiSms_ConcatSms.current_sending ;
+ }
+ }
+
+ //·¢ËͽáÊø£¬³öÏÖ´íÎó
+ if( g_zUfiSms_ConcatSms.current_sending == g_zUfiSms_ConcatSms.total_msg && !g_zUfiSms_IsConcatSendSuc )
+ {
+ T_zUfiSms_StatusInfo tSendStatus;
+
+ memset((void*)&tSendStatus,0,sizeof(T_zUfiSms_StatusInfo));
+ tSendStatus.err_code = ZTE_SMS_CMS_NONE;
+ tSendStatus.send_failed_count = g_zUfiSms_SendFailedCount;
+ tSendStatus.delete_failed_count = 0;
+ tSendStatus.cmd_status = WMS_CMD_FAILED;
+ tSendStatus.cmd = WMS_SMS_CMD_MSG_SEND;
+ (void)zUfiSms_SetCmdStatus(&tSendStatus);
+
+ sc_cfg_set(NV_SMS_SEND_RESULT, "fail");
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+ //return ZUFI_FAIL;
+ }
+ }
+#if 0
+ if (g_zUfiSms_ConcatSms.total_msg > 1)
+ {
+ //³¤¶ÌÐÅ
+ printf("====zUfiSms_SendConcatSms.\n");
+ zUfiSms_SendConcatSms(cid);
+ }
+ else
+ {
+ //¶Ì¶ÌÐÅ£¬ ¸ù¾ÝÈ«¾ÖÊý¾ÝÀ´Ìî³ätClientMsg¡¢tDbSaveData
+ memset((void*)&tClientMsg,0, sizeof(T_zUfiSms_ClientMsg));
+ memset((void*)&tDbSaveData, 0, sizeof(tDbSaveData));
+ zUfiSms_SetPduData(&tClientMsg,&tDbSaveData);
+
+ printf("====zUfiSms_SendnoramlSms.\n");
+
+ if(WMS_CMD_FAILED == zUfiSms_SendOutSms(&tDbSaveData, cid))
+ {
+ printf("!!!!!zUfiSms_SendOutSms Fail.\n");
+ g_zUfiSms_SendFailedCount++;
+ return WMS_CMD_FAILED;
+ }
+ }
#endif
-(void)String2Bytes(g_zUfiSms_FinalCmgsBuf.pdu,tmpBuf1,(0x158b+660-0x181d));
-Bytes2String(tmpBuf1,tmpBuf2,strlen(tmpBuf1));nSmscLength=atoi(tmpBuf2);if(
-nSmscLength<(0xaa1+331-0xbec)||nSmscLength>INT_MAX-(0x24+2803-0xb16)){at_print(
-LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x6e\x53\x6d\x73\x63\x4c\x65\x6e\x67\x74\x68\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,nSmscLength);nSmscLength=(0x1d7d+1265-0x226e);;}nSmscLength++;
-g_zUfiSms_FinalCmgsBuf.length=iPduLength/(0xcb+3018-0xc93)-nSmscLength;
-#if (0xcaf+5774-0x233c)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4d\x61\x6b\x65\x46\x69\x6e\x61\x6c\x43\x6d\x67\x73\x42\x75\x66\x20\x6d\x61\x6b\x65\x20\x65\x6e\x64\x20\x70\x64\x75\x20\x64\x61\x74\x61" "\n"
-);printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x6c\x65\x6e\x3a\x25\x64\x2c\x20\x25\x73" "\n"
-,g_zUfiSms_FinalCmgsBuf.length,g_zUfiSms_FinalCmgsBuf.pdu);
+ return WMS_CMD_SUCCESS;
+}
+
+
+//½«tDataµÄÈÕÆÚ¸ñʽ»¯µ½ptTimestampÖÐ
+int zUfiSms_FormatDeliverTimestamp(T_zUfiSms_Date tData,T_zUfiSms_TimeStamp *ptTimestamp)
+{
+ unsigned char tTimeZone[5] = {0};
+ int tmp_i = 0;
+
+ memset(ptTimestamp,0,sizeof(T_zUfiSms_TimeStamp));
+ if(strlen(tData.year) == 1)
+ {
+ ptTimestamp->year = zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.year[0]);
+ }
+ else if(strlen(tData.year) == 2)
+ {
+ ptTimestamp->year = zUfiSms_atohex(tData.year[0])*16 + zUfiSms_atohex(tData.year[1]);
+ }
+ else if(strlen(tData.year) == 4)
+ {
+ ptTimestamp->year = zUfiSms_atohex(tData.year[2])*16 + zUfiSms_atohex(tData.year[3]);
+ }
+ else
+ {
+ printf("unknown year.");
+ return ZUFI_FAIL;
+ }
+
+ if(strlen(tData.month) == 1)
+ {
+ ptTimestamp->month= zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.month[0]);
+ }
+ else if(strlen(tData.month) == 2)
+ {
+ ptTimestamp->month= zUfiSms_atohex(tData.month[0])*16 + zUfiSms_atohex(tData.month[1]);
+ }
+ else
+ {
+ printf("unknown day.");
+ }
+
+ if(strlen(tData.day) == 1)
+ {
+ ptTimestamp->day= zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.day[0]);
+ }
+ else if(strlen(tData.day) == 2)
+ {
+ ptTimestamp->day= zUfiSms_atohex(tData.day[0])*16 + zUfiSms_atohex(tData.day[1]);
+ }
+ else
+ {
+ printf("unknown day.");
+ }
+
+ if(strlen(tData.hour) == 1)
+ {
+ ptTimestamp->hour= zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.hour[0]);
+ }
+ else if(strlen(tData.hour) == 2)
+ {
+ ptTimestamp->hour= zUfiSms_atohex(tData.hour[0])*16 + zUfiSms_atohex(tData.hour[1]);
+ }
+ else
+ {
+ printf("unknown hour.");
+ }
+
+ if(strlen(tData.min) == 1)
+ {
+ ptTimestamp->minute= zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.min[0]);
+ }
+ else if(strlen(tData.min) == 2)
+ {
+ ptTimestamp->minute= zUfiSms_atohex(tData.min[0])*16 + zUfiSms_atohex(tData.min[1]);
+ }
+ else
+ {
+ printf("unknown minute.");
+ }
+
+ if(strlen(tData.sec) == 1)
+ {
+ ptTimestamp->second= zUfiSms_atohex('0')*16 + zUfiSms_atohex(tData.sec[0]);
+ }
+ else if(strlen(tData.sec) == 2)
+ {
+ ptTimestamp->second= zUfiSms_atohex(tData.sec[0])*16 + zUfiSms_atohex(tData.sec[1]);
+ }
+ else
+ {
+ printf("unknown second.");
+ }
+ tmp_i = atoi(tData.timezone);
+ if(tmp_i < INT_MIN+1 || tmp_i > INT_MAX-1) { //kw 3
+ printf("unknown tData timezone:%d.\n", tmp_i);
+ return ZUFI_FAIL;
+ }
+
+ memset(tTimeZone,0,sizeof(tTimeZone));
+ snprintf(tTimeZone,sizeof(tTimeZone),"%d",tmp_i*4);
+ if(tData.timezone[0] == '-')
+ {
+ if(strlen(tTimeZone) == 2)
+ {
+ ptTimestamp->timezone = zUfiSms_atohex('0')*16 + zUfiSms_atohex(tTimeZone[1]);
+ }
+ else if(strlen(tTimeZone) == 3)
+ {
+ ptTimestamp->timezone = zUfiSms_atohex(tTimeZone[1])*10 + zUfiSms_atohex(tTimeZone[2]);
+ }
+ else
+ {
+ printf("unknown -timezone.");
+ }
+ ptTimestamp->timezone = 0 - ptTimestamp->timezone;
+ }
+ else
+ {
+ if(strlen(tTimeZone) == 1)
+ {
+ ptTimestamp->timezone = zUfiSms_atohex('0')*16 + zUfiSms_atohex(tTimeZone[0]);
+ }
+ else if(strlen(tTimeZone) == 2)
+ {
+ ptTimestamp->timezone = zUfiSms_atohex(tTimeZone[0])*10 + zUfiSms_atohex(tTimeZone[1]);
+ }
+ else
+ {
+ printf("unknown +timezone.");
+ }
+ }
+ return ZUFI_SUCC;
+}
+
+void zUfiSms_FillDeliver(T_zUfiSms_DeliverPdu *deliver,T_zUfiSms_ConcatInfo *concat_sms,
+ T_zUfiSms_DbStoreData *ptDbSaveData)
+{
+ static UINT16 msg_ref = 0;
+
+ deliver->user_data_header_present = TRUE;
+ if (0 == concat_sms->current_sending)
+ {
+ g_zUfiSms_ConcatSmsReference ++;
+ (void)zUfiSms_SetConcatMaxRefer(g_zUfiSms_ConcatSmsReference);
+ }
+
+ deliver->user_data_header_present = TRUE;
+ deliver->user_data.num_headers = 1;
+ deliver->user_data.headers[0].header_id = WMS_UDH_CONCAT_8;
+ deliver->user_data.headers[0].u.concat_8.msg_ref = msg_ref;
+ deliver->user_data.headers[0].u.concat_8.total_sm = concat_sms->total_msg;
+ deliver->user_data.headers[0].u.concat_8.seq_num = concat_sms->current_sending + 1;
+
+ ptDbSaveData->concat_sms = 1;
+ ptDbSaveData->concat_info[0] = msg_ref;
+}
+
+/* ¸ù¾Ýconcat_smsºÍgroup_smsÉèÖÃptDeliverÓëptDbSaveData */
+void zUfiSms_FillDeliverPdu
+(
+ T_zUfiSms_DeliverPdu *ptDeliver,
+ T_zUfiSms_ConcatInfo *concat_sms,
+ T_zUfiSms_GroupInfo *group_sms,
+ int iSmsLen,
+ T_zUfiSms_DbStoreData *ptDbSaveData
+)
+{
+ if (NULL == concat_sms || NULL == group_sms)
+ {
+ return ;
+ }
+
+ ptDeliver->more = FALSE;
+ ptDeliver->reply_path_present = FALSE;
+ ptDeliver->status_report_enabled = g_zUfiSms_CurSmsPara.status_report_on;
+ ptDeliver->pid = WMS_PID_DEFAULT;
+ ptDeliver->dcs.msg_class = WMS_MESSAGE_CLASS_NONE;
+ ptDeliver->dcs.is_compressed = FALSE;
+
+ if (g_zUfiSms_Dcs == DCS_ASC)
+ {
+ ptDeliver->dcs.alphabet = WMS_GW_ALPHABET_7_BIT_DEFAULT;
+ }
+ else
+ {
+ ptDeliver->dcs.alphabet = WMS_GW_ALPHABET_UCS2;
+ }
+
+ if (concat_sms->total_msg > 1)
+ {
+ zUfiSms_FillDeliver(ptDeliver,concat_sms,ptDbSaveData);
+
+ ptDbSaveData->concat_sms = 1;
+ ptDbSaveData->concat_info[2] = concat_sms->current_sending+1; /*start at 1 and increment by one */
+ ptDbSaveData->concat_info[1] = concat_sms->total_msg;
+ ptDbSaveData->concat_info[0] = ptDeliver->user_data.headers[0].u.concat_8.msg_ref;
+ }
+ else
+ {
+ ptDeliver->user_data_header_present = FALSE;
+ ptDeliver->user_data.num_headers = 0;
+ }
+
+ ptDeliver->user_data.sm_len = iSmsLen;
+ memcpy(ptDeliver->user_data.sm_data, concat_sms->msg_contents[concat_sms->current_sending], iSmsLen);
+ if (group_sms->receivers[group_sms->current_receiver][0] == '+')
+ {
+ (void)zUfiSms_CharToInt(group_sms->receivers[group_sms->current_receiver] + 1,
+ strlen(group_sms->receivers[group_sms->current_receiver]) - 1, ptDeliver->address.digits);
+ ptDeliver->address.number_type = WMS_NUMBER_INTERNATIONAL;
+ ptDeliver->address.number_of_digits = (UINT8)strlen(group_sms->receivers[group_sms->current_receiver]) - 1;
+ }
+ else
+ {
+ (void)zUfiSms_CharToInt(group_sms->receivers[group_sms->current_receiver], strlen(group_sms->receivers[group_sms->current_receiver]), ptDeliver->address.digits);
+ ptDeliver->address.number_type = WMS_NUMBER_UNKNOWN;
+ ptDeliver->address.number_of_digits = (UINT8)strlen(group_sms->receivers[group_sms->current_receiver]);
+ }
+
+ ptDeliver->address.digit_mode = WMS_DIGIT_MODE_4_BIT;
+ ptDeliver->address.number_mode = WMS_NUMBER_MODE_NONE_DATA_NETWORK;
+ ptDeliver->address.number_plan = WMS_NUMBER_PLAN_TELEPHONY;
+}
+
+T_zUfiSms_CmdStatus zUfiSms_SaveConcatSms
+(
+ T_zUfiSms_SaveReq *ptSaveSms,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_GroupInfo *ptGroupSms,
+ T_zUfiSms_DbStoreData *ptDbSaveData,
+ int iSmsLen
+)
+{
+ printf("[SMS] zUfiSms_SaveConcatSms mem_store=%d(NV==01)\n",ptSaveSms->mem_store);
+ if(ptSaveSms->mem_store == WMS_STORAGE_TYPE_NV_V01)/*else only write to nv */
+ {
+ if(ZUFI_FAIL == zUfiSms_WriteSmsToDb(ptDbSaveData,WMS_STORAGE_TYPE_NV_V01,-1))
+ {
+ at_print(LOG_ERR,"write sms to nv failed.");
+ return WMS_CMD_FAILED;
+ }
+ }
+ else
+ {
+ return WMS_CMD_FAILED;
+ }
+
+ g_zUfiSms_MsgRefer++;
+ ptDbSaveData->msg_ref = g_zUfiSms_MsgRefer;
+ (void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);
+
+ return WMS_CMD_SUCCESS;
+}
+
+T_zUfiSms_CmdStatus zUfiSms_SaveNormalSms(T_zUfiSms_SaveReq *ptSaveSms, T_zUfiSms_DbStoreData *ptDbSaveData)
+{
+ g_zUfiSms_MsgRefer++;
+ ptDbSaveData->msg_ref = g_zUfiSms_MsgRefer;
+
+ if(ptSaveSms->mem_store == WMS_STORAGE_TYPE_NV_V01)/*else only write to nv */
+ {
+ if(ZUFI_SUCC == zUfiSms_WriteSmsToDb(ptDbSaveData,WMS_STORAGE_TYPE_NV_V01,ptSaveSms->id))
+ {
+ (void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);
+ return WMS_CMD_SUCCESS;
+ }
+ else
+ {
+ printf("write sms to nv failed.");
+ return WMS_CMD_FAILED;
+ }
+ }
+ return WMS_CMD_SUCCESS;
+}
+
+/*½«¶ÌÐÅÄÚÈÝ´æÈëÊý¾Ý¿â */
+T_zUfiSms_CmdStatus zUfiSms_SaveSmsToDb
+(
+ T_zUfiSms_SaveReq *ptSaveSms,
+ T_zUfiSms_ConcatInfo *ptConcatSms,
+ T_zUfiSms_GroupInfo *ptGroupSms,
+ int iSmsLength
+)
+{
+ T_zUfiSms_ClientTsData tClientTsData;
+ T_zUfiSms_ClientMsg tClientMsg;
+ T_zUfiSms_DbStoreData tDbSaveData;
+ T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
+ int current_sending = 0;
+
+ if(NULL == ptSaveSms || NULL == ptConcatSms || NULL == ptGroupSms||(-1 == iSmsLength))
+ {
+ return WMS_CMD_FAILED;
+ }
+ for(ptConcatSms->current_sending = 0; ptConcatSms->current_sending < ptConcatSms->total_msg; ptConcatSms->current_sending++)
+ {
+ memset((void*)&tClientMsg,0, sizeof(T_zUfiSms_ClientMsg));
+ memset((void*)&tClientTsData, 0, sizeof(T_zUfiSms_ClientTsData));
+ memset((void*)&tDbSaveData, 0, sizeof(T_zUfiSms_DbStoreData));
+ // !!!!!!!ÀàÐͲ»Æ¥Åä
+ tClientMsg.msg_hdr.mem_store = (ptSaveSms->mem_store == WMS_STORAGE_TYPE_UIM_V01) ? WMS_STORAGE_TYPE_UIM_V01 : WMS_STORAGE_TYPE_NV_V01;
+ tClientMsg.msg_hdr.tag = (T_zUfiSms_SmsTag)ptSaveSms->tags;
+ tClientMsg.msg_hdr.message_mode = WMS_MESSAGE_MODE_GW;
+ tClientMsg.u.gw_message.is_broadcast = FALSE;
+
+ tClientTsData.format = WMS_FORMAT_GW_PP;
+
+ switch(ptSaveSms->tags)
+ {
+ case WMS_TAG_TYPE_MO_SENT_V01:
+ case WMS_TAG_TYPE_MO_NOT_SENT_V01:
+ case 4: /*for saved sms*/
+ {
+ tClientTsData.u.gw_pp.tpdu_type = WMS_TPDU_SUBMIT;
+ (void)zUfiSms_FillSubmitTpdu(ptConcatSms,ptGroupSms,iSmsLength,&tClientTsData.u.gw_pp.u.submit,&tDbSaveData);
+ break;
+ }
+ case WMS_TAG_TYPE_MT_READ_V01:
+ case WMS_TAG_TYPE_MT_NOT_READ_V01:
+ {
+ tClientTsData.u.gw_pp.tpdu_type = WMS_TPDU_DELIVER;
+ (void)zUfiSms_FormatDeliverTimestamp(ptSaveSms->date,&(tClientTsData.u.gw_pp.u.deliver.timestamp));
+ zUfiSms_FillDeliverPdu(&tClientTsData.u.gw_pp.u.deliver,ptConcatSms,ptGroupSms,iSmsLength,&tDbSaveData);
+ break;
+ }
+ default:
+ {
+ printf("unknown tags.");
+ break;
+ }
+ }
+
+ //½«tClientTsDataÖеÄsubmitÊý¾Ý¸ñʽ»¯µ½tClientMsgÖÐ
+ (void)wms_ts_encode(&tClientTsData,&tClientMsg.u.gw_message.raw_ts_data);
+ zUfiSms_FillSca(&tClientMsg);
+ zUfiSms_FillDbSaveData(&tClientMsg,&tClientTsData,ptConcatSms,ptGroupSms,iSmsLength,&tDbSaveData);
+ strncpy(tDbSaveData.draft_group_id, ptSaveSms->draft_group_id,sizeof(tDbSaveData.draft_group_id)-1);
+
+ if (TRUE == g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV])
+ {
+ //g_zUfiSms_StatusInfo.err_code = ZTE_SMS_CMS_MEM_FULL;
+ result = WMS_CMD_FAILED;
+ printf("[SMS] zUfiSms_SaveSmsToDb NV memory is full,save error\n");
+ }
+ else
+ {
+ if (tDbSaveData.concat_sms == 1) /*concat sms*/
+ {
+ result = zUfiSms_SaveConcatSms(ptSaveSms,ptConcatSms,ptGroupSms,&tDbSaveData,iSmsLength);
+ current_sending = ptConcatSms->current_sending + 1;
+ if (ptConcatSms->sms_len < iSmsLength * (current_sending +1))
+ {
+ iSmsLength = ptConcatSms->sms_len - iSmsLength * current_sending;
+ }
+ }
+ else
+ {
+ result = zUfiSms_SaveNormalSms(ptSaveSms,&tDbSaveData);
+ }
+ }
+ }
+ return result;
+}
+
+/** ɾ³ý¿¨ÖеĶÌÐÅ */
+int zUfiSms_DeleteSmsInSim()
+{
+ char str_index[128] = {0};
+ int index = 0;
+ int is_cc = 0;
+ int iSmsId = 0;
+ T_zUfiSms_ModifyTag tDeleteInfo = {0};
+ char StrValue[10] = {0};
+
+ memset(&tDeleteInfo,0,sizeof(T_zUfiSms_ModifyTag));
+ iSmsId = g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_index];
+ if(-1 == (is_cc = zUfiSms_IsConcatSms(iSmsId)))
+ {
+ printf("[SMS] zUfiSms_DeleteSmsInSim check concat failed.\n");
+ return ZUFI_FAIL;
+ }
+
+ printf("[SMS] zUfiSms_DeleteSmsInSim is_cc:%d, id=%d\n",is_cc,iSmsId);
+ if(1 == is_cc)
+ {
+ //¼¶Áª¶ÌÐÅ
+ if(ZUFI_FAIL == zUfiSms_GetSmsIndex(iSmsId,&tDeleteInfo,is_cc))
+ {
+ return ZUFI_FAIL;
+ }
+ g_zUfiSms_DelMsg.sim_index++ ;
+ g_zUfiSms_DelMsg.sim_index_count-- ;
+ //Öð¸öɾ³ý
+ while(tDeleteInfo.num_of_indices > 0)
+ {
+ index = tDeleteInfo.indices[tDeleteInfo.id_index];
+ g_deleteIndex.index[g_deleteIndex.total] = index;
+ g_deleteIndex.total++;
+
+ //zUfiSms_DelModemSms(index);
+ //SMS_SendToBackEx(AT_CMGD_CMD,AT_CMD_TYPE_SET, MSG_TYPE_CMGD, &Para,sizeof(T_zCmgd_SetCmd));
+ tDeleteInfo.id_index++;
+ tDeleteInfo.num_of_indices--;
+ }
+ }
+ else
+ {
+ //¶Ì¶ÌÐÅ
+ memset(str_index,0,sizeof(str_index));
+ if(ZUFI_FAIL == zUfiSms_GetStorePosById("ind",str_index,sizeof(str_index),iSmsId))
+ {
+ at_print(LOG_ERR,"get index from db faild.");
+ return ZUFI_FAIL;
+ }
+ index = atoi(str_index);
+ //atSms_SendCmgdReq(&index);
+ g_deleteIndex.index[g_deleteIndex.total] = index;
+ g_deleteIndex.total++;
+ //sat_print(LOG_DEBUGStrValue,"%d",index);
+ //atBase_SendMsgToSelf(ZAT_CMGD_CMD, StrValue, (UINT16)strlen(StrValue));
+ //atSms_SendCmgdReq(StrValue);
+ g_zUfiSms_DelMsg.sim_index++;
+ g_zUfiSms_DelMsg.sim_index_count--;
+ }
+ (void)zUfiSms_DeleteSmsInDb();
+ return ZUFI_SUCC;
+}
+
+/* ɾ³ý¿¨ÖжÌÐÅ */
+T_zUfiSms_CmdStatus zUfiSms_DeleteSimSms(VOID)
+{
+ int atRes = 0;
+ char StrValue[10] = {0};
+
+ zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
+ memset(&g_deleteIndex,0,sizeof(T_zUfiSms_DelIndexInfo));
+ while( g_zUfiSms_DelMsg.sim_index_count >0)
+ {
+ if(ZUFI_FAIL == zUfiSms_DeleteSmsInSim())
+ {
+ printf("[SMS] zUfiSms_DeleteSimSms delete all:%d sms failed\n",WMS_STORAGE_TYPE_UIM_V01);
+ return WMS_CMD_FAILED;
+ }
+ }
+ while(g_deleteIndex.cur_index < g_deleteIndex.total)
+ {
+ //snat_print(LOG_DEBUGStrValue,sizeof(StrValue),"%d",g_deleteIndex.index[g_deleteIndex.cur_index]);
+ //atBase_SendMsgToSelf(ZAT_CMGD_CMD, StrValue, (UINT16)strlen(StrValue));
+ atRes = zSms_SendCmgdReq(g_deleteIndex.index[g_deleteIndex.cur_index]);
+ if(atRes == ZSMS_RESULT_OK)
+ {
+ zSms_RecvCmgdOk();
+ }
+ else
+ {
+ zSms_RecvCmgdErr();
+ }
+ g_deleteIndex.cur_index++;
+ }
+ zSms_RecvCmgdFinish();
+ printf("[SMS] zUfiSms_DeleteSimSms success\n");
+ return WMS_CMD_SUCCESS;
+}
+
+// ´ÓPduÖжÁ³ö״̬±¨¸æ×Ö¶Î
+void zUfiSms_GetReportStatus(char *pdu_tmp,int *stat)
+{
+ unsigned char tmp; // ÄÚ²¿ÓõÄÁÙʱ×Ö½Ú±äÁ¿
+ unsigned char first_octet; //ÓÃÀ´±£´æ±£´æfirst octetµÄÐÅÏ¢
+
+ if(pdu_tmp == NULL )
+ {
+ return ;
+ }
+
+ // ¶ÌÐÅÖÐÐĵØÖ·ÐÅÏ¢¶Î
+ (void)String2Bytes(pdu_tmp, &tmp, 2);
+ if(tmp == 0)
+ {
+ // Èç¹û¶ÌÏûÏ¢ÖÐÐĵØÖ·³¤¶ÈΪ0£¬ÔòÖ¸ÕëÖµÖ»¼Ó2
+ pdu_tmp += 2;
+ }
+ else
+ {
+ // Èç¹û¶ÌÏûÏ¢ÖÐÐĵØÖ·³¤¶È²»Îª0£¬ÔòÖ¸ÕëÖµ°´tmpµÄÖµ¼Ó
+ tmp = (tmp + 1) * 2;// SMSCºÅÂë´®³¤¶È
+ pdu_tmp += tmp;// Ö¸ÕëºóÒÆ
+ }
+
+ // TPDU¶Î»ù±¾²ÎÊý¡¢»Ø¸´µØÖ·µÈ
+ (void)String2Bytes(pdu_tmp, &tmp, 2);// È¡»ù±¾²ÎÊýfirst octet
+ first_octet = tmp;
+ if(first_octet & 0x02)
+ {
+ *stat = 5;
+ }
+}
+
+T_zUfiSms_TpduType zUfiSms_GetTpduType(UINT8 *pData)
+{
+ T_zUfiSms_TpduType iTpduType;
+ UINT8 mti =0;
+
+ mti = (T_zUfiSms_TpduType) (pData[0] & 0x03); /*bit 0 and bit 1*/
+ switch(mti)
+ {
+ case 0:
+ iTpduType = WMS_TPDU_DELIVER;
+ break;
+ case 1:
+ iTpduType = WMS_TPDU_SUBMIT;
+ break;
+ case 2:
+ iTpduType = WMS_TPDU_STATUS_REPORT;
+ break;
+ default:
+ iTpduType = WMS_TPDU_MAX;
+ break;
+ }
+
+ return iTpduType;
+}
+
+static void zUfiSms_FormatDeliverNumber
+(
+ wms_address_s_type tAddress,
+ unsigned char *pNumber
+)
+{
+ UINT8 number_type = 0;
+
+ memset(pNumber, 0, ZTE_WMS_ADDRESS_LEN_MAX+1);
+ if (tAddress.number_type == WMS_NUMBER_INTERNATIONAL)
+ {
+ pNumber[0] = '+';
+ pNumber++;
+ }
+ if (tAddress.digit_mode != WMS_DIGIT_MODE_8_BIT)
+ {
+ (void)zUfiSms_SmsiAddrToStr(tAddress, (byte*)pNumber, &number_type);
+ }
+ else
+ {
+ memcpy(pNumber, tAddress.digits, tAddress.number_of_digits * sizeof(tAddress.digits[0]));
+ }
+}
+
+byte * zUfiSms_UtilTimeStamp
+(
+ T_zUfiSms_TimeStamp zte_wms_time, /* Pointer to Time Stamp */
+ byte * res_ptr, /* Pointer to the result buffer */
+ T_zUfiSms_Date *date
+)
+{
+ UINT8 tmp;
+
+ if (NULL == date)
+ {
+ return NULL;
+ }
+ /* Convert BCDs to strings */
+ *res_ptr++ = '"';
+ tmp = zte_wms_time.year;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr );
+ zUfiSms_SprintfTime(date->year, sizeof(date->year),zte_wms_time.year);
+ *res_ptr++ = '/';
+ tmp = zte_wms_time.month;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr );
+ zUfiSms_SprintfTime(date->month, sizeof(date->month),zte_wms_time.month);
+ *res_ptr++ = '/';
+ tmp = zte_wms_time.day;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr);
+ zUfiSms_SprintfTime(date->day, sizeof(date->day),zte_wms_time.day);
+ *res_ptr++ = ',';
+ tmp = zte_wms_time.hour;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr);
+ zUfiSms_SprintfTime(date->hour, sizeof(date->hour),zte_wms_time.hour);
+ *res_ptr++ = ':';
+ tmp = zte_wms_time.minute;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr);
+ zUfiSms_SprintfTime(date->min, sizeof(date->min),zte_wms_time.minute);
+ *res_ptr++ = ':';
+ tmp = zte_wms_time.second;
+ res_ptr = zUfiSms_SmsiUtilitoaFill( (tmp & 0x0F) + ((tmp >> 4) * 10),
+ res_ptr);
+ zUfiSms_SprintfTime(date->sec, sizeof(date->sec),zte_wms_time.second);
+
+ if( zte_wms_time.timezone < 0 )
+ {
+ *res_ptr++ = '-';
+ tmp = (UINT8)(zte_wms_time.timezone * (-1));
+ snprintf(date->timezone, sizeof(date->timezone),"-%d", -1 * zte_wms_time.timezone);
+ }
+ else
+ {
+ *res_ptr++ = '+';
+ tmp = (UINT8)zte_wms_time.timezone;
+ snprintf(date->timezone, sizeof(date->timezone),"+%d", zte_wms_time.timezone);
+ }
+ res_ptr = zUfiSms_SmsiUtilitoaFill( tmp, res_ptr);
+ *res_ptr++ = '"';
+
+ return res_ptr;
+}
+
+T_zUfiSms_CmdStatus zUfiSms_HandleReport( unsigned char* ptPduData)
+{
+ T_zUfiSms_RawTsData tRawTsData;
+ T_zUfiSms_ClientTsData tClientTsData;
+ int iReportStatus = 0;
+ unsigned char acDeliverNumber[ZTE_WMS_ADDRESS_LEN_MAX + 1];
+ unsigned char tTpScts[ZTE_WMS_TP_SCTS_LEN_MAX + 1];
+ T_zUfiSms_Date tSmsDate;
+ char acRecFlag[5] = {0};
+ int iRpCount = 0;
+ char tmp[10];
+ int tmp_i = 0;
+ unsigned int pos = 0;
+
+ if(NULL == ptPduData)
+ {
+ return WMS_CMD_FAILED;
+ }
+ memset(acDeliverNumber,0,sizeof(acDeliverNumber));
+ memset(&tSmsDate,0,sizeof(T_zUfiSms_Date));
+ memset(tTpScts,0,sizeof(tTpScts));
+ memset(&tRawTsData,0,sizeof(T_zUfiSms_RawTsData));
+ memset(&tClientTsData,0,sizeof(T_zUfiSms_ClientTsData));
+
+ snprintf(tmp,sizeof(tmp),"%X",ptPduData[0]);
+ tmp_i = atoi(tmp);
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]ptPduData err:%d\n", tmp_i);
+ return WMS_CMD_FAILED;
+ }
+ pos = tmp_i + 1;
+ if (pos >= ZSMS_PDU_SIZE) {//klocwork,//from AE
+ return WMS_CMD_FAILED;
+ }
+
+ memcpy((void*)tRawTsData.data,(void*)(ptPduData + pos),sizeof(tRawTsData.data));
+ tRawTsData.tpdu_type = zUfiSms_GetTpduType(ptPduData + pos);
+ tRawTsData.format = WMS_FORMAT_GW_PP;
+ (void)wms_ts_decode(&tRawTsData,&tClientTsData);
+ if(WMS_TPDU_STATUS_REPORT != tClientTsData.u.gw_pp.tpdu_type)
+ {
+ at_print(LOG_ERR,"does not gw/wcdma sms report status.");
+ return WMS_CMD_FAILED;
+ }
+ /*write sms report status:0:did not received report ,1:success,2:failed,3:unkown status */
+ switch(tClientTsData.u.gw_pp.u.status_report.tp_status)
+ {
+ case WMS_TP_STATUS_RECEIVED_OK:
+ case WMS_TP_STATUS_UNABLE_TO_CONFIRM_DELIVERY:
+ case WMS_TP_STATUS_REPLACED:
+ {
+ iReportStatus = 1;
+ break;
+ }
+ case WMS_TP_STATUS_TRYING_CONGESTION:
+ case WMS_TP_STATUS_TRYING_SME_BUSY:
+ case WMS_TP_STATUS_TRYING_NO_RESPONSE_FROM_SME:
+ case WMS_TP_STATUS_TRYING_SERVICE_REJECTED:
+ case WMS_TP_STATUS_TRYING_QOS_NOT_AVAILABLE:
+ case WMS_TP_STATUS_TRYING_SME_ERROR:
+ {
+ iReportStatus = 3;
+ break;
+ }
+ default:
+ {
+ iReportStatus = 2;
+ break;
+ }
+ }
+
+ zUfiSms_FormatDeliverNumber(tClientTsData.u.gw_pp.u.status_report.address, acDeliverNumber);
+ (void)zUfiSms_UtilTimeStamp(tClientTsData.u.gw_pp.u.status_report.timestamp,tTpScts, &tSmsDate);
+ if(ZUFI_FAIL == zUfiSms_InsertReportStatusToDb(acDeliverNumber,&tSmsDate,iReportStatus))
+ {
+ at_print(LOG_ERR,"update sms report status failed.");
+ return WMS_CMD_FAILED;
+ }
+ memset(acRecFlag,0,sizeof(acRecFlag));
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SMS_REPORT,acRecFlag,sizeof(acRecFlag));
+ iRpCount = atoi(acRecFlag);
+ if(iRpCount < 0 || iRpCount > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]iRpCount err:%d\n", iRpCount);
+ return WMS_CMD_FAILED;
+ }
+ memset(acRecFlag,0,sizeof(acRecFlag));
+ snprintf(acRecFlag,sizeof(acRecFlag),"%d",iRpCount + 1);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SMS_REPORT, acRecFlag);
+
+ return WMS_CMD_SUCCESS;
+}
+
+
+void zUfiSms_DelModemSms(int in_index)
+{
+#if 0 //zhangfen platform 20170210
+ char StrValue[10] = {0};
+ printf("[SMS] zUfiSms_DelModemSms fun used!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+ snat_print(LOG_DEBUGStrValue,sizeof(StrValue),"%d",in_index);
+ //atBase_SendMsgToSelf(ZAT_CMGD_CMD, StrValue, (UINT16)strlen(StrValue));
+ zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_DEL_SIM_SMS,strlen(StrValue),StrValue);
#endif
-return ZUFI_SUCC;}int zUfiSms_FillSubmitTpdu(T_zUfiSms_ConcatInfo*ptConcatSms,
-T_zUfiSms_GroupInfo*ptGroupSms,int iSmsLen,T_zUfiSms_SubmitTpdu*ptSubmit,
-T_zUfiSms_DbStoreData*ptDbSaveData){if(NULL==ptSubmit||NULL==ptConcatSms||NULL==
-ptGroupSms||NULL==ptDbSaveData){return-(0x28f+8935-0x2575);}ptSubmit->
-reject_duplicates=FALSE;ptSubmit->reply_path_present=FALSE;ptSubmit->
-user_data_header_present=FALSE;ptSubmit->status_report_enabled=
-g_zUfiSms_CurSmsPara.status_report_on;if(((0x1559+2266-0x1e32)<ptConcatSms->
-total_msg)&&(ptConcatSms->current_sending+(0xa1d+5452-0x1f68)<ptConcatSms->
-total_msg)){ptSubmit->status_report_enabled=(0x1def+263-0x1ef6);}ptSubmit->
-message_reference=g_zUfiSms_MsgRefer;ptSubmit->pid=WMS_PID_DEFAULT;ptSubmit->dcs
-.msg_class=(wms_message_class_e_type)(0x44c+6782-0x1ec6);ptSubmit->dcs.
-is_compressed=(0x10b2+3609-0x1ecb);ptSubmit->dcs.alphabet=(g_zUfiSms_Dcs==
-DCS_ASC)?WMS_GW_ALPHABET_7_BIT_DEFAULT:WMS_GW_ALPHABET_UCS2;ptSubmit->validity.
-format=WMS_GW_VALIDITY_RELATIVE;zUfiSms_DecodeRelativeTime(g_zUfiSms_CurSmsPara.
-tp_validity_period,&ptSubmit->validity.u.time);ptSubmit->user_data.num_headers=
-(0x172f+3735-0x25c6);if(ptConcatSms->total_msg>(0x16f4+498-0x18e5)){
-zUfiSms_FillDateheader(ptSubmit,ptConcatSms,ptDbSaveData);ptDbSaveData->
-concat_info[(0x1506+379-0x167f)]=ptConcatSms->current_sending+
-(0x1d93+942-0x2140);ptDbSaveData->concat_info[(0x1ba0+2389-0x24f4)]=ptConcatSms
-->total_msg;}if(g_zUfiSms_Language==DCS_PORTUGUESE){UINT8 i=ptSubmit->user_data.
-num_headers;ptSubmit->user_data_header_present=TRUE;ptSubmit->user_data.headers[
-i].header_id=WMS_UDH_NAT_LANG_SS;ptSubmit->user_data.headers[ptSubmit->user_data
-.num_headers].u.nat_lang_ss.nat_lang_id=WMS_UDH_NAT_LANG_PORTUGUESE;ptSubmit->
-user_data.num_headers++;g_zUfiSms_IsLanguageShift=WMS_UDH_NAT_LANG_SS;}ptSubmit
-->user_data.sm_len=iSmsLen;memcpy(ptSubmit->user_data.sm_data,ptConcatSms->
-msg_contents[ptConcatSms->current_sending],iSmsLen);if(ptGroupSms->receivers[
-ptGroupSms->current_receiver][(0x107d+5003-0x2408)]==((char)(0x1c79+10-0x1c58)))
-{(void)zUfiSms_CharToInt(ptGroupSms->receivers[ptGroupSms->current_receiver]+
-(0xa25+4432-0x1b74),strlen(ptGroupSms->receivers[ptGroupSms->current_receiver])-
-(0x1cd6+2132-0x2529),ptSubmit->address.digits);ptSubmit->address.number_type=
-WMS_NUMBER_INTERNATIONAL;ptSubmit->address.number_of_digits=strlen(ptGroupSms->
-receivers[ptGroupSms->current_receiver])-(0x7e3+6178-0x2004);}else if(ptGroupSms
-->receivers[ptGroupSms->current_receiver][(0xeaa+3464-0x1c32)]==
-((char)(0xbfa+4928-0x1f0a))&&ptGroupSms->receivers[ptGroupSms->current_receiver]
-[(0x158+2372-0xa9b)]==((char)(0xd06+2174-0x1554))){(void)zUfiSms_CharToInt(
-ptGroupSms->receivers[ptGroupSms->current_receiver]+(0xac7+3792-0x1995),strlen(
-ptGroupSms->receivers[ptGroupSms->current_receiver])-(0x1132+955-0x14eb),
-ptSubmit->address.digits);ptSubmit->address.number_type=WMS_NUMBER_INTERNATIONAL
-;ptSubmit->address.number_of_digits=strlen(ptGroupSms->receivers[ptGroupSms->
-current_receiver])-(0xfd+3392-0xe3b);}else{(void)zUfiSms_CharToInt(ptGroupSms->
-receivers[ptGroupSms->current_receiver],strlen(ptGroupSms->receivers[ptGroupSms
-->current_receiver]),ptSubmit->address.digits);ptSubmit->address.number_type=
-WMS_NUMBER_UNKNOWN;ptSubmit->address.number_of_digits=strlen(ptGroupSms->
-receivers[ptGroupSms->current_receiver]);}ptSubmit->address.digit_mode=(
-wms_digit_mode_e_type)(0x20e2+793-0x23fb);ptSubmit->address.number_mode=(
-wms_number_mode_e_type)(0x427+3445-0x119c);ptSubmit->address.number_plan=
-WMS_NUMBER_PLAN_TELEPHONY;memset(&g_zUfiSms_SendingSms,(0xf74+393-0x10fd),sizeof
-(SMS_PARAM));snprintf(g_zUfiSms_SendingSms.TPA,sizeof(g_zUfiSms_SendingSms.TPA),
-"\x25\x73",ptGroupSms->receivers[ptGroupSms->current_receiver]);if(
-g_zUfiSms_Language!=NOT_DEFINE_LANGUAGE){g_zUfiSms_SendingSms.TP_DCS=CODE_GSM7;}
-else{if(g_zUfiSms_Dcs==DCS_USC){g_zUfiSms_SendingSms.TP_DCS=CODE_UCS2;}else{
-g_zUfiSms_SendingSms.TP_DCS=CODE_GSM8;}}if(g_zUfiSms_SendingSms.TP_DCS==
-CODE_GSM7){zUfiSms_FillGlobalTpudGsm7(ptSubmit,ptConcatSms,ptDbSaveData);}else{
-zUfiSms_FillGlobalTpudUcs2(ptSubmit,ptConcatSms,ptDbSaveData);}(void)
-zUfiSms_MakeFinalCmgsBuf();return ZUFI_SUCC;}void zUfiSms_FillSca(
-T_zUfiSms_ClientMsg*ptClientMsg){char sca[ZTE_WMS_SCA_LEN_MAX]={
-(0x1c5b+1573-0x2280)};int i=(0x1c49+1191-0x20f0);if(NULL==ptClientMsg){return;}
-memcpy((void*)sca,(void*)(g_zUfiSms_CurSmsPara.sca),sizeof(g_zUfiSms_CurSmsPara.
-sca));if(sca[(0x190f+152-0x19a7)]==((char)(0x1d13+834-0x202a))){ptClientMsg->u.
-gw_message.sc_address.number_type=WMS_NUMBER_INTERNATIONAL;}ptClientMsg->u.
-gw_message.sc_address.digit_mode=WMS_DIGIT_MODE_8_BIT;ptClientMsg->u.gw_message.
-sc_address.number_plan=WMS_NUMBER_PLAN_TELEPHONY;ptClientMsg->u.gw_message.
-sc_address.number_of_digits=strlen(sca);if(sca[(0x1448+4353-0x2549)]==
-((char)(0x30a+6635-0x1cca))){ptClientMsg->u.gw_message.sc_address.
-number_of_digits--;for(i=(0x3a1+7345-0x2052);i<ptClientMsg->u.gw_message.
-sc_address.number_of_digits;i++){sca[i]=sca[i+(0x891+7061-0x2425)];}}else if(sca
-[(0x87c+4486-0x1a02)]==((char)(0xcc0+4917-0x1fc5))&&sca[(0x9a4+2941-0x1520)]==
-((char)(0x96+6545-0x19f7))){ptClientMsg->u.gw_message.sc_address.
-number_of_digits-=(0x5bf+2285-0xeaa);for(i=(0x12d3+4814-0x25a1);i<ptClientMsg->u
-.gw_message.sc_address.number_of_digits;i++){sca[i]=sca[i+(0x197+4623-0x13a4)];}
-}(void)zUfiSms_CharToInt(sca,ptClientMsg->u.gw_message.sc_address.
-number_of_digits,ptClientMsg->u.gw_message.sc_address.digits);}void
-zUfiSms_FillDbSaveData(T_zUfiSms_ClientMsg*ptClientMsg,T_zUfiSms_ClientTsData*
-ptClientData,T_zUfiSms_ConcatInfo*ptConcatSms,T_zUfiSms_GroupInfo*ptGroupSms,int
- iSmsLen,T_zUfiSms_DbStoreData*ptDbSaveData){if(NULL==ptClientMsg||NULL==
-ptClientData||NULL==ptConcatSms||NULL==ptGroupSms||NULL==ptDbSaveData){at_print(
-LOG_ERR,"\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73" "\n");return;
-}ptDbSaveData->mem_store=ptClientMsg->msg_hdr.mem_store;ptDbSaveData->index=
-ptClientMsg->msg_hdr.index;ptDbSaveData->mode=ptClientMsg->msg_hdr.message_mode;
-ptDbSaveData->tag=ptClientMsg->msg_hdr.tag;memset(ptDbSaveData->number,
-(0xd4+9505-0x25f5),ZTE_WMS_ADDRESS_LEN_MAX+(0x6ec+2812-0x11e7));memcpy(
-ptDbSaveData->number,ptGroupSms->receivers[ptGroupSms->current_receiver],strlen(
-ptGroupSms->receivers[ptGroupSms->current_receiver]));ptDbSaveData->tp_dcs=
-DCS_USC;ptDbSaveData->tp_pid=ptClientData->u.gw_pp.u.submit.pid;ptDbSaveData->
-msg_ref=ptClientData->u.gw_pp.u.submit.message_reference;memset(ptDbSaveData->
-sms_content,(0x81+8715-0x228c),sizeof(ptDbSaveData->sms_content));if(
-g_zUfiSms_Dcs==DCS_USC){ptDbSaveData->alphabet=WMS_GW_ALPHABET_UCS2;}else if(
-g_zUfiSms_Dcs==DCS_ASC){ptDbSaveData->alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;}(
-void)zUfiSms_DispatchWtoi(ptConcatSms->msg_contents[ptConcatSms->current_sending
-],iSmsLen,(UINT8*)ptDbSaveData->sms_content);memcpy(&(ptDbSaveData->julian_date)
-,&(ptConcatSms->date),sizeof(T_zUfiSms_Date));memcpy(&g_zUfiSms_DbStoreData[
-ptConcatSms->current_sending],ptDbSaveData,sizeof(zte_wms_db_sms_data_s_type));}
-void zUfiSms_SetPduData(T_zUfiSms_ClientMsg*ptClientMsg,T_zUfiSms_DbStoreData*
-ptDbSaveData){T_zUfiSms_ClientTsData tClientTsData;ptClientMsg->msg_hdr.
-mem_store=WMS_MEMORY_STORE_NV_GW;ptClientMsg->msg_hdr.tag=WMS_TAG_MO_NOT_SENT;
-ptClientMsg->msg_hdr.message_mode=WMS_MESSAGE_MODE_GW;ptClientMsg->u.gw_message.
-is_broadcast=FALSE;memset((void*)&tClientTsData,(0x6c2+2753-0x1183),sizeof(
-wms_client_ts_data_s_type));tClientTsData.format=WMS_FORMAT_GW_PP;tClientTsData.
-u.gw_pp.tpdu_type=WMS_TPDU_SUBMIT;(void)zUfiSms_FillSubmitTpdu(&
-g_zUfiSms_ConcatSms,&g_zUfiSms_GroupSms,g_zUfiSms_UnitLen,&tClientTsData.u.gw_pp
-.u.submit,ptDbSaveData);(void)wms_ts_encode(&tClientTsData,&ptClientMsg->u.
-gw_message.raw_ts_data);zUfiSms_FillSca(ptClientMsg);zUfiSms_FillDbSaveData(
-ptClientMsg,&tClientTsData,&g_zUfiSms_ConcatSms,&g_zUfiSms_GroupSms,
-g_zUfiSms_UnitLen,ptDbSaveData);}int zUfiSms_StoreNormalSmsToDb(
-T_zUfiSms_DbStoreData*ptDbSaveData,const char*pMemStore,long iSmsId){int result=
-ZUFI_SUCC;char*pContent=NULL;int iTotalCount=(0x15fb+1357-0x1b48);pContent=(char
-*)malloc((0x952+3356-0x166a)*ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX);if(pContent
-==NULL){return ZUFI_FAIL;}memset(pContent,(0xb4b+6933-0x2660),(0x533+406-0x6c5)*
-ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX);if(WMS_GW_ALPHABET_7_BIT_DEFAULT==
-ptDbSaveData->alphabet){static char data[(0xa4b+4459-0x1bb2)*
-ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX+(0xc8d+5657-0x22a5)]={(0x1a8+3416-0xf00)};memset
-(data,(0xe2+7013-0x1c47),(0xcb2+4953-0x2007)*ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX+
-(0xc95+969-0x105d));(void)zUfiSms_DecodeContent((char*)ptDbSaveData->sms_content
-,strlen(ptDbSaveData->sms_content),FALSE,data);strncpy(pContent,data,
-(0x13ac+1492-0x197c)*ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX-(0x2d5+3103-0xef3));}
-else{strncpy(pContent,ptDbSaveData->sms_content,(0x17d9+3386-0x250f)*
-ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX-(0xcbb+3592-0x1ac2));}ptDbSaveData->tp_dcs
-=(unsigned char)(0x1122+2975-0x1cbf);if(-(0x529+4546-0x16ea)==iSmsId){if(
-ZUFI_FAIL==zUfiSms_GetTotalCount(pMemStore,&iTotalCount)){free(pContent);
-pContent=NULL;return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x74\x6f\x72\x65\x4e\x6f\x72\x6d\x61\x6c\x53\x6d\x73\x54\x6f\x44\x62\x20\x69\x54\x6f\x74\x61\x6c\x43\x6f\x75\x6e\x74\x3d\x25\x64" "\n"
-,iTotalCount);if(iTotalCount>=g_zUfiSms_StoreCapablity[(strcmp(pMemStore,
-"\x6e\x76")?ZTE_WMS_MEMORY_SIM:ZTE_WMS_MEMORY_NV)]){free(pContent);pContent=NULL
-;return-(0x722+5773-0x1dae);}if(ZUFI_FAIL==zUfiSms_InsertNormalSmsToDb(
-ptDbSaveData,pMemStore,pContent)){result=ZUFI_FAIL;}}else{if(ZUFI_FAIL==
-zUfiSms_UpdateNormalSmsToDb(ptDbSaveData,pMemStore,pContent,iSmsId)){result=
-ZUFI_FAIL;}}free(pContent);pContent=NULL;return result;}static int
-zUfiSms_ConcatDataFree(T_zUfiSms_DbStoreData*ptDbSaveData,int count,char**
-out_result){int i=(0x994+2797-0x1481);for(i=(0x1c74+662-0x1f0a);i<count;i++){if(
-ptDbSaveData->concat_info[(0x1997+1096-0x1ddd)]==i+(0x3c3+968-0x78a)){free(
-out_result[i]);out_result[i]=NULL;break;}}return(0x1391+4256-0x2431);}int
-zUfiSms_AddNewSmsToConcatData(T_zUfiSms_DbStoreData*ptDbSaveData,char*
-pOldContent,char*pFormatNewContent,char*pRealNewContent,T_zUfiSms_DbStoreStr*pac
-,int*pConcatTotalNum,int len){int count=(0x18c7+156-0x1963);char**out_result=
-NULL;char cSegChar=((char)(0xf0d+4348-0x1fce));int i=(0x46d+3464-0x11f5);int
-iTotalSegNum=(0x1c48+1202-0x20fa);char acContentSeg[(0x5e2+6359-0x1eb7)*
-ZTE_WMS_SMS_MSG_CONTENT_STORE_LEN_MAX*ZTE_WMS_SMS_COUNT_MAX]={
-(0x2323+831-0x2662)};char*pCurConPos=acContentSeg;boolean isEsc=FALSE;if(NULL==
-pOldContent){return-(0x1940+1627-0x1f9a);}count=zUfiSms_SplitString(pOldContent,
-&out_result,cSegChar);for(i=(0x2ad+9231-0x26bc);i<count;i++){if(ptDbSaveData->
-concat_info[(0x13c8+1847-0x1afd)]==i+(0x10a+3773-0xfc6)){out_result[i]=(char*)
-malloc(sizeof(ptDbSaveData->sms_content));memset(out_result[i],
-(0x1508+1202-0x19ba),sizeof(ptDbSaveData->sms_content));if(
-WMS_GW_ALPHABET_7_BIT_DEFAULT==ptDbSaveData->alphabet){isEsc=
-zUfiSms_DecodeContent(ptDbSaveData->sms_content,strlen(ptDbSaveData->sms_content
-),isEsc,out_result[i]);}else{strncpy(out_result[i],ptDbSaveData->sms_content,
-sizeof(ptDbSaveData->sms_content)-(0x54+6592-0x1a13));}break;}}for(i=
-(0xc9a+54-0xcd0);i<count;i++){snprintf(acContentSeg+strlen(acContentSeg),sizeof(
-acContentSeg)-strlen(acContentSeg),"\x25\x73",out_result[i]);strcat(
-pFormatNewContent,out_result[i]);if(i!=count-(0x10fa+1754-0x17d3)){strcat(
-pFormatNewContent,"\x3b");}}strncpy(pRealNewContent,acContentSeg,len);
-zUfiSms_ConcatDataFree(ptDbSaveData,count,out_result);free(out_result);
-out_result=NULL;count=zUfiSms_SplitString(pac->IndStr,&out_result,cSegChar);for(
-i=(0xff1+3429-0x1d56);i<count;i++){if(ptDbSaveData->concat_info[
-(0xd50+1157-0x11d3)]==i+(0x1d8b+1317-0x22af)){out_result[i]=(char*)malloc(
-SHORT_INT_LEN);memset(out_result[i],(0x1612+2377-0x1f5b),SHORT_INT_LEN);snprintf
-(out_result[i],SHORT_INT_LEN,"\x25\x64",ptDbSaveData->index);break;}}for(i=
-(0xde2+306-0xf14);i<count;i++){snprintf(pac->FormatInd+strlen(pac->FormatInd),
-sizeof(pac->FormatInd)-strlen(pac->FormatInd),"\x25\x73",out_result[i]);if(i!=
-count-(0x3c2+8148-0x2395)){snprintf(pac->FormatInd+strlen(pac->FormatInd),sizeof
-(pac->FormatInd)-strlen(pac->FormatInd),"\x3b");}}zUfiSms_ConcatDataFree(
-ptDbSaveData,count,out_result);free(out_result);out_result=NULL;count=
-zUfiSms_SplitString(pac->Seg_Seq,&out_result,cSegChar);for(i=(0x977+1448-0xf1f);
-i<count;i++){if(ptDbSaveData->concat_info[(0x43f+6240-0x1c9d)]==i+
-(0x1c04+1719-0x22ba)){out_result[i]=(char*)malloc(SHORT_INT_LEN);memset(
-out_result[i],(0xb77+1609-0x11c0),SHORT_INT_LEN);snprintf(out_result[i],
-SHORT_INT_LEN,"\x25\x64",ptDbSaveData->concat_info[(0x5b6+7568-0x2344)]);break;}
-}for(i=(0xe68+6078-0x2626);i<count;i++){snprintf(pac->FormatSeq+strlen(pac->
-FormatSeq),sizeof(pac->FormatSeq)-strlen(pac->FormatSeq),"\x25\x73",out_result[i
-]);if(i!=count-(0x187+4210-0x11f8)){snprintf(pac->FormatSeq+strlen(pac->
-FormatSeq),sizeof(pac->FormatSeq)-strlen(pac->FormatSeq),"\x3b");}if(
-(0x19fb+3237-0x26a0)!=strcmp(out_result[i],"")){iTotalSegNum++;}}*
-pConcatTotalNum=iTotalSegNum;zUfiSms_ConcatDataFree(ptDbSaveData,count,
-out_result);free(out_result);out_result=NULL;return(0x685+4469-0x17fa);}int
-zUfiSms_UpdateConcatSms(T_zUfiSms_DbStoreData*ptDbSaveData,const char*pStorePos,
-long iSmsId){T_zUfiSms_DbStoreStr ac={(0x957+127-0x9d6)};char*pOldContent=NULL;
-char*pFormatNewContent=NULL;char*pRealNewContent=NULL;int iTotalNum=
-(0x5c6+3733-0x145b);int result=ZUFI_SUCC;int spaceLen=(0xcc9+4404-0x1df9)*
-ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX+(0xb42+5122-0x1f40)
-;pOldContent=(char*)malloc(spaceLen);pFormatNewContent=(char*)malloc(spaceLen);
-pRealNewContent=(char*)malloc(spaceLen);if(pOldContent==NULL||pFormatNewContent
-==NULL||pRealNewContent==NULL){if(pOldContent)free(pOldContent);if(
-pFormatNewContent)free(pFormatNewContent);if(pRealNewContent)free(
-pRealNewContent);return ZUFI_FAIL;}memset(pRealNewContent,(0xe58+3472-0x1be8),
-spaceLen);memset(pOldContent,(0x15d5+71-0x161c),spaceLen);memset(
-pFormatNewContent,(0x5cd+485-0x7b2),spaceLen);(void)zUfiSms_GetConcatInfo(
-pStorePos,iSmsId,&ac,pOldContent,spaceLen);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x20\x2d\x30\x20\x49\x6e\x64\x53\x74\x72\x3a\x25\x73\x2c\x53\x65\x67\x5f\x53\x65\x71\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x49\x6e\x64\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x53\x65\x71\x3a\x25\x73" "\n"
-,ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);if(-(0x7ad+4908-0x1ad8)==
-zUfiSms_AddNewSmsToConcatData(ptDbSaveData,pOldContent,pFormatNewContent,
-pRealNewContent,&ac,&iTotalNum,spaceLen)){result=ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x20\x30\x20\x49\x6e\x64\x53\x74\x72\x3a\x25\x73\x2c\x53\x65\x67\x5f\x53\x65\x71\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x49\x6e\x64\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x53\x65\x71\x3a\x25\x73" "\n"
-,ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);ptDbSaveData->tp_dcs=
-(0x1b6+5651-0x17c7);if(ZUFI_FAIL==zUfiSms_UpdateConcatSmsToDb(ptDbSaveData,
-pStorePos,pFormatNewContent,pRealNewContent,&ac,iTotalNum,iSmsId)){result=
-ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x74\x65\x65\x74\x20\x31\x20\x49\x6e\x64\x53\x74\x72\x3a\x25\x73\x2c\x53\x65\x67\x5f\x53\x65\x71\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x49\x6e\x64\x3a\x25\x73\x2c\x46\x6f\x72\x6d\x61\x74\x53\x65\x71\x3a\x25\x73" "\n"
-,ac.IndStr,ac.Seg_Seq,ac.FormatInd,ac.FormatSeq);free(pRealNewContent);free(
-pOldContent);free(pFormatNewContent);pRealNewContent=NULL;pOldContent=NULL;
-pFormatNewContent=NULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x55\x70\x64\x61\x74\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x20\x73\x75\x63\x63\x65\x73\x73\x2e" "\n"
-);return result;}int zUfiSms_InsertConcatSms(T_zUfiSms_DbStoreData*ptDbSaveData,
-const char*pStorePos){T_zUfiSms_DbStoreStr ac={(0x18c2+2366-0x2200)};int
-iSms_TotalCount=(0xb58+5987-0x22bb);int i=(0x16f4+826-0x1a2e);char acTmpContent[
-(0x1a1+5747-0x1714)];int iConcatNum=(0xc8+4018-0x107a);char*pFormatConcat=NULL;
-char*pContent=NULL;int spaceLen=(0x13cf+2302-0x1cc9)*
-ZTE_WMS_SMS_MSG_CONTENT_LEN_MAX*ZTE_WMS_CONCAT_SMS_COUNT_MAX+(0x271+6308-0x1b11)
-;if(NULL==ptDbSaveData||NULL==pStorePos){return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x65\x6e\x74\x65\x72\x20\x49\x6e\x73\x65\x72\x74\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x2e" "\n"
-);memset(acTmpContent,(0x5a5+384-0x725),sizeof(acTmpContent));iSms_TotalCount=
-ptDbSaveData->concat_info[(0xf6+1846-0x82b)];for(i=(0x893+2703-0x1321);i<
-iSms_TotalCount;i++){strcat(ac.IndStr,"\x3b");strcat(ac.Seg_Seq,"\x3b");strcat(
-acTmpContent,"\x3b");}pFormatConcat=(char*)malloc(spaceLen);if(NULL==
-pFormatConcat){return ZUFI_FAIL;}memset(pFormatConcat,(0x3f7+7884-0x22c3),
-spaceLen);pContent=(char*)malloc(spaceLen);if(pContent==NULL){free(pFormatConcat
-);return ZUFI_FAIL;}memset(pContent,(0xa55+3255-0x170c),spaceLen);if(-
-(0x210+6127-0x19fe)==zUfiSms_AddNewSmsToConcatData(ptDbSaveData,acTmpContent,
-pFormatConcat,pContent,&ac,&iConcatNum,spaceLen)){free(pFormatConcat);free(
-pContent);pFormatConcat=NULL;pContent=NULL;return ZUFI_FAIL;}ptDbSaveData->
-tp_dcs=(0x4d5+2165-0xd48);if(ZUFI_FAIL==zUfiSms_InsertConcatSmsToDb(ptDbSaveData
-,pStorePos,pFormatConcat,pContent,&ac,iConcatNum)){free(pFormatConcat);free(
-pContent);pFormatConcat=NULL;pContent=NULL;return ZUFI_FAIL;}free(pFormatConcat)
-;free(pContent);pFormatConcat=NULL;pContent=NULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x49\x6e\x73\x65\x72\x74\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x20\x73\x75\x63\x63\x65\x73\x73\x2e" "\n"
-);return ZUFI_SUCC;}int zUfiSms_StoreConcatSmsToDb(T_zUfiSms_DbStoreData*
-ptDbSaveData,char*pMemStore){long iSmsId=(0x7bb+1866-0xf05);int total_count=
-(0x657+7694-0x2465);if(NULL==ptDbSaveData||NULL==pMemStore){return ZUFI_FAIL;}
-iSmsId=zUfiSms_SearchConcatSmsInDb(ptDbSaveData,pMemStore);if(-
-(0x922+7283-0x2594)!=iSmsId){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x74\x6f\x72\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x20\x45\x6e\x74\x65\x72\x20\x55\x70\x64\x61\x74\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x20\x53\x6d\x73\x49\x64\x3a\x25\x64\x2e" "\n"
-,iSmsId);return zUfiSms_UpdateConcatSms(ptDbSaveData,pMemStore,iSmsId);}else{if(
-ZUFI_FAIL==zUfiSms_GetTotalCount(pMemStore,&total_count)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x74\x6f\x72\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x20\x47\x65\x74\x54\x6f\x74\x61\x6c\x43\x6f\x75\x6e\x74\x20\x46\x61\x69\x6c\x65\x64\x2e" "\n"
-);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x74\x6f\x72\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x20\x70\x4d\x65\x6d\x53\x74\x6f\x72\x65\x3d\x25\x73\x2c\x74\x6f\x74\x61\x6c\x5f\x63\x6f\x75\x6e\x74\x3d\x25\x64\x2e" "\n"
-,pMemStore,total_count);if(total_count>=g_zUfiSms_StoreCapablity[(strcmp(
-pMemStore,"\x6e\x76")?ZTE_WMS_MEMORY_SIM:ZTE_WMS_MEMORY_NV)]){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x74\x6f\x72\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x54\x6f\x44\x62\x20\x53\x6d\x73\x20\x6d\x65\x6d\x6f\x72\x79\x20\x69\x73\x20\x46\x75\x6c\x6c\x2e" "\n"
-);return ZUFI_FAIL;}return zUfiSms_InsertConcatSms(ptDbSaveData,pMemStore);}}int
- zUfiSms_WriteSmsToDb(T_zUfiSms_DbStoreData*ptDbSaveData,zUfiSms_StoreType
-iMemStore,long iSmsId){char acDbMemStore[(0x15f9+4025-0x25a8)];int iTotalCount=
-(0x39c+4556-0x1568);int id=(0x117c+2909-0x1cd9);UINT8 needCheckMemory=
-(0x5ea+8477-0x2706);if(NULL==ptDbSaveData){return ZUFI_FAIL;}memset(acDbMemStore
-,(0x1785+3189-0x23fa),sizeof(acDbMemStore));if(WMS_STORAGE_TYPE_UIM_V01==
-iMemStore){strncpy(acDbMemStore,ZTE_WMS_DB_SIM_TABLE,sizeof(acDbMemStore)-
-(0x16d1+2555-0x20cb));}else{strncpy(acDbMemStore,ZTE_WMS_DB_NV_TABLE,sizeof(
-acDbMemStore)-(0x1c9d+1103-0x20eb));}if((0x2fc+8231-0x2322)==ptDbSaveData->
-concat_sms){id=zUfiSms_SearchConcatSmsInDb(ptDbSaveData,&acDbMemStore);if(-
-(0x9b9+2925-0x1525)!=id){needCheckMemory=(0x382+950-0x738);}}if(needCheckMemory
-==(0xfa0+5824-0x265f)){if(ZUFI_FAIL==zUfiSms_GetTotalCount(acDbMemStore,&
-iTotalCount)){return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x53\x6d\x73\x54\x6f\x44\x62\x20\x69\x54\x6f\x74\x61\x6c\x43\x6f\x75\x6e\x74\x3d\x25\x64\x28\x6e\x65\x65\x64\x43\x68\x65\x63\x6b\x4d\x65\x6d\x6f\x72\x79\x3d\x3d\x31\x29" "\n"
-,iTotalCount);if(iTotalCount>=g_zUfiSms_StoreCapablity[(strcmp(acDbMemStore,
-"\x6e\x76")?ZTE_WMS_MEMORY_SIM:ZTE_WMS_MEMORY_NV)]){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x53\x6d\x73\x54\x6f\x44\x62\x20\x6d\x65\x6d\x6f\x72\x79\x20\x66\x75\x6c\x6c\x2c\x20\x65\x72\x72\x6f\x72" "\n"
-);return ZTE_WMS_NV_MEMORY_FULL;}}if(ptDbSaveData->concat_info[
-(0x1ea2+1217-0x2361)]==(0xfd3+2585-0x19ec)||ptDbSaveData->concat_info[
-(0x14ad+1517-0x1a98)]>ptDbSaveData->concat_info[(0x8b8+3693-0x1724)]){
-ptDbSaveData->concat_sms=(0xb61+3391-0x18a0);}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x53\x6d\x73\x54\x6f\x44\x62\x20\x54\x6f\x74\x61\x6c\x43\x6f\x75\x6e\x74\x3a\x25\x64\x2e\x63\x6f\x6e\x63\x61\x74\x5f\x73\x6d\x73\x3a\x25\x64\x2e\x63\x6f\x6e\x63\x61\x74\x5f\x69\x6e\x66\x6f\x5b\x31\x5d\x3a\x25\x64" "\n"
-,iTotalCount,ptDbSaveData->concat_sms,ptDbSaveData->concat_info[
-(0x133a+4931-0x267c)]);if((0x34d+8425-0x2435)==ptDbSaveData->concat_sms){if(
-ZTE_WMS_CONCAT_SMS_COUNT_MAX<ptDbSaveData->concat_info[(0x1c8c+629-0x1f00)]){
-return ZUFI_FAIL;}else{return zUfiSms_StoreConcatSmsToDb(ptDbSaveData,
-acDbMemStore);}}else{return zUfiSms_StoreNormalSmsToDb(ptDbSaveData,acDbMemStore
-,iSmsId);}}T_zUfiSms_CmdStatus zUfiSms_SendOutSms(T_zUfiSms_DbStoreData*
-ptDbSaveData,int cid){int atRes=(0x41d+2904-0xf75);if(NULL==ptDbSaveData){return
- WMS_CMD_FAILED;}if(!g_zUfiSms_IsConcatSendSuc){ptDbSaveData->tag=
-WMS_TAG_TYPE_MO_NOT_SENT_V01;if(ZUFI_SUCC==zUfiSms_WriteSmsToDb(ptDbSaveData,
-WMS_STORAGE_TYPE_NV_V01,-(0xdd5+1020-0x11d0))){g_zUfiSms_MsgRefer++;ptDbSaveData
-->msg_ref=g_zUfiSms_MsgRefer;(void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);}
-}else{CHAR sendfailRetry[(0x9e5+7064-0x254b)]={(0x12b6+1323-0x17e1)};sc_cfg_get(
-NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));if((0x7fb+2841-0x1314)==
-strcmp("\x31",sendfailRetry)){g_zUfiSms_SendFailedRetry=(0x6c6+7716-0x24e7);}
-atRes=zSms_SendCmgsReq();if(atRes!=ZSMS_RESULT_OK){zSms_RecvCmgsErr();}else{
-zSms_RecvCmgsOk();}}return WMS_CMD_SUCCESS;}int zUfiSms_SendConcatSms(int cid){
-int atRes=(0x1c+5107-0x140f);T_zUfiSms_ClientMsg tClientMsg;
-T_zUfiSms_DbStoreData tDbSaveData;int result=ZUFI_FAIL;if(g_zUfiSms_ConcatSms.
-current_sending>=g_zUfiSms_ConcatSms.total_msg){return ZUFI_FAIL;}memset((void*)
-&tClientMsg,(0x106f+1551-0x167e),sizeof(T_zUfiSms_ClientMsg));memset((void*)&
-tDbSaveData,(0xf36+4598-0x212c),sizeof(tDbSaveData));zUfiSms_SetPduData(&
-tClientMsg,&tDbSaveData);if(!g_zUfiSms_IsConcatSendSuc){tDbSaveData.tag=
-WMS_TAG_TYPE_MO_NOT_SENT_V01;(void)zUfiSms_WriteSmsToDb(&tDbSaveData,
-WMS_STORAGE_TYPE_NV_V01,-(0xead+1230-0x137a));g_zUfiSms_SendFailedCount++;}else{
-CHAR sendfailRetry[(0x1427+2453-0x1d8a)]={(0xc1a+4608-0x1e1a)};sc_cfg_get(
-NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));if((0xbb8+1746-0x128a)==
-strcmp("\x31",sendfailRetry)){g_zUfiSms_SendFailedRetry=(0xf83+1596-0x15bc);}
-atRes=zSms_SendCmgsReq();if(atRes!=ZSMS_RESULT_OK){zSms_RecvCmgsErr();}else{
-zSms_RecvCmgsOk();}}g_zUfiSms_ConcatSms.current_sending++;if(g_zUfiSms_ConcatSms
-.current_sending<g_zUfiSms_ConcatSms.total_msg){if(g_zUfiSms_ConcatSms.sms_len<
-g_zUfiSms_UnitLen*(g_zUfiSms_ConcatSms.current_sending+(0x1e7d+1119-0x22db))){
-g_zUfiSms_UnitLen=g_zUfiSms_ConcatSms.sms_len-g_zUfiSms_UnitLen*
-g_zUfiSms_ConcatSms.current_sending;}}if(g_zUfiSms_ConcatSms.current_sending==
-g_zUfiSms_ConcatSms.total_msg&&!g_zUfiSms_IsConcatSendSuc){T_zUfiSms_StatusInfo
-tSendStatus;memset((void*)&tSendStatus,(0x25d+236-0x349),sizeof(
-T_zUfiSms_StatusInfo));tSendStatus.err_code=ZTE_SMS_CMS_NONE;tSendStatus.
-send_failed_count=g_zUfiSms_SendFailedCount;tSendStatus.delete_failed_count=
-(0x1159+3525-0x1f1e);tSendStatus.cmd_status=WMS_CMD_FAILED;tSendStatus.cmd=
-WMS_SMS_CMD_MSG_SEND;(void)zUfiSms_SetCmdStatus(&tSendStatus);sc_cfg_set(
-NV_SMS_SEND_RESULT,"\x66\x61\x69\x6c");sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");
-return ZUFI_FAIL;}if(!g_zUfiSms_IsConcatSendSuc){zUfiSms_SendConcatSms(cid);}
-return result;}int zSvr_sendCmgs(VOID){int atRes=(0xe3f+502-0x1035);int i=
-(0x4c1+3424-0x1221);atRes=zSms_SendCmgsReq();if(atRes!=ZSMS_RESULT_OK){CHAR
-sendfailRetry[(0x125b+614-0x148f)]={(0x105c+2225-0x190d)};sc_cfg_get(
-NV_SENDFAIL_RETRY,sendfailRetry,sizeof(sendfailRetry));if((0x108b+80-0x10db)==
-strcmp("\x31",sendfailRetry)){for(i=(0x410+4613-0x1615);i<SMS_RETRY_COUNT;i++){
-atRes=zSms_SendCmgsReq();if(atRes==ZSMS_RESULT_OK){break;}}}}return atRes;}
-T_zUfiSms_CmdStatus zUfiSms_SendSms(VOID){T_zUfiSms_ClientMsg tClientMsg;
-T_zUfiSms_DbStoreData tDbSaveData;int res=(0xce9+6611-0x26bc);if(-
-(0x19a5+2116-0x21e8)==g_zUfiSms_UnitLen){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x21\x21\x21\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x53\x6d\x73\x3a\x20\x4e\x6f\x20\x63\x6f\x6e\x74\x65\x6e\x74\x21\x2e" "\n"
-);return WMS_CMD_FAILED;}while(g_zUfiSms_ConcatSms.current_sending<
-g_zUfiSms_ConcatSms.total_msg){memset((void*)&tClientMsg,(0x1068+5469-0x25c5),
-sizeof(T_zUfiSms_ClientMsg));memset((void*)&tDbSaveData,(0x867+3581-0x1664),
-sizeof(tDbSaveData));zUfiSms_SetPduData(&tClientMsg,&tDbSaveData);if(!
-g_zUfiSms_IsConcatSendSuc){tDbSaveData.tag=WMS_TAG_TYPE_MO_NOT_SENT_V01;(void)
-zUfiSms_WriteSmsToDb(&tDbSaveData,WMS_STORAGE_TYPE_NV_V01,-(0xcb+1337-0x603));
-g_zUfiSms_SendFailedCount++;}else{res=zSvr_sendCmgs();if(res!=ZSMS_RESULT_OK){
-zSms_RecvCmgsErr();}else{zSms_RecvCmgsOk();}}g_zUfiSms_ConcatSms.current_sending
-++;if(g_zUfiSms_ConcatSms.current_sending<g_zUfiSms_ConcatSms.total_msg){if(
-g_zUfiSms_ConcatSms.sms_len<g_zUfiSms_UnitLen*(g_zUfiSms_ConcatSms.
-current_sending+(0x674+1263-0xb62))){g_zUfiSms_UnitLen=g_zUfiSms_ConcatSms.
-sms_len-g_zUfiSms_UnitLen*g_zUfiSms_ConcatSms.current_sending;}}if(
-g_zUfiSms_ConcatSms.current_sending==g_zUfiSms_ConcatSms.total_msg&&!
-g_zUfiSms_IsConcatSendSuc){T_zUfiSms_StatusInfo tSendStatus;memset((void*)&
-tSendStatus,(0x337+6752-0x1d97),sizeof(T_zUfiSms_StatusInfo));tSendStatus.
-err_code=ZTE_SMS_CMS_NONE;tSendStatus.send_failed_count=
-g_zUfiSms_SendFailedCount;tSendStatus.delete_failed_count=(0x138d+2128-0x1bdd);
-tSendStatus.cmd_status=WMS_CMD_FAILED;tSendStatus.cmd=WMS_SMS_CMD_MSG_SEND;(void
-)zUfiSms_SetCmdStatus(&tSendStatus);sc_cfg_set(NV_SMS_SEND_RESULT,
-"\x66\x61\x69\x6c");sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");}}
-#if (0xa79+4613-0x1c7e)
-if(g_zUfiSms_ConcatSms.total_msg>(0x9b2+5601-0x1f92)){printf(
-"\x3d\x3d\x3d\x3d\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x2e" "\n"
-);zUfiSms_SendConcatSms(cid);}else{memset((void*)&tClientMsg,
-(0x1379+3734-0x220f),sizeof(T_zUfiSms_ClientMsg));memset((void*)&tDbSaveData,
-(0x134a+1191-0x17f1),sizeof(tDbSaveData));zUfiSms_SetPduData(&tClientMsg,&
-tDbSaveData);printf(
-"\x3d\x3d\x3d\x3d\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x6e\x6f\x72\x61\x6d\x6c\x53\x6d\x73\x2e" "\n"
-);if(WMS_CMD_FAILED==zUfiSms_SendOutSms(&tDbSaveData,cid)){printf(
-"\x21\x21\x21\x21\x21\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x4f\x75\x74\x53\x6d\x73\x20\x46\x61\x69\x6c\x2e" "\n"
-);g_zUfiSms_SendFailedCount++;return WMS_CMD_FAILED;}}
+ int atRes = 0;
+
+ atRes = zSms_SendCmgdReq(in_index);
+ if(atRes == ZSMS_RESULT_OK)
+ {
+ zSms_RecvCmgdOk();
+ }
+ else
+ {
+ zSms_RecvCmgdErr();
+ }
+ zSms_RecvCmgdFinish();
+}
+
+VOID zUfiSms_getModifyInfo(T_zUfiSms_ModifyFlag *ptModifyBuff)
+{
+ int i = 0;
+
+ memset(&g_zUfiSms_modifyMsg, 0, sizeof(T_zUfiSms_ModifySms));
+
+ for(i = 0; i < ptModifyBuff->total_id; i++)
+ {
+ g_zUfiSms_modifyMsg.sim_id[g_zUfiSms_modifyMsg.sim_count] = ptModifyBuff->id[i];
+ g_zUfiSms_modifyMsg.sim_count++;
+ g_zUfiSms_modifyMsg.sim_index_count++;
+ }
+}
+
+
+/** ͳ¼Æ¿¨ÖеÄδ¶Á¶ÌÐÅ */
+int zUfiSms_GetUnreadSmsIndexInSim()
+{
+ char str_index[128] = {0};
+ int index = 0;
+ int is_cc = 0;
+ int iSmsId = 0;
+ T_zUfiSms_ModifyTag tModifyInfo = {0};
+ char StrValue[10] = {0};
+
+ memset(&tModifyInfo,0,sizeof(T_zUfiSms_ModifyTag));
+ iSmsId = g_zUfiSms_modifyMsg.sim_id[g_zUfiSms_modifyMsg.sim_index];
+ if(-1 == (is_cc = zUfiSms_IsConcatSms(iSmsId)))
+ {
+ at_print(LOG_ERR,"check concat failed.");
+ return ZUFI_FAIL;
+ }
+
+ printf("[SMS] zUfiSms_GetUnreadSmsIndexInSim is_cc:%d",is_cc);
+ if(1 == is_cc)
+ {
+ //¼¶Áª¶ÌÐÅ
+ if(ZUFI_FAIL == zUfiSms_GetSmsIndex(iSmsId,&tModifyInfo,is_cc))
+ {
+ return ZUFI_FAIL;
+ }
+ g_zUfiSms_modifyMsg.sim_index++ ;
+ g_zUfiSms_modifyMsg.sim_index_count-- ;
+
+ while(tModifyInfo.num_of_indices > 0)
+ {
+ index = tModifyInfo.indices[tModifyInfo.id_index];
+ g_modifyIndex.index[g_modifyIndex.total] = index;
+ g_modifyIndex.total++;
+ tModifyInfo.id_index++;
+ tModifyInfo.num_of_indices--;
+ printf("[SMS] zUfiSms_GetUnreadSmsIndexInSim [1 == is_cc] index = %d, total=%d\n", index, g_modifyIndex.total);
+ }
+ }
+ else
+ {
+ //¶Ì¶ÌÐÅ
+ memset(str_index,0,sizeof(str_index));
+ if(ZUFI_FAIL == zUfiSms_GetStorePosById("ind",str_index,sizeof(str_index),iSmsId))
+ {
+ at_print(LOG_ERR,"get index from db faild.");
+ return ZUFI_FAIL;
+ }
+ index = atoi(str_index);
+ g_modifyIndex.index[g_modifyIndex.total] = index;
+ g_modifyIndex.total++;
+ g_zUfiSms_modifyMsg.sim_index++;
+ g_zUfiSms_modifyMsg.sim_index_count--;
+ printf("[SMS] zUfiSms_GetUnreadSmsIndexInSim [1 != is_cc]index = %d, total=%d\n", index, g_modifyIndex.total);
+ }
+
+ return ZUFI_SUCC;
+}
+
+
+void zUfiSms_ModifyModemSms(T_zUfiSms_ModifyFlag *ptModifyBuff)
+{
+ int atRes = 0;
+ char StrValue[10] = {0};
+ printf("[SMS] zUfiSms_ModifyModemSms ptModifyBuff->type = %d!\n",ptModifyBuff->type);
+ //cmd from ufi monitor
+ //if(ptModifyBuff->type == 1)
+ {
+ zUfiSms_getModifyInfo(ptModifyBuff);
+ memset(&g_modifyIndex,0,sizeof(T_zUfiSms_ModifyIndexInfo));
+ printf("[SMS] zUfiSms_ModifyModemSms ptModifyBuff->total_id = %d!\n",ptModifyBuff->total_id);
+ while(g_zUfiSms_modifyMsg.sim_index_count > 0)
+ {
+ if(ZUFI_FAIL == zUfiSms_GetUnreadSmsIndexInSim())
+ {
+ at_print(LOG_ERR,"delete all:%d sms failed\n",WMS_STORAGE_TYPE_UIM_V01);
+ return;
+ }
+ }
+ while(g_modifyIndex.cur_index < g_modifyIndex.total)
+ {
+ snprintf(StrValue,sizeof(StrValue),"%d",g_modifyIndex.index[g_modifyIndex.cur_index]);
+ //atBase_SendMsgToSelf(ZAT_CMGR_CMD, StrValue, (UINT16)strlen(StrValue));
+ atRes = zSms_SendCmgrReq(g_modifyIndex.index[g_modifyIndex.cur_index]);
+ printf("[SMS] zUfiSms_ModifyModemSms index = %s \n", StrValue);
+ g_modifyIndex.cur_index++;
+ }
+ }
+/*
+ else //cmd from webui
+ {
+ //sat_print(LOG_DEBUGStrValue,"%d",0);
+ //atBase_SendMsgToSelf(ZAT_CMGL_CMD, StrValue, (UINT16)strlen(StrValue));
+ atRes = atSms_SendCmglReq(ZUFI_NULL, cid, errCode, ZSVR_AT_RES_CODE_LEN);
+ }
+*/
+}
+
+
+static int zUfiSms_FormatGwDbData
+(
+ T_zUfiSms_ClientTsData *ts_data_ptr,
+ T_zUfiSms_DbStoreData *db_data
+)
+{
+ int result = ZUFI_SUCC;
+
+ if((NULL == ts_data_ptr) || (NULL == db_data))
+ {
+ at_print(LOG_ERR,"invalid inputs.");
+ return ZUFI_FAIL;
+ }
+ if (WMS_FORMAT_GW_PP == ts_data_ptr->format)
+ {
+ switch (ts_data_ptr->u.gw_pp.tpdu_type)
+ {
+ case WMS_TPDU_DELIVER:
+ {
+ result = zUfiSms_FormatDeliverDbdata(ts_data_ptr, db_data);
+ break;
+ }
+ case WMS_TPDU_SUBMIT:
+ {
+ result = zUfiSms_FormatSubmitDbdata(ts_data_ptr, db_data);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
+/* ¶Ô½ÓÊÕµ½µÄ¶ÌÐÅ»òÕß¶ÌÐű¨¸æ½øÐнâÂë */
+int zUfiSms_DecodeSmsData
+(
+ T_zUfiSms_DbStoreData *pDb_Data,
+ int msg_index,
+ zUfiSms_StoreType iStorePos,
+ T_SmsStatus bSms_Status,
+ wms_message_format_enum_v01 format,
+ long iPdu_Len,
+ unsigned char *pPdu_Received
+)
+{
+ T_zUfiSms_RawTsData raw_ts;
+ T_zUfiSms_ClientTsData ts_data_ptr;
+ char tmp[10];
+ int tmp_i = 0;
+ unsigned int pos = 0;
+ int result = ZUFI_SUCC;
+
+ if(NULL == pDb_Data)
+ {
+ return ZUFI_FAIL;
+ }
+
+ pDb_Data->mem_store = (unsigned long)iStorePos;
+ pDb_Data->index = (unsigned short)msg_index;
+
+ if(RECEIVED_UNREAD == bSms_Status)
+ {
+ pDb_Data->tag = WMS_TAG_TYPE_MT_NOT_READ_V01;
+ }
+ else if(RECEIVED_READ == bSms_Status)
+ {
+ pDb_Data->tag = WMS_TAG_TYPE_MT_READ_V01;
+ }
+ else if(STORED_UNSEND == bSms_Status)
+ {
+ pDb_Data->tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ }
+ else
+ {
+ pDb_Data->tag = WMS_TAG_TYPE_MO_SENT_V01;
+ }
+
+ pDb_Data->mode = (unsigned short)format;
+
+ memset(&raw_ts,0,sizeof(T_zUfiSms_RawTsData));
+ memset(&ts_data_ptr,0,sizeof(wms_client_ts_data_s_type));
+
+ //´æ´¢Î»ÖÃ
+ memset(tmp,0,sizeof(tmp));
+ snprintf(tmp,sizeof(tmp),"%d",pPdu_Received[0]);
+ tmp_i = atoi(tmp); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]pPdu_Received err:%d\n", tmp_i);
+ return ZUFI_FAIL;
+ }
+ pos = tmp_i + 1;
+ if (pos >= iPdu_Len) {//klocwork
+ return ZUFI_FAIL;
+ }
+ raw_ts.len = iPdu_Len - pos;
+ memcpy((void*)raw_ts.data, (void*)(pPdu_Received + pos), WMS_MAX_LEN);
+ raw_ts.tpdu_type = zUfiSms_GetTpduType(pPdu_Received + pos);
+ raw_ts.format = (WMS_MESSAGE_FORMAT_CDMA_V01 == format) ? WMS_FORMAT_CDMA : WMS_FORMAT_GW_PP;
+
+ (void)wms_ts_decode(&raw_ts,&ts_data_ptr);
+ switch(format)
+ {
+ case WMS_MESSAGE_FORMAT_CDMA_V01:
+ {
+ result = ZUFI_SUCC;
+ break;
+ }
+ case WMS_MESSAGE_FORMAT_GW_PP_V01:
+ {
+ result = zUfiSms_FormatGwDbData(&ts_data_ptr, pDb_Data);
+ break;
+ }
+ case WMS_MESSAGE_FORMAT_GW_BC_V01:
+ case WMS_MESSAGE_FORMAT_MWI_V01:
+ {
+ result = ZUFI_FAIL;
+ break;
+ }
+ default:
+ {
+ result = ZUFI_FAIL;
+ break;
+ }
+ }
+ return result;
+}
+
+T_zUfiSms_CmdStatus IsSmsLoadSuccess(void)
+{
+ char IsInit[36] = {0};
+ sc_cfg_get(NV_SMS_LOAD_RESULT,IsInit,sizeof(IsInit));
+ if(0 == strcmp("ok", IsInit))
+ {
+ printf("[SMS] sms Load success!\n");
+ return WMS_CMD_SUCCESS;
+ }
+ else
+ {
+ printf("[SMS] sms Load wrong !\n");
+ return WMS_CMD_FAILED;
+ }
+}
+
+#if 0
+//½«at_rec·¢À´µÄ¶ÌÐÅÔʼÄÚÈݰ´ÕÕ¶ÔÓ¦µÄÐÅÔª£¬¸ñʽ»¯Êä³öµ½ptSmsParaÖÐ
+int zUfiSms_FormatSms(CHAR *pSmsRawContent, int contentSize, T_zUfiSms_SmsItem *ptSmsPara, int iCmdId)
+{
+ //ÕÒµ½Èý¸ö¶ººÅ
+ char* P1 = strchr(pSmsRawContent,',');
+ if(NULL == P1)
+ {
+ return ZUFI_FAIL;
+ }
+
+ char* P2 = strchr((char*)(P1+1),',');
+ if(NULL == P2)
+ {
+ return ZUFI_FAIL;
+ }
+ char* P3 = strchr((char*)(P2+1),',');
+
+ /* Ô¤´¦Àí²ÎÊýÐÐ */
+ atBase_PreProcRes(pSmsRawContent,contentSize);
+ // cgmlµÄÉϱ¨´¦Àí
+ if (1 == iCmdId)
+ {
+ if (P3==P2+1) // when the reserved segment is null, cmgl is like as: 1,1,,160,"0891...."
+ {
+ sscanf(pSmsRawContent,"%d %d %d ", &ptSmsPara->index, &ptSmsPara->stat,&ptSmsPara->length);
+ }
+ else // when the reserved segment is not null, the cmgl is like as: 1,1,"xxx",160,"0891...."
+ {
+ sscanf(pSmsRawContent,"%d %d %32s %d ", &ptSmsPara->index, &ptSmsPara->stat, ptSmsPara->alpha, &ptSmsPara->length);
+ }
+ }
+ else if(2 == iCmdId)// cgmrµÄÉϱ¨´¦Àí
+ {
+ if (P2 == P1+1) // when the reserved segment is null, cmgr is like as: +cmgr:1,,68
+ {
+ sscanf(pSmsRawContent,"%d %d ", &ptSmsPara->stat,&ptSmsPara->length);
+ }
+ else // when the reserved segment is not null, the cmgr is like as: +cmgr:1,"xxx",68
+ {
+ sscanf(pSmsRawContent,"%d %32s %d ", &ptSmsPara->stat, ptSmsPara->alpha, &ptSmsPara->length);
+ }
+ }
+ /* »Ö¸´×Ö·û´®²ÎÊý */
+ atBase_RestoreString(ptSmsPara->alpha);
+ atBase_RestoreString(ptSmsPara->pdu);
+ return ZUFI_SUCC;
+}
#endif
-return WMS_CMD_SUCCESS;}int zUfiSms_FormatDeliverTimestamp(T_zUfiSms_Date tData,
-T_zUfiSms_TimeStamp*ptTimestamp){unsigned char tTimeZone[(0x52a+7371-0x21f0)]={
-(0x17d4+1967-0x1f83)};int tmp_i=(0xe56+4197-0x1ebb);memset(ptTimestamp,
-(0xb7d+2081-0x139e),sizeof(T_zUfiSms_TimeStamp));if(strlen(tData.year)==
-(0x14f8+309-0x162c)){ptTimestamp->year=zUfiSms_atohex(((char)(0x4ea+640-0x73a)))
-*(0x44d+1833-0xb66)+zUfiSms_atohex(tData.year[(0xc83+3888-0x1bb3)]);}else if(
-strlen(tData.year)==(0x44f+2172-0xcc9)){ptTimestamp->year=zUfiSms_atohex(tData.
-year[(0x669+1227-0xb34)])*(0x1532+3884-0x244e)+zUfiSms_atohex(tData.year[
-(0x1617+3303-0x22fd)]);}else if(strlen(tData.year)==(0x92a+3976-0x18ae)){
-ptTimestamp->year=zUfiSms_atohex(tData.year[(0x808+4634-0x1a20)])*
-(0x218+7376-0x1ed8)+zUfiSms_atohex(tData.year[(0x1559+2181-0x1ddb)]);}else{
-printf("\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x79\x65\x61\x72\x2e");return ZUFI_FAIL;
-}if(strlen(tData.month)==(0x543+8193-0x2543)){ptTimestamp->month=zUfiSms_atohex(
-((char)(0x5a3+4926-0x18b1)))*(0x1d43+1475-0x22f6)+zUfiSms_atohex(tData.month[
-(0x3c7+1290-0x8d1)]);}else if(strlen(tData.month)==(0x107+7252-0x1d59)){
-ptTimestamp->month=zUfiSms_atohex(tData.month[(0x1a28+2412-0x2394)])*
-(0x1e7+2413-0xb44)+zUfiSms_atohex(tData.month[(0x14d4+4466-0x2645)]);}else{
-printf("\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x64\x61\x79\x2e");}if(strlen(tData.day)
-==(0x7ea+6993-0x233a)){ptTimestamp->day=zUfiSms_atohex(
-((char)(0x619+7926-0x24df)))*(0xfb8+2551-0x199f)+zUfiSms_atohex(tData.day[
-(0x1166+3416-0x1ebe)]);}else if(strlen(tData.day)==(0x1803+2906-0x235b)){
-ptTimestamp->day=zUfiSms_atohex(tData.day[(0x5d2+5877-0x1cc7)])*
-(0x62f+4569-0x17f8)+zUfiSms_atohex(tData.day[(0x1714+1354-0x1c5d)]);}else{printf
-("\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x64\x61\x79\x2e");}if(strlen(tData.hour)==
-(0x28a+7527-0x1ff0)){ptTimestamp->hour=zUfiSms_atohex(
-((char)(0x87b+4310-0x1921)))*(0x1c70+2419-0x25d3)+zUfiSms_atohex(tData.hour[
-(0x1755+3355-0x2470)]);}else if(strlen(tData.hour)==(0x1249+153-0x12e0)){
-ptTimestamp->hour=zUfiSms_atohex(tData.hour[(0x380+3702-0x11f6)])*
-(0x3c5+2914-0xf17)+zUfiSms_atohex(tData.hour[(0x157c+110-0x15e9)]);}else{printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x68\x6f\x75\x72\x2e");}if(strlen(tData.min)==
-(0x911+3148-0x155c)){ptTimestamp->minute=zUfiSms_atohex(
-((char)(0x2c3+1719-0x94a)))*(0x1027+2199-0x18ae)+zUfiSms_atohex(tData.min[
-(0x279+2108-0xab5)]);}else if(strlen(tData.min)==(0x14ba+2209-0x1d59)){
-ptTimestamp->minute=zUfiSms_atohex(tData.min[(0x3b+4002-0xfdd)])*
-(0x1b26+2759-0x25dd)+zUfiSms_atohex(tData.min[(0xc81+3229-0x191d)]);}else{printf
-("\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x6d\x69\x6e\x75\x74\x65\x2e");}if(strlen(
-tData.sec)==(0x29f+3295-0xf7d)){ptTimestamp->second=zUfiSms_atohex(
-((char)(0xe0+7237-0x1cf5)))*(0x1570+2786-0x2042)+zUfiSms_atohex(tData.sec[
-(0x19f+1968-0x94f)]);}else if(strlen(tData.sec)==(0xf15+189-0xfd0)){ptTimestamp
-->second=zUfiSms_atohex(tData.sec[(0x817+6616-0x21ef)])*(0x5f2+3419-0x133d)+
-zUfiSms_atohex(tData.sec[(0x630+419-0x7d2)]);}else{printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x73\x65\x63\x6f\x6e\x64\x2e");}tmp_i=atoi(
-tData.timezone);if(tmp_i<INT_MIN+(0xef1+3529-0x1cb9)||tmp_i>INT_MAX-
-(0x3a3+214-0x478)){printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x74\x44\x61\x74\x61\x20\x74\x69\x6d\x65\x7a\x6f\x6e\x65\x3a\x25\x64\x2e" "\n"
-,tmp_i);return ZUFI_FAIL;}memset(tTimeZone,(0x3c1+7800-0x2239),sizeof(tTimeZone)
-);snprintf(tTimeZone,sizeof(tTimeZone),"\x25\x64",tmp_i*(0x305+1517-0x8ee));if(
-tData.timezone[(0x27+1131-0x492)]==((char)(0x1d72+1538-0x2347))){if(strlen(
-tTimeZone)==(0x137d+2779-0x1e56)){ptTimestamp->timezone=zUfiSms_atohex(
-((char)(0x1485+4559-0x2624)))*(0x990+6137-0x2179)+zUfiSms_atohex(tTimeZone[
-(0x12f0+1063-0x1716)]);}else if(strlen(tTimeZone)==(0xc82+4209-0x1cf0)){
-ptTimestamp->timezone=zUfiSms_atohex(tTimeZone[(0x252+4596-0x1445)])*
-(0x80c+2723-0x12a5)+zUfiSms_atohex(tTimeZone[(0xba6+4588-0x1d90)]);}else{printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x2d\x74\x69\x6d\x65\x7a\x6f\x6e\x65\x2e");}
-ptTimestamp->timezone=(0x865+4557-0x1a32)-ptTimestamp->timezone;}else{if(strlen(
-tTimeZone)==(0x1728+1936-0x1eb7)){ptTimestamp->timezone=zUfiSms_atohex(
-((char)(0x11cd+5102-0x258b)))*(0x1d94+198-0x1e4a)+zUfiSms_atohex(tTimeZone[
-(0xdca+1746-0x149c)]);}else if(strlen(tTimeZone)==(0x317+5341-0x17f2)){
-ptTimestamp->timezone=zUfiSms_atohex(tTimeZone[(0x762+4929-0x1aa3)])*
-(0x44+2917-0xb9f)+zUfiSms_atohex(tTimeZone[(0x6b6+2819-0x11b8)]);}else{printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x2b\x74\x69\x6d\x65\x7a\x6f\x6e\x65\x2e");}}
-return ZUFI_SUCC;}void zUfiSms_FillDeliver(T_zUfiSms_DeliverPdu*deliver,
-T_zUfiSms_ConcatInfo*concat_sms,T_zUfiSms_DbStoreData*ptDbSaveData){static
-UINT16 msg_ref=(0x643+33-0x664);deliver->user_data_header_present=TRUE;if(
-(0x15d6+3599-0x23e5)==concat_sms->current_sending){g_zUfiSms_ConcatSmsReference
-++;(void)zUfiSms_SetConcatMaxRefer(g_zUfiSms_ConcatSmsReference);}deliver->
-user_data_header_present=TRUE;deliver->user_data.num_headers=(0x190d+457-0x1ad5)
-;deliver->user_data.headers[(0x8b4+5618-0x1ea6)].header_id=WMS_UDH_CONCAT_8;
-deliver->user_data.headers[(0x1b70+2687-0x25ef)].u.concat_8.msg_ref=msg_ref;
-deliver->user_data.headers[(0xb37+4696-0x1d8f)].u.concat_8.total_sm=concat_sms->
-total_msg;deliver->user_data.headers[(0xcd7+4840-0x1fbf)].u.concat_8.seq_num=
-concat_sms->current_sending+(0x733+2250-0xffc);ptDbSaveData->concat_sms=
-(0x33+5541-0x15d7);ptDbSaveData->concat_info[(0x283+5516-0x180f)]=msg_ref;}void
-zUfiSms_FillDeliverPdu(T_zUfiSms_DeliverPdu*ptDeliver,T_zUfiSms_ConcatInfo*
-concat_sms,T_zUfiSms_GroupInfo*group_sms,int iSmsLen,T_zUfiSms_DbStoreData*
-ptDbSaveData){if(NULL==concat_sms||NULL==group_sms){return;}ptDeliver->more=
-FALSE;ptDeliver->reply_path_present=FALSE;ptDeliver->status_report_enabled=
-g_zUfiSms_CurSmsPara.status_report_on;ptDeliver->pid=WMS_PID_DEFAULT;ptDeliver->
-dcs.msg_class=WMS_MESSAGE_CLASS_NONE;ptDeliver->dcs.is_compressed=FALSE;if(
-g_zUfiSms_Dcs==DCS_ASC){ptDeliver->dcs.alphabet=WMS_GW_ALPHABET_7_BIT_DEFAULT;}
-else{ptDeliver->dcs.alphabet=WMS_GW_ALPHABET_UCS2;}if(concat_sms->total_msg>
-(0x153b+3932-0x2496)){zUfiSms_FillDeliver(ptDeliver,concat_sms,ptDbSaveData);
-ptDbSaveData->concat_sms=(0x17b9+2794-0x22a2);ptDbSaveData->concat_info[
-(0x1ef+632-0x465)]=concat_sms->current_sending+(0x109+4908-0x1434);ptDbSaveData
-->concat_info[(0x14ef+3943-0x2455)]=concat_sms->total_msg;ptDbSaveData->
-concat_info[(0x9f2+565-0xc27)]=ptDeliver->user_data.headers[(0x92a+3982-0x18b8)]
-.u.concat_8.msg_ref;}else{ptDeliver->user_data_header_present=FALSE;ptDeliver->
-user_data.num_headers=(0x9e6+5832-0x20ae);}ptDeliver->user_data.sm_len=iSmsLen;
-memcpy(ptDeliver->user_data.sm_data,concat_sms->msg_contents[concat_sms->
-current_sending],iSmsLen);if(group_sms->receivers[group_sms->current_receiver][
-(0x112a+1611-0x1775)]==((char)(0x364+3697-0x11aa))){(void)zUfiSms_CharToInt(
-group_sms->receivers[group_sms->current_receiver]+(0xb00+7050-0x2689),strlen(
-group_sms->receivers[group_sms->current_receiver])-(0xd59+3186-0x19ca),ptDeliver
-->address.digits);ptDeliver->address.number_type=WMS_NUMBER_INTERNATIONAL;
-ptDeliver->address.number_of_digits=(UINT8)strlen(group_sms->receivers[group_sms
-->current_receiver])-(0xe95+1529-0x148d);}else{(void)zUfiSms_CharToInt(group_sms
-->receivers[group_sms->current_receiver],strlen(group_sms->receivers[group_sms->
-current_receiver]),ptDeliver->address.digits);ptDeliver->address.number_type=
-WMS_NUMBER_UNKNOWN;ptDeliver->address.number_of_digits=(UINT8)strlen(group_sms->
-receivers[group_sms->current_receiver]);}ptDeliver->address.digit_mode=
-WMS_DIGIT_MODE_4_BIT;ptDeliver->address.number_mode=
-WMS_NUMBER_MODE_NONE_DATA_NETWORK;ptDeliver->address.number_plan=
-WMS_NUMBER_PLAN_TELEPHONY;}T_zUfiSms_CmdStatus zUfiSms_SaveConcatSms(
-T_zUfiSms_SaveReq*ptSaveSms,T_zUfiSms_ConcatInfo*ptConcatSms,T_zUfiSms_GroupInfo
-*ptGroupSms,T_zUfiSms_DbStoreData*ptDbSaveData,int iSmsLen){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x61\x76\x65\x43\x6f\x6e\x63\x61\x74\x53\x6d\x73\x20\x6d\x65\x6d\x5f\x73\x74\x6f\x72\x65\x3d\x25\x64\x28\x4e\x56\x3d\x3d\x30\x31\x29" "\n"
-,ptSaveSms->mem_store);if(ptSaveSms->mem_store==WMS_STORAGE_TYPE_NV_V01){if(
-ZUFI_FAIL==zUfiSms_WriteSmsToDb(ptDbSaveData,WMS_STORAGE_TYPE_NV_V01,-
-(0x339+5000-0x16c0))){at_print(LOG_ERR,
-"\x77\x72\x69\x74\x65\x20\x73\x6d\x73\x20\x74\x6f\x20\x6e\x76\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return WMS_CMD_FAILED;}}else{return WMS_CMD_FAILED;}g_zUfiSms_MsgRefer++;
-ptDbSaveData->msg_ref=g_zUfiSms_MsgRefer;(void)zUfiSms_SetMaxReference(
-g_zUfiSms_MsgRefer);return WMS_CMD_SUCCESS;}T_zUfiSms_CmdStatus
-zUfiSms_SaveNormalSms(T_zUfiSms_SaveReq*ptSaveSms,T_zUfiSms_DbStoreData*
-ptDbSaveData){g_zUfiSms_MsgRefer++;ptDbSaveData->msg_ref=g_zUfiSms_MsgRefer;if(
-ptSaveSms->mem_store==WMS_STORAGE_TYPE_NV_V01){if(ZUFI_SUCC==
-zUfiSms_WriteSmsToDb(ptDbSaveData,WMS_STORAGE_TYPE_NV_V01,ptSaveSms->id)){(void)
-zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);return WMS_CMD_SUCCESS;}else{printf(
-"\x77\x72\x69\x74\x65\x20\x73\x6d\x73\x20\x74\x6f\x20\x6e\x76\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return WMS_CMD_FAILED;}}return WMS_CMD_SUCCESS;}T_zUfiSms_CmdStatus
-zUfiSms_SaveSmsToDb(T_zUfiSms_SaveReq*ptSaveSms,T_zUfiSms_ConcatInfo*ptConcatSms
-,T_zUfiSms_GroupInfo*ptGroupSms,int iSmsLength){T_zUfiSms_ClientTsData
-tClientTsData;T_zUfiSms_ClientMsg tClientMsg;T_zUfiSms_DbStoreData tDbSaveData;
-T_zUfiSms_CmdStatus result=WMS_CMD_SUCCESS;int current_sending=
-(0x152f+3721-0x23b8);if(NULL==ptSaveSms||NULL==ptConcatSms||NULL==ptGroupSms||(-
-(0x11f+9179-0x24f9)==iSmsLength)){return WMS_CMD_FAILED;}for(ptConcatSms->
-current_sending=(0x114d+3410-0x1e9f);ptConcatSms->current_sending<ptConcatSms->
-total_msg;ptConcatSms->current_sending++){memset((void*)&tClientMsg,
-(0xb60+775-0xe67),sizeof(T_zUfiSms_ClientMsg));memset((void*)&tClientTsData,
-(0xe14+264-0xf1c),sizeof(T_zUfiSms_ClientTsData));memset((void*)&tDbSaveData,
-(0x19b9+1952-0x2159),sizeof(T_zUfiSms_DbStoreData));tClientMsg.msg_hdr.mem_store
-=(ptSaveSms->mem_store==WMS_STORAGE_TYPE_UIM_V01)?WMS_STORAGE_TYPE_UIM_V01:
-WMS_STORAGE_TYPE_NV_V01;tClientMsg.msg_hdr.tag=(T_zUfiSms_SmsTag)ptSaveSms->tags
-;tClientMsg.msg_hdr.message_mode=WMS_MESSAGE_MODE_GW;tClientMsg.u.gw_message.
-is_broadcast=FALSE;tClientTsData.format=WMS_FORMAT_GW_PP;switch(ptSaveSms->tags)
-{case WMS_TAG_TYPE_MO_SENT_V01:case WMS_TAG_TYPE_MO_NOT_SENT_V01:case
-(0xce8+4999-0x206b):{tClientTsData.u.gw_pp.tpdu_type=WMS_TPDU_SUBMIT;(void)
-zUfiSms_FillSubmitTpdu(ptConcatSms,ptGroupSms,iSmsLength,&tClientTsData.u.gw_pp.
-u.submit,&tDbSaveData);break;}case WMS_TAG_TYPE_MT_READ_V01:case
-WMS_TAG_TYPE_MT_NOT_READ_V01:{tClientTsData.u.gw_pp.tpdu_type=WMS_TPDU_DELIVER;(
-void)zUfiSms_FormatDeliverTimestamp(ptSaveSms->date,&(tClientTsData.u.gw_pp.u.
-deliver.timestamp));zUfiSms_FillDeliverPdu(&tClientTsData.u.gw_pp.u.deliver,
-ptConcatSms,ptGroupSms,iSmsLength,&tDbSaveData);break;}default:{printf(
-"\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x74\x61\x67\x73\x2e");break;}}(void)
-wms_ts_encode(&tClientTsData,&tClientMsg.u.gw_message.raw_ts_data);
-zUfiSms_FillSca(&tClientMsg);zUfiSms_FillDbSaveData(&tClientMsg,&tClientTsData,
-ptConcatSms,ptGroupSms,iSmsLength,&tDbSaveData);strncpy(tDbSaveData.
-draft_group_id,ptSaveSms->draft_group_id,sizeof(tDbSaveData.draft_group_id)-
-(0xc50+1306-0x1169));if(TRUE==g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV]){result=
-WMS_CMD_FAILED;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x61\x76\x65\x53\x6d\x73\x54\x6f\x44\x62\x20\x4e\x56\x20\x6d\x65\x6d\x6f\x72\x79\x20\x69\x73\x20\x66\x75\x6c\x6c\x2c\x73\x61\x76\x65\x20\x65\x72\x72\x6f\x72" "\n"
-);}else{if(tDbSaveData.concat_sms==(0x2a5+5428-0x17d8)){result=
-zUfiSms_SaveConcatSms(ptSaveSms,ptConcatSms,ptGroupSms,&tDbSaveData,iSmsLength);
-current_sending=ptConcatSms->current_sending+(0x5f4+6198-0x1e29);if(ptConcatSms
-->sms_len<iSmsLength*(current_sending+(0xbdc+5238-0x2051))){iSmsLength=
-ptConcatSms->sms_len-iSmsLength*current_sending;}}else{result=
-zUfiSms_SaveNormalSms(ptSaveSms,&tDbSaveData);}}}return result;}int
-zUfiSms_DeleteSmsInSim(){char str_index[(0x2035+426-0x215f)]={
-(0x31c+5579-0x18e7)};int index=(0x1419+4821-0x26ee);int is_cc=
-(0x1a79+2203-0x2314);int iSmsId=(0x37a+709-0x63f);T_zUfiSms_ModifyTag
-tDeleteInfo={(0x5eb+4919-0x1922)};char StrValue[(0xcd6+6678-0x26e2)]={
-(0x107+44-0x133)};memset(&tDeleteInfo,(0x13d8+677-0x167d),sizeof(
-T_zUfiSms_ModifyTag));iSmsId=g_zUfiSms_DelMsg.sim_id[g_zUfiSms_DelMsg.sim_index]
-;if(-(0x207+5767-0x188d)==(is_cc=zUfiSms_IsConcatSms(iSmsId))){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x6d\x73\x49\x6e\x53\x69\x6d\x20\x63\x68\x65\x63\x6b\x20\x63\x6f\x6e\x63\x61\x74\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x6d\x73\x49\x6e\x53\x69\x6d\x20\x69\x73\x5f\x63\x63\x3a\x25\x64\x2c\x20\x69\x64\x3d\x25\x64" "\n"
-,is_cc,iSmsId);if((0x266+9256-0x268d)==is_cc){if(ZUFI_FAIL==zUfiSms_GetSmsIndex(
-iSmsId,&tDeleteInfo,is_cc)){return ZUFI_FAIL;}g_zUfiSms_DelMsg.sim_index++;
-g_zUfiSms_DelMsg.sim_index_count--;while(tDeleteInfo.num_of_indices>
-(0x35c+4166-0x13a2)){index=tDeleteInfo.indices[tDeleteInfo.id_index];
-g_deleteIndex.index[g_deleteIndex.total]=index;g_deleteIndex.total++;tDeleteInfo
-.id_index++;tDeleteInfo.num_of_indices--;}}else{memset(str_index,
-(0x1d2a+272-0x1e3a),sizeof(str_index));if(ZUFI_FAIL==zUfiSms_GetStorePosById(
-"\x69\x6e\x64",str_index,sizeof(str_index),iSmsId)){at_print(LOG_ERR,
-"\x67\x65\x74\x20\x69\x6e\x64\x65\x78\x20\x66\x72\x6f\x6d\x20\x64\x62\x20\x66\x61\x69\x6c\x64\x2e"
-);return ZUFI_FAIL;}index=atoi(str_index);g_deleteIndex.index[g_deleteIndex.
-total]=index;g_deleteIndex.total++;g_zUfiSms_DelMsg.sim_index++;g_zUfiSms_DelMsg
-.sim_index_count--;}(void)zUfiSms_DeleteSmsInDb();return ZUFI_SUCC;}
-T_zUfiSms_CmdStatus zUfiSms_DeleteSimSms(VOID){int atRes=(0x12e0+3404-0x202c);
-char StrValue[(0x1481+3306-0x2161)]={(0x23c1+523-0x25cc)};zUfiSms_SetSmsLocation
-(SMS_LOCATION_SIM);memset(&g_deleteIndex,(0x75f+763-0xa5a),sizeof(
-T_zUfiSms_DelIndexInfo));while(g_zUfiSms_DelMsg.sim_index_count>
-(0x12d5+4598-0x24cb)){if(ZUFI_FAIL==zUfiSms_DeleteSmsInSim()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x69\x6d\x53\x6d\x73\x20\x64\x65\x6c\x65\x74\x65\x20\x61\x6c\x6c\x3a\x25\x64\x20\x73\x6d\x73\x20\x66\x61\x69\x6c\x65\x64" "\n"
-,WMS_STORAGE_TYPE_UIM_V01);return WMS_CMD_FAILED;}}while(g_deleteIndex.cur_index
-<g_deleteIndex.total){atRes=zSms_SendCmgdReq(g_deleteIndex.index[g_deleteIndex.
-cur_index]);if(atRes==ZSMS_RESULT_OK){zSms_RecvCmgdOk();}else{zSms_RecvCmgdErr()
-;}g_deleteIndex.cur_index++;}zSms_RecvCmgdFinish();printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x69\x6d\x53\x6d\x73\x20\x73\x75\x63\x63\x65\x73\x73" "\n"
-);return WMS_CMD_SUCCESS;}void zUfiSms_GetReportStatus(char*pdu_tmp,int*stat){
-unsigned char tmp;unsigned char first_octet;if(pdu_tmp==NULL){return;}(void)
-String2Bytes(pdu_tmp,&tmp,(0x269+5940-0x199b));if(tmp==(0x1330+3629-0x215d)){
-pdu_tmp+=(0x30b+8806-0x256f);}else{tmp=(tmp+(0x1ac5+349-0x1c21))*
-(0x191b+26-0x1933);pdu_tmp+=tmp;}(void)String2Bytes(pdu_tmp,&tmp,
-(0x955+4770-0x1bf5));first_octet=tmp;if(first_octet&(0x178+2987-0xd21)){*stat=
-(0x348+5299-0x17f6);}}T_zUfiSms_TpduType zUfiSms_GetTpduType(UINT8*pData){
-T_zUfiSms_TpduType iTpduType;UINT8 mti=(0xae1+213-0xbb6);mti=(T_zUfiSms_TpduType
-)(pData[(0x1fc9+235-0x20b4)]&(0x2048+574-0x2283));switch(mti){case
-(0xadf+710-0xda5):iTpduType=WMS_TPDU_DELIVER;break;case(0x199+4560-0x1368):
-iTpduType=WMS_TPDU_SUBMIT;break;case(0x2022+1299-0x2533):iTpduType=
-WMS_TPDU_STATUS_REPORT;break;default:iTpduType=WMS_TPDU_MAX;break;}return
-iTpduType;}static void zUfiSms_FormatDeliverNumber(wms_address_s_type tAddress,
-unsigned char*pNumber){UINT8 number_type=(0xf07+2906-0x1a61);memset(pNumber,
-(0x24fa+217-0x25d3),ZTE_WMS_ADDRESS_LEN_MAX+(0x49+408-0x1e0));if(tAddress.
-number_type==WMS_NUMBER_INTERNATIONAL){pNumber[(0x702+4605-0x18ff)]=
-((char)(0xce5+3472-0x1a4a));pNumber++;}if(tAddress.digit_mode!=
-WMS_DIGIT_MODE_8_BIT){(void)zUfiSms_SmsiAddrToStr(tAddress,(byte*)pNumber,&
-number_type);}else{memcpy(pNumber,tAddress.digits,tAddress.number_of_digits*
-sizeof(tAddress.digits[(0x1bdb+1316-0x20ff)]));}}byte*zUfiSms_UtilTimeStamp(
-T_zUfiSms_TimeStamp zte_wms_time,byte*res_ptr,T_zUfiSms_Date*date){UINT8 tmp;if(
-NULL==date){return NULL;}*res_ptr++=((char)(0x1222+4362-0x230a));tmp=
-zte_wms_time.year;res_ptr=zUfiSms_SmsiUtilitoaFill((tmp&(0x1088+5490-0x25eb))+((
-tmp>>(0x58a+5300-0x1a3a))*(0xc63+5214-0x20b7)),res_ptr);zUfiSms_SprintfTime(date
-->year,sizeof(date->year),zte_wms_time.year);*res_ptr++=
-((char)(0x1a0d+215-0x1ab5));tmp=zte_wms_time.month;res_ptr=
-zUfiSms_SmsiUtilitoaFill((tmp&(0x13fb+1301-0x1901))+((tmp>>(0x80a+4702-0x1a64))*
-(0x252d+175-0x25d2)),res_ptr);zUfiSms_SprintfTime(date->month,sizeof(date->month
-),zte_wms_time.month);*res_ptr++=((char)(0x145b+2108-0x1c68));tmp=zte_wms_time.
-day;res_ptr=zUfiSms_SmsiUtilitoaFill((tmp&(0x420+6778-0x1e8b))+((tmp>>
-(0x1cb+2991-0xd76))*(0x7c2+3918-0x1706)),res_ptr);zUfiSms_SprintfTime(date->day,
-sizeof(date->day),zte_wms_time.day);*res_ptr++=((char)(0x10ba+3786-0x1f58));tmp=
-zte_wms_time.hour;res_ptr=zUfiSms_SmsiUtilitoaFill((tmp&(0x185d+3401-0x2597))+((
-tmp>>(0x3af+2056-0xbb3))*(0x6a4+4767-0x1939)),res_ptr);zUfiSms_SprintfTime(date
-->hour,sizeof(date->hour),zte_wms_time.hour);*res_ptr++=
-((char)(0x1aa9+479-0x1c4e));tmp=zte_wms_time.minute;res_ptr=
-zUfiSms_SmsiUtilitoaFill((tmp&(0x1ab+4929-0x14dd))+((tmp>>(0xc2c+5074-0x1ffa))*
-(0x1abf+2686-0x2533)),res_ptr);zUfiSms_SprintfTime(date->min,sizeof(date->min),
-zte_wms_time.minute);*res_ptr++=((char)(0x6c1+1078-0xabd));tmp=zte_wms_time.
-second;res_ptr=zUfiSms_SmsiUtilitoaFill((tmp&(0xba3+2556-0x1590))+((tmp>>
-(0x99+3061-0xc8a))*(0x4f9+5092-0x18d3)),res_ptr);zUfiSms_SprintfTime(date->sec,
-sizeof(date->sec),zte_wms_time.second);if(zte_wms_time.timezone<
-(0x11f5+4233-0x227e)){*res_ptr++=((char)(0x16c4+932-0x1a3b));tmp=(UINT8)(
-zte_wms_time.timezone*(-(0x4ca+5653-0x1ade)));snprintf(date->timezone,sizeof(
-date->timezone),"\x2d\x25\x64",-(0x126f+3420-0x1fca)*zte_wms_time.timezone);}
-else{*res_ptr++=((char)(0x11cb+2385-0x1af1));tmp=(UINT8)zte_wms_time.timezone;
-snprintf(date->timezone,sizeof(date->timezone),"\x2b\x25\x64",zte_wms_time.
-timezone);}res_ptr=zUfiSms_SmsiUtilitoaFill(tmp,res_ptr);*res_ptr++=
-((char)(0xa3d+1073-0xe4c));return res_ptr;}T_zUfiSms_CmdStatus
-zUfiSms_HandleReport(unsigned char*ptPduData){T_zUfiSms_RawTsData tRawTsData;
-T_zUfiSms_ClientTsData tClientTsData;int iReportStatus=(0x16c1+321-0x1802);
-unsigned char acDeliverNumber[ZTE_WMS_ADDRESS_LEN_MAX+(0x526+7328-0x21c5)];
-unsigned char tTpScts[ZTE_WMS_TP_SCTS_LEN_MAX+(0xde2+2810-0x18db)];
-T_zUfiSms_Date tSmsDate;char acRecFlag[(0x65b+6909-0x2153)]={(0x502+5973-0x1c57)
-};int iRpCount=(0x1227+1012-0x161b);char tmp[(0x1ea4+1645-0x2507)];int tmp_i=
-(0x1bb+6575-0x1b6a);unsigned int pos=(0xf+7433-0x1d18);if(NULL==ptPduData){
-return WMS_CMD_FAILED;}memset(acDeliverNumber,(0xdd+9732-0x26e1),sizeof(
-acDeliverNumber));memset(&tSmsDate,(0x4b5+7476-0x21e9),sizeof(T_zUfiSms_Date));
-memset(tTpScts,(0x4fd+3793-0x13ce),sizeof(tTpScts));memset(&tRawTsData,
-(0xb81+75-0xbcc),sizeof(T_zUfiSms_RawTsData));memset(&tClientTsData,
-(0x1670+186-0x172a),sizeof(T_zUfiSms_ClientTsData));snprintf(tmp,sizeof(tmp),
-"\x25\x58",ptPduData[(0x18b+9367-0x2622)]);tmp_i=atoi(tmp);if(tmp_i<
-(0x985+1892-0x10e9)||tmp_i>INT_MAX-(0x10dc+915-0x146e)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x70\x74\x50\x64\x75\x44\x61\x74\x61\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return WMS_CMD_FAILED;}pos=tmp_i+(0xb07+3974-0x1a8c);if(pos>=
-ZSMS_PDU_SIZE){return WMS_CMD_FAILED;}memcpy((void*)tRawTsData.data,(void*)(
-ptPduData+pos),sizeof(tRawTsData.data));tRawTsData.tpdu_type=zUfiSms_GetTpduType
-(ptPduData+pos);tRawTsData.format=WMS_FORMAT_GW_PP;(void)wms_ts_decode(&
-tRawTsData,&tClientTsData);if(WMS_TPDU_STATUS_REPORT!=tClientTsData.u.gw_pp.
-tpdu_type){at_print(LOG_ERR,
-"\x64\x6f\x65\x73\x20\x6e\x6f\x74\x20\x67\x77\x2f\x77\x63\x64\x6d\x61\x20\x73\x6d\x73\x20\x72\x65\x70\x6f\x72\x74\x20\x73\x74\x61\x74\x75\x73\x2e"
-);return WMS_CMD_FAILED;}switch(tClientTsData.u.gw_pp.u.status_report.tp_status)
-{case WMS_TP_STATUS_RECEIVED_OK:case WMS_TP_STATUS_UNABLE_TO_CONFIRM_DELIVERY:
-case WMS_TP_STATUS_REPLACED:{iReportStatus=(0x72a+3551-0x1508);break;}case
-WMS_TP_STATUS_TRYING_CONGESTION:case WMS_TP_STATUS_TRYING_SME_BUSY:case
-WMS_TP_STATUS_TRYING_NO_RESPONSE_FROM_SME:case
-WMS_TP_STATUS_TRYING_SERVICE_REJECTED:case
-WMS_TP_STATUS_TRYING_QOS_NOT_AVAILABLE:case WMS_TP_STATUS_TRYING_SME_ERROR:{
-iReportStatus=(0xefa+5615-0x24e6);break;}default:{iReportStatus=
-(0x1ab6+1558-0x20ca);break;}}zUfiSms_FormatDeliverNumber(tClientTsData.u.gw_pp.u
-.status_report.address,acDeliverNumber);(void)zUfiSms_UtilTimeStamp(
-tClientTsData.u.gw_pp.u.status_report.timestamp,tTpScts,&tSmsDate);if(ZUFI_FAIL
-==zUfiSms_InsertReportStatusToDb(acDeliverNumber,&tSmsDate,iReportStatus)){
-at_print(LOG_ERR,
-"\x75\x70\x64\x61\x74\x65\x20\x73\x6d\x73\x20\x72\x65\x70\x6f\x72\x74\x20\x73\x74\x61\x74\x75\x73\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return WMS_CMD_FAILED;}memset(acRecFlag,(0x273+8432-0x2363),sizeof(acRecFlag))
-;sc_cfg_get(ZTE_WMS_NVCONFIG_SMS_REPORT,acRecFlag,sizeof(acRecFlag));iRpCount=
-atoi(acRecFlag);if(iRpCount<(0x1055+362-0x11bf)||iRpCount>INT_MAX-
-(0x284+8652-0x244f)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x69\x52\x70\x43\x6f\x75\x6e\x74\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,iRpCount);return WMS_CMD_FAILED;}memset(acRecFlag,(0xa96+3503-0x1845),sizeof(
-acRecFlag));snprintf(acRecFlag,sizeof(acRecFlag),"\x25\x64",iRpCount+
-(0xbe8+2774-0x16bd));sc_cfg_set(ZTE_WMS_NVCONFIG_SMS_REPORT,acRecFlag);return
-WMS_CMD_SUCCESS;}void zUfiSms_DelModemSms(int in_index){
-#if (0xe6f+3647-0x1cae)
-char StrValue[(0x2db+3448-0x1049)]={(0x762+4851-0x1a55)};printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x4d\x6f\x64\x65\x6d\x53\x6d\x73\x20\x66\x75\x6e\x20\x75\x73\x65\x64\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21\x21" "\n"
-);snat_print(LOG_DEBUGStrValue,sizeof(StrValue),"\x25\x64",in_index);
-zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,
-MSG_CMD_AT_DEL_SIM_SMS,strlen(StrValue),StrValue);
+void zUfiSms_CmglRespProc(T_zSms_SmsInd *pSmsItem)
+{
+ T_zUfiSms_CmdStatus result = WMS_CMD_PROCESSING;
+ T_zUfiSms_DbStoreData db_data = {0};
+ zUfiSms_StoreType mem_store = WMS_STORAGE_TYPE_UIM_V01;
+ unsigned char pdu_tmp[ZSMS_PDU_SIZE]={0};
+ int total_count = 0;
+ int sim_capability = 0;
+
+ printf("[SMS] Enter zUfiSms_CmglRespProc! index:%d/stat:%d/length:%d!\n", pSmsItem->index,pSmsItem->stat,pSmsItem->length);
+ printf("[SMS] pdu data_len:%d, str:%s!\n", strlen(pSmsItem->pdu),pSmsItem->pdu);
+
+ //½âÂëת»»
+ memset(&db_data, 0, sizeof(db_data));
+ memset(pdu_tmp, 0, sizeof(pdu_tmp));
+ (void)String2Bytes(pSmsItem->pdu, pdu_tmp, (int)strlen(pSmsItem->pdu));
+
+ //TSP_MODEL ÊÇʹÓÃ×ÔÑÐоƬʱµÄºê£¬×ÔÑÐоƬÓë¸ßͨоƬÓÐËùÇø±ð
+#if 1//defined (TSP_MODEL)
+ zUfiSms_GetReportStatus(pSmsItem->pdu, &pSmsItem->stat);
+ if(5 == pSmsItem->stat)
+ {
+ printf("[SMS] Enter pSmsItem->stat == 5\n");
+ (void)zUfiSms_HandleReport(pdu_tmp);
+ zUfiSms_DelModemSms(pSmsItem->index);
+ return;
+ }
#endif
-int atRes=(0x10c2+3159-0x1d19);atRes=zSms_SendCmgdReq(in_index);if(atRes==
-ZSMS_RESULT_OK){zSms_RecvCmgdOk();}else{zSms_RecvCmgdErr();}zSms_RecvCmgdFinish(
-);}VOID zUfiSms_getModifyInfo(T_zUfiSms_ModifyFlag*ptModifyBuff){int i=
-(0x1691+1045-0x1aa6);memset(&g_zUfiSms_modifyMsg,(0x476+8539-0x25d1),sizeof(
-T_zUfiSms_ModifySms));for(i=(0x1e7a+1898-0x25e4);i<ptModifyBuff->total_id;i++){
-g_zUfiSms_modifyMsg.sim_id[g_zUfiSms_modifyMsg.sim_count]=ptModifyBuff->id[i];
-g_zUfiSms_modifyMsg.sim_count++;g_zUfiSms_modifyMsg.sim_index_count++;}}int
-zUfiSms_GetUnreadSmsIndexInSim(){char str_index[(0x8e7+1240-0xd3f)]={
-(0xbf6+76-0xc42)};int index=(0x18bf+171-0x196a);int is_cc=(0x1b8a+388-0x1d0e);
-int iSmsId=(0x111+2828-0xc1d);T_zUfiSms_ModifyTag tModifyInfo={
-(0xb9c+2209-0x143d)};char StrValue[(0x778+3689-0x15d7)]={(0x132+5724-0x178e)};
-memset(&tModifyInfo,(0xc94+1534-0x1292),sizeof(T_zUfiSms_ModifyTag));iSmsId=
-g_zUfiSms_modifyMsg.sim_id[g_zUfiSms_modifyMsg.sim_index];if(-
-(0x2037+223-0x2115)==(is_cc=zUfiSms_IsConcatSms(iSmsId))){at_print(LOG_ERR,
-"\x63\x68\x65\x63\x6b\x20\x63\x6f\x6e\x63\x61\x74\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return ZUFI_FAIL;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x55\x6e\x72\x65\x61\x64\x53\x6d\x73\x49\x6e\x64\x65\x78\x49\x6e\x53\x69\x6d\x20\x69\x73\x5f\x63\x63\x3a\x25\x64"
-,is_cc);if((0x5ca+2918-0x112f)==is_cc){if(ZUFI_FAIL==zUfiSms_GetSmsIndex(iSmsId,
-&tModifyInfo,is_cc)){return ZUFI_FAIL;}g_zUfiSms_modifyMsg.sim_index++;
-g_zUfiSms_modifyMsg.sim_index_count--;while(tModifyInfo.num_of_indices>
-(0x3c6+400-0x556)){index=tModifyInfo.indices[tModifyInfo.id_index];g_modifyIndex
-.index[g_modifyIndex.total]=index;g_modifyIndex.total++;tModifyInfo.id_index++;
-tModifyInfo.num_of_indices--;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x55\x6e\x72\x65\x61\x64\x53\x6d\x73\x49\x6e\x64\x65\x78\x49\x6e\x53\x69\x6d\x20\x5b\x31\x20\x3d\x3d\x20\x69\x73\x5f\x63\x63\x5d\x20\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x64\x2c\x20\x74\x6f\x74\x61\x6c\x3d\x25\x64" "\n"
-,index,g_modifyIndex.total);}}else{memset(str_index,(0x85d+4334-0x194b),sizeof(
-str_index));if(ZUFI_FAIL==zUfiSms_GetStorePosById("\x69\x6e\x64",str_index,
-sizeof(str_index),iSmsId)){at_print(LOG_ERR,
-"\x67\x65\x74\x20\x69\x6e\x64\x65\x78\x20\x66\x72\x6f\x6d\x20\x64\x62\x20\x66\x61\x69\x6c\x64\x2e"
-);return ZUFI_FAIL;}index=atoi(str_index);g_modifyIndex.index[g_modifyIndex.
-total]=index;g_modifyIndex.total++;g_zUfiSms_modifyMsg.sim_index++;
-g_zUfiSms_modifyMsg.sim_index_count--;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x47\x65\x74\x55\x6e\x72\x65\x61\x64\x53\x6d\x73\x49\x6e\x64\x65\x78\x49\x6e\x53\x69\x6d\x20\x5b\x31\x20\x21\x3d\x20\x69\x73\x5f\x63\x63\x5d\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x64\x2c\x20\x74\x6f\x74\x61\x6c\x3d\x25\x64" "\n"
-,index,g_modifyIndex.total);}return ZUFI_SUCC;}void zUfiSms_ModifyModemSms(
-T_zUfiSms_ModifyFlag*ptModifyBuff){int atRes=(0x462+5968-0x1bb2);char StrValue[
-(0xebc+2211-0x1755)]={(0x37b+991-0x75a)};printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4d\x6f\x64\x69\x66\x79\x4d\x6f\x64\x65\x6d\x53\x6d\x73\x20\x70\x74\x4d\x6f\x64\x69\x66\x79\x42\x75\x66\x66\x2d\x3e\x74\x79\x70\x65\x20\x3d\x20\x25\x64\x21" "\n"
-,ptModifyBuff->type);{zUfiSms_getModifyInfo(ptModifyBuff);memset(&g_modifyIndex,
-(0xcba+4081-0x1cab),sizeof(T_zUfiSms_ModifyIndexInfo));printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4d\x6f\x64\x69\x66\x79\x4d\x6f\x64\x65\x6d\x53\x6d\x73\x20\x70\x74\x4d\x6f\x64\x69\x66\x79\x42\x75\x66\x66\x2d\x3e\x74\x6f\x74\x61\x6c\x5f\x69\x64\x20\x3d\x20\x25\x64\x21" "\n"
-,ptModifyBuff->total_id);while(g_zUfiSms_modifyMsg.sim_index_count>
-(0x96b+2530-0x134d)){if(ZUFI_FAIL==zUfiSms_GetUnreadSmsIndexInSim()){at_print(
-LOG_ERR,
-"\x64\x65\x6c\x65\x74\x65\x20\x61\x6c\x6c\x3a\x25\x64\x20\x73\x6d\x73\x20\x66\x61\x69\x6c\x65\x64" "\n"
-,WMS_STORAGE_TYPE_UIM_V01);return;}}while(g_modifyIndex.cur_index<g_modifyIndex.
-total){snprintf(StrValue,sizeof(StrValue),"\x25\x64",g_modifyIndex.index[
-g_modifyIndex.cur_index]);atRes=zSms_SendCmgrReq(g_modifyIndex.index[
-g_modifyIndex.cur_index]);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x4d\x6f\x64\x69\x66\x79\x4d\x6f\x64\x65\x6d\x53\x6d\x73\x20\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x73\x20" "\n"
-,StrValue);g_modifyIndex.cur_index++;}}}static int zUfiSms_FormatGwDbData(
-T_zUfiSms_ClientTsData*ts_data_ptr,T_zUfiSms_DbStoreData*db_data){int result=
-ZUFI_SUCC;if((NULL==ts_data_ptr)||(NULL==db_data)){at_print(LOG_ERR,
-"\x69\x6e\x76\x61\x6c\x69\x64\x20\x69\x6e\x70\x75\x74\x73\x2e");return ZUFI_FAIL
-;}if(WMS_FORMAT_GW_PP==ts_data_ptr->format){switch(ts_data_ptr->u.gw_pp.
-tpdu_type){case WMS_TPDU_DELIVER:{result=zUfiSms_FormatDeliverDbdata(ts_data_ptr
-,db_data);break;}case WMS_TPDU_SUBMIT:{result=zUfiSms_FormatSubmitDbdata(
-ts_data_ptr,db_data);break;}default:{break;}}}return result;}int
-zUfiSms_DecodeSmsData(T_zUfiSms_DbStoreData*pDb_Data,int msg_index,
-zUfiSms_StoreType iStorePos,T_SmsStatus bSms_Status,wms_message_format_enum_v01
-format,long iPdu_Len,unsigned char*pPdu_Received){T_zUfiSms_RawTsData raw_ts;
-T_zUfiSms_ClientTsData ts_data_ptr;char tmp[(0x12ff+2514-0x1cc7)];int tmp_i=
-(0x300+2111-0xb3f);unsigned int pos=(0xc1b+4401-0x1d4c);int result=ZUFI_SUCC;if(
-NULL==pDb_Data){return ZUFI_FAIL;}pDb_Data->mem_store=(unsigned long)iStorePos;
-pDb_Data->index=(unsigned short)msg_index;if(RECEIVED_UNREAD==bSms_Status){
-pDb_Data->tag=WMS_TAG_TYPE_MT_NOT_READ_V01;}else if(RECEIVED_READ==bSms_Status){
-pDb_Data->tag=WMS_TAG_TYPE_MT_READ_V01;}else if(STORED_UNSEND==bSms_Status){
-pDb_Data->tag=WMS_TAG_TYPE_MO_NOT_SENT_V01;}else{pDb_Data->tag=
-WMS_TAG_TYPE_MO_SENT_V01;}pDb_Data->mode=(unsigned short)format;memset(&raw_ts,
-(0xcb4+1651-0x1327),sizeof(T_zUfiSms_RawTsData));memset(&ts_data_ptr,
-(0x1ad6+1239-0x1fad),sizeof(wms_client_ts_data_s_type));memset(tmp,
-(0x1979+269-0x1a86),sizeof(tmp));snprintf(tmp,sizeof(tmp),"\x25\x64",
-pPdu_Received[(0xc9a+5425-0x21cb)]);tmp_i=atoi(tmp);if(tmp_i<(0x3a9+1773-0xa96)
-||tmp_i>INT_MAX-(0x57+9379-0x24f9)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x70\x50\x64\x75\x5f\x52\x65\x63\x65\x69\x76\x65\x64\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);return ZUFI_FAIL;}pos=tmp_i+(0x10e8+3542-0x1ebd);if(pos>=iPdu_Len){
-return ZUFI_FAIL;}raw_ts.len=iPdu_Len-pos;memcpy((void*)raw_ts.data,(void*)(
-pPdu_Received+pos),WMS_MAX_LEN);raw_ts.tpdu_type=zUfiSms_GetTpduType(
-pPdu_Received+pos);raw_ts.format=(WMS_MESSAGE_FORMAT_CDMA_V01==format)?
-WMS_FORMAT_CDMA:WMS_FORMAT_GW_PP;(void)wms_ts_decode(&raw_ts,&ts_data_ptr);
-switch(format){case WMS_MESSAGE_FORMAT_CDMA_V01:{result=ZUFI_SUCC;break;}case
-WMS_MESSAGE_FORMAT_GW_PP_V01:{result=zUfiSms_FormatGwDbData(&ts_data_ptr,
-pDb_Data);break;}case WMS_MESSAGE_FORMAT_GW_BC_V01:case
-WMS_MESSAGE_FORMAT_MWI_V01:{result=ZUFI_FAIL;break;}default:{result=ZUFI_FAIL;
-break;}}return result;}T_zUfiSms_CmdStatus IsSmsLoadSuccess(void){char IsInit[
-(0x14d3+206-0x157d)]={(0x4e0+3661-0x132d)};sc_cfg_get(NV_SMS_LOAD_RESULT,IsInit,
-sizeof(IsInit));if((0x16fb+3018-0x22c5)==strcmp("\x6f\x6b",IsInit)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x20\x4c\x6f\x61\x64\x20\x73\x75\x63\x63\x65\x73\x73\x21" "\n"
-);return WMS_CMD_SUCCESS;}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x6d\x73\x20\x4c\x6f\x61\x64\x20\x77\x72\x6f\x6e\x67\x20\x21" "\n"
-);return WMS_CMD_FAILED;}}
-#if (0x69a+254-0x798)
-int zUfiSms_FormatSms(CHAR*pSmsRawContent,int contentSize,T_zUfiSms_SmsItem*
-ptSmsPara,int iCmdId){char*P1=strchr(pSmsRawContent,((char)(0x9cb+5752-0x2017)))
-;if(NULL==P1){return ZUFI_FAIL;}char*P2=strchr((char*)(P1+(0x64+5378-0x1565)),
-((char)(0x1345+2488-0x1cd1)));if(NULL==P2){return ZUFI_FAIL;}char*P3=strchr((
-char*)(P2+(0x255+1696-0x8f4)),((char)(0x1f6+9303-0x2621)));atBase_PreProcRes(
-pSmsRawContent,contentSize);if((0xcd2+3764-0x1b85)==iCmdId){if(P3==P2+
-(0x2eb+7481-0x2023)){sscanf(pSmsRawContent,
-"\x25\x64\x20\x25\x64\x20\x25\x64\x20",&ptSmsPara->index,&ptSmsPara->stat,&
-ptSmsPara->length);}else{sscanf(pSmsRawContent,
-"\x25\x64\x20\x25\x64\x20\x25\x33\x32\x73\x20\x25\x64\x20",&ptSmsPara->index,&
-ptSmsPara->stat,ptSmsPara->alpha,&ptSmsPara->length);}}else if(
-(0xb29+6589-0x24e4)==iCmdId){if(P2==P1+(0xc3d+5642-0x2246)){sscanf(
-pSmsRawContent,"\x25\x64\x20\x25\x64\x20",&ptSmsPara->stat,&ptSmsPara->length);}
-else{sscanf(pSmsRawContent,"\x25\x64\x20\x25\x33\x32\x73\x20\x25\x64\x20",&
-ptSmsPara->stat,ptSmsPara->alpha,&ptSmsPara->length);}}atBase_RestoreString(
-ptSmsPara->alpha);atBase_RestoreString(ptSmsPara->pdu);return ZUFI_SUCC;}
+
+ #if 1//corem
+ printf("****undecode:%s\n", pdu_tmp);
+ #endif
+ (void)zUfiSms_DecodeSmsData(&db_data,pSmsItem->index, mem_store,(T_SmsStatus)pSmsItem->stat,
+ WMS_MESSAGE_FORMAT_GW_PP_V01, pSmsItem->length, pdu_tmp);
+
+ #if 1//corem
+ printf("****decodeed:%s\n", db_data.sms_content);
+ #endif
+ (void)zUfiSms_WriteSmsToDb(&db_data,mem_store,-1);
+ //if(WMS_STORAGE_TYPE_NV_V01 == mem_store)
+ {
+ //zUfiSms_DelModemSms(pSmsItem->index); ÔÝʱÆÁ±Î
+ }
+
+#if 1//defined (TSP_MODEL)
+ if(SMS_LOCATION_SIM == g_zUfiSms_CurLocation)
+ {
+ CHAR simCapability[50]={0};
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CAPABILITY,simCapability,sizeof(simCapability));
+ sim_capability = atoi(simCapability);
+ (void)zUfiSms_GetTotalCount(ZTE_WMS_DB_SIM_TABLE, &total_count);
+ if(total_count == sim_capability )
+ {
+ zUfiSms_DelModemSms(pSmsItem->index);
+ }
+ }
#endif
-void zUfiSms_CmglRespProc(T_zSms_SmsInd*pSmsItem){T_zUfiSms_CmdStatus result=
-WMS_CMD_PROCESSING;T_zUfiSms_DbStoreData db_data={(0x3fc+3047-0xfe3)};
-zUfiSms_StoreType mem_store=WMS_STORAGE_TYPE_UIM_V01;unsigned char pdu_tmp[
-ZSMS_PDU_SIZE]={(0xbf2+4430-0x1d40)};int total_count=(0x1411+2897-0x1f62);int
-sim_capability=(0x5ed+7937-0x24ee);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x45\x6e\x74\x65\x72\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x6c\x52\x65\x73\x70\x50\x72\x6f\x63\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x21" "\n"
-,pSmsItem->index,pSmsItem->stat,pSmsItem->length);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x70\x64\x75\x20\x64\x61\x74\x61\x5f\x6c\x65\x6e\x3a\x25\x64\x2c\x20\x73\x74\x72\x3a\x25\x73\x21" "\n"
-,strlen(pSmsItem->pdu),pSmsItem->pdu);memset(&db_data,(0x3a1+8598-0x2537),sizeof
-(db_data));memset(pdu_tmp,(0x681+6211-0x1ec4),sizeof(pdu_tmp));(void)
-String2Bytes(pSmsItem->pdu,pdu_tmp,(int)strlen(pSmsItem->pdu));
-#if (0xbcb+3564-0x19b6)
-zUfiSms_GetReportStatus(pSmsItem->pdu,&pSmsItem->stat);if((0x5e6+4278-0x1697)==
-pSmsItem->stat){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x45\x6e\x74\x65\x72\x20\x70\x53\x6d\x73\x49\x74\x65\x6d\x2d\x3e\x73\x74\x61\x74\x20\x3d\x3d\x20\x35" "\n"
-);(void)zUfiSms_HandleReport(pdu_tmp);zUfiSms_DelModemSms(pSmsItem->index);
-return;}
-#endif
-#if (0xbeb+4770-0x1e8c)
-printf("\x2a\x2a\x2a\x2a\x75\x6e\x64\x65\x63\x6f\x64\x65\x3a\x25\x73" "\n",
-pdu_tmp);
-#endif
-(void)zUfiSms_DecodeSmsData(&db_data,pSmsItem->index,mem_store,(T_SmsStatus)
-pSmsItem->stat,WMS_MESSAGE_FORMAT_GW_PP_V01,pSmsItem->length,pdu_tmp);
-#if (0x6cf+2478-0x107c)
-printf("\x2a\x2a\x2a\x2a\x64\x65\x63\x6f\x64\x65\x65\x64\x3a\x25\x73" "\n",
-db_data.sms_content);
-#endif
-(void)zUfiSms_WriteSmsToDb(&db_data,mem_store,-(0x1541+597-0x1795));{}
-#if (0x1cf+6224-0x1a1e)
-if(SMS_LOCATION_SIM==g_zUfiSms_CurLocation){CHAR simCapability[
-(0x11ff+2334-0x1aeb)]={(0x1fca+1760-0x26aa)};sc_cfg_get(
-ZTE_WMS_NVCONFIG_SIM_CAPABILITY,simCapability,sizeof(simCapability));
-sim_capability=atoi(simCapability);(void)zUfiSms_GetTotalCount(
-ZTE_WMS_DB_SIM_TABLE,&total_count);if(total_count==sim_capability){
-zUfiSms_DelModemSms(pSmsItem->index);}}
-#endif
-}void zUfiSms_InitDb(void){if(ZUFI_FAIL==zUfiSms_CheckStoreDir()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x68\x65\x63\x6b\x73\x74\x6f\x72\x65\x44\x69\x72\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);return;}
+}
+/*******************************
+Á÷³Ì³õʼ»¯º¯Êý
+********************************/
+void zUfiSms_InitDb(void)
+{
+ if(ZUFI_FAIL == zUfiSms_CheckStoreDir())
+ {
+ printf("[SMS] zUfiSms_CheckstoreDir failed.\n");
+ return;
+ }
#ifdef WEBS_SECURITY
-if(access(ZTE_WMS_DB_PATH,F_OK)!=(0x12c4+2546-0x1cb6)){if((access(
-ZTE_WMS_TMP1_PATH,F_OK)==(0x752+73-0x79b))&&(access(ZTE_WMS_SEC_PATH,F_OK)!=
-(0x3cc+663-0x663))){if(rename(ZTE_WMS_TMP1_PATH,ZTE_WMS_SEC_PATH)!=
-(0xc3d+1785-0x1336)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x57\x4d\x53\x5f\x54\x4d\x50\x31\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);}}if((access(ZTE_WMS_TMP0_PATH,F_OK)==(0x15d6+2600-0x1ffe))&&(access(
-ZTE_WMS_SEC_PATH,F_OK)!=(0x1bb9+1817-0x22d2))){if(rename(ZTE_WMS_TMP0_PATH,
-ZTE_WMS_SEC_PATH)!=(0x239+1258-0x723)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x57\x4d\x53\x5f\x54\x4d\x50\x30\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c\x65\x64\x2e" "\n"
-);}}if(access(ZTE_WMS_SEC_PATH,F_OK)==(0x17e8+3681-0x2649)){char rnum_buf[
-(0x16f0+2391-0x202f)]={(0x1006+510-0x1204)};char cmd[(0x431+8361-0x245a)]={
-(0x3f8+990-0x7d6)};sc_cfg_get("\x72\x6e\x75\x6d\x5f\x61\x74",rnum_buf,sizeof(
-rnum_buf));snprintf(cmd,sizeof(cmd),
-"\x2f\x62\x69\x6e\x2f\x6f\x70\x65\x6e\x73\x73\x6c\x20\x65\x6e\x63\x20\x2d\x64\x20\x2d\x61\x65\x73\x32\x35\x36\x20\x2d\x73\x61\x6c\x74\x20\x2d\x69\x6e\x20\x25\x73\x20\x2d\x6f\x75\x74\x20\x25\x73\x20\x2d\x70\x61\x73\x73\x20\x70\x61\x73\x73\x3a\x25\x73"
-,ZTE_WMS_SEC_PATH,ZTE_WMS_DB_PATH,rnum_buf);zxic_system(cmd);}}
+ if(access(ZTE_WMS_DB_PATH, F_OK) != 0)
+ {
+ if((access(ZTE_WMS_TMP1_PATH, F_OK) == 0)&&(access(ZTE_WMS_SEC_PATH, F_OK) != 0))
+ {
+ if(rename(ZTE_WMS_TMP1_PATH, ZTE_WMS_SEC_PATH) != 0)
+ {
+ printf("[SMS] WMS_TMP1_PATH failed.\n");
+ }
+ }
+ if((access(ZTE_WMS_TMP0_PATH, F_OK) == 0)&&(access(ZTE_WMS_SEC_PATH, F_OK) != 0))
+ {
+ if(rename(ZTE_WMS_TMP0_PATH, ZTE_WMS_SEC_PATH) != 0)
+ {
+ printf("[SMS] WMS_TMP0_PATH failed.\n");
+ }
+ }
+ if(access(ZTE_WMS_SEC_PATH, F_OK) == 0)
+ {
+ char rnum_buf[24] = {0};
+ char cmd[128] = {0};
+
+ sc_cfg_get("rnum_at", rnum_buf, sizeof(rnum_buf));
+ snprintf(cmd, sizeof(cmd), "/bin/openssl enc -d -aes256 -salt -in %s -out %s -pass pass:%s", ZTE_WMS_SEC_PATH, ZTE_WMS_DB_PATH, rnum_buf);
+ zxic_system(cmd);
+ }
+ }
#endif
-if(ZUFI_FAIL==zUfiSms_CheckSmsDb()){zUfiSms_GetDefaultCfgPara();}if(ZUFI_SUCC!=
-zUfiSms_CreateAllTable()){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x72\x65\x61\x74\x65\x41\x6c\x6c\x54\x61\x62\x6c\x65\x20\x66\x61\x69\x6c\x65\x64" "\n"
-);return;}if(ZUFI_SUCC!=zUfiSms_LoadSmsPara()){zUfiSms_GetDefaultPara();}(void)
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);zUfiSms_SendSmsStatusInfo(
-MSG_SMS_DEFAULT);g_zUfiSms_MsgRefer=zUfiSms_GetSmsMaxReferInDb();
-g_zUfiSms_ConcatSmsReference=zUfiSms_GetConcatMaxReferInDb();}void
-zUfiSms_CfgSmsNvInit(void){char tmp[(0x432+4121-0x1441)]={(0x91d+5032-0x1cc5)};
-sc_cfg_set(NV_SMS_STORE,"");sc_cfg_set(NV_SMS_LOAD_RESULT,"");sc_cfg_set(
-ZTE_WMS_NVCONFIG_RECEVIED,"");sc_cfg_set(NV_SMS_CENTER_NUM,"");snprintf(tmp,
-sizeof(tmp),"\x25\x64",ZTE_WMS_DB_MSG_COUNT_MAX);sc_cfg_set(
-ZTE_WMS_NVCONFIG_NV_CAPABILITY,tmp);}VOID zUfiSms_InitCmdStatus(
-T_zUfiSms_StatusInfo*pStatusInfo,T_zUfiSms_CmdType iCmdId){memset((void*)
-pStatusInfo,(0x9a9+3749-0x184e),sizeof(T_zUfiSms_StatusInfo));pStatusInfo->cmd=
-iCmdId;pStatusInfo->cmd_status=WMS_CMD_PROCESSING;pStatusInfo->err_code=
-ZTE_SMS_CMS_NONE;pStatusInfo->send_failed_count=(0xc31+2285-0x151e);pStatusInfo
-->delete_failed_count=(0x91a+1306-0xe34);(void)zUfiSms_SetCmdStatus(pStatusInfo)
-;}void zUfiSms_CfgInit(void){char tmp[(0x1401+2391-0x1d4e)]={(0x723+6394-0x201d)
-};sc_cfg_set(NV_SMS_STATE,"");sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED,"");
-sc_cfg_set(NV_SMS_LOAD_RESULT,"");sc_cfg_set(NV_SMS_RECV_RESULT,"");snprintf(tmp
-,sizeof(tmp),"\x25\x64",ZTE_WMS_DB_MSG_COUNT_MAX);sc_cfg_set(
-ZTE_WMS_NVCONFIG_NV_CAPABILITY,tmp);sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CAPABILITY,
-"");sc_cfg_set(ZTE_WMS_NVCONFIG_SMS_REPORT,"");sc_cfg_set(NV_SMS_DB_CHANGE,
-"\x31");sc_cfg_set(NV_SMS_CENTER_NUM,"");}int zUfiSms_IsUnreadSms(
-T_zUfiSms_MemoryType mem_store){int total_count=(0x391+3671-0x11e8);char buf[
-(0x8ca+4894-0x1bd4)]={(0x1872+159-0x1911)};if(ZUFI_FAIL==zUfiSms_GetTagCountInDb
-(mem_store,WMS_TAG_TYPE_MT_NOT_READ_V01,&total_count)){return FALSE;}sprintf(buf
-,"\x25\x64",total_count);sc_cfg_set(
-"\x73\x6d\x73\x5f\x75\x6e\x72\x65\x61\x64\x5f\x63\x6f\x75\x6e\x74",buf);if(
-(0x543+4755-0x17d6)==total_count){return FALSE;}else{return TRUE;}}VOID
-zUfiSms_SendSmsStatusInfo(wms_message_status_info sms_op){
-T_zUfi_SmsStatusInfoInd ind={(0x922+5766-0x1fa8)};CHAR temp[(0x12d4+2443-0x1c2d)
-]={(0x4c8+3118-0x10f6)};if(sms_op==MSG_SMS_NEW){ind.sms_new_ind=
-(0x1369+2825-0x1e71);}if(sms_op==MSG_SMS_READING){ind.sms_is_reading=
-(0xb14+5546-0x20bd);}if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)){ind.
-sms_unread_ind=(0x11f+4894-0x143c);}else{ind.sms_unread_ind=(0xa20+2822-0x1526);
-}sc_cfg_get("\x73\x6d\x73\x5f\x75\x6e\x72\x65\x61\x64\x5f\x63\x6f\x75\x6e\x74",
-temp,sizeof(temp));ind.sms_unread_count=atoi(temp);if((g_zUfiSms_MemFullFlag[
-WMS_STORAGE_TYPE_NV_V01]==TRUE)||(g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01
-]==TRUE)){ind.sms_memory_full_ind=(0x1408+1015-0x17fe);}else{ind.
-sms_memory_full_ind=(0x351+1790-0xa4f);}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x53\x6d\x73\x53\x74\x61\x74\x75\x73\x49\x6e\x66\x6f\x20\x75\x6e\x72\x65\x61\x64\x20\x3d\x20\x25\x64\x2c\x20\x66\x75\x6c\x6c\x3d\x25\x64\x2c\x20\x6e\x65\x77\x3d\x25\x64\x2c\x20\x72\x65\x61\x64\x69\x6e\x67\x3d\x25\x64" "\n"
-,ind.sms_unread_ind,ind.sms_memory_full_ind,ind.sms_new_ind,ind.sms_is_reading);
-ipc_send_message(MODULE_ID_SMS,MODULE_ID_MMI,MSG_CMD_SMS_STATUS_INFO_IND,sizeof(
-T_zUfi_SmsStatusInfoInd),&ind,(0x205d+940-0x2409));if(ind.sms_memory_full_ind==
-(0x7d0+3876-0x16f3)){sc_cfg_set(NV_SMS_INIT_STATUS,
-"\x73\x6d\x73\x5f\x6d\x65\x6d\x6f\x72\x79\x5f\x66\x75\x6c\x6c");}else if(ind.
-sms_unread_ind==(0x836+3292-0x1511)){sc_cfg_set(NV_SMS_INIT_STATUS,
-"\x73\x6d\x73\x5f\x75\x6e\x72\x65\x61\x64");}else{sc_cfg_set(NV_SMS_INIT_STATUS,
-"\x73\x6d\x73\x5f\x6e\x6f\x72\x6d\x61\x6c");}return;}VOID BakNotificationSms(
-char*pushSms,int pushSmsLen){FILE*fp=NULL;int len;fp=fopen(
-"\x2f\x75\x73\x72\x2f\x64\x6d\x2f\x66\x6f\x74\x61\x5f\x70\x75\x73\x68\x5f\x6d\x73\x67\x2e\x64\x61\x74\x61"
-,"\x77\x2b");if(fp==NULL){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x42\x61\x6b\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x53\x6d\x73\x20\x66\x6f\x70\x65\x6e\x20\x65\x72\x72\x6f\x72" "\n"
-);at_print(LOG_ERR,
-"\x66\x6f\x70\x65\x6e\x28\x20\x2f\x75\x73\x72\x2f\x64\x6d\x2f\x66\x6f\x74\x61\x5f\x70\x75\x73\x68\x5f\x6d\x73\x67\x2e\x64\x61\x74\x61\x20\x2c\x20\x27\x77\x2b\x27\x29\x20\x65\x72\x72\x6f\x72\x21"
-);return;}len=fwrite(pushSms,(0x4d2+4637-0x16ee),pushSmsLen,fp);if(len==
-pushSmsLen){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x42\x61\x6b\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x53\x6d\x73\x20\x77\x72\x69\x74\x65\x20\x74\x6f\x20\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x62\x61\x6b\x20\x66\x69\x6c\x65\x20\x4f\x4b\x2c\x20\x6c\x65\x6e\x3d\x25\x64\x20" "\n"
-,len);printf(
-"\x77\x72\x69\x74\x65\x20\x74\x6f\x20\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x62\x61\x6b\x20\x66\x69\x6c\x65\x20\x4f\x4b\x2c\x20\x6c\x65\x6e\x3d\x25\x64\x21"
-,len);fclose(fp);return;}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x42\x61\x6b\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x53\x6d\x73\x20\x77\x72\x69\x74\x65\x20\x74\x6f\x20\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x62\x61\x6b\x20\x66\x69\x6c\x65\x20\x66\x61\x69\x6c\x64\x2c\x20\x6c\x65\x6e\x3d\x25\x64\x20" "\n"
-,len);printf(
-"\x77\x72\x69\x74\x65\x20\x74\x6f\x20\x4e\x6f\x74\x69\x66\x69\x63\x61\x74\x69\x6f\x6e\x62\x61\x6b\x20\x66\x69\x6c\x65\x20\x66\x61\x69\x6c\x64\x2c\x20\x6c\x65\x6e\x3d\x25\x64\x21"
-,len);fclose(fp);return;}}
+ if(ZUFI_FAIL == zUfiSms_CheckSmsDb())//ÅжÏÎļþÊÇ·ñ´æÔÚ
+ {
+ zUfiSms_GetDefaultCfgPara();//get default parameter from config file
+ }
+ /*create all the needed sms database*/
+ if(ZUFI_SUCC != zUfiSms_CreateAllTable())
+ {
+ printf("[SMS] zUfiSms_CreateAllTable failed\n");
+ return;
+ }
+
+ /*load sms parameters*/
+ if(ZUFI_SUCC != zUfiSms_LoadSmsPara())
+ {
+ zUfiSms_GetDefaultPara();
+ }
+ /*check nv memory full or not?*/
+ (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
+
+ g_zUfiSms_MsgRefer = zUfiSms_GetSmsMaxReferInDb();
+ g_zUfiSms_ConcatSmsReference = zUfiSms_GetConcatMaxReferInDb();
+}
+//É豸²à´æ´¢µÄsmsÈÝÁ¿µÈ³õʼ»¯
+void zUfiSms_CfgSmsNvInit(void)
+{
+ char tmp[10]={0};
+
+ sc_cfg_set(NV_SMS_STORE,"");
+ sc_cfg_set(NV_SMS_LOAD_RESULT,"");//mengyuan add on 20100302 for sms
+ sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED,"");
+ sc_cfg_set(NV_SMS_CENTER_NUM,"");
+
+ snprintf(tmp,sizeof(tmp),"%d",ZTE_WMS_DB_MSG_COUNT_MAX);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_NV_CAPABILITY, tmp);/*lint !e534*/
+}
+
+VOID zUfiSms_InitCmdStatus(T_zUfiSms_StatusInfo *pStatusInfo,T_zUfiSms_CmdType iCmdId)
+{
+ memset((void*)pStatusInfo,0,sizeof(T_zUfiSms_StatusInfo));
+ pStatusInfo->cmd = iCmdId;
+ pStatusInfo->cmd_status = WMS_CMD_PROCESSING;
+ pStatusInfo->err_code = ZTE_SMS_CMS_NONE;
+ pStatusInfo->send_failed_count = 0;
+ pStatusInfo->delete_failed_count = 0;
+ (void)zUfiSms_SetCmdStatus(pStatusInfo);
+}
+
+void zUfiSms_CfgInit(void)
+{
+ char tmp[10]={0};
+
+ sc_cfg_set(NV_SMS_STATE,"");/*lint !e534*/
+ sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED,"");/*lint !e534*/
+ sc_cfg_set(NV_SMS_LOAD_RESULT, "");/*lint !e534*/
+ sc_cfg_set(NV_SMS_RECV_RESULT, "");/*lint !e534*/
+
+ snprintf(tmp,sizeof(tmp),"%d",ZTE_WMS_DB_MSG_COUNT_MAX);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_NV_CAPABILITY, tmp);/*lint !e534*/
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CAPABILITY,"");/*lint !e534*/
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SMS_REPORT, "");/*lint !e534*/
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+ sc_cfg_set(NV_SMS_CENTER_NUM,"");
+}
+
+int zUfiSms_IsUnreadSms(T_zUfiSms_MemoryType mem_store)
+{
+ int total_count = 0;
+ char buf[20] = {0};
+
+ //²éѯδ¶Á¶ÌÐŵÄÊýÁ¿
+ if(ZUFI_FAIL == zUfiSms_GetTagCountInDb(mem_store,WMS_TAG_TYPE_MT_NOT_READ_V01,&total_count))
+ {
+ return FALSE;
+ }
+
+ sprintf(buf,"%d", total_count);
+ sc_cfg_set("sms_unread_count", buf);
+
+ if(0 == total_count)
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+}
+
+VOID zUfiSms_SendSmsStatusInfo(wms_message_status_info sms_op)
+{
+ T_zUfi_SmsStatusInfoInd ind = {0};
+
+ CHAR temp[50] = {0};
+
+ if(sms_op == MSG_SMS_NEW)
+ {
+ ind.sms_new_ind = 1;
+ }
+ if(sms_op == MSG_SMS_READING)
+ {
+ ind.sms_is_reading = 1;
+ }
+ /*check nv unread sms or not?*/
+ if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
+ {
+ ind.sms_unread_ind = 1;
+ }
+ else
+ {
+ ind.sms_unread_ind = 0;
+ }
+
+ sc_cfg_get("sms_unread_count",temp,sizeof(temp));
+
+ ind.sms_unread_count = atoi(temp);
+ //ind.sms_memory_full_ind = (UINT8)g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01];
+ if((g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01] == TRUE) || (g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_UIM_V01] == TRUE))
+ {
+ ind.sms_memory_full_ind = 1;
+ }
+ else
+ {
+ ind.sms_memory_full_ind = 0;
+ }
+ printf("[SMS] zUfiSms_SendSmsStatusInfo unread = %d, full=%d, new=%d, reading=%d\n",ind.sms_unread_ind,ind.sms_memory_full_ind, ind.sms_new_ind, ind.sms_is_reading);
+
+ ipc_send_message(MODULE_ID_SMS, MODULE_ID_MMI, MSG_CMD_SMS_STATUS_INFO_IND, sizeof(T_zUfi_SmsStatusInfoInd), &ind, 0);
+
+ if(ind.sms_memory_full_ind == 1)
+ {
+ sc_cfg_set(NV_SMS_INIT_STATUS,"sms_memory_full");
+ }
+ else if(ind.sms_unread_ind == 1)
+ {
+ sc_cfg_set(NV_SMS_INIT_STATUS,"sms_unread");
+ }
+ else
+ {
+ sc_cfg_set(NV_SMS_INIT_STATUS,"sms_normal");
+ }
+ return;
+}
+
+VOID BakNotificationSms(char * pushSms,int pushSmsLen)
+{
+ FILE *fp = NULL;
+ int len;
+
+ fp = fopen("/usr/dm/fota_push_msg.data", "w+");
+ if(fp == NULL)
+ {
+ printf("[SMS] BakNotificationSms fopen error\n");
+ at_print(LOG_ERR,"fopen( /usr/dm/fota_push_msg.data , 'w+') error!");
+ return;
+ }
+
+ len = fwrite(pushSms,1,pushSmsLen,fp); //ʵ¼ÊдÈëµÄ³¤¶È
+ if(len==pushSmsLen)
+ {
+ printf("[SMS] BakNotificationSms write to Notificationbak file OK, len=%d \n", len);
+ printf("write to Notificationbak file OK, len=%d!",len);
+ fclose(fp);
+ return;
+ }
+ else
+ {
+ printf("[SMS] BakNotificationSms write to Notificationbak file faild, len=%d \n", len);
+ printf("write to Notificationbak file faild, len=%d!",len);
+ fclose(fp);
+ return;
+ }
+}
+
+
+
diff --git a/ap/app/zte_comm/sms/src/sms_main.c b/ap/app/zte_comm/sms/src/sms_main.c
index cc3588e..26ebd18 100755
--- a/ap/app/zte_comm/sms/src/sms_main.c
+++ b/ap/app/zte_comm/sms/src/sms_main.c
@@ -1,394 +1,1176 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2013 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : sms
+* ÎÄ ¼þ Ãû : sms_main.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : SMSÏûÏ¢Á÷³Ì¿ØÖÆ´¦Àí
+* ×÷ Õß : ÕÅ·Ò
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2017.2.9
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
#include <errno.h>
#include <sys/msg.h>
#include <semaphore.h>
#include <limits.h>
#include <pthread.h>
+
#include "sms_code.h"
-typedef VOID(*pAtWeb_SmsMsgProc)(UINT8*pDatabuf);typedef struct{UINT32 msg_id;
-VOID(*func_ptr)(UINT8*pDatabuf);BOOL need_block;}T_zSmsHandleTable;VOID
-atWeb_SendSms(UINT8*pDatabuf);VOID atWeb_DelSmsByIndex(UINT8*pDatabuf);VOID
-atWeb_DelSmsByType(UINT8*pDatabuf);VOID atWeb_ReadSms(UINT8*pDatabuf);VOID
-atWeb_SaveSms(UINT8*pDatabuf);VOID atWeb_SetSms(UINT8*pDatabuf);VOID
-atWeb_OutdateSmsCheck(UINT8*pDatabuf);int zSms_SendZmgrReq(int index);extern
-UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX];extern T_zSms_SendSmsReq
-g_zUfiSms_FinalCmgsBuf;extern int g_zUfiSms_CurConcatSegNo;extern
-T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];extern
- int g_zUfiSms_SendFailedCount;extern int g_zUfiSms_ConcatTotalNum;extern UINT8
-g_zUfiSms_IsConcatSendSuc;int iSmsIndex=(0x491+3896-0x13c9);int g_zSms_MsqId=-
-(0x24+7436-0x1d2f);int g_zSms_LocalMsqId=-(0x222+3114-0xe4b);sem_t g_sms_sem_id;
-T_zSms_optRsp g_smsOptRsp={(0xaf9+2542-0x14e7)};static const T_zSmsHandleTable
-SmsHandleWebTab[]={{MSG_CMD_SEND_SMS,atWeb_SendSms,TRUE},{
-MSG_CMD_DEL_SMS_BY_INDEX,atWeb_DelSmsByIndex,TRUE},{MSG_CMD_SMS_MODIFY_TAG,
-atWeb_ReadSms,TRUE},{MSG_CMD_DRAFTS_SAVE,atWeb_SaveSms,FALSE},{
-MSG_CMD_SMS_LOCATION_SET,atWeb_SetSms,TRUE},{MSG_CMD_SMS_OUTDATE_CHECK,
-atWeb_OutdateSmsCheck,TRUE},{(0xc1c+3312-0x190c),NULL,FALSE}};VOID atWeb_SendSms
-(UINT8*pDatabuf){T_zGoaheadMsgBuf*ptMessage=NULL;T_zUfiSms_StatusInfo tStatus={
-(0x38c+4353-0x148d)};assert(pDatabuf!=NULL);ptMessage=(T_zGoaheadMsgBuf*)
-pDatabuf;zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_SEND);(void)
-zUfiSms_SendRawSms((T_zUfiSms_SendReq*)ptMessage->msg_data);}VOID
-atWeb_DelSmsByIndex(UINT8*pDatabuf){T_zUfiSms_DelReq tDelReq={
-(0x1467+3798-0x233d)};T_zUfiSms_CmdStatus result=WMS_CMD_PROCESSING;
-T_zUfiSms_StatusInfo tStatus={(0x5d2+3619-0x13f5)};assert(pDatabuf!=NULL);printf
-("[SMS] atWeb_DelSmsByIndex recv msg\n");memcpy(&tDelReq,pDatabuf,sizeof(
-T_zUfiSms_DelReq));zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_DELETE);result
-=zUfiSms_DeleteSms(&tDelReq);tStatus.cmd_status=result;(void)
-zUfiSms_SetCmdStatus(&tStatus);zUfiMmi_SendSmsStatus();}VOID atWeb_DelSmsByType(
-UINT8*pDatabuf){
-#if (0x344+368-0x4b4)
-WEB_DEL_SMS_BY_TYPE*req=NULL;req=(WEB_DEL_SMS_BY_TYPE*)pDatabuf;assert(req!=NULL
-);if(req->eLocation!=ZSMS_LOCATION_SIM){ZTE_LOG(LOG_ERR,
-"\x7a\x53\x6d\x73\x5f\x50\x72\x65\x70\x44\x65\x6c\x42\x79\x54\x79\x70\x65\x20\x70\x61\x72\x61\x20\x4e\x55\x4c\x4c\x2e" "\n"
-);return;}zSms_ChangeMainState(ZSMS_STATE_DELING);ZTE_LOG(LOG_DEBUG,
-"\x7a\x53\x6d\x73\x5f\x50\x72\x65\x70\x44\x65\x6c\x42\x79\x54\x79\x70\x65\x20\x70\x73\x74\x52\x65\x71\x2d\x3e\x65\x42\x6f\x78\x4e\x61\x6d\x65\x3d\x25\x64" "\n"
-,req->eBoxName);SMS_DeleteRecordFromXML(SMS_LOCATION_SIM,(0x1a7+5576-0x176f),req
-->eBoxName);if(req->eBoxName==SMS_INBOX){sms_LoadSmsFromSim();}
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+//#define MODULE_ID_SMS_LOCAL 0x2001
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef VOID (*pAtWeb_SmsMsgProc)(UINT8 *pDatabuf);
+
+typedef struct
+{
+ UINT32 msg_id;
+ VOID (*func_ptr)(UINT8 *pDatabuf);
+ BOOL need_block;//ÊÇ·ñÐèÒª×èÈû£¬Èç¹û×èÈû£¬ÐèÒª½«ÏûϢתµ½ÄÚ²¿Ï̴߳¦Àí
+}T_zSmsHandleTable;
+
+
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+VOID atWeb_SendSms(UINT8 *pDatabuf);
+VOID atWeb_DelSmsByIndex(UINT8 *pDatabuf);
+VOID atWeb_DelSmsByType(UINT8 *pDatabuf);
+VOID atWeb_ReadSms(UINT8 *pDatabuf);
+VOID atWeb_SaveSms(UINT8 *pDatabuf);
+VOID atWeb_SetSms(UINT8 *pDatabuf);
+VOID atWeb_OutdateSmsCheck(UINT8 *pDatabuf);
+
+int zSms_SendZmgrReq(int index);
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+extern UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX];
+extern T_zSms_SendSmsReq g_zUfiSms_FinalCmgsBuf;
+extern int g_zUfiSms_CurConcatSegNo;
+extern T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];
+extern int g_zUfiSms_SendFailedCount;
+extern int g_zUfiSms_ConcatTotalNum;
+extern UINT8 g_zUfiSms_IsConcatSendSuc;
+
+//ÔÚcmgrÇëÇóÖмǼindex£¬ÓÃÓÚÓ¦´ðÏûÏ¢ÖеĴ洢
+int iSmsIndex = 0;
+int g_zSms_MsqId = -1;
+int g_zSms_LocalMsqId = -1;
+sem_t g_sms_sem_id;
+T_zSms_optRsp g_smsOptRsp = {0};
+
+
+static const T_zSmsHandleTable SmsHandleWebTab[] =
+{
+ {MSG_CMD_SEND_SMS, atWeb_SendSms, TRUE},
+ {MSG_CMD_DEL_SMS_BY_INDEX, atWeb_DelSmsByIndex, TRUE},
+ //{MSG_CMD_DEL_SMS_BY_TYPE, atWeb_DelSmsByType},
+ {MSG_CMD_SMS_MODIFY_TAG, atWeb_ReadSms, TRUE},
+ {MSG_CMD_DRAFTS_SAVE, atWeb_SaveSms, FALSE}, //corem
+ {MSG_CMD_SMS_LOCATION_SET, atWeb_SetSms, TRUE},
+ {MSG_CMD_SMS_OUTDATE_CHECK, atWeb_OutdateSmsCheck, TRUE},
+ {0, NULL, FALSE}
+};
+
+
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+
+// pDatabufΪpstMsg->aucDataBuf
+VOID atWeb_SendSms(UINT8 *pDatabuf)
+{
+ T_zGoaheadMsgBuf *ptMessage = NULL;
+ T_zUfiSms_StatusInfo tStatus = {0};
+ assert(pDatabuf != NULL);
+
+ ptMessage = (T_zGoaheadMsgBuf *)pDatabuf;
+
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_SEND);
+
+
+ //pthread_mutex_lock(&smsdb_mutex);
+ (void)zUfiSms_SendRawSms((T_zUfiSms_SendReq *)ptMessage->msg_data);
+ //pthread_mutex_unlock(&smsdb_mutex);
+}
+
+VOID atWeb_DelSmsByIndex(UINT8 *pDatabuf)
+{
+ T_zUfiSms_DelReq tDelReq = {0};
+ T_zUfiSms_CmdStatus result = WMS_CMD_PROCESSING;
+ T_zUfiSms_StatusInfo tStatus = {0};
+ assert(pDatabuf != NULL);
+
+ printf("[SMS] atWeb_DelSmsByIndex recv msg\n");
+ memcpy(&tDelReq, pDatabuf,sizeof(T_zUfiSms_DelReq));
+
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_DELETE);
+ result = zUfiSms_DeleteSms(&tDelReq);
+
+ tStatus.cmd_status = result;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+ zUfiMmi_SendSmsStatus();
+}
+
+VOID atWeb_DelSmsByType(UINT8 *pDatabuf)
+{
+ #if 0
+ WEB_DEL_SMS_BY_TYPE *req = NULL;
+ req = (WEB_DEL_SMS_BY_TYPE *)pDatabuf;
+ assert(req != NULL);
+ if(req->eLocation != ZSMS_LOCATION_SIM)
+ {
+ ZTE_LOG(LOG_ERR, "zSms_PrepDelByType para NULL.\n");
+ return;
+ }
+ zSms_ChangeMainState(ZSMS_STATE_DELING);
+ ZTE_LOG(LOG_DEBUG, "zSms_PrepDelByType pstReq->eBoxName=%d\n",req->eBoxName);
+ SMS_DeleteRecordFromXML(SMS_LOCATION_SIM, 0, req->eBoxName);
+ if (req->eBoxName == SMS_INBOX)
+ {
+ sms_LoadSmsFromSim();
+ }
+ #endif
+}
+//¶ÌÐÅ״̬ÓÉδ¶Á±äΪÒѶÁ
+VOID atWeb_ReadSms(UINT8 *pDatabuf)
+{
+ T_zGoaheadMsgBuf * ptMessage = NULL;
+ T_zUfiSms_CmdStatus result = WMS_CMD_PROCESSING;
+ T_zUfiSms_StatusInfo tStatus = {0};
+ assert(pDatabuf != NULL);
+
+ ptMessage = (T_zGoaheadMsgBuf *)pDatabuf;
+
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_MODIFY_TAG);
+ result = zUfiSms_ModifySmsTag((T_zUfiSms_ModifyFlag *)ptMessage->msg_data);
+
+ tStatus.cmd_status = result;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+}
+
+VOID atWeb_SaveSms(UINT8 *pDatabuf)
+{
+ T_zGoaheadMsgBuf * ptMessage = NULL;
+ T_zUfiSms_CmdStatus result = WMS_CMD_PROCESSING;
+ T_zUfiSms_StatusInfo tStatus = {0};
+ assert(pDatabuf != NULL);
+
+ ptMessage = (T_zGoaheadMsgBuf *)pDatabuf;
+
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_WRITE);
+ result = zUfiSms_WriteRawSms((T_zUfiSms_SaveReq *)ptMessage->msg_data);
+
+ if(g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV])
+ {
+ tStatus.err_code = ZTE_SMS_CMS_MEM_FULL;
+ printf("[SMS] atWeb_SaveSms mem full\n");
+ }
+ tStatus.cmd_status = result;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+
+ //zSms_ChangeMainState(ZSMS_STATE_SAVING);
+ zUfiSms_ChangeMainState(SMS_STATE_SAVING);
+ sc_cfg_set(NV_SMS_SAVE_RESULT, "ok");
+
+}
+
+VOID atWeb_SetSms(UINT8 *pDatabuf)
+{
+ T_zGoaheadMsgBuf * ptMessage = NULL;
+ T_zUfiSms_CmdStatus result = WMS_CMD_PROCESSING;
+ T_zUfiSms_StatusInfo tStatus = {0};
+
+ printf( "INTO atWeb_SetSms.\n");
+
+ assert(pDatabuf != NULL);
+
+ ptMessage = (T_zGoaheadMsgBuf *)pDatabuf;
+
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_CFG_SET_PARAMETERS);
+ result = zUfiSms_SetSmsPara((T_zUfiSms_ParaInfo *)ptMessage->msg_data);
+
+ tStatus.cmd_status = result;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+}
+
+VOID atWeb_OutdateSmsCheck(UINT8 *pDatabuf)
+{
+ T_zUfiSms_DelReq tSmsDel = {0};
+
+ zUfiSms_CheckDbOutdateSms(ZTE_WMS_DB_NV_TABLE, &tSmsDel);
+ printf("----out coun nvt: %d----\n",tSmsDel.all_or_count);
+ //for(i=0;i<tSmsDel.all_or_count;i++)printf("----out id: %d----\n",tSmsDel.id[i]);
+
+ if(tSmsDel.all_or_count > 0)
+ {
+ atWeb_DelSmsByIndex(&tSmsDel);
+ }
+
+ memset(&tSmsDel, 0, sizeof(T_zUfiSms_DelReq));
+ zUfiSms_CheckDbOutdateSms(ZTE_WMS_DB_SIM_TABLE, &tSmsDel);
+ printf("----out count sim: %d----\n",tSmsDel.all_or_count);
+ //for(i=0;i<tSmsDel.all_or_count;i++)printf("----out id: %d----\n",tSmsDel.id[i]);
+
+ if(tSmsDel.all_or_count > 0)
+ {
+ atWeb_DelSmsByIndex(&tSmsDel);
+ }
+}
+
+VOID zSms_HandleWebMsg(MSG_BUF *ptMsgBuf)
+{
+ UINT32 i = 0;
+ assert(ptMsgBuf != NULL);
+
+ printf("sms recv msg from webserver:%d\n", ptMsgBuf->usMsgCmd);
+ while(0 != SmsHandleWebTab[i].msg_id)
+ {
+ if(ptMsgBuf->usMsgCmd == SmsHandleWebTab[i].msg_id)
+ {
+ if(SmsHandleWebTab[i].need_block && ptMsgBuf->src_id != MODULE_ID_SMS)
+ {
+ ipc_send_message(MODULE_ID_SMS, MODULE_ID_SMS_LOCAL, ptMsgBuf->usMsgCmd, ptMsgBuf->usDataLen, (unsigned char *)ptMsgBuf->aucDataBuf, 0);
+ }
+ else if(NULL != SmsHandleWebTab[i].func_ptr)
+ {
+ SmsHandleWebTab[i].func_ptr(ptMsgBuf->aucDataBuf);
+ }
+ break;
+ }
+ i++;
+ }
+}
+
+
+//
+SINT32 zSms_SendMsg(USHORT Msg_cmd,USHORT us_DataLen,UCHAR *pData)
+{
+ printf( "sms send msg cmd:%d\n", Msg_cmd);
+ ipc_send_message(MODULE_ID_SMS, MODULE_ID_AT_CTL, Msg_cmd, us_DataLen, (unsigned char *)pData,0);
+
+ return 0;
+}
+
+
+/*¶ÔÓ¦atSms_SendCmgsReq*/
+SINT32 zSms_SendCmgsReq(VOID)
+{
+ T_zSms_SendSmsReq sendSmsInfo = {0};
+
+ memset(&sendSmsInfo, 0x00, sizeof(T_zSms_SendSmsReq));
+ sendSmsInfo.length = g_zUfiSms_FinalCmgsBuf.length;
+
+ if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE-1)
+ {
+ memcpy(sendSmsInfo.pdu, g_zUfiSms_FinalCmgsBuf.pdu, strlen(g_zUfiSms_FinalCmgsBuf.pdu));
+ }
+ else
+ {
+ printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",g_zUfiSms_FinalCmgsBuf.pdu);
+ memcpy(sendSmsInfo.pdu, g_zUfiSms_FinalCmgsBuf.pdu, ZSMS_PDU_SIZE-2);
+ }
+ // Ìí¼Ó½áβ·û
+ *(sendSmsInfo.pdu + strlen(g_zUfiSms_FinalCmgsBuf.pdu)) = ZSMS_CTRL_Z_CHAR;
+#if 1//corem for debug
+ printf("[SMS] atSms_SendCmgsReq send data\n");
+ printf("\n[SMS]%s\n",sendSmsInfo.pdu);
#endif
-}VOID atWeb_ReadSms(UINT8*pDatabuf){T_zGoaheadMsgBuf*ptMessage=NULL;
-T_zUfiSms_CmdStatus result=WMS_CMD_PROCESSING;T_zUfiSms_StatusInfo tStatus={
-(0x20b+4601-0x1404)};assert(pDatabuf!=NULL);ptMessage=(T_zGoaheadMsgBuf*)
-pDatabuf;zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_MSG_MODIFY_TAG);result=
-zUfiSms_ModifySmsTag((T_zUfiSms_ModifyFlag*)ptMessage->msg_data);tStatus.
-cmd_status=result;(void)zUfiSms_SetCmdStatus(&tStatus);}VOID atWeb_SaveSms(UINT8
-*pDatabuf){T_zGoaheadMsgBuf*ptMessage=NULL;T_zUfiSms_CmdStatus result=
-WMS_CMD_PROCESSING;T_zUfiSms_StatusInfo tStatus={(0x98f+1762-0x1071)};assert(
-pDatabuf!=NULL);ptMessage=(T_zGoaheadMsgBuf*)pDatabuf;zUfiSms_InitCmdStatus(&
-tStatus,WMS_SMS_CMD_MSG_WRITE);result=zUfiSms_WriteRawSms((T_zUfiSms_SaveReq*)
-ptMessage->msg_data);if(g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV]){tStatus.
-err_code=ZTE_SMS_CMS_MEM_FULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x57\x65\x62\x5f\x53\x61\x76\x65\x53\x6d\x73\x20\x6d\x65\x6d\x20\x66\x75\x6c\x6c" "\n"
-);}tStatus.cmd_status=result;(void)zUfiSms_SetCmdStatus(&tStatus);
-zUfiSms_ChangeMainState(SMS_STATE_SAVING);sc_cfg_set(NV_SMS_SAVE_RESULT,
-"\x6f\x6b");}VOID atWeb_SetSms(UINT8*pDatabuf){T_zGoaheadMsgBuf*ptMessage=NULL;
-T_zUfiSms_CmdStatus result=WMS_CMD_PROCESSING;T_zUfiSms_StatusInfo tStatus={
-(0x16eb+1028-0x1aef)};printf(
-"\x49\x4e\x54\x4f\x20\x61\x74\x57\x65\x62\x5f\x53\x65\x74\x53\x6d\x73\x2e" "\n")
-;assert(pDatabuf!=NULL);ptMessage=(T_zGoaheadMsgBuf*)pDatabuf;
-zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_CFG_SET_PARAMETERS);result=
-zUfiSms_SetSmsPara((T_zUfiSms_ParaInfo*)ptMessage->msg_data);tStatus.cmd_status=
-result;(void)zUfiSms_SetCmdStatus(&tStatus);}VOID atWeb_OutdateSmsCheck(UINT8*
-pDatabuf){T_zUfiSms_DelReq tSmsDel={(0x7f0+7623-0x25b7)};
-zUfiSms_CheckDbOutdateSms(ZTE_WMS_DB_NV_TABLE,&tSmsDel);printf(
-"\x2d\x2d\x2d\x2d\x6f\x75\x74\x20\x63\x6f\x75\x6e\x20\x6e\x76\x74\x3a\x20\x25\x64\x2d\x2d\x2d\x2d" "\n"
-,tSmsDel.all_or_count);if(tSmsDel.all_or_count>(0x12b+6943-0x1c4a)){
-atWeb_DelSmsByIndex(&tSmsDel);}memset(&tSmsDel,(0x709+941-0xab6),sizeof(
-T_zUfiSms_DelReq));zUfiSms_CheckDbOutdateSms(ZTE_WMS_DB_SIM_TABLE,&tSmsDel);
-printf(
-"\x2d\x2d\x2d\x2d\x6f\x75\x74\x20\x63\x6f\x75\x6e\x74\x20\x73\x69\x6d\x3a\x20\x25\x64\x2d\x2d\x2d\x2d" "\n"
-,tSmsDel.all_or_count);if(tSmsDel.all_or_count>(0x4c+4306-0x111e)){
-atWeb_DelSmsByIndex(&tSmsDel);}}VOID zSms_HandleWebMsg(MSG_BUF*ptMsgBuf){UINT32
-i=(0x162d+3387-0x2368);assert(ptMsgBuf!=NULL);printf(
-"\x73\x6d\x73\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x66\x72\x6f\x6d\x20\x77\x65\x62\x73\x65\x72\x76\x65\x72\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);while((0x1f32+747-0x221d)!=SmsHandleWebTab[i].msg_id){if(
-ptMsgBuf->usMsgCmd==SmsHandleWebTab[i].msg_id){if(SmsHandleWebTab[i].need_block
-&&ptMsgBuf->src_id!=MODULE_ID_SMS){ipc_send_message(MODULE_ID_SMS,
-MODULE_ID_SMS_LOCAL,ptMsgBuf->usMsgCmd,ptMsgBuf->usDataLen,(unsigned char*)
-ptMsgBuf->aucDataBuf,(0x1a87+1294-0x1f95));}else if(NULL!=SmsHandleWebTab[i].
-func_ptr){SmsHandleWebTab[i].func_ptr(ptMsgBuf->aucDataBuf);}break;}i++;}}SINT32
- zSms_SendMsg(USHORT Msg_cmd,USHORT us_DataLen,UCHAR*pData){printf(
-"\x73\x6d\x73\x20\x73\x65\x6e\x64\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,Msg_cmd);ipc_send_message(MODULE_ID_SMS,MODULE_ID_AT_CTL,Msg_cmd,us_DataLen,(
-unsigned char*)pData,(0x1303+5102-0x26f1));return(0x1d49+1315-0x226c);}SINT32
-zSms_SendCmgsReq(VOID){T_zSms_SendSmsReq sendSmsInfo={(0xd73+3579-0x1b6e)};
-memset(&sendSmsInfo,(0x4e6+7181-0x20f3),sizeof(T_zSms_SendSmsReq));sendSmsInfo.
-length=g_zUfiSms_FinalCmgsBuf.length;if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)<
-ZSMS_PDU_SIZE-(0x12cb+5109-0x26bf)){memcpy(sendSmsInfo.pdu,
-g_zUfiSms_FinalCmgsBuf.pdu,strlen(g_zUfiSms_FinalCmgsBuf.pdu));}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6d\x67\x73\x52\x65\x71\x20\x70\x64\x75\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x25\x73" "\n"
-,g_zUfiSms_FinalCmgsBuf.pdu);memcpy(sendSmsInfo.pdu,g_zUfiSms_FinalCmgsBuf.pdu,
-ZSMS_PDU_SIZE-(0x263+6187-0x1a8c));}*(sendSmsInfo.pdu+strlen(
-g_zUfiSms_FinalCmgsBuf.pdu))=ZSMS_CTRL_Z_CHAR;
-#if (0x13a4+3823-0x2292)
-printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6d\x67\x73\x52\x65\x71\x20\x73\x65\x6e\x64\x20\x64\x61\x74\x61" "\n"
-);printf("\n" "\x5b\x53\x4d\x53\x5d\x25\x73" "\n",sendSmsInfo.pdu);
-#endif
-zSms_SendMsg(MSG_CMD_SENDSMS_REQ,sizeof(T_zSms_SendSmsReq),&sendSmsInfo);
-sem_wait(&g_sms_sem_id);if(g_smsOptRsp.result==(0x58f+8057-0x2507)){return
-ZSMS_RESULT_OK;}else{return ZSMS_RESULT_ERROR;}}VOID zSms_RecvCmgsOk(VOID){
-printf(
-"\x73\x6d\x73\x20\x73\x65\x6e\x64\x65\x64\x20\x73\x75\x63\x63\x65\x73\x73\x2e\x20" "\n"
-);g_zUfiSms_CurConcatSegNo++;if(g_zUfiSms_CurConcatSegNo>
-ZTE_WMS_CONCAT_SMS_COUNT_MAX){return;}g_zUfiSms_DbStoreData[
-g_zUfiSms_CurConcatSegNo-(0x199d+794-0x1cb6)].tag=WMS_TAG_TYPE_MO_SENT_V01;
-zUfiSms_CmgsRespProc();}VOID zSms_RecvCmgsErr(VOID){printf(
-"\x73\x6d\x73\x20\x73\x65\x6e\x64\x65\x64\x20\x66\x61\x69\x6c\x2e\x20" "\n");
-g_zUfiSms_CurConcatSegNo++;if(g_zUfiSms_CurConcatSegNo>
-ZTE_WMS_CONCAT_SMS_COUNT_MAX){return;}g_zUfiSms_SendFailedCount++;printf(
-"\x73\x65\x6e\x64\x20\x73\x6d\x73\x20\x66\x61\x69\x6c\x65\x64\x2c\x73\x6f\x20\x77\x72\x69\x74\x65\x20\x73\x6d\x73\x20\x74\x6f\x20\x64\x72\x61\x66\x74\x62\x6f\x78\x2e" "\n"
-);g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-(0xb23+6995-0x2675)].tag=
-WMS_TAG_TYPE_MO_NOT_SENT_V01;if(g_zUfiSms_ConcatTotalNum>(0xda1+4409-0x1ed9)){
-g_zUfiSms_IsConcatSendSuc=FALSE;}zUfiSms_CmgsRespProc();}SINT32 zSms_SendCmgdReq
-(UINT8 index){T_zSms_DelSmsReq delSmsReq={(0x150d+548-0x1731)};delSmsReq.index=
-index;zSms_SendMsg(MSG_CMD_DELSMS_REQ,sizeof(T_zSms_DelSmsReq),&delSmsReq);
-sem_wait(&g_sms_sem_id);if(g_smsOptRsp.result==(0xb8d+6650-0x2586)){return
-ZSMS_RESULT_OK;}else{return ZSMS_RESULT_ERROR;}}VOID zSms_RecvCmgdOk(VOID){CHAR
-strUsed[(0x1f6+4782-0x149a)]={(0x7c7+1653-0xe3c)};int used=(0x1d52+1382-0x22b8);
-int tmp_i=(0x41c+8940-0x2708);sc_cfg_set(NV_SMS_DEL_RESULT,"\x6f\x6b");printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x74\x20\x73\x69\x6d\x5f\x64\x65\x6c\x5f\x72\x65\x73\x75\x6c\x74\x20\x74\x6f\x20\x4f\x4b\x2e\x20" "\n"
-);sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));tmp_i=atoi(
-strUsed);if(tmp_i<(0xd2+2286-0x9c0)||tmp_i>INT_MAX-(0x58f+4477-0x170b)){at_print
-(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x57\x4d\x53\x5f\x4e\x56\x43\x4f\x4e\x46\x49\x47\x5f\x53\x49\x4d\x5f\x43\x41\x52\x44\x5f\x55\x53\x45\x44\x20\x74\x6d\x70\x5f\x69\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,tmp_i);tmp_i=(0x1e87+2085-0x26ac);}used=tmp_i-(0x1509+833-0x1849);if(used<
-(0x815+3685-0x167a)){used=(0x76a+2959-0x12f9);}memset(&strUsed,
-(0x28c+9143-0x2643),(0x131c+4422-0x2458));snprintf(strUsed,sizeof(strUsed),
-"\x25\x64",used);sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed);}VOID
-zSms_RecvCmgdErr(VOID){sc_cfg_set(NV_SMS_DEL_RESULT,"\x66\x61\x69\x6c");printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x74\x20\x73\x69\x6d\x5f\x64\x65\x6c\x5f\x72\x65\x73\x75\x6c\x74\x20\x74\x6f\x20\x66\x61\x69\x6c\x2e\x20" "\n"
-);}VOID zSms_RecvCmgdFinish(VOID){char StrValue[(0x1645+741-0x1920)]={
-(0x120+8615-0x22c7)};CHAR strTotal[(0x362+1659-0x9d3)]={(0x6c6+2727-0x116d)};
-CHAR strUsed[(0x147a+1195-0x191b)]={(0xc7+4977-0x1438)};int total=
-(0x11c8+5139-0x25db);int used=(0x310+4312-0x13e8);int remain=(0x332+1387-0x89d);
-sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));used=atoi(
-strUsed);if(used<(0xb24+881-0xe95)||used>INT_MAX-(0x7a8+958-0xb65)){at_print(
-LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x57\x4d\x53\x5f\x4e\x56\x43\x4f\x4e\x46\x49\x47\x5f\x53\x49\x4d\x5f\x43\x41\x52\x44\x5f\x55\x53\x45\x44\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,used);used=(0x18d4+2299-0x21cf);}sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,
-strTotal,sizeof(strTotal));total=atoi(strTotal);if(total<(0xd04+5453-0x2251)||
-total>INT_MAX-(0x41d+6249-0x1c85)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x57\x4d\x53\x5f\x4e\x56\x43\x4f\x4e\x46\x49\x47\x5f\x53\x49\x4d\x5f\x43\x41\x52\x44\x5f\x54\x4f\x54\x41\x4c\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,total);total=(0x848+4425-0x1991);}remain=total-used;if(remain<
-(0x11cf+4952-0x2527)){remain=(0x765+669-0xa02);}memset(&StrValue,
-(0x2307+585-0x2550),(0x1bf7+666-0x1e87));snprintf(StrValue,sizeof(StrValue),
-"\x25\x64",remain);sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x69\x6d\x53\x6d\x73\x20\x75\x73\x65\x64\x3d\x25\x64\x2c\x72\x65\x6d\x61\x69\x6e\x3d\x25\x64\x2c\x74\x6f\x74\x61\x6c\x3d\x25\x64" "\n"
-,used,remain,total);zUfiSms_ChangeMainState(SMS_STATE_DELED);sc_cfg_set(
-NV_SMS_DB_CHANGE,"\x31");}int zSms_SendZmenaReq(SINT32 avail){T_zSms_StroageReq
-storageReq={(0xddb+1645-0x1448)};storageReq.type=avail;zSms_SendMsg(
-MSG_CMD_STORAGE_CAP_REQ,sizeof(T_zSms_StroageReq),&storageReq);sem_wait(&
-g_sms_sem_id);if(g_smsOptRsp.result==(0xe8c+3887-0x1dba)){return ZSMS_RESULT_OK;
-}else{return ZSMS_RESULT_ERROR;}}int zSms_SendCmgrReq(UINT8 index){
-T_zSms_ModifyTagReq modTagReq={(0x1290+3141-0x1ed5)};modTagReq.index=index;
-zSms_SendMsg(MSG_CMD_MODIFY_TAG_REQ,sizeof(T_zSms_ModifyTagReq),&modTagReq);
-sem_wait(&g_sms_sem_id);if(g_smsOptRsp.result==(0x6c5+6712-0x20fc)){return
-ZSMS_RESULT_OK;}else{return ZSMS_RESULT_ERROR;}}int zSms_SetCscaReq(PSTR sca){
-T_zSms_SetScaReq setscareq;strncpy(setscareq.sca,sca,sizeof(setscareq.sca)-
-(0x323+2292-0xc16));zSms_SendMsg(MSG_CMD_SCA_SET_REQ,sizeof(T_zSms_SetScaReq),&
-setscareq);sem_wait(&g_sms_sem_id);if(g_smsOptRsp.result==(0xd3d+5876-0x2430)){
-return ZSMS_RESULT_OK;}else{return ZSMS_RESULT_ERROR;}}int zSms_SendCnmiReq(PSTR
- pAtCmdPara){T_zSms_NotifySetReq notifySetReq={(0x2145+404-0x22d9)};if(
-(0x13fd+1059-0x1820)==strcmp(pAtCmdPara,"\x73\x69\x6d")){notifySetReq.mt=
-(0x23a2+328-0x24e9);}else{notifySetReq.mt=(0x17d6+3494-0x257a);}zSms_SendMsg(
-MSG_CMD_NOTIFY_SET_REQ,sizeof(T_zSms_NotifySetReq),¬ifySetReq);sem_wait(&
-g_sms_sem_id);if(g_smsOptRsp.result==(0x1b5+8977-0x24c5)){return ZSMS_RESULT_OK;
-}else{return ZSMS_RESULT_ERROR;}}VOID zSms_RecvCmtInd(UINT8*pDatabuf){CHAR
-needSMS[(0x908+1777-0xfc7)]={(0x10f0+4378-0x220a)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0x8fb+3132-0x1537)==strcmp(
-needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}T_zSms_SmsInd tCmtRsp={(0x358+8885-0x260d)};memcpy(&tCmtRsp,(
-T_zSms_SmsInd*)pDatabuf,sizeof(T_zSms_SmsInd));zUfiSms_CmtRespProc(&tCmtRsp);
-zUfiMmi_SendSmsStatus();sc_cfg_set(NV_SMS_RECV_RESULT,"\x6f\x6b");}VOID
-zSms_RecvCmtiInd(UINT8*pDatabuf){char sms_Main_state[(0x2dc+7721-0x20e7)]={
-(0xe84+5410-0x23a6)};T_zSms_SmsIndexInd*smsIdxInd=(T_zSms_SmsIndexInd*)pDatabuf;
-CHAR needSMS[(0xd7a+4550-0x1f0e)]={(0xa76+7146-0x2660)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0x867+2088-0x108f)==strcmp(
-needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));if(
-strcmp(sms_Main_state,"\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67")==
-(0x18b7+1300-0x1dcb)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x69\x52\x73\x70\x3a\x20\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67" "\n"
-);return;}if((0xe4c+637-0x10c9)==strncmp("\x53\x4d",smsIdxInd->storetype,
-(0xe8b+2252-0x1755))){zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
-zUfiSms_ChangeMainState(SMS_STATE_RECVING);zSms_SendZmgrReq(smsIdxInd->index);}
-else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x69\x52\x73\x70\x20\x3a\x73\x74\x6f\x72\x65\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x6e\x6f\x74\x20\x53\x4d\x2e" "\n"
-);}sc_cfg_set(NV_SMS_RECV_RESULT,"");}VOID zSms_RecvCdsInd(UINT8*pDatabuf){CHAR
-needSMS[(0x9bf+2246-0x1253)]={(0x2285+389-0x240a)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0x19f0+2873-0x2529)==strcmp(
-needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}T_zSms_SmsInd tCmtRsp={(0x80b+2814-0x1309)};memcpy(&tCmtRsp,(
-T_zSms_SmsInd*)pDatabuf,sizeof(T_zSms_SmsInd));zUfiSms_CdsRespProc(&tCmtRsp);
-zUfiMmi_SendSmsStatus();sc_cfg_set(NV_SMS_RECV_RESULT,"\x6f\x6b");}VOID
-zSms_RecvCdsiInd(UINT8*pDatabuf){char sms_Main_state[(0x1c9d+521-0x1e88)]={
-(0xbba+2772-0x168e)};T_zSms_SmsIndexInd*smsIdxInd=(T_zSms_SmsIndexInd*)pDatabuf;
-CHAR needSMS[(0xab+3971-0xffc)]={(0x5ca+286-0x6e8)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0xdf4+4121-0x1e0d)==strcmp(
-needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));if(
-strcmp(sms_Main_state,"\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67")==
-(0x983+3381-0x16b8)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x3a\x20\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67" "\n"
-);return;}if((0x1d39+1720-0x23f1)==strncmp("\x53\x4d",smsIdxInd->storetype,
-(0x1cf+301-0x2fa))){zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
-zUfiSms_ChangeMainState(SMS_STATE_RECVING);zSms_SendZmgrReq(smsIdxInd->index);}
-else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x20\x3a\x73\x74\x6f\x72\x65\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x6e\x6f\x74\x20\x53\x4d\x2e" "\n"
-);}sc_cfg_set(NV_SMS_RECV_RESULT,"");}int zSms_SendCnmaReq(int ack_mode){
-T_zSms_SmsAckReq ackReq={(0x1094+1044-0x14a8)};CHAR ackPduStr[
-(0x1a11+1201-0x1e90)]={(0x162b+3850-0x2535)};ackReq.ackmode=ack_mode;if(ack_mode
-==(0x9fa+5551-0x1fa7)){zUfiSms_EncodePdu_DeliverReport(ackPduStr,
-(0x143f+3491-0x210f));memcpy(ackReq.pdu,ackPduStr,strlen(ackPduStr));
-#if (0x63f+934-0x9e5)
-if(strlen(ackPduStr)<ZSMS_PDU_SIZE-(0x8d4+2780-0x13af)){memcpy(ackReq.pdu,
-ackPduStr,strlen(ackPduStr));}else{at_print(LOG_DEBUG
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6e\x6d\x61\x52\x65\x71\x20\x70\x64\x75\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x25\x73" "\n"
-,ackPduStr);memcpy(ackReq.pdu,ackPduStr,ZSMS_PDU_SIZE-(0x1102+4875-0x240b));}
+
+ zSms_SendMsg(MSG_CMD_SENDSMS_REQ, sizeof(T_zSms_SendSmsReq), &sendSmsInfo);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+VOID zSms_RecvCmgsOk(VOID)
+{
+ printf("sms sended success. \n");
+ g_zUfiSms_CurConcatSegNo++;
+
+ if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ return;
+ }
+
+ //·¢Ëͳɹ¦Ò»½Ú
+ g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_SENT_V01;
+
+ zUfiSms_CmgsRespProc();
+}
+
+VOID zSms_RecvCmgsErr(VOID)
+{
+ printf("sms sended fail. \n");
+ g_zUfiSms_CurConcatSegNo++;
+ if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ return;
+ }
+
+ //ʧ°ÜÊýÁ¿£¬×îÖÕдÈëÊý¾Ý¿â
+ g_zUfiSms_SendFailedCount++;
+
+ printf("send sms failed,so write sms to draftbox.\n");
+ g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ if(g_zUfiSms_ConcatTotalNum > 1)
+ {
+ // ³¤¶ÌÐÅ·¢ËÍʧ°Ü£¬ÖÃΪfalse
+ g_zUfiSms_IsConcatSendSuc = FALSE;
+ }
+
+ zUfiSms_CmgsRespProc();
+}
+
+/*¶ÔÓ¦atSms_SendCmgdReq*/
+SINT32 zSms_SendCmgdReq(UINT8 index)
+{
+ T_zSms_DelSmsReq delSmsReq = {0};
+
+ delSmsReq.index = index;
+
+ zSms_SendMsg(MSG_CMD_DELSMS_REQ, sizeof(T_zSms_DelSmsReq), &delSmsReq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+VOID zSms_RecvCmgdOk(VOID)
+{
+ CHAR strUsed[10] = {0};
+ int used = 0;
+ int tmp_i = 0;
+
+ sc_cfg_set(NV_SMS_DEL_RESULT, "ok");
+ printf("[SMS] set sim_del_result to OK. \n");
+
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
+
+ tmp_i = atoi(strUsed); //kw 3
+ if(tmp_i < 0 || tmp_i > INT_MAX-1) {
+ at_print(LOG_ERR,"[SMS]WMS_NVCONFIG_SIM_CARD_USED tmp_i err:%d\n", tmp_i);
+ tmp_i = 0;
+ }
+
+ used = tmp_i - 1;
+ if(used < 0)
+ {
+ used = 0;
+ }
+ memset(&strUsed, 0, 10);
+ snprintf(strUsed,sizeof(strUsed),"%d", used);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED, strUsed);
+}
+
+VOID zSms_RecvCmgdErr(VOID)
+{
+
+ sc_cfg_set(NV_SMS_DEL_RESULT, "fail");
+ printf("[SMS] set sim_del_result to fail. \n");
+}
+
+VOID zSms_RecvCmgdFinish(VOID)
+{
+ char StrValue[10] = {0};
+ CHAR strTotal[10] = {0};
+ CHAR strUsed[10] = {0};
+ int total = 0;
+ int used = 0;
+ int remain = 0;
+
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
+ used = atoi(strUsed);
+ if(used < 0 || used > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]WMS_NVCONFIG_SIM_CARD_USED err:%d\n", used);
+ used = 0;
+ }
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strTotal,sizeof(strTotal));
+ total = atoi(strTotal);
+ if(total < 0 || total > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]WMS_NVCONFIG_SIM_CARD_TOTAL err:%d\n", total);
+ total = 0;
+ }
+
+ remain = total - used;
+ if(remain < 0)
+ {
+ remain = 0;
+ }
+
+ memset(&StrValue, 0, 10);
+ snprintf(StrValue,sizeof(StrValue),"%d", remain);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue);
+ printf("[SMS] zUfiSms_DeleteSimSms used=%d,remain=%d,total=%d\n",used,remain,total);
+ zUfiSms_ChangeMainState(SMS_STATE_DELED);
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+}
+
+/*¶ÔÓ¦atSms_SendZmenaReq*/
+int zSms_SendZmenaReq(SINT32 avail)
+{
+ T_zSms_StroageReq storageReq = {0};
+
+ storageReq.type = avail;
+
+ zSms_SendMsg(MSG_CMD_STORAGE_CAP_REQ, sizeof(T_zSms_StroageReq), &storageReq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+//SMS²»¹ØÐÄcmgrµÄÏìÓ¦
+/*¶ÔÓ¦atSms_SendCmgrReq*/
+int zSms_SendCmgrReq(UINT8 index)
+{
+ T_zSms_ModifyTagReq modTagReq = {0};
+
+ modTagReq.index = index;
+
+ zSms_SendMsg(MSG_CMD_MODIFY_TAG_REQ, sizeof(T_zSms_ModifyTagReq), &modTagReq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+/*¶ÔÓ¦ atBase_SendAtCscaSetReq*/
+int zSms_SetCscaReq(PSTR sca)
+{
+ T_zSms_SetScaReq setscareq;
+
+ strncpy(setscareq.sca, sca, sizeof(setscareq.sca)-1);
+
+ zSms_SendMsg(MSG_CMD_SCA_SET_REQ, sizeof(T_zSms_SetScaReq), &setscareq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+/*¶ÔÓ¦atBase_SendAtCnmiReq*/
+int zSms_SendCnmiReq(PSTR pAtCmdPara)
+{
+ T_zSms_NotifySetReq notifySetReq = {0};
+
+ if(0 == strcmp(pAtCmdPara, "sim"))
+ {
+ notifySetReq.mt = 1;
+ }
+ else
+ {
+ notifySetReq.mt = 2;
+ }
+
+ zSms_SendMsg(MSG_CMD_NOTIFY_SET_REQ, sizeof(T_zSms_NotifySetReq), ¬ifySetReq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+/*¶ÔÓ¦atSms_RecvCmtRsp*/
+VOID zSms_RecvCmtInd(UINT8 *pDatabuf)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ T_zSms_SmsInd tCmtRsp = {0};
+
+ memcpy(&tCmtRsp, (T_zSms_SmsInd*)pDatabuf, sizeof(T_zSms_SmsInd));
+
+ //pthread_mutex_lock(&smsdb_mutex);
+ zUfiSms_CmtRespProc(&tCmtRsp);
+ zUfiMmi_SendSmsStatus();
+ //pthread_mutex_unlock(&smsdb_mutex);
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+
+}
+
+/*¶ÔÓ¦atSms_RecvCmtiRsp */
+VOID zSms_RecvCmtiInd(UINT8 *pDatabuf)
+{
+ char sms_Main_state[30] = {0};
+ T_zSms_SmsIndexInd *smsIdxInd = (T_zSms_SmsIndexInd*)pDatabuf;
+
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
+ sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
+ if(strcmp(sms_Main_state,"sms_deling")==0)
+ {
+ printf("[SMS] atSms_RecvCmtiRsp: sms_deling\n");
+ return;
+ }
+
+ if(0 == strncmp("SM", smsIdxInd->storetype, 2))
+ {
+ zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVING);
+ //send ZMGR
+ zSms_SendZmgrReq(smsIdxInd->index);
+ }
+ else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
+ {
+ printf("[SMS] atSms_RecvCmtiRsp :store location not SM.\n");
+ }
+ sc_cfg_set(NV_SMS_RECV_RESULT, "");
+}
+
+/*¶ÔÓ¦atSms_RecvCdsRsp*/
+VOID zSms_RecvCdsInd(UINT8 *pDatabuf)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ T_zSms_SmsInd tCmtRsp = {0};
+
+ memcpy(&tCmtRsp, (T_zSms_SmsInd*)pDatabuf, sizeof(T_zSms_SmsInd));
+
+ //pthread_mutex_lock(&smsdb_mutex);
+ zUfiSms_CdsRespProc(&tCmtRsp);
+ zUfiMmi_SendSmsStatus();
+ //pthread_mutex_unlock(&smsdb_mutex);
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+}
+
+
+/*¶ÔÓ¦atSms_RecvCdsiRsp*/
+VOID zSms_RecvCdsiInd(UINT8 *pDatabuf)
+{
+ char sms_Main_state[30] = {0};
+ T_zSms_SmsIndexInd *smsIdxInd = (T_zSms_SmsIndexInd*)pDatabuf;
+
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
+ sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
+ if(strcmp(sms_Main_state,"sms_deling")==0)
+ {
+ printf("[SMS] atSms_RecvCdsiRsp: sms_deling\n");
+ return;
+ }
+
+ if(0 == strncmp("SM", smsIdxInd->storetype, 2))
+ {
+ zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVING);
+ //send ZMGR
+ zSms_SendZmgrReq(smsIdxInd->index);
+ }
+ else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
+ {
+ printf("[SMS] atSms_RecvCdsiRsp :store location not SM.\n");
+ }
+ sc_cfg_set(NV_SMS_RECV_RESULT, "");
+}
+
+
+/*¶ÔÓ¦atSms_SendCnmaReq*/
+int zSms_SendCnmaReq(int ack_mode)
+{
+ T_zSms_SmsAckReq ackReq = {0};
+ CHAR ackPduStr[50] = {0};
+
+ ackReq.ackmode = ack_mode;
+
+ if(ack_mode == 2)
+ {
+ zUfiSms_EncodePdu_DeliverReport(ackPduStr, 0xD3);
+ memcpy(ackReq.pdu, ackPduStr, strlen(ackPduStr));
+#if 0
+ if(strlen(ackPduStr)< ZSMS_PDU_SIZE-1)
+ {
+ memcpy(ackReq.pdu, ackPduStr, strlen(ackPduStr));
+ }
+ else
+ {
+ at_print(LOG_DEBUG"[SMS] atSms_SendCnmaReq pdu too long:%s\n",ackPduStr);
+ memcpy(ackReq.pdu, ackPduStr, ZSMS_PDU_SIZE-2);
+ }
#endif
-*(ackReq.pdu+strlen(ackPduStr))=ZSMS_CTRL_Z_CHAR;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6e\x6d\x61\x52\x65\x71\x2e\x20\x70\x64\x75\x3d\x20\x25\x73" "\n"
-,ackReq.pdu);ackReq.length=strlen(ackPduStr)/(0xae5+3505-0x1894);}zSms_SendMsg(
-MSG_CMD_SMSACK_REQ,sizeof(T_zSms_SmsAckReq),&ackReq);sem_wait(&g_sms_sem_id);if(
-g_smsOptRsp.result==(0x525+2491-0xedf)){return ZSMS_RESULT_OK;}else{return
-ZSMS_RESULT_ERROR;}}int zSms_SendZmgrReq(int index){T_zSms_ReadSmsReq readSmsReq
-={(0x142d+4208-0x249d)};iSmsIndex=index;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x5a\x6d\x67\x72\x52\x65\x71\x20\x47\x65\x74\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2e" "\n"
-,iSmsIndex);readSmsReq.index=index;zSms_SendMsg(MSG_CMD_READSMS_REQ,sizeof(
-T_zSms_ReadSmsReq),&readSmsReq);return(0x13c+5559-0x16f3);}VOID zSms_RecvZmgrRsp
-(UINT8*pDatabuf){T_zSms_SmsInd tCmgrRsp={(0x13af+2920-0x1f17)};memcpy(&tCmgrRsp,
-(T_zSms_SmsInd*)pDatabuf,sizeof(T_zSms_SmsInd));tCmgrRsp.index=iSmsIndex;
-zUfiSms_ZmgrRespProc(&tCmgrRsp);zUfiMmi_SendSmsStatus();}VOID zSms_RecvZmgrOk(
-UINT8*pDatabuf){T_zSms_optRsp smsOptRsp={(0x1d65+454-0x1f2b)};memcpy(&smsOptRsp,
-(T_zSms_optRsp*)pDatabuf,sizeof(T_zSms_optRsp));if(smsOptRsp.result==
-(0xb9c+875-0xf06)){sc_cfg_set(NV_SMS_RECV_RESULT,"\x6f\x6b");}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x5a\x6d\x67\x72\x45\x72\x72\x20\x20\x53\x4d\x53\x20\x7a\x6d\x67\x72\x20\x69\x73\x20\x66\x61\x69\x6c" "\n"
-);sc_cfg_set(NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(
-SMS_STATE_RECVED);}}VOID zSms_RecvZpbicInd(UINT8*pDatabuf){T_zAt_ZpbicRes*ptPara
-=ZUFI_NULL;if(pDatabuf==NULL){return;}ptPara=(T_zAt_ZpbicRes*)(pDatabuf);if((
-(0x7c3+7342-0x2470)==ptPara->result)&&((0x96a+5767-0x1ff1)==ptPara->opertype)){
-CHAR needSms[(0x11a4+4522-0x231c)]={(0x1dd+7039-0x1d5c)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSms,sizeof(needSms));if((0x553+860-0x8af)!=strcmp(
-needSms,"\x6e\x6f")){zSvr_Zpbic_Sms_Init();}}}VOID zSms_RecvCpmsInd(UINT8*
-pDatabuf){T_zSms_CpmsInd*cpmsInd=(T_zSms_CpmsInd*)pDatabuf;CHAR strBuf[
-(0x34f+7123-0x1f18)]={(0xdba+6094-0x2588)};int remainSpace=(0x70f+6278-0x1f95);
-snprintf(strBuf,sizeof(strBuf),"\x25\x64",cpmsInd->total);sc_cfg_set(
-ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strBuf);sc_cfg_set(
-ZTE_WMS_NVCONFIG_SIM_CAPABILITY,strBuf);memset(&strBuf,(0x1a1+1197-0x64e),
-(0x5cc+6259-0x1e35));snprintf(strBuf,sizeof(strBuf),"\x25\x64",cpmsInd->used);
-sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strBuf);remainSpace=cpmsInd->total-
-cpmsInd->used;memset(&strBuf,(0xaef+5647-0x20fe),(0x659+776-0x957));snprintf(
-strBuf,sizeof(strBuf),"\x25\x64",remainSpace);sc_cfg_set(
-ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,strBuf);sc_cfg_set(NV_SMS_STORE,"\x6f\x6b");}
-#define AT_CMD_MAX (0xfab+1648-0x15db)
-#define ZAT_TAB_REPLACE ((unsigned char )(\
-(0x1c9c+2460-0x253c)))
-#define ZAT_NULL_FILL ((unsigned char )((0x122+2248-0x8ed)\
-))
-#define ZAT_SPACE_REPLACE ((unsigned char )(\
-(0x1731+2168-0x1eab)))
-#define ZAT_LF_REPLACE ((unsigned char )(\
-(0x62a+4773-0x17d4)))
-#define ZAT_CR_REPLACE ((unsigned char )(\
-(0x553+8614-0x25ff)))
-static void atBase_PreProcRes(char*pParaLine,int paraSize){signed long flg=
-(0xe43+5379-0x2346);unsigned long i=(0x622+4342-0x1718);unsigned long length=
-(0x1157+3151-0x1da6);char*pSource=pParaLine;char*pDest=NULL;char*pStrDestMalloc=
-(char*)malloc(AT_CMD_MAX);if(NULL==pStrDestMalloc){return;}memset(pStrDestMalloc
-,(0x892+6111-0x2071),AT_CMD_MAX);assert(pParaLine!=NULL);pDest=pStrDestMalloc;
-length=strlen(pParaLine);if((length==(0xb37+871-0xe9e))||(length>=AT_CMD_MAX)){
-free(pStrDestMalloc);return;}for(i=(0x9d5+7250-0x2627);(i<length)&&(pDest-
-pStrDestMalloc<AT_CMD_MAX);i++){if(((char)(0x110b+2214-0x198f))==*pSource){flg=(
-(0x16dd+1489-0x1cae)==flg)?(0x287+3229-0xf23):(0x1392+528-0x15a2);if(
-((char)(0xdd3+3510-0x1b67))==*(pSource+(0x1225+942-0x15d2))){*pDest++=(char)
-ZAT_NULL_FILL;}}else if((((char)(0x851+1619-0xe78))==*pSource)&&(
-(0x1758+1232-0x1c28)==flg)){*pDest++=((char)(0xe7b+379-0xfd6));if(
-((char)(0x12ad+5113-0x267a))==*(pSource+(0xdd1+2970-0x196a))){*pDest++=
-((char)(0x3e2+3098-0xfc3));}else if('\0'==*(pSource+(0x1a69+519-0x1c6f))){*pDest
-++=(char)ZAT_NULL_FILL;}}else{if((((char)(0x1b94+2916-0x26d8))==*pSource)&&(
-(0x5c6+1446-0xb6b)==flg)){*pDest++=(char)ZAT_SPACE_REPLACE;}else if(('\t'==*
-pSource)&&((0x55a+8478-0x2677)==flg)){*pDest++=(char)ZAT_TAB_REPLACE;}else if((
-'\n'==*pSource)&&((0x245+4523-0x13ef)==flg)){*pDest++=(char)ZAT_LF_REPLACE;}else
- if(('\r'==*pSource)&&((0x75b+3123-0x138d)==flg)){*pDest++=(char)ZAT_CR_REPLACE;
-}else{*pDest++=*pSource;}}pSource++;}memset(pParaLine,(0x383+404-0x517),paraSize
-);strncpy(pParaLine,pStrDestMalloc,paraSize-(0x4f1+6200-0x1d28));free(
-pStrDestMalloc);}VOID zSms_RecvCscaInd(UINT8*pDatabuf){T_zSms_CscaInd cscaInd={
-(0x385+1585-0x9b6)};
-#if (0xb62+5910-0x2277)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x7a\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x73\x63\x61\x49\x6e\x64\x20\x64\x61\x74\x61\x62\x75\x66\x3a\x25\x73" "\n"
-,pDatabuf);
-#endif
-atBase_PreProcRes(pDatabuf,strlen(pDatabuf));sscanf(pDatabuf,
-"\x25\x32\x31\x73\x20\x25\x32\x31\x73",cscaInd.sca,cscaInd.tosca);
-#if (0x121+6723-0x1b63)
-printf(
-"\x5b\x53\x4d\x53\x63\x6f\x72\x65\x6d\x5d\x7a\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x73\x63\x61\x49\x6e\x64\x20\x73\x63\x61\x3a\x25\x73\x2c\x20\x74\x6f\x73\x63\x61\x25\x73" "\n"
-,cscaInd.sca,cscaInd.tosca);
-#endif
-sc_cfg_set(NV_SMS_CENTER_NUM,cscaInd.sca);zUfiSms_SetScaPara(cscaInd.sca);}VOID
-zSms_RecvZmglInd(UINT8*pDatabuf){zUfiSms_CmglRespProc((T_zSms_SmsInd*)pDatabuf);
-}int zSms_SendSmsInitReq(VOID){zSms_SendMsg(MSG_CMD_SMSINIT_REQ,
-(0x1748+156-0x17e4),NULL);return(0x626+1706-0xcd0);}VOID zSms_initAtOk(VOID){
-T_zUfiSms_StatusInfo tStatus={(0x10b+411-0x2a6)};sc_cfg_set(NV_SMS_STORE,
-"\x6f\x6b");sc_cfg_set(NV_SMS_LOAD_RESULT,"\x6f\x6b");tStatus.cmd_status=
-WMS_CMD_SUCCESS;tStatus.cmd=WMS_SMS_CMD_INIT;(void)zUfiSms_SetCmdStatus(&tStatus
-);zUfiSms_ChangeMainState(SMS_STATE_LOADED);}VOID zSms_initAtErr(VOID){
-T_zUfiSms_StatusInfo tStatus={(0x584+6585-0x1f3d)};sc_cfg_set(NV_SMS_LOAD_RESULT
-,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(SMS_STATE_LOADED);tStatus.
-cmd_status=WMS_CMD_FAILED;tStatus.cmd=WMS_SMS_CMD_INIT;(void)
-zUfiSms_SetCmdStatus(&tStatus);}VOID zSms_RecvSmsInitRst(UINT8*pDatabuf){memcpy(
-&g_smsOptRsp,pDatabuf,sizeof(T_zSms_optRsp));if(g_smsOptRsp.result==
-(0x1bc5+748-0x1eb0)){zSms_initAtOk();}else{zSms_initAtErr();}}UINT8
-zSms_SmsMsgCreat(VOID){g_zSms_MsqId=msgget(MODULE_ID_SMS,IPC_CREAT|
-(0xc74+1274-0xfee));if(g_zSms_MsqId==-(0xc6b+3916-0x1bb6)){return ZUFI_FAIL;}
-g_zSms_LocalMsqId=msgget(MODULE_ID_SMS_LOCAL,IPC_CREAT|(0x7fc+5701-0x1cc1));if(
-g_zSms_LocalMsqId==-(0x1c9b+65-0x1cdb)){return ZUFI_FAIL;}sem_init(&g_sms_sem_id
-,(0x1922+1102-0x1d70),(0x1af6+2504-0x24be));return ZUFI_SUCC;}void
-zSms_HandleAtctlLocalMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x73\x6d\x73\x20\x6c\x6f\x63\x61\x6c\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_ZPBIC_IND:
-zSms_RecvZpbicInd(ptMsgBuf->aucDataBuf);break;case MSG_CMD_ZMGL_IND:
-zSms_RecvZmglInd(ptMsgBuf->aucDataBuf);break;case MSG_CMD_NEWSMS_STATUS_IND:
-zSms_RecvCdsInd(ptMsgBuf->aucDataBuf);break;case MSG_CMD_NEWSMS_IND:
-zSms_RecvCmtInd(ptMsgBuf->aucDataBuf);default:break;}}VOID zSms_HandleAtctlMsg(
-MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
-"\x73\x6d\x73\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_SENDSMS_RSP:case
-MSG_CMD_DELSMS_RSP:case MSG_CMD_STORAGE_CAP_RSP:case MSG_CMD_MODIFY_TAG_RSP:case
- MSG_CMD_NOTIFY_SET_RSP:case MSG_CMD_SCA_SET_RSP:case MSG_CMD_SMSACK_RSP:{memcpy
-(&g_smsOptRsp,ptMsgBuf->aucDataBuf,sizeof(T_zSms_optRsp));sem_post(&g_sms_sem_id
-);}break;case MSG_CMD_CPMS_IND:zSms_RecvCpmsInd(ptMsgBuf->aucDataBuf);break;case
- MSG_CMD_CSCA_IND:zSms_RecvCscaInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_ZMGR_IND:zSms_RecvZmgrRsp(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_READSMS_RSP:zSms_RecvZmgrOk(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_SMSINIT_RSP:zSms_RecvSmsInitRst(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_NEWSMS_INDEX_IND:zSms_RecvCmtiInd(ptMsgBuf->aucDataBuf);break;case
-MSG_CMD_NEWSMS_STATUS_INDEX_IND:zSms_RecvCdsiInd(ptMsgBuf->aucDataBuf);break;
-case MSG_CMD_NEWSMS_IND:case MSG_CMD_ZPBIC_IND:case MSG_CMD_ZMGL_IND:case
-MSG_CMD_NEWSMS_STATUS_IND:ipc_send_message(MODULE_ID_SMS,MODULE_ID_SMS_LOCAL,
-ptMsgBuf->usMsgCmd,ptMsgBuf->usDataLen,(unsigned char*)ptMsgBuf->aucDataBuf,
-(0x25a+7929-0x2153));break;default:break;}}VOID zSms_HandleResetToFactory(){CHAR
- clearSms[(0x1871+2544-0x222f)]={(0x759+1666-0xddb)};sc_cfg_get(
-NV_CLEAR_SMS_WHEN_RESTORE,clearSms,sizeof(clearSms));printf(
-"\x61\x74\x57\x65\x62\x5f\x52\x65\x73\x74\x6f\x72\x65\x46\x61\x63\x74\x6f\x72\x79\x53\x65\x74\x74\x69\x6e\x67\x20\x65\x6e\x74\x65\x72\x65\x64\x21\x20" "\n"
-);printf(
-"\x63\x6c\x65\x61\x72\x5f\x73\x6d\x73\x5f\x77\x68\x65\x6e\x5f\x72\x65\x73\x74\x6f\x72\x65\x3d\x25\x73\x20" "\n"
-,clearSms);if(strcmp(clearSms,"\x79\x65\x73")==(0x327+5545-0x18d0)){printf(
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x72\x6f\x70\x41\x6c\x6c\x54\x61\x62\x6c\x65\x20\x65\x6e\x74\x65\x72\x65\x64\x21\x20" "\n"
-);zUfiSms_DropAllTable();}else{printf(
-"\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x72\x6f\x70\x41\x6c\x6c\x54\x61\x62\x6c\x65\x45\x78\x63\x65\x70\x74\x53\x6d\x73\x20\x65\x6e\x74\x65\x72\x65\x64\x21\x20" "\n"
-);zUfiSms_DropAllTableExceptSms();}ipc_send_message(MODULE_ID_SMS,
-MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_RSP,(0x1461+3029-0x2036),NULL,
-(0x163+6829-0x1c10));}void zSms_HandleMainCtrlMsg(MSG_BUF*ptMsgBuf){assert(
-ptMsgBuf!=NULL);printf(
-"\x73\x6d\x73\x20\x72\x65\x63\x76\x20\x6d\x61\x69\x6e\x20\x63\x74\x72\x6c\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
-,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_RESET_NOTIFY:
-zSms_HandleResetToFactory(ptMsgBuf->aucDataBuf);break;default:break;}}void
-sms_msg_thread_proc(void*arg){int iRet=(0xb60+1700-0x1204);MSG_BUF stMsg={
-(0x3d4+8753-0x2605)};int msgSize=sizeof(MSG_BUF)-sizeof(long);int queueId=*((int
-*)arg);prctl(PR_SET_NAME,"\x73\x6d\x73\x5f\x6c\x6f\x63\x61\x6c",
-(0x12c9+582-0x150f),(0x91b+1988-0x10df),(0xf74+4524-0x2120));while(
-(0xb22+3411-0x1874)){iRet=(0x59b+2292-0xe8f);memset(&stMsg,(0x529+2870-0x105f),
-sizeof(MSG_BUF));iRet=msgrcv(queueId,&stMsg,msgSize,(0xe87+2449-0x1818),
-(0x19f0+3295-0x26cf));if(iRet>=(0x22a1+326-0x23e7)){switch(stMsg.src_id){case
-MODULE_ID_WEB_CGI:{zSms_HandleWebMsg(&stMsg);break;}case MODULE_ID_AT_CTL:{
-zSms_HandleAtctlMsg(&stMsg);break;}case MODULE_ID_SMS:{zSms_HandleWebMsg(&stMsg)
-;zSms_HandleAtctlLocalMsg(&stMsg);break;}case MODULE_ID_MAIN_CTRL:{
-zSms_HandleMainCtrlMsg(&stMsg);break;}default:{break;}}}else{at_print(AT_DEBUG,
-"\x65\x72\x72\x6e\x6f\x20\x3d\x20\x25\x64\x2c\x20\x65\x72\x72\x6d\x73\x67\x20\x3d\x20\x25\x73" "\n"
-,errno,strerror(errno));}}}int sms_main(int argc,char*argv[]){pthread_t
-recv_thread_tid=(0x546+178-0x5f8);MSG_BUF msgBuf={(0x85a+5342-0x1d38)};CHAR
-needSMS[(0x16ea+2122-0x1f02)]={(0xea3+1178-0x133d)};prctl(PR_SET_NAME,
-"\x73\x6d\x73\x5f\x6d\x61\x69\x6e",(0x14fd+359-0x1664),(0xcb6+5473-0x2217),
-(0x322+7676-0x211e));loglevel_init();sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,
-sizeof(needSMS));if((0x453+7708-0x226f)!=strcmp(needSMS,"\x6e\x6f")){
-zUfiSms_InitDb();zUfiSms_CfgSmsNvInit();zUfiMmi_SendSmsStatus();zSms_SmsMsgCreat
-();}else{return-(0x189f+1040-0x1cae);}printf(
-"\x73\x6d\x73\x20\x61\x70\x70\x20\x69\x6e\x69\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64\x2c\x20\x77\x69\x6c\x6c\x20\x74\x6f\x20\x72\x65\x63\x65\x69\x76\x65\x20\x6d\x73\x67\x2c\x20\x6d\x73\x67\x69\x64\x3a\x25\x64" "\n"
-,g_zSms_MsqId);if(pthread_create(&recv_thread_tid,NULL,sms_msg_thread_proc,(void
-*)(&g_zSms_LocalMsqId))==-(0x4f5+7384-0x21cc)){assert((0x270+7721-0x2099));}
-sms_msg_thread_proc(&g_zSms_MsqId);return(0x8bc+7114-0x2486);}
+ // Ìí¼Ó½áβ·û
+ *(ackReq.pdu + strlen(ackPduStr)) = ZSMS_CTRL_Z_CHAR;
+ printf("[SMS] atSms_SendCnmaReq. pdu= %s\n", ackReq.pdu);
+
+ ackReq.length = strlen(ackPduStr)/2;
+ }
+
+ zSms_SendMsg(MSG_CMD_SMSACK_REQ, sizeof(T_zSms_SmsAckReq), &ackReq);
+
+ sem_wait(&g_sms_sem_id);
+
+ if(g_smsOptRsp.result == 1)
+ {
+ return ZSMS_RESULT_OK;
+ }
+ else
+ {
+ return ZSMS_RESULT_ERROR;
+ }
+}
+
+
+/*¶ÔÓ¦atSms_SendZmgrReq*/
+int zSms_SendZmgrReq(int index)
+{
+ T_zSms_ReadSmsReq readSmsReq = {0};
+
+ iSmsIndex = index;
+ printf("[SMS] atSms_SendZmgrReq Get index:%d.\n",iSmsIndex);
+
+ readSmsReq.index = index;
+ zSms_SendMsg(MSG_CMD_READSMS_REQ, sizeof(T_zSms_ReadSmsReq), &readSmsReq);
+
+ //´Ë´¦²»ÄÜ×èÈûµÈ´ý
+ return 0;
+}
+
+/*¶ÔÓ¦atSms_RecvZmgrRsp */
+VOID zSms_RecvZmgrRsp(UINT8 *pDatabuf)
+{
+ T_zSms_SmsInd tCmgrRsp = {0};
+
+ memcpy(&tCmgrRsp, (T_zSms_SmsInd*)pDatabuf, sizeof(T_zSms_SmsInd));
+
+ tCmgrRsp.index = iSmsIndex;
+
+ zUfiSms_ZmgrRespProc(&tCmgrRsp);
+ zUfiMmi_SendSmsStatus();
+
+}
+
+VOID zSms_RecvZmgrOk(UINT8 *pDatabuf)
+{
+ T_zSms_optRsp smsOptRsp = {0};
+
+ memcpy(&smsOptRsp, (T_zSms_optRsp*)pDatabuf, sizeof(T_zSms_optRsp));
+ if(smsOptRsp.result == 1)
+ {
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+ }
+ else
+ {
+ printf("[SMS] atSms_RecvZmgrErr SMS zmgr is fail\n");
+
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+
+ }
+}
+
+VOID zSms_RecvZpbicInd(UINT8 *pDatabuf)
+{
+ T_zAt_ZpbicRes *ptPara = ZUFI_NULL;
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+ ptPara = (T_zAt_ZpbicRes*)(pDatabuf);
+
+ if((1 == ptPara->result) && (0 == ptPara->opertype))
+ {
+ //ÅжÏNV,added by wenqin 2016-5-18
+ CHAR needSms[50]={0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSms,sizeof(needSms));
+ if(0 != strcmp(needSms,"no"))
+ {
+ zSvr_Zpbic_Sms_Init();
+ }
+ }
+}
+
+
+
+VOID zSms_RecvCpmsInd(UINT8 *pDatabuf)
+{
+ T_zSms_CpmsInd *cpmsInd = (T_zSms_CpmsInd*)pDatabuf;
+ CHAR strBuf[10] = {0};
+ int remainSpace = 0;
+
+ snprintf(strBuf,sizeof(strBuf),"%d", cpmsInd->total);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strBuf);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CAPABILITY,strBuf);
+
+ memset(&strBuf, 0, 10);
+ snprintf(strBuf,sizeof(strBuf),"%d", cpmsInd->used);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strBuf);
+
+ remainSpace = cpmsInd->total - cpmsInd->used;
+ memset(&strBuf, 0, 10);
+ snprintf(strBuf,sizeof(strBuf),"%d", remainSpace);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,strBuf);
+
+ sc_cfg_set(NV_SMS_STORE,"ok");
+
+}
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: VOID atBase_PreProcRes(char *)
+* ¹¦ÄÜÃèÊö: Ô¤´¦Àí²ÎÊýÐк¯Êý¡£ÎªÁË·½±ã½âÎö²ÎÊýÐУ¬ÔÚ½âÎö֮ǰ£¬ÏÈÔ¤´¦Àí¸Ã²Î
+* ÊýÐУ¬¶ÔÓÚ·Ö¸î²ÎÊýµÄ¶ººÅ£¬ÓÿոñÌæ»»£¬¶ÔÓÚ×Ö·û´®ÐͲÎÊýÖеĿոñ
+* ÓÿոñÌæ»»·ûÌæ»»£¬¶ÔÓÚ±êʶ×Ö·û´®µÄË«ÒýºÅÓèÒÔɾ³ý£¬¶ÔÓÚ¿ÕµÄ×Ö·û
+* ²ÎÊý˵Ã÷: (IN) pParaLine : ´ýÔ¤´¦ÀíµÄ×Ö·û´®²ÎÊýÐУ»
+* (OUT)pParaLine : Ô¤´¦ÀíºóµÄ×Ö·û´®²ÎÊýÐУ»
+* ·µ »Ø Öµ:
+* ÆäËü˵Ã÷:ÒÆÖ²
+**************************************************************************/
+#define AT_CMD_MAX 64
+
+#define ZAT_TAB_REPLACE ((unsigned char )(0xFC)) /* ÖÆ±í·ûÌæ»»·û */
+#define ZAT_NULL_FILL ((unsigned char )(0xFD)) /* ¿Õ´®Õ¼Î»·û */
+#define ZAT_SPACE_REPLACE ((unsigned char )(0xFE)) /* ¿Õ¸ñÌæ»»·û */
+#define ZAT_LF_REPLACE ((unsigned char )(0xFB)) /* LFÌæ»»·û */
+#define ZAT_CR_REPLACE ((unsigned char )(0xFA)) /* CRÌæ»»·û */
+static void atBase_PreProcRes(char *pParaLine, int paraSize)//×Ö·û´®¸ñʽ»¯Ê¹Ó㬺óÐøÐèÒªÓÅ»¯£¬¼òµ¥»¯
+{
+ signed long flg = 0;
+ unsigned long i = 0;
+ unsigned long length = 0;
+ char *pSource = pParaLine;
+ char *pDest = NULL;
+
+ char *pStrDestMalloc = (char *)malloc(AT_CMD_MAX);
+ if(NULL == pStrDestMalloc)
+ {
+ return;
+ }
+ memset(pStrDestMalloc, 0, AT_CMD_MAX);
+
+ assert(pParaLine != NULL);
+ pDest = pStrDestMalloc;
+ length = strlen(pParaLine);
+ if ((length == 0) || (length >= AT_CMD_MAX))
+ {
+ free(pStrDestMalloc);
+ return;
+ }
+ for (i = 0; (i < length )&& (pDest - pStrDestMalloc < AT_CMD_MAX); i++)
+ {
+ if ('"' == *pSource)
+ {
+ flg = (0 == flg)?1:0; /* Ë«ÒýºÅ ɾ³ý */
+ if ('"' == *(pSource + 1)) /* ÐǺźóÃæ½ô¸úÐǺţ¬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = (char)ZAT_NULL_FILL;
+ }
+ }
+ else if ((',' == *pSource) && (0 == flg))
+ {
+ *pDest++ = ' '; /* Ë«ÒýºÅÍâÃæµÄ¶ººÅ£¬Ìæ»»³É¿Õ¸ñ */
+ if(',' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = '9'; //±£Áô²ÎÊýÓÃ9ÔÝʱ´úÌæ
+ }
+ else if('\0' == *(pSource + 1)) /* ¶ººÅºóÃæ½ô¸ú¶ººÅ£¬»òÕßÒÔ¶ººÅ½á⣬²åÈë¿Õ´®Õ¼Î»·û */
+ {
+ *pDest++ = (char)ZAT_NULL_FILL;
+ }
+ }
+ else
+ {
+ //*pDest++ = ((' ' == *pSource) && (1 == flg))?(char)ZAT_SPACE_REPLACE:((('\t' == *pSource) && (1 == flg))?(char)ZAT_TAB_REPLACE:((('\n' == *pSource) && (1 == flg))?(char)ZAT_LF_REPLACE:((('\r' == *pSource) && (1 == flg))?(char)ZAT_CR_REPLACE:(*pSource))));
+ if((' ' == *pSource) && (1 == flg))
+ {
+ *pDest++ = (char)ZAT_SPACE_REPLACE;
+ }
+ else if(('\t' == *pSource) && (1 == flg))
+ {
+ *pDest++ = (char)ZAT_TAB_REPLACE;
+ }
+ else if(('\n' == *pSource) && (1 == flg))
+ {
+ *pDest++ = (char)ZAT_LF_REPLACE;
+ }
+ else if(('\r' == *pSource) && (1 == flg))
+ {
+ *pDest++ = (char)ZAT_CR_REPLACE;
+ }
+ else
+ {
+ *pDest++ = *pSource;
+ }
+ }
+ pSource++;
+ }
+ memset(pParaLine, 0, paraSize); /* ½«Ô¤´¦ÀíºóµÄÄÚÈÝ¿½±´»Ø²ÎÊýÐÐÖÐ */
+ strncpy(pParaLine, pStrDestMalloc,paraSize-1);
+ free(pStrDestMalloc);
+}
+
+//´æ´¢¶ÌÐÅÖÐÐÄ
+VOID zSms_RecvCscaInd(UINT8 *pDatabuf)
+{
+ T_zSms_CscaInd cscaInd = {0};
+
+ #if 1//corem for debug
+ printf("[SMScorem]zSms_RecvCscaInd databuf:%s\n",pDatabuf);
+ #endif
+ atBase_PreProcRes(pDatabuf, strlen(pDatabuf));
+
+ sscanf(pDatabuf, "%21s %21s", cscaInd.sca, cscaInd.tosca);
+ #if 1//corem for debug
+ printf("[SMScorem]zSms_RecvCscaInd sca:%s, tosca%s\n", cscaInd.sca, cscaInd.tosca);
+ #endif
+ sc_cfg_set(NV_SMS_CENTER_NUM,cscaInd.sca);
+ zUfiSms_SetScaPara(cscaInd.sca);
+}
+
+
+VOID zSms_RecvZmglInd(UINT8 *pDatabuf)
+{
+ zUfiSms_CmglRespProc((T_zSms_SmsInd*)pDatabuf);
+}
+
+
+int zSms_SendSmsInitReq(VOID)
+{
+ zSms_SendMsg(MSG_CMD_SMSINIT_REQ, 0, NULL);
+ return 0;
+}
+
+VOID zSms_initAtOk(VOID)
+{
+ T_zUfiSms_StatusInfo tStatus = {0};
+ //´Ë´¦»áµ¼ÖÂcmglÔÙ·¢Ò»´Î¼ÓÔØµ½ME´¦
+ //zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+ sc_cfg_set(NV_SMS_STORE,"ok");
+
+ sc_cfg_set(NV_SMS_LOAD_RESULT, "ok");
+ tStatus.cmd_status = WMS_CMD_SUCCESS;
+ tStatus.cmd = WMS_SMS_CMD_INIT;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+ zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+}
+
+VOID zSms_initAtErr(VOID)
+{
+ T_zUfiSms_StatusInfo tStatus = {0};
+
+ sc_cfg_set(NV_SMS_LOAD_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+
+ tStatus.cmd_status = WMS_CMD_FAILED;
+ tStatus.cmd = WMS_SMS_CMD_INIT;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+}
+
+VOID zSms_RecvSmsInitRst(UINT8 *pDatabuf)
+{
+ memcpy(&g_smsOptRsp, pDatabuf, sizeof(T_zSms_optRsp));
+
+ if(g_smsOptRsp.result == 1)
+ {
+ zSms_initAtOk();
+ }
+ else
+ {
+ zSms_initAtErr();
+ }
+}
+
+
+
+
+UINT8 zSms_SmsMsgCreat(VOID)
+{
+ g_zSms_MsqId = msgget(MODULE_ID_SMS, IPC_CREAT | 0600);
+ if(g_zSms_MsqId == -1)
+ {
+ return ZUFI_FAIL;
+ }
+ g_zSms_LocalMsqId = msgget(MODULE_ID_SMS_LOCAL, IPC_CREAT | 0600);
+ if(g_zSms_LocalMsqId == -1)
+ {
+ return ZUFI_FAIL;
+ }
+ sem_init(&g_sms_sem_id, 0 ,0);
+
+ return ZUFI_SUCC;
+}
+
+void zSms_HandleAtctlLocalMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "sms local recv msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_ZPBIC_IND:
+ zSms_RecvZpbicInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_ZMGL_IND:
+ zSms_RecvZmglInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_NEWSMS_STATUS_IND:
+ zSms_RecvCdsInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_NEWSMS_IND:
+ zSms_RecvCmtInd(ptMsgBuf->aucDataBuf);
+ default:
+ break;
+
+ }
+}
+
+VOID zSms_HandleAtctlMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "sms recv msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_SENDSMS_RSP:
+ case MSG_CMD_DELSMS_RSP:
+ case MSG_CMD_STORAGE_CAP_RSP:
+ case MSG_CMD_MODIFY_TAG_RSP:
+ case MSG_CMD_NOTIFY_SET_RSP:
+ case MSG_CMD_SCA_SET_RSP:
+ case MSG_CMD_SMSACK_RSP:
+ {
+ memcpy(&g_smsOptRsp, ptMsgBuf->aucDataBuf, sizeof(T_zSms_optRsp));
+ sem_post(&g_sms_sem_id);
+ }
+ break;
+ case MSG_CMD_CPMS_IND:
+ zSms_RecvCpmsInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_CSCA_IND:
+ zSms_RecvCscaInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_ZMGR_IND://ZMGR¶ÁÒ»Ìõ¶ÌÐÅÖÐ;µÄÉϱ¨ÐÅÏ¢
+ zSms_RecvZmgrRsp(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_READSMS_RSP://ZMGR¶ÁÒ»Ìõ¶ÌÐŽáÊø£¬OK/ERROR
+ zSms_RecvZmgrOk(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_SMSINIT_RSP:
+ zSms_RecvSmsInitRst(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_NEWSMS_INDEX_IND:
+ zSms_RecvCmtiInd(ptMsgBuf->aucDataBuf);
+ break;
+
+ case MSG_CMD_NEWSMS_STATUS_INDEX_IND:
+ zSms_RecvCdsiInd(ptMsgBuf->aucDataBuf);
+ break;
+ case MSG_CMD_NEWSMS_IND:
+ case MSG_CMD_ZPBIC_IND:
+ case MSG_CMD_ZMGL_IND:
+ case MSG_CMD_NEWSMS_STATUS_IND:
+ ipc_send_message(MODULE_ID_SMS, MODULE_ID_SMS_LOCAL, ptMsgBuf->usMsgCmd, ptMsgBuf->usDataLen, (unsigned char *)ptMsgBuf->aucDataBuf,0);
+ break;
+
+ default:
+ break;
+
+ }
+}
+
+VOID zSms_HandleResetToFactory()
+{
+ CHAR clearSms[50] = {0};
+
+ sc_cfg_get(NV_CLEAR_SMS_WHEN_RESTORE,clearSms,sizeof(clearSms));
+
+ printf("atWeb_RestoreFactorySetting entered! \n");
+ printf("clear_sms_when_restore=%s \n", clearSms);
+ if(strcmp(clearSms, "yes") == 0)
+ {
+ printf("zUfiSms_DropAllTable entered! \n");
+ zUfiSms_DropAllTable();
+ }
+ else
+ {
+ printf("zUfiSms_DropAllTableExceptSms entered! \n");
+ zUfiSms_DropAllTableExceptSms();
+ }
+ ipc_send_message(MODULE_ID_SMS, MODULE_ID_MAIN_CTRL, MSG_CMD_RESET_RSP, 0, NULL,0);
+}
+
+void zSms_HandleMainCtrlMsg(MSG_BUF *ptMsgBuf)
+{
+ assert(ptMsgBuf != NULL);
+ printf( "sms recv main ctrl msg cmd:%d\n", ptMsgBuf->usMsgCmd);
+ switch(ptMsgBuf->usMsgCmd)
+ {
+ case MSG_CMD_RESET_NOTIFY:
+ zSms_HandleResetToFactory(ptMsgBuf->aucDataBuf);
+ break;
+ default:
+ break;
+
+ }
+}
+
+
+void sms_msg_thread_proc(void* arg)
+{
+ int iRet = 0;
+ MSG_BUF stMsg = {0};
+ int msgSize = sizeof(MSG_BUF) - sizeof(long);
+ int queueId = *((int*)arg);
+ prctl(PR_SET_NAME, "sms_local", 0, 0, 0);
+ while(1)
+ {
+ iRet = 0;
+ memset(&stMsg, 0x00, sizeof(MSG_BUF));
+ iRet = msgrcv(queueId, &stMsg, msgSize, 0, 0);
+ if (iRet >= 0)
+ {
+ switch (stMsg.src_id)
+ {
+ case MODULE_ID_WEB_CGI:
+ {
+ zSms_HandleWebMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_AT_CTL:
+ {
+ zSms_HandleAtctlMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_SMS:
+ {
+ zSms_HandleWebMsg(&stMsg);
+ zSms_HandleAtctlLocalMsg(&stMsg);
+ break;
+ }
+ case MODULE_ID_MAIN_CTRL:
+ {
+ zSms_HandleMainCtrlMsg(&stMsg);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ at_print(AT_DEBUG,"errno = %d, errmsg = %s\n", errno,strerror(errno));
+ }
+ }
+}
+
+
+int sms_main(int argc, char* argv[])
+{
+ pthread_t recv_thread_tid = 0;
+ MSG_BUF msgBuf = {0};
+ CHAR needSMS[50] = {0};
+ prctl(PR_SET_NAME, "sms_main", 0, 0, 0);
+ //¸ù¾ÝNV³õʼ»¯´òÓ¡¼¶±ð£¬²¢×¢²á¶¯Ì¬µ÷Õû´òÓ¡¼¶±ðÐźÅÁ¿
+ loglevel_init();
+
+ //ÅжÏNV,added by wenqin 2016-5-18
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 != strcmp(needSMS, "no"))
+ {
+ zUfiSms_InitDb();
+ zUfiSms_CfgSmsNvInit();
+ zUfiMmi_SendSmsStatus();
+ zSms_SmsMsgCreat();
+ }
+ else
+ {
+ return -1;
+ }
+ printf("sms app init finished, will to receive msg, msgid:%d\n", g_zSms_MsqId);
+ //¸ÃÏß³ÌÓÃÓÚ´¦ÀíÄÚ²¿×èÈûµÄÏûÏ¢£¬¶ÔÓ¦ÏûÏ¢µÄsourceIdÊÇMODULE_ID_SMS
+ if(pthread_create(&recv_thread_tid, NULL, sms_msg_thread_proc, (void*)(&g_zSms_LocalMsqId)) == -1)
+ {
+ assert(0);
+ }
+ //Ö÷Ïß³ÌÓÃÓÚ´¦ÀíÍⲿ½ÓÊÕÏûÏ¢£¬¶ÔÓ¦ÏûÏ¢µÄsourceId·ÇMODULE_ID_SMS
+ sms_msg_thread_proc(&g_zSms_MsqId);
+ return 0;
+}
+
diff --git a/ap/app/zte_comm/sms/src/sms_proc.c b/ap/app/zte_comm/sms/src/sms_proc.c
index fe2cb6f..10e326d 100755
--- a/ap/app/zte_comm/sms/src/sms_proc.c
+++ b/ap/app/zte_comm/sms/src/sms_proc.c
@@ -1,662 +1,1748 @@
-
+/**************************************************************************
+*
+* Copyright (c) 2012 ZTE Corporation.
+*
+***************************************************************************
+* Ä£ ¿é Ãû : AT_SERVER
+* ÎÄ ¼þ Ãû : sms_proc.c
+* Ïà¹ØÎļþ :
+* ʵÏÖ¹¦ÄÜ : AtServerÄ£¿ésmsÁ÷³Ì¿ØÖÆÎļþ
+* ×÷ Õß : G.F
+* °æ ±¾ : V1.0
+* Íê³ÉÈÕÆÚ : 2013-09-29
+* ÆäËü˵Ã÷ :
+**************************************************************************/
+
+/**************************************************************************
+* Ð޸ļǼ1:
+***************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : EC:617002775301, EC617002775301
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.5.30
+* ÐÞ¸ÄÄÚÈÝ : (´úÂë×ß²é)ÐÞ¸ÄÏà¹ØSMS½ÓÊÕ¶ÌÐÅÁ÷³Ì´¦Àí
+**************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.6.24
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
+**************************************************************************/
+/**************************************************************************
+* Ð޸ıàºÅ : й¦ÄÜ
+* ÐÞ ¸Ä ÈË : chenjie10092374
+* ÐÞ¸ÄÈÕÆÚ : 2014.08.07
+* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÏòMMI·¢ËͶÌÐÅ״̬µÄ´úÂë
+**************************************************************************/
+/**************************************************************************
+* #includeÇø
+**************************************************************************/
#include <limits.h>
#include "sms_code.h"
#include <sys/msg.h>
-T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;T_zUfiSms_GroupInfo g_zUfiSms_GroupSms;
-T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];UINT8
-g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX]={FALSE,FALSE};T_zUfiSms_DelSms
-g_zUfiSms_DelMsg;T_zUfiSms_DelIndexInfo g_deleteIndex={(0x11ab+5072-0x257b)};
-T_zUfiSms_ModifySms g_zUfiSms_modifyMsg={(0x13a1+2914-0x1f03)};
-T_zUfiSms_ModifyIndexInfo g_modifyIndex={(0xb83+6302-0x2421)};int
-g_zUfiSms_UnitLen=(0x1755+2050-0x1f57);int g_zUfiSms_ConcatTotalNum=
-(0x114+3667-0xf67);int g_zUfiSms_CurConcatSegNo=(0x1494+4280-0x254c);UINT8
-g_zUfiSms_IsConcatSendSuc=TRUE;int g_zUfiSms_SendFailedCount=(0xdb0+4655-0x1fdf)
-;int g_zUfiSms_MsgRefer=(0xbe1+1037-0xfee);int g_zUfiSms_SendFailedRetry=
-(0x2dc+5290-0x1786);char g_Zmena_value[(0xf5a+1876-0x16ac)]={(0xc87+4385-0x1da8)
-};int g_displaymode=(0xf63+981-0x1338);extern SMS_LOCATION g_zUfiSms_CurLocation
-;extern T_zUfiSms_CmdStatus zUfiSms_HandleReport(unsigned char*ptPduData);extern
- void zUfiSms_GetReportStatus(char*pdu_tmp,int*stat);extern VOID
-zUfiSms_ResendAtCmdZmena(int cid);extern int zUfiSms_DecodeSmsData(
-T_zUfiSms_DbStoreData*pDb_Data,int msg_index,zUfiSms_StoreType iStorePos,
-T_SmsStatus bSms_Status,wms_message_format_enum_v01 format,long iPdu_Len,
-unsigned char*pPdu_Received);typedef struct{long mtype;char mtext[
-(0xc44+918-0xfce)];}FOTA_MSG_BUF;
-#define WEBUI_NOTIFY_PUSH_MSG_ (0x3e4+5049-0x179a)
-typedef struct{unsigned int isread_record;unsigned int inbox_full;}
-T_zUfiMmi_SmsRecord;void zUfiMmi_SendSmsStatus(void){int iSmsNum=
-(0x43d+5275-0x18d8);T_zUfiMmi_SmsRecord tRecord={(0x1e7+8202-0x21f1)};CHAR
-smsNum[(0xe6+3806-0xf92)]={(0x1de5+2272-0x26c5)};sc_cfg_get(NV_SMS_IN_NUM,smsNum
-,sizeof(smsNum));iSmsNum=atoi(smsNum);tRecord.isread_record=zUfiSms_IsUnreadSms(
-ZTE_WMS_MEMORY_MAX);if(iSmsNum>=ZSMS_NUM_MAX_CPE){tRecord.inbox_full=
-(0x101b+2079-0x1839);}else{tRecord.inbox_full=(0xb43+1124-0xfa7);}}VOID
-zUfiSms_Init(VOID){zUfiSms_CfgInit();zUfiSms_ChangeMainState(SMS_STATE_INITING);
-}VOID zSvr_Zpbic_Sms_Init(VOID){int atRes=(0x1425+3977-0x23ae);
-T_zUfiSms_StatusInfo tStatus={(0xb58+2689-0x15d9)};CHAR outDate[
-(0xe37+6067-0x25b8)]={(0x638+2049-0xe39)};zUfiSms_Init();zUfiSms_InitCmdStatus(&
-tStatus,WMS_SMS_CMD_INIT);zSms_SendSmsInitReq();at_print(LOG_DEBUG,
-"corem zSvr_Zpbic_Sms_Init has send init req\n");zSms_SendZmenaReq(
-(0x8fc+7037-0x2479));at_print(LOG_DEBUG,
-"\x63\x6f\x72\x65\x6d\x20\x7a\x53\x76\x72\x5f\x5a\x70\x62\x69\x63\x5f\x53\x6d\x73\x5f\x49\x6e\x69\x74\x20\x68\x61\x73\x20\x73\x65\x6e\x64\x20\x7a\x6d\x65\x6e\x61\x20\x72\x65\x71" "\n"
-);sc_cfg_get(NV_OUTDATE_DELETE,outDate,sizeof(outDate));at_print(LOG_DEBUG,
-"\x63\x6f\x72\x65\x6d\x20\x7a\x53\x76\x72\x5f\x5a\x70\x62\x69\x63\x5f\x53\x6d\x73\x5f\x49\x6e\x69\x74\x20\x6f\x75\x74\x64\x61\x74\x65\x20\x63\x68\x65\x63\x6b\x20\x25\x73" "\n"
-,outDate);if((0x488+714-0x752)==strcmp(outDate,"\x31")){atWeb_OutdateSmsCheck(
-ZUFI_NULL);}}VOID zUfiSms_DeleteAllSimSms(VOID){zUfiSms_DeleteAllSimSmsInDb();}
-#if (0xd69+3281-0x1a3a)
-VOID zUfiSms_ResendAtCmdZmena(int cid){CHAR netType[(0x14b4+2675-0x1ef5)]={
-(0x7b2+2096-0xfe2)};sc_cfg_get(NV_NETWORK_TYPE,netType,sizeof(netType));if(!
-g_Zmena_rsp&&((0x1515+3-0x1518)!=strcmp(
-"\x4e\x6f\x20\x53\x65\x72\x76\x69\x63\x65",netType)&&(0x1019+5417-0x2542)!=
-strcmp("\x4c\x69\x6d\x69\x74\x65\x64\x20\x53\x65\x72\x76\x69\x63\x65",netType)))
-{atUnsoli_Report_Zmena(NULL,cid);}}
+
+/**************************************************************************
+* ³£Á¿¶¨ÒåÇø
+**************************************************************************/
+
+/* **********È«¾Ö³£Á¿ **************/
+
+// ³¤¶ÌÐŵļ¶ÁªÐÅÏ¢
+T_zUfiSms_ConcatInfo g_zUfiSms_ConcatSms;
+
+// Ⱥ·¢ÐÅÏ¢
+T_zUfiSms_GroupInfo g_zUfiSms_GroupSms;
+
+//Êý¾Ý¿âÖд洢µÄÐÅÏ¢£¬ÓÃÓÚ´æ´¢ÒÑ·¢ÐÅÏ¢
+T_zUfiSms_DbStoreData g_zUfiSms_DbStoreData[ZTE_WMS_CONCAT_SMS_COUNT_MAX];
+
+/* ¿¨ÖÐÊÇ·ñ´æ´¢ÒÑÂú, 0--¿¨, 1--nv */
+UINT8 g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_MAX] = {FALSE,FALSE};
+
+// ¶ÌÐÅɾ³ýÐÅÏ¢
+T_zUfiSms_DelSms g_zUfiSms_DelMsg;
+T_zUfiSms_DelIndexInfo g_deleteIndex={0};
+
+//¶ÌÐÅδ¶Á±êÖ¾ÐÞ¸Ä
+T_zUfiSms_ModifySms g_zUfiSms_modifyMsg={0};
+T_zUfiSms_ModifyIndexInfo g_modifyIndex={0};
+
+// ³¤¶ÌÐŵĵ¥Î»·¢Ëͳ¤¶È
+int g_zUfiSms_UnitLen = 0;
+
+// ³¤¶ÌÐŵÄ×Ü·Ö¶ÎÊý,ÓÃÓÚÅж϶ÌÐÅ·Ö¶ÎÊÇ·ñ·¢ËÍÍê±Ï
+int g_zUfiSms_ConcatTotalNum = 0;
+
+//µ±Ç°·¢Ë͵ij¤¶ÌÐÅÆ¬¶ÎºÅ£¬ÓÃÓڼǼÿ¶ÎµÄ·¢Ëͽá¹ûºÍÅжÏÊÇ·ñ·¢ËͽáÊø
+int g_zUfiSms_CurConcatSegNo = 0;
+
+//³¤¶ÌÐÅÊÇ·ñ·¢Ëͳɹ¦£¬Ä¬ÈÏ·¢Ëͳɹ¦
+UINT8 g_zUfiSms_IsConcatSendSuc = TRUE;
+
+// ¶ÌÐÅ·¢ËÍʧ°ÜµÄÌõÊý£¬ÓÃÓÚ³¤¶ÌÐŵķ¢ËͼÆÊý
+int g_zUfiSms_SendFailedCount = 0;
+
+//¶ÌÐŲÎÕÕÊý¾Ý£¬¸ø×é×°¼¶Áª¶ÌÐŵĶÌÐÅͷʱÓÃ
+int g_zUfiSms_MsgRefer = 0;
+
+// ¶ÌÐÅ·¢ËÍʧ°ÜºóÖØÊÔ´ÎÊý
+int g_zUfiSms_SendFailedRetry = 0;
+
+//¼Ç¼µ±Ç°×´Ì¬£¬ÓÃÓÚWebserverÏÔʾ
+//T_zUfiSms_StatusInfo g_zUfiSms_StatusInfo;
+
+char g_Zmena_value[2] = {0};
+//Êý¾Ý¿âÖÐָʾһÌõ¶ÌÐżÇ¼ÊÇ·ñ±»WEBUIÏÔʾ
+//0:ÏÔʾ£»1:²»ÏÔʾ
+int g_displaymode = 0;
+
+
+extern SMS_LOCATION g_zUfiSms_CurLocation;
+extern T_zUfiSms_CmdStatus zUfiSms_HandleReport( unsigned char* ptPduData);
+extern void zUfiSms_GetReportStatus(char *pdu_tmp,int *stat);
+extern VOID zUfiSms_ResendAtCmdZmena(int cid);
+extern int zUfiSms_DecodeSmsData
+(
+ T_zUfiSms_DbStoreData *pDb_Data,
+ int msg_index,
+ zUfiSms_StoreType iStorePos,
+ T_SmsStatus bSms_Status,
+ wms_message_format_enum_v01 format,
+ long iPdu_Len,
+ unsigned char *pPdu_Received
+);
+
+typedef struct{
+ long mtype;
+ char mtext[12];
+}FOTA_MSG_BUF;
+
+#define WEBUI_NOTIFY_PUSH_MSG_ 3
+
+/* ºê´¦Àí */
+
+/**************************************************************************
+* Êý¾Ý½á¹¹¶¨ÒåÇø
+**************************************************************************/
+typedef struct
+{
+ unsigned int isread_record;
+ unsigned int inbox_full;
+}T_zUfiMmi_SmsRecord;
+/**************************************************************************
+* staticº¯ÊýÉùÃ÷Çø
+**************************************************************************/
+
+/**************************************************************************
+* È«¾Ö±äÁ¿¶¨ÒåÇø
+**************************************************************************/
+
+
+/**************************************************************************
+* º¯ÊýʵÏÖÇø
+**************************************************************************/
+//ËùÓÐsmsÏà¹ØµÄ¹¦Äܳõʼ»¯
+void zUfiMmi_SendSmsStatus(void)
+{
+ int iSmsNum = 0;
+ T_zUfiMmi_SmsRecord tRecord = { 0 };
+ CHAR smsNum[50]={0};
+ sc_cfg_get(NV_SMS_IN_NUM,smsNum,sizeof(smsNum));
+
+ iSmsNum = atoi(smsNum);
+ // *G.F*
+ tRecord.isread_record = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_MAX);
+ if(iSmsNum >= ZSMS_NUM_MAX_CPE)
+ {
+ tRecord.inbox_full = 1;
+ }
+ else
+ {
+ tRecord.inbox_full = 0;
+ }
+ //zUfi_SendMsgToAp(MODULE_ID_MMI,MSG_MMICHANNEL_MESSAGE, sizeof(tRecord), (CHAR*)&tRecord);
+}
+
+VOID zUfiSms_Init(VOID)
+{
+ zUfiSms_CfgInit();
+ zUfiSms_ChangeMainState(SMS_STATE_INITING); /* ÉèÖÃ״̬Ϊiniting, ÒÔ¹©Ò³ÃæÆÁ±Î²Ù×÷*/
+ //zUfiSms_InitDb();
+
+ //zUfiMmi_SendSmsStatus();
+}
+
+VOID zSvr_Zpbic_Sms_Init(VOID)
+{
+ int atRes = 0;
+ T_zUfiSms_StatusInfo tStatus = {0};
+ CHAR outDate[50]={0};
+
+ zUfiSms_Init();
+ zUfiSms_InitCmdStatus(&tStatus,WMS_SMS_CMD_INIT);
+
+ //zSvr_Sms_At_Init(cid);
+ zSms_SendSmsInitReq();
+ at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send init req\n");
+ //atUnsoli_Report_Zmena("0", cid);
+ zSms_SendZmenaReq(0);
+ at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init has send zmena req\n");
+ sc_cfg_get(NV_OUTDATE_DELETE,outDate,sizeof(outDate));
+ at_print(LOG_DEBUG,"corem zSvr_Zpbic_Sms_Init outdate check %s\n", outDate);
+ if(0 == strcmp(outDate, "1"))
+ {
+ atWeb_OutdateSmsCheck(ZUFI_NULL);
+ }
+}
+
+
+VOID zUfiSms_DeleteAllSimSms(VOID)
+{
+ zUfiSms_DeleteAllSimSmsInDb();
+}
+
+#if 0
+VOID zUfiSms_ResendAtCmdZmena(int cid)
+{
+ CHAR netType[50]={0};
+ sc_cfg_get(NV_NETWORK_TYPE,netType,sizeof(netType));
+
+ if(!g_Zmena_rsp &&
+ (0!=strcmp("No Service",netType)&&0!=strcmp("Limited Service",netType)))
+ {
+ atUnsoli_Report_Zmena(NULL,cid);
+ }
+}
#endif
-void zUfiSms_Ack_new_msg(BOOL needAck){
-#if (0x13f7+3455-0x2176)
-CHAR ackPduStr[(0x15e0+691-0x1703)]={(0x1c4+8832-0x2444)};SMS_PARAM reportParam=
-{(0x1aac+1494-0x2082)};int total_length=(0x6dc+147-0x76f);UINT8 TP_FCS=
-(0x2f5+8132-0x22b9);CHAR strValue[(0x10af+3716-0x1f31)]={(0x12a5+782-0x15b3)};if
-(needAck){TP_FCS=(0x1021+3013-0x1be6);sprintf(strValue,"\x25\x64",
-(0xdda+1677-0x1466));}else{TP_FCS=(0x1a8+8976-0x23e5);sprintf(strValue,
-"\x25\x64",(0x1c31+584-0x1e77));}sprintf(reportParam.SCA,"\x25\x73",cfg_get(
-"\x73\x6d\x73\x5f\x63\x65\x6e\x74\x65\x72\x5f\x6e\x75\x6d"));total_length=
-zUfiSms_EncodePdu_DeliverReport(&reportParam,ackPduStr,TP_FCS);memset(&
-g_zUfiSms_ackPdu,(0xdaf+5972-0x2503),sizeof(g_zUfiSms_ackPdu));g_zUfiSms_ackPdu.
-length=String2Bytes(ackPduStr,g_zUfiSms_ackPdu.pdu,strlen(ackPduStr));memset(
-g_zUfiSms_ackPdu.pdu,(0x90d+2911-0x146c),sizeof(g_zUfiSms_ackPdu.pdu));memcpy(&
-g_zUfiSms_ackPdu.pdu,&ackPduStr,sizeof(ackPduStr));atBase_SendMsgToSelf(
-ZAT_CNMA_CMD,strValue,sizeof(strValue));
+
+void zUfiSms_Ack_new_msg(BOOL needAck)
+{
+#if 0
+ CHAR ackPduStr[400] = {0};
+ SMS_PARAM reportParam = {0};
+ int total_length = 0;
+ UINT8 TP_FCS = 0;
+ CHAR strValue[2] = {0};
+
+ if(needAck)
+ {
+ TP_FCS = 0x00;
+ sprintf(strValue, "%d", 1);
+ }
+ else
+ {
+ TP_FCS = 0xD3;
+ sprintf(strValue, "%d", 2);
+ }
+
+ sprintf(reportParam.SCA, "%s", cfg_get("sms_center_num"));
+ total_length = zUfiSms_EncodePdu_DeliverReport(&reportParam, ackPduStr, TP_FCS);
+
+ memset(&g_zUfiSms_ackPdu, 0, sizeof(g_zUfiSms_ackPdu));
+ g_zUfiSms_ackPdu.length = String2Bytes(ackPduStr, g_zUfiSms_ackPdu.pdu, strlen(ackPduStr));
+
+ memset(g_zUfiSms_ackPdu.pdu, 0, sizeof(g_zUfiSms_ackPdu.pdu));
+ memcpy(&g_zUfiSms_ackPdu.pdu, &ackPduStr, sizeof(ackPduStr));
+
+ atBase_SendMsgToSelf(ZAT_CNMA_CMD, strValue, sizeof(strValue));
#endif
-#if (0x72a+5465-0x1c83)
-CHAR strValue[(0xe55+4258-0x1ef5)]={(0x1132+167-0x11d9)};if(needAck){snprintf(
-strValue,sizeof(strValue),"\x25\x64",(0x1276+2761-0x1d3e));}else{snprintf(
-strValue,sizeof(strValue),"\x25\x64",(0x15c8+1400-0x1b3e));}zSvr_InnerSendMsg(
-ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_CNMA,strlen(strValue
-),strValue);
+#if 0//zhangfen for platform
+ CHAR strValue[2] = {0};
+
+ if(needAck)
+ {
+ snprintf(strValue, sizeof(strValue),"%d", 1);
+ }
+ else
+ {
+ snprintf(strValue, sizeof(strValue),"%d", 2);
+ }
+ zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_CNMA,strlen(strValue),strValue);
#endif
-if(needAck){zSms_SendCnmaReq((0x1136+5367-0x262c));}else{zSms_SendCnmaReq(
-(0xd58+317-0xe93));}}T_zUfiSms_CmdStatus zUfiSms_SendRawSms(T_zUfiSms_SendReq*
-ptSendMsg){if(NULL==ptSendMsg||(0x57a+6022-0x1d00)==ptSendMsg->receiver_count){
-return WMS_CMD_FAILED;}at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x52\x61\x77\x53\x6d\x73\x20\x72\x65\x63\x65\x69\x76\x65\x72\x5f\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2f\x64\x65\x73\x74\x5f\x6e\x75\x6d\x3a\x25\x73\x2f\x6d\x73\x67\x5f\x6c\x65\x6e\x3a\x25\x64\x2f\x69\x64\x3a\x25\x64\x2e" "\n"
-,ptSendMsg->receiver_count,ptSendMsg->dest_num[(0xe43+5767-0x24ca)],ptSendMsg->
-msg_len,ptSendMsg->id);
-#if (0xe94+287-0xfb2)
-at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x52\x61\x77\x53\x6d\x73\x20\x64\x63\x73\x3a\x25\x64" "\n"
-,ptSendMsg->dcs);
-#endif
-sc_cfg_set(NV_SMS_SEND_RESULT,"");g_zUfiSms_SendFailedCount=(0x6ad+3566-0x149b);
-if(ptSendMsg->isDelete==TRUE||-(0x1379+2062-0x1b86)!=ptSendMsg->id){(void)
-zUfiSms_DeleteDraftSms(ptSendMsg->id);}zUfiSms_SetGlobalDcsLang(ptSendMsg->dcs);
-memset(&g_zUfiSms_GroupSms,(0xa63+4849-0x1d54),sizeof(g_zUfiSms_GroupSms));if(
-ZUFI_FAIL==zUfiSms_FillGroupSms(ptSendMsg,&g_zUfiSms_GroupSms)){return
-WMS_CMD_FAILED;}memset(&g_zUfiSms_ConcatSms,(0x50+3418-0xdaa),sizeof(
-g_zUfiSms_ConcatSms));g_zUfiSms_UnitLen=zUfiSms_FillConcatSms(ptSendMsg,&
-g_zUfiSms_ConcatSms);g_zUfiSms_IsConcatSendSuc=TRUE;g_zUfiSms_CurConcatSegNo=
-(0x11ec+683-0x1497);memset(g_zUfiSms_DbStoreData,(0xff+6232-0x1957),sizeof(
-g_zUfiSms_DbStoreData));if(ptSendMsg->mem_store==(0x4fb+2182-0xd77)){
-g_displaymode=(0x852+6110-0x202f);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x53\x6d\x73\x3a\x20\x6d\x73\x67\x5f\x64\x69\x73\x70\x6c\x61\x79\x6d\x6f\x64\x65\x20\x3d\x20\x31" "\n"
-);}else{g_displaymode=(0x40d+1942-0xba3);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x6e\x64\x53\x6d\x73\x3a\x20\x6d\x73\x67\x5f\x64\x69\x73\x70\x6c\x61\x79\x6d\x6f\x64\x65\x20\x3d\x20\x30" "\n"
-);}return zUfiSms_SendSms();}T_zUfiSms_CmdStatus zUfiSms_WriteRawSms(
-T_zUfiSms_SaveReq*pSaveBuff){T_zUfiSms_ConcatInfo tConcatSms;T_zUfiSms_GroupInfo
- tGroupSms;int iSmsLen=(0x742+2786-0x1224);T_zUfiSms_CmdStatus result=
-WMS_CMD_SUCCESS;if(NULL==pSaveBuff){return WMS_CMD_FAILED;}if(
-g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV]){at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x52\x61\x77\x53\x6d\x73\x20\x6e\x76\x20\x6d\x65\x6d\x6f\x72\x79\x20\x69\x73\x20\x66\x75\x6c\x6c\x2c\x72\x65\x74\x75\x72\x6e" "\n"
-);return WMS_CMD_FAILED;}if(pSaveBuff->isDelete==TRUE){(void)
-zUfiSms_DeleteDraftSms(pSaveBuff->id);}zUfiSms_SetGlobalDcsLang(pSaveBuff->dcs);
-memset(&tConcatSms,(0x1c6+351-0x325),sizeof(T_zUfiSms_ConcatInfo));memset(&
-tGroupSms,(0x764+922-0xafe),sizeof(T_zUfiSms_GroupInfo));(void)
-zUfiSms_FillGroupSms(pSaveBuff,&tGroupSms);iSmsLen=zUfiSms_FillConcatSms(
-pSaveBuff,&tConcatSms);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x52\x61\x77\x53\x6d\x73\x20\x74\x6f\x74\x61\x6c\x5f\x72\x65\x63\x65\x69\x76\x65\x72\x3d\x25\x64\x2c\x69\x53\x6d\x73\x4c\x65\x6e\x3d\x25\x64" "\n"
-,tGroupSms.total_receiver,iSmsLen);for(tGroupSms.current_receiver=
-(0x1960+1255-0x1e47);tGroupSms.current_receiver<tGroupSms.total_receiver;
-tGroupSms.current_receiver++){tConcatSms.current_sending=(0xd41+1574-0x1367);
-result=zUfiSms_SaveSmsToDb(pSaveBuff,&tConcatSms,&tGroupSms,iSmsLen);at_print(
-LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x52\x61\x77\x53\x6d\x73\x20\x63\x75\x72\x72\x65\x6e\x74\x5f\x72\x65\x63\x65\x69\x76\x65\x72\x3d\x25\x64\x2c\x72\x65\x73\x75\x6c\x74\x3d\x25\x64" "\n"
-,tGroupSms.current_receiver,result);}sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);if(g_zUfiSms_MemFullFlag[
-WMS_STORAGE_TYPE_NV_V01]){zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);}at_print(
-LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x57\x72\x69\x74\x65\x52\x61\x77\x53\x6d\x73\x20\x65\x6e\x64\x20\x61\x6e\x64\x20\x72\x65\x73\x75\x6c\x74\x3d\x25\x64" "\n"
-,result);return result;}T_zUfiSms_CmdStatus zUfiSms_DeleteSms(T_zUfiSms_DelReq*
-ptDelBuff){T_zUfiSms_CmdStatus result=WMS_CMD_SUCCESS;BOOL
-memoryFullbeforeDelete=FALSE;BOOL unreadBeforeDelete=FALSE;if(NULL==ptDelBuff){
-return WMS_CMD_FAILED;}at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x21\x21\x21\x21\x21\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x6d\x73\x21\x21\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2f\x69\x64\x5b\x25\x64\x5d\x2e" "\n"
-,ptDelBuff->all_or_count,ptDelBuff->id[(0x114b+3604-0x1f5f)]);(void)
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);zUfiSms_ChangeMainState(
-SMS_STATE_DELING);memset(&g_zUfiSms_DelMsg,(0x1c66+202-0x1d30),sizeof(
-T_zUfiSms_DelSms));if(ZUFI_FAIL==zUfiSms_SetDeleteInfo(ptDelBuff)){at_print(
-LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x21\x21\x21\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x74\x44\x65\x6c\x65\x74\x65\x49\x6e\x66\x6f\x20\x66\x61\x69\x6c\x2e" "\n"
-);zUfiSms_ChangeMainState(SMS_STATE_DELED);return WMS_CMD_FAILED;}at_print(
-LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x21\x21\x21\x7a\x55\x66\x69\x53\x6d\x73\x5f\x53\x65\x74\x44\x65\x6c\x65\x74\x65\x49\x6e\x66\x6f\x20\x52\x65\x61\x64\x20\x74\x6f\x20\x44\x65\x6c\x65\x74\x65\x3a\x6e\x76\x5f\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2f\x73\x69\x6d\x5f\x63\x6f\x75\x6e\x74\x3a\x25\x64\x2e" "\n"
-,g_zUfiSms_DelMsg.nv_count,g_zUfiSms_DelMsg.sim_count);if((0x980+2743-0x1437)<
-g_zUfiSms_DelMsg.nv_count){if(g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]){
-memoryFullbeforeDelete=TRUE;}unreadBeforeDelete=zUfiSms_IsUnreadSms(
-ZTE_WMS_MEMORY_NV);result=(T_zUfiSms_CmdStatus)zUfiSms_DeleteNvSms();(void)
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);zUfiSms_ChangeMainState(
-SMS_STATE_DELED);sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x4e\x76\x53\x6d\x73\x20\x6d\x65\x6d\x6f\x72\x79\x46\x75\x6c\x6c\x62\x65\x66\x6f\x72\x65\x44\x65\x6c\x65\x74\x65\x3d\x25\x64\x2c\x4d\x65\x6d\x46\x75\x6c\x6c\x46\x6c\x61\x67\x28\x4e\x56\x29\x3d\x25\x64" "\n"
-,memoryFullbeforeDelete,g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]);if(
-memoryFullbeforeDelete&&!g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]){
-at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x4e\x76\x53\x6d\x73\x3a\x20\x73\x65\x6e\x64\x20\x41\x54\x2b\x5a\x4d\x45\x4e\x41\x3d\x30" "\n"
-);zSms_SendZmenaReq((0xd95+2081-0x15b6));}if(memoryFullbeforeDelete&&!
-g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]||unreadBeforeDelete&&!
-zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)){zUfiSms_SendSmsStatusInfo(
-MSG_SMS_DEFAULT);}}if((0x391+5270-0x1827)<g_zUfiSms_DelMsg.sim_count){result=
-zUfiSms_DeleteSimSms();(void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_SIM);}
-at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x6d\x73\x20\x72\x65\x73\x75\x6c\x74\x3d\x25\x64" "\n"
-,result);return result;}T_zUfiSms_CmdStatus zUfiSms_ModifySmsTag(
-T_zUfiSms_ModifyFlag*ptModifyBuff){unsigned long i=(0x67d+78-0x6cb);
-T_zUfiSms_CmdStatus result=WMS_CMD_SUCCESS;char acStorePos[(0xa4b+2857-0x1542)]=
-{(0x6ca+3788-0x1596)};if(NULL==ptModifyBuff){at_print(LOG_ERR,
-"\x69\x6e\x70\x75\x74\x73\x20\x69\x73\x20\x6e\x75\x6c\x6c\x2e");return
-WMS_CMD_FAILED;}for(i=(0x2db+3157-0xf30);i<ptModifyBuff->total_id;i++){if(
-ptModifyBuff->id[i]<(0xcfa+5204-0x214d)||ZUFI_FAIL==zUfiSms_UpdateSmsTagInDb(
-ptModifyBuff->id[i],ptModifyBuff->tags)){result=WMS_CMD_FAILED;}else{result=
-WMS_CMD_SUCCESS;}}if(ZUFI_FAIL==zUfiSms_GetStorePosById(
-"\x4d\x65\x6d\x5f\x53\x74\x6f\x72\x65",acStorePos,sizeof(acStorePos),
-ptModifyBuff->id[(0x1b6+2999-0xd6d)])){return ZUFI_FAIL;}if((0x18ec+1375-0x1e4b)
-==strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE)){zUfiSms_SendSmsStatusInfo(
-MSG_SMS_READING);}if((0xae9+3027-0x16bc)==strcmp(acStorePos,ZTE_WMS_DB_SIM_TABLE
-)&&ptModifyBuff->total_id>(0x594+4811-0x185f)){zUfiSms_ModifyModemSms(
-ptModifyBuff);}return result;}T_zUfiSms_CmdStatus zUfiSms_SetSmsPara(
-T_zUfiSms_ParaInfo*ptParaBuff){int atRes=(0xe21+2138-0x167b);CHAR sca[
-ZTE_WMS_ADDRESS_DIGIT_MAX_V01+(0x1283+3113-0x1eab)]={(0x93d+4710-0x1ba3)};CHAR
-store[(0x9f2+2095-0x120d)]={(0x14a+1509-0x72f)};CHAR defaultStore[
-(0x217+4442-0x133f)]={(0xbb+7806-0x1f39)};if(ptParaBuff==ZUFI_NULL){return
-WMS_CMD_FAILED;}if(strlen(ptParaBuff->sca)!=(0x1260+2650-0x1cba)){strncpy(sca,
-ptParaBuff->sca,sizeof(sca)-(0x6bc+1352-0xc03));at_print(LOG_DEBUG,
-"\x73\x65\x6e\x64\x20\x5a\x41\x54\x5f\x43\x53\x43\x41\x5f\x53\x45\x54\x5f\x43\x4d\x44\x20\x6d\x65\x73\x73\x61\x67\x65\x20\x63\x73\x63\x61\x20\x69\x73\x20\x25\x73\x2e" "\n"
-,sca);atRes=zSms_SetCscaReq(ptParaBuff->sca);if(atRes!=ZSMS_RESULT_OK){return
-WMS_CMD_FAILED;}}sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
-if((*(ptParaBuff->default_store)!='\0')&&((0x3c+2694-0xac2)!=strcmp(defaultStore
-,ptParaBuff->default_store))){{strncpy(store,ptParaBuff->default_store,sizeof(
-store)-(0x884+5123-0x1c86));}atRes=zSms_SendCnmiReq(store);if(atRes!=
-ZSMS_RESULT_OK){return WMS_CMD_FAILED;}}if(-(0x846+6859-0x2310)==
-zUfiSms_SetDbParameters(ptParaBuff)){at_print(LOG_ERR,
-"\x73\x65\x74\x20\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73\x20\x74\x6f\x20\x74\x61\x62\x6c\x65\x20\x66\x61\x69\x6c\x65\x64\x2e"
-);return WMS_CMD_FAILED;}return WMS_CMD_SUCCESS;}void zUfiSms_CmgrNvSet(void){
-char sms_rec_flag[(0x16d+1853-0x8a5)]={(0x897+3326-0x1595)};char remind_flag[
-(0xbe3+1705-0x1287)];int sms_count=(0x88b+3327-0x158a);int remind_count=
-(0xa91+674-0xd33);memset(sms_rec_flag,(0x1171+425-0x131a),sizeof(sms_rec_flag));
-sc_cfg_get(ZTE_WMS_NVCONFIG_RECEVIED,sms_rec_flag,sizeof(sms_rec_flag));
-sms_count=atoi(sms_rec_flag);if(sms_count<(0x3d7+5576-0x199f)||sms_count>INT_MAX
--(0xe8a+1188-0x132d)){at_print(LOG_ERR,
-"\x5b\x53\x4d\x53\x5d\x73\x6d\x73\x5f\x63\x6f\x75\x6e\x74\x20\x65\x72\x72\x3a\x25\x64" "\n"
-,sms_count);return;}memset(sms_rec_flag,(0x987+2733-0x1434),sizeof(sms_rec_flag)
-);snprintf(sms_rec_flag,sizeof(sms_rec_flag),"\x25\x64",sms_count+
-(0x93d+5305-0x1df5));sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED,sms_rec_flag);
-sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_LED,sms_rec_flag);memset(remind_flag,
-(0x1003+3708-0x1e7f),sizeof(remind_flag));snprintf(remind_flag,sizeof(
-remind_flag),"\x25\x64",remind_count+(0x38+9457-0x2528));sc_cfg_set(
-ZTE_WMS_NVCONFIG_RECEVIED_REMIND,remind_flag);sc_cfg_set(NV_SMS_RECV_RESULT,
-"\x6f\x6b");sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");}void zUfiSms_CdsRespProc(
-T_zSms_SmsInd*ptRespData){unsigned char acFormatPdu[ZSMS_PDU_SIZE]={
-(0x9ea+4102-0x19f0)};T_zUfiSms_DbStoreData tDbStoreData={(0xe76+2412-0x17e2)};
-int isPushSms=(0x381+247-0x478);if(strcmp(ptRespData->pdu,"")==
-(0x1052+195-0x1115)){CHAR srState[(0xac9+1469-0x1054)]={(0x1c56+180-0x1d0a)};
-sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));if((0x82f+5473-0x1d90)!=strcmp(
-srState,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x69\x6e\x67")){sc_cfg_set(
-NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(SMS_STATE_RECVED)
-;}else{sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");}
-return;}zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);(void)
-String2Bytes(ptRespData->pdu,acFormatPdu,(int)strlen(ptRespData->pdu));if(
-(0xce3+2467-0x1681)==ptRespData->stat){(void)zUfiSms_HandleReport(acFormatPdu);
-sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");
-zUfiSms_Ack_new_msg(TRUE);return;}return;}int zUfiSms_CheckIfWholeSms(
-T_zUfiSms_DbStoreData*data,SMS_MSG_INFO*pmsg){if(data->concat_sms!=
-(0x617+4819-0x18e9)){return(0x3ac+8367-0x245b);}zUfiSms_GetCurrentRecvTotalSeq(
-data,pmsg);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x68\x65\x63\x6b\x49\x66\x57\x68\x6f\x6c\x65\x53\x6d\x73\x20\x69\x64\x20\x3d\x20\x25\x73\x2c\x20\x74\x6f\x74\x61\x6c\x53\x65\x71\x20\x3d\x20\x25\x64\x2c\x72\x65\x66\x20\x3d\x25\x64\x2c\x74\x6f\x74\x61\x6c\x20\x3d\x25\x64\x2c\x20\x73\x65\x71\x3d\x25\x64" "\n"
-,pmsg->id,atoi(pmsg->total_seq),data->concat_info[(0x147+7478-0x1e7d)],data->
-concat_info[(0xad8+5057-0x1e98)],data->concat_info[(0x7c6+2218-0x106e)]);if(data
-->concat_info[(0x5d5+1524-0xbc8)]==atoi(pmsg->total_seq)){return
-(0x685+4804-0x1949);}return-(0x5b3+8404-0x2686);}void
-zUfiSms_TrafficChangeSmsTag(T_zUfiSms_DbStoreData*data){CHAR smsNumber[
-(0x672+7618-0x2402)]={(0x15f0+3582-0x23ee)};sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,
-smsNumber,sizeof(smsNumber));if((0xaa4+35-0xac7)==strcmp(smsNumber,data->number)
-){data->tag=WMS_TAG_TYPE_MT_READ_V01;data->msg_displaymode=(0x114f+5388-0x265a);
-}}void zUfiSms_HandleTrafficSms(T_zUfiSms_DbStoreData*data){int iSmsId=
-(0x1257+4896-0x2577);SMS_MSG_INFO msg={(0xa77+520-0xc7f)};CHAR smsNumber[
-(0x55f+4296-0x15f5)]={(0xb36+726-0xe0c)};sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,
-smsNumber,sizeof(smsNumber));at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x74\x44\x62\x53\x74\x6f\x72\x65\x44\x61\x74\x61\x2e\x6e\x75\x6d\x62\x65\x72\x20\x3d\x20\x25\x73\x2c\x20\x74\x72\x61\x66\x66\x69\x63\x5f\x73\x6d\x73\x5f\x6e\x75\x6d\x62\x65\x72\x20\x3d\x20\x25\x73" "\n"
-,data->number,smsNumber);if((0x4e3+3708-0x135f)==strcmp(smsNumber,data->number))
-{if((0xa9a+6219-0x22e5)!=zUfiSms_CheckIfWholeSms(data,&msg)){at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x63\x6d\x74\x20\x69\x6e\x64\x2c\x20\x72\x65\x63\x76\x20\x73\x6d\x73\x2c\x20\x62\x75\x74\x20\x6e\x6f\x74\x20\x77\x68\x6f\x6c\x65\x20\x73\x6d\x73\x2c\x20\x77\x61\x69\x74\x20\x74\x6f\x20\x72\x65\x63\x76\x20\x6e\x65\x78\x74\x20\x73\x65\x67" "\n"
-);return;}sc_cfg_set(NV_TRAFFIC_RECV_SMS_ID,msg.id);sc_cfg_set(
-NV_TRAFFIC_SMS_NUMBER,"\x30");at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x5b\x74\x72\x61\x66\x66\x69\x63\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x48\x61\x6e\x64\x6c\x65\x54\x72\x61\x66\x66\x69\x63\x53\x6d\x73\x20\x20\x20\x74\x72\x61\x66\x66\x69\x63\x5f\x72\x65\x63\x76\x5f\x73\x6d\x73\x5f\x69\x64\x20\x3d\x20\x25\x73" "\n"
-,msg.id);}}void zUfiSms_CmtRespProc(T_zSms_SmsInd*ptRespData){zUfiSms_StoreType
-iStorePos=WMS_STORAGE_TYPE_NV_V01;unsigned char acFormatPdu[ZSMS_PDU_SIZE]={
-(0xeef+2228-0x17a3)};T_zUfiSms_DbStoreData tDbStoreData;int isPushSms=
-(0x1781+1027-0x1b84);SMS_PARAM one_sms={(0x176b+2186-0x1ff5)};int
-unread_sms_before_recv_new_sms=(0x8ab+123-0x926);memset(&tDbStoreData,
-(0x1497+3887-0x23c6),sizeof(T_zUfiSms_DbStoreData));at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x45\x6e\x74\x65\x72\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2f\x70\x64\x75\x3a\x25\x73\x21" "\n"
-,ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);if(
-strcmp(ptRespData->pdu,"")==(0x48a+576-0x6ca)){CHAR srState[(0x358+391-0x4ad)]={
-(0xa85+1245-0xf62)};sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));if(
-(0x1667+1461-0x1c1c)!=strcmp(srState,
-"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x69\x6e\x67")){sc_cfg_set(
-NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(SMS_STATE_RECVED)
-;}else{sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");}
-return;}isPushSms=DecodePushPdu(ptRespData->pdu,&one_sms);at_print(LOG_DEBUG,
-"\x5b\x73\x6d\x73\x5d\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x20\x69\x73\x50\x75\x73\x68\x53\x6d\x73\x20\x3d\x20\x25\x64" "\n"
-,isPushSms);if(SMS_NOTIFICATION==isPushSms){BakNotificationSms(one_sms.TP_UD,
-strlen(one_sms.TP_UD));zte_fota_notifyPushMsg((0x2413+502-0x2609));}if(
-SMS_NO_PUSH!=isPushSms){at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x64" "\n"
-,one_sms.index);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x52\x65\x66\x65\x72\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_ReferNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x41\x6c\x6c\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_AllPieceNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x43\x75\x72\x72\x65\x6e\x74\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_CurrentPieceNum);zUfiSms_ChangeMainState(SMS_STATE_RECVED);
-zUfiSms_Ack_new_msg(TRUE);return;}zUfiSms_GetReportStatus(ptRespData->pdu,&
-ptRespData->stat);(void)String2Bytes(ptRespData->pdu,acFormatPdu,(int)strlen(
-ptRespData->pdu));if((0xfd9+1406-0x1552)==ptRespData->stat){(void)
-zUfiSms_HandleReport(acFormatPdu);sc_cfg_set(NV_SR_STATE,
-"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");zUfiSms_Ack_new_msg(TRUE);return
-;}(void)zUfiSms_DecodeSmsData(&tDbStoreData,ptRespData->index,iStorePos,(
-T_SmsStatus)ptRespData->stat,WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length,
-acFormatPdu);if(tDbStoreData.sms_class==WMS_MESSAGE_CLASS_2){iStorePos=
-WMS_STORAGE_TYPE_UIM_V01;}if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)){
-unread_sms_before_recv_new_sms=(0x131d+1448-0x18c4);}else{
-unread_sms_before_recv_new_sms=(0x39c+2825-0xea5);}zUfiSms_TrafficChangeSmsTag(&
-tDbStoreData);if(ZTE_WMS_NV_MEMORY_FULL==zUfiSms_WriteSmsToDb(&tDbStoreData,
-iStorePos,-(0x1a58+1345-0x1f98))){zUfiSms_Ack_new_msg(FALSE);zSms_SendZmenaReq(
-(0x16f4+787-0x1a06));return;}if(tDbStoreData.sms_class!=WMS_MESSAGE_CLASS_2){
-zUfiSms_Ack_new_msg(TRUE);}zUfiSms_CmgrNvSet();zUfiSms_CheckMemoryFull(
-ZTE_WMS_MEMORY_NV);zUfiSms_ChangeMainState(SMS_STATE_RECVED);
-zUfiSms_SendSmsStatusInfo(MSG_SMS_NEW);zUfiSms_HandleTrafficSms(&tDbStoreData);
-return;}void zUfiSms_ZmgrRespProc(T_zSms_SmsInd*ptRespData){zUfiSms_StoreType
-iStorePos=WMS_STORAGE_TYPE_NV_V01;unsigned char acFormatPdu[ZSMS_PDU_SIZE]={
-(0x19b6+1348-0x1efa)};T_zUfiSms_DbStoreData tDbStoreData;int isPushSms=
-(0x2f9+4293-0x13be);SMS_PARAM one_sms={(0xb03+5728-0x2163)};CHAR defaultStore[
-(0x1154+5303-0x25d9)]={(0x1c2+572-0x3fe)};memset(&tDbStoreData,
-(0x3bd+4483-0x1540),sizeof(T_zUfiSms_DbStoreData));at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x45\x6e\x74\x65\x72\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2f\x70\x64\x75\x3a\x25\x73\x21" "\n"
-,ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);if(
-strcmp(ptRespData->pdu,"")==(0xa8b+6603-0x2456)){CHAR srState[
-(0x16ac+918-0x1a10)]={(0x607+2098-0xe39)};sc_cfg_get(NV_SR_STATE,srState,sizeof(
-srState));if((0xdb4+4069-0x1d99)!=strcmp(srState,
-"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x69\x6e\x67")){sc_cfg_set(
-NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(SMS_STATE_RECVED)
-;}else{sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");}
-return;}isPushSms=DecodePushPdu(ptRespData->pdu,&one_sms);at_print(LOG_DEBUG,
-"\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x20\x69\x73\x50\x75\x73\x68\x53\x6d\x73\x20\x3d\x20\x25\x64" "\n"
-,isPushSms);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x20\x69\x73\x50\x75\x73\x68\x53\x6d\x73\x20\x3d\x25\x64\x20" "\n"
-,isPushSms);if(SMS_NOTIFICATION==isPushSms){BakNotificationSms(one_sms.TP_UD,
-strlen(one_sms.TP_UD));zte_fota_notifyPushMsg((0xb0a+6584-0x24c2));}if(
-SMS_NO_PUSH!=isPushSms){at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x64" "\n"
-,one_sms.index);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x52\x65\x66\x65\x72\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_ReferNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x41\x6c\x6c\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_AllPieceNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x43\x75\x72\x72\x65\x6e\x74\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_CurrentPieceNum);zUfiSms_ChangeMainState(SMS_STATE_RECVED);return;}
-zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);(void)String2Bytes(
-ptRespData->pdu,acFormatPdu,(int)strlen(ptRespData->pdu));if(
-(0x1208+4515-0x23a6)==ptRespData->stat){(void)zUfiSms_HandleReport(acFormatPdu);
-sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");return;}
-sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));if(
-(0x62+2104-0x89a)==strcmp(defaultStore,"\x73\x69\x6d")){iStorePos=
-WMS_STORAGE_TYPE_UIM_V01;}(void)zUfiSms_DecodeSmsData(&tDbStoreData,ptRespData->
-index,iStorePos,(T_SmsStatus)ptRespData->stat,WMS_MESSAGE_FORMAT_GW_PP_V01,
-ptRespData->length,acFormatPdu);if(tDbStoreData.sms_class==WMS_MESSAGE_CLASS_2){
-iStorePos=WMS_STORAGE_TYPE_UIM_V01;}zUfiSms_TrafficChangeSmsTag(&tDbStoreData);
-if(ZTE_WMS_NV_MEMORY_FULL==zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-
-(0x297+4578-0x1478))){return;}if(tDbStoreData.sms_class!=WMS_MESSAGE_CLASS_2){}
-zUfiSms_CmgrNvSet();zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
-zUfiSms_ChangeMainState(SMS_STATE_RECVED);zUfiSms_HandleTrafficSms(&tDbStoreData
-);return;}void zUfiSms_CmgrRespProc(T_zSms_SmsInd*ptRespData){zUfiSms_StoreType
-iStorePos=WMS_STORAGE_TYPE_NV_V01;unsigned char acFormatPdu[ZSMS_PDU_SIZE]={
-(0x8b7+7273-0x2520)};T_zUfiSms_DbStoreData tDbStoreData;int isPushSms=
-(0x54a+8076-0x24d6);SMS_PARAM one_sms={(0x125b+1354-0x17a5)};int
-unread_sms_before_recv_new_sms=(0x4aa+5375-0x19a9);memset(&tDbStoreData,
-(0xda9+3736-0x1c41),sizeof(T_zUfiSms_DbStoreData));at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x45\x6e\x74\x65\x72\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2f\x70\x64\x75\x3a\x25\x73\x21" "\n"
-,ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);
-zUfiSms_SendSmsStatusInfo(MSG_SMS_READING);if(strcmp(ptRespData->pdu,"")==
-(0x1001+3027-0x1bd4)){CHAR srState[(0x21cf+916-0x2531)]={(0x1840+2664-0x22a8)};
-sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));if((0x696+1415-0xc1d)!=strcmp(
-srState,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x69\x6e\x67")){sc_cfg_set(
-NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(SMS_STATE_RECVED)
-;}else{sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");}
-return;}isPushSms=DecodePushPdu(ptRespData->pdu,&one_sms);at_print(LOG_DEBUG,
-"\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x20\x69\x73\x50\x75\x73\x68\x53\x6d\x73\x20\x3d\x20\x25\x64" "\n"
-,isPushSms);at_print(LOG_DEBUG,
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x43\x6d\x67\x72\x52\x65\x73\x70\x50\x72\x6f\x63\x20\x69\x73\x50\x75\x73\x68\x53\x6d\x73\x20\x3d\x25\x64\x20" "\n"
-,isPushSms);if(SMS_NOTIFICATION==isPushSms){BakNotificationSms(one_sms.TP_UD,
-strlen(one_sms.TP_UD));zte_fota_notifyPushMsg((0x301+6959-0x1e30));}if(
-SMS_NO_PUSH!=isPushSms){at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x69\x6e\x64\x65\x78\x20\x3d\x20\x25\x64" "\n"
-,one_sms.index);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x52\x65\x66\x65\x72\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_ReferNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x41\x6c\x6c\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_AllPieceNum);at_print(LOG_DEBUG,
-"\x20\x6f\x6e\x65\x5f\x73\x6d\x73\x2e\x54\x50\x5f\x43\x75\x72\x72\x65\x6e\x74\x50\x69\x65\x63\x65\x4e\x75\x6d\x20\x3d\x20\x25\x64" "\n"
-,one_sms.TP_CurrentPieceNum);zUfiSms_ChangeMainState(SMS_STATE_RECVED);return;}
-zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);(void)String2Bytes(
-ptRespData->pdu,acFormatPdu,(int)strlen(ptRespData->pdu));if(
-(0x135f+3869-0x2277)==ptRespData->stat){(void)zUfiSms_HandleReport(acFormatPdu);
-sc_cfg_set(NV_SR_STATE,"\x73\x72\x5f\x72\x65\x63\x65\x69\x76\x65\x64");return;}(
-void)zUfiSms_DecodeSmsData(&tDbStoreData,ptRespData->index,iStorePos,(
-T_SmsStatus)ptRespData->stat,WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length,
-acFormatPdu);if(tDbStoreData.sms_class==WMS_MESSAGE_CLASS_2){iStorePos=
-WMS_STORAGE_TYPE_UIM_V01;}if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV)){
-unread_sms_before_recv_new_sms=(0xf71+5803-0x261b);}else{
-unread_sms_before_recv_new_sms=(0xd67+1763-0x144a);}if(ZTE_WMS_NV_MEMORY_FULL==
-zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-(0xc16+328-0xd5d))){return;}if(
-tDbStoreData.sms_class!=WMS_MESSAGE_CLASS_2){}zUfiSms_CmgrNvSet();
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);zUfiSms_ChangeMainState(
-SMS_STATE_RECVED);return;}void zUfiSms_CmgsRespProc(VOID){T_zUfiSms_StatusInfo
-tStatusInfo={(0x700+2008-0xed8)};g_zUfiSms_DbStoreData->msg_displaymode=
-g_displaymode;if(g_zUfiSms_DbStoreData->msg_displaymode!=(0x1bbc+2507-0x2586)){
-if((0x1bd4+1105-0x2025)==zUfiSms_WriteSmsToDb(&g_zUfiSms_DbStoreData[
-g_zUfiSms_CurConcatSegNo-(0x35f+2529-0xd3f)],WMS_STORAGE_TYPE_NV_V01,-
-(0x183+1522-0x774))){g_zUfiSms_MsgRefer++;(void)zUfiSms_SetMaxReference(
-g_zUfiSms_MsgRefer);}}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x67\x73\x52\x73\x70\x20\x73\x65\x67\x4e\x6f\x3a\x25\x64\x2f\x54\x6f\x74\x61\x6c\x4e\x75\x6d\x3a\x25\x64\x2f\x46\x61\x69\x6c\x4e\x75\x6d\x3a\x25\x64\x2e" "\n"
-,g_zUfiSms_CurConcatSegNo,g_zUfiSms_ConcatTotalNum,g_zUfiSms_SendFailedCount);if
-(g_zUfiSms_CurConcatSegNo==g_zUfiSms_ConcatTotalNum){g_zUfiSms_CurConcatSegNo=
-(0x362+8307-0x23d5);memset((void*)&tStatusInfo,(0x183+5112-0x157b),sizeof(
-T_zUfiSms_StatusInfo));tStatusInfo.err_code=ZTE_SMS_CMS_NONE;tStatusInfo.
-send_failed_count=g_zUfiSms_SendFailedCount;tStatusInfo.delete_failed_count=
-(0x866+7294-0x24e4);if(g_zUfiSms_SendFailedCount==(0xa62+1848-0x119a)){
-tStatusInfo.cmd_status=WMS_CMD_SUCCESS;sc_cfg_set(NV_SMS_SEND_RESULT,"\x6f\x6b")
-;}else{tStatusInfo.cmd_status=WMS_CMD_FAILED;sc_cfg_set(NV_SMS_SEND_RESULT,
-"\x66\x61\x69\x6c");}tStatusInfo.cmd=WMS_SMS_CMD_MSG_SEND;(void)
-zUfiSms_SetCmdStatus(&tStatusInfo);sc_cfg_set(NV_SMS_DB_CHANGE,"\x31");
-zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);if(g_zUfiSms_MemFullFlag[
-WMS_STORAGE_TYPE_NV_V01]){zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);}}else{}}
-int zte_fota_notifyPushMsg(int cmd){FOTA_MSG_BUF msg={(0x8f+7512-0x1de7)};int
-errs=(0x5a0+6377-0x1e89);key_t req_id=ftok(
-"\x2f\x6d\x65\x64\x69\x61\x2f\x7a\x74\x65\x2f\x7a\x74\x65\x5f\x73\x6f\x63\x6b\x65\x74\x2f\x66\x6f\x74\x61\x5f\x64\x6d\x61\x70\x70\x5f\x6d\x73\x67"
-,(0x138f+1262-0x187c));int msgid=msgget(req_id,(0x205+558-0x433));if(msgid!=-
-(0x334+1294-0x841)){msg.mtype=(0x6c3+245-0x7b7);msg.mtext[(0x1a46+1438-0x1fe4)]=
-WEBUI_NOTIFY_PUSH_MSG_;errs=msgsnd(msgid,&msg,sizeof(msg)-sizeof(long),
-(0x42a+6169-0x1c43));}return(errs<(0x505+8564-0x2679)?(0x13c8+4378-0x24e2):
-(0x556+5523-0x1ae8));}
-#if (0x979+7072-0x2519)
-int atSms_SendCmglReq(PSTR pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){return
-zSvr_SendAtSyn(ZAT_CMGL_CMD,"\x41\x54\x2b\x43\x4d\x47\x4c\x3d\x30" "\r\n",cid,
-pAtRst,atRstSize);}VOID atSms_RecvCmglRsp(T_zAt_AtRes*pResLine){return;}
+ if(needAck)
+ {
+ zSms_SendCnmaReq(1);
+ }
+ else
+ {
+ zSms_SendCnmaReq(2);
+ }
+}
+
+
+/* ·¢ËͶÌÐÅ */
+T_zUfiSms_CmdStatus zUfiSms_SendRawSms(T_zUfiSms_SendReq *ptSendMsg)
+{
+ if(NULL == ptSendMsg || 0 == ptSendMsg->receiver_count)
+ {
+ return WMS_CMD_FAILED;
+ }
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_SendRawSms receiver_count:%d/dest_num:%s/msg_len:%d/id:%d.\n",ptSendMsg->receiver_count,ptSendMsg->dest_num[0],ptSendMsg->msg_len,ptSendMsg->id);
+ #if 1//corem for debug
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_SendRawSms dcs:%d\n",ptSendMsg->dcs);
+ #endif
+
+ sc_cfg_set(NV_SMS_SEND_RESULT, "");
+ g_zUfiSms_SendFailedCount = 0;
+
+ // Ö¸¶¨ÒªÉ¾³ý£¬»òÕßÊǴӲݸåÏäÖлñÈ¡(idÓÐЧ)£¬ÏÈɾ³ýÔ¶ÌÐÅ¡£*/
+ if (ptSendMsg->isDelete == TRUE || -1 != ptSendMsg->id)
+ {
+ (void)zUfiSms_DeleteDraftSms(ptSendMsg->id);
+ }
+
+ //¼Ç¼±àÂë¸ñʽºÍÓïÑÔ£¬ºóÐøÄÚÈÝת»»Ê±Ê¹ÓÃ
+ zUfiSms_SetGlobalDcsLang(ptSendMsg->dcs);
+
+ // Ìî³äȺ·¢¼Ç¼
+ memset(&g_zUfiSms_GroupSms,0,sizeof(g_zUfiSms_GroupSms));
+ if(ZUFI_FAIL == zUfiSms_FillGroupSms(ptSendMsg, &g_zUfiSms_GroupSms))//kw 3
+ {
+ return WMS_CMD_FAILED;
+ }
+
+ // ²ð·Ö¼¶Áª¶ÌÐÅ£¬ÄÚÈÝÌîµ½g_zUfiSms_ConcatSmsÖУ¬·µ»Ø¶ÌÐŵĵ¥Î»³¤¶È
+ memset(&g_zUfiSms_ConcatSms,0,sizeof(g_zUfiSms_ConcatSms));
+ g_zUfiSms_UnitLen = zUfiSms_FillConcatSms(ptSendMsg,&g_zUfiSms_ConcatSms);
+
+ g_zUfiSms_IsConcatSendSuc = TRUE;
+ g_zUfiSms_CurConcatSegNo = 0;
+ memset(g_zUfiSms_DbStoreData,0,sizeof(g_zUfiSms_DbStoreData));
+
+ //for traffic
+ //Á÷Á¿Ð£×¼¹¦ÄÜ·¢Ë͵ĶÌÐŲ»ÐèÒªÏÔʾ¸øWEBUI
+ if(ptSendMsg->mem_store == 10)
+ {
+ g_displaymode = 1;
+ at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 1\n");
+ }
+ else
+ {
+ g_displaymode = 0;
+ at_print(LOG_DEBUG,"[SMS][traffic]zUfiSms_SendSms: msg_displaymode = 0\n");
+ }
+ return zUfiSms_SendSms();
+}
+
+T_zUfiSms_CmdStatus zUfiSms_WriteRawSms(T_zUfiSms_SaveReq *pSaveBuff)
+{
+ T_zUfiSms_ConcatInfo tConcatSms;
+ T_zUfiSms_GroupInfo tGroupSms;
+ int iSmsLen = 0;
+ T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
+
+ if(NULL == pSaveBuff)
+ {
+ return WMS_CMD_FAILED;
+ }
+
+ if (g_zUfiSms_MemFullFlag[ZTE_WMS_MEMORY_NV])
+ {
+ // NVÒÑÂú
+ at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms nv memory is full,return\n");
+ //g_zUfiSms_StatusInfo.err_code = ZTE_SMS_CMS_MEM_FULL;
+ return WMS_CMD_FAILED;
+ }
+
+ if (pSaveBuff->isDelete == TRUE)
+ {
+ (void)zUfiSms_DeleteDraftSms(pSaveBuff->id);
+ }
+ zUfiSms_SetGlobalDcsLang(pSaveBuff->dcs);
+
+ memset(&tConcatSms,0,sizeof(T_zUfiSms_ConcatInfo));
+ memset(&tGroupSms,0,sizeof(T_zUfiSms_GroupInfo));
+ (void)zUfiSms_FillGroupSms(pSaveBuff,&tGroupSms);
+ iSmsLen = zUfiSms_FillConcatSms(pSaveBuff,&tConcatSms);
+
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms total_receiver=%d,iSmsLen=%d\n",tGroupSms.total_receiver,iSmsLen);
+ //°´ÕÕ·¢¼þÈË£¬Öð¸ö½øÐжÌÐű£´æ
+ for(tGroupSms.current_receiver = 0; tGroupSms.current_receiver < tGroupSms.total_receiver; tGroupSms.current_receiver++)
+ {
+ tConcatSms.current_sending = 0;
+ result = zUfiSms_SaveSmsToDb(pSaveBuff,&tConcatSms,&tGroupSms,iSmsLen);
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_WriteRawSms current_receiver=%d,result=%d\n",tGroupSms.current_receiver,result);
+ }
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+
+ zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
+ {
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
+ }
+
+ at_print(LOG_DEBUG,"[SMS] zUfiSms_WriteRawSms end and result=%d\n",result);
+ return result;
+
+}
+
+T_zUfiSms_CmdStatus zUfiSms_DeleteSms(T_zUfiSms_DelReq *ptDelBuff)
+{
+ T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
+ BOOL memoryFullbeforeDelete = FALSE;
+ BOOL unreadBeforeDelete = FALSE;
+
+ if(NULL == ptDelBuff)
+ {
+ return WMS_CMD_FAILED;
+ }
+ at_print(LOG_DEBUG, "[SMS] !!!!!zUfiSms_DeleteSms!!count:%d/id[%d].\n",ptDelBuff->all_or_count,ptDelBuff->id[0]);
+ (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ zUfiSms_ChangeMainState(SMS_STATE_DELING);
+
+ // ¹¹Ôì¶ÌÐŵÄÏêϸɾ³ýÐÅÏ¢
+ memset(&g_zUfiSms_DelMsg,0,sizeof(T_zUfiSms_DelSms));
+ if(ZUFI_FAIL == zUfiSms_SetDeleteInfo(ptDelBuff))
+ {
+ at_print(LOG_DEBUG,"[SMS] !!!zUfiSms_SetDeleteInfo fail.\n");
+ zUfiSms_ChangeMainState(SMS_STATE_DELED);
+ return WMS_CMD_FAILED;
+ }
+ at_print(LOG_DEBUG, "[SMS] !!!zUfiSms_SetDeleteInfo Read to Delete:nv_count:%d/sim_count:%d.\n",g_zUfiSms_DelMsg.nv_count,g_zUfiSms_DelMsg.sim_count);
+
+ if(0 < g_zUfiSms_DelMsg.nv_count) /* delete nv sms*/
+ {
+ if(g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
+ {
+ memoryFullbeforeDelete = TRUE;
+ }
+
+ unreadBeforeDelete = zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV);
+
+ result = (T_zUfiSms_CmdStatus)zUfiSms_DeleteNvSms();
+ (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ zUfiSms_ChangeMainState(SMS_STATE_DELED);
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_DeleteNvSms memoryFullbeforeDelete=%d,MemFullFlag(NV)=%d\n",memoryFullbeforeDelete,g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]);
+ if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
+ {
+ //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
+ //sat_print(LOG_DEBUGg_Zmena_value, "%d", 0);
+ //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
+ at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteNvSms: send AT+ZMENA=0\n");
+ //atUnsoli_Report_Zmena("0", cid);
+ zSms_SendZmenaReq(0);
+ }
+
+ if(memoryFullbeforeDelete && !g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01]
+ || unreadBeforeDelete && !zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
+ {
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
+ }
+ }
+ if(0 < g_zUfiSms_DelMsg.sim_count) /*delete sim sms*/
+ {
+ result = zUfiSms_DeleteSimSms();
+ (void)zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_SIM);
+ }
+ at_print(LOG_DEBUG,"[SMS] zUfiSms_DeleteSms result=%d\n",result);
+ return result;
+}
+
+
+// δ¶Á±äÒѶÁ
+T_zUfiSms_CmdStatus zUfiSms_ModifySmsTag(T_zUfiSms_ModifyFlag *ptModifyBuff)
+{
+ unsigned long i = 0;
+ T_zUfiSms_CmdStatus result = WMS_CMD_SUCCESS;
+ char acStorePos[50] = {0};
+
+ if(NULL == ptModifyBuff)
+ {
+ at_print(LOG_ERR,"inputs is null.");
+ return WMS_CMD_FAILED;
+ }
+
+ for(i = 0; i < ptModifyBuff->total_id; i++)
+ {
+ if(ptModifyBuff->id[i] < 1 || ZUFI_FAIL == zUfiSms_UpdateSmsTagInDb(ptModifyBuff->id[i],ptModifyBuff->tags))
+ {
+ result = WMS_CMD_FAILED;
+ }
+ else
+ {
+ result = WMS_CMD_SUCCESS;
+ }
+ }
+
+ if(ZUFI_FAIL == zUfiSms_GetStorePosById("Mem_Store",acStorePos,sizeof(acStorePos),ptModifyBuff->id[0]))
+ {
+ return ZUFI_FAIL;
+ }
+
+ if(0 == strcmp(acStorePos,ZTE_WMS_DB_NV_TABLE)) //!zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV) &&
+ {
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_READING);
+ }
+
+ if(0 == strcmp(acStorePos,ZTE_WMS_DB_SIM_TABLE) && ptModifyBuff->total_id > 0)/*sim sms*/
+ {
+ zUfiSms_ModifyModemSms(ptModifyBuff);
+ }
+ return result;
+}
+
+//ÉèÖöÌÐŲÎÊý
+T_zUfiSms_CmdStatus zUfiSms_SetSmsPara(T_zUfiSms_ParaInfo *ptParaBuff)
+{
+ int atRes = 0;
+ CHAR sca[ZTE_WMS_ADDRESS_DIGIT_MAX_V01 + 1] = {0};
+ CHAR store[20] = {0};
+ CHAR defaultStore[50]={0};
+
+ if (ptParaBuff == ZUFI_NULL)
+ {
+ return WMS_CMD_FAILED;
+ }
+
+ if (strlen(ptParaBuff->sca) != 0)
+ {
+ strncpy(sca, ptParaBuff->sca,sizeof(sca)-1);
+ at_print(LOG_DEBUG, "send ZAT_CSCA_SET_CMD message csca is %s.\n", sca);
+ //atBase_SendMsgToSelf(ZAT_CSCA_SET_CMD, (CHAR *)&tCscaPara, sizeof(tCscaPara));
+ //zhangfen for platform
+ atRes = zSms_SetCscaReq(ptParaBuff->sca);
+ if(atRes != ZSMS_RESULT_OK)
+ {
+ return WMS_CMD_FAILED;
+ }
+ }
+
+ sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
+ if((*(ptParaBuff->default_store) != '\0') &&
+ (0 != strcmp(defaultStore, ptParaBuff->default_store)))
+ {
+
+ //atBase_SendMsgToSelf(ZAT_CNMI_CMD, NULL, 0);
+ //zhangfen for platform
+ //kw 3
+ //if(ptParaBuff->default_store == NULL)
+ //{
+ // sc_cfg_get(NV_DEFAULT_STORE,store,sizeof(store));
+ //}
+ //else
+ {
+ strncpy(store, ptParaBuff->default_store,sizeof(store)-1);
+ }
+ atRes = zSms_SendCnmiReq(store);
+ if(atRes != ZSMS_RESULT_OK)
+ {
+ return WMS_CMD_FAILED;
+ }
+ }
+
+ if(-1 == zUfiSms_SetDbParameters(ptParaBuff))
+ {
+ at_print(LOG_ERR,"set parameters to table failed.");
+ return WMS_CMD_FAILED;
+ }
+
+ //memcpy((VOID *)&g_zUfiSms_CurSmsPara, (VOID *)ptParaBuff, sizeof(T_zUfiSms_ParaInfo));
+
+ return WMS_CMD_SUCCESS;
+}
+
+void zUfiSms_CmgrNvSet(void)
+{
+ char sms_rec_flag[5] = {0};
+ char remind_flag[5];
+ int sms_count = 0;
+ int remind_count =0;
+
+ //NVÖжÌÐÅÊýÁ¿¼ÓÒ»
+ memset(sms_rec_flag,0,sizeof(sms_rec_flag));
+ sc_cfg_get(ZTE_WMS_NVCONFIG_RECEVIED,sms_rec_flag,sizeof(sms_rec_flag));
+ sms_count = atoi(sms_rec_flag);
+ if(sms_count < 0 || sms_count > INT_MAX-1) { //kw 3
+ at_print(LOG_ERR,"[SMS]sms_count err:%d\n", sms_count);
+ return;
+ }
+
+ memset(sms_rec_flag,0,sizeof(sms_rec_flag));
+ snprintf(sms_rec_flag,sizeof(sms_rec_flag),"%d",sms_count + 1);
+
+ sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED, sms_rec_flag);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_LED, sms_rec_flag);
+
+ memset(remind_flag,0,sizeof(remind_flag));
+ snprintf(remind_flag,sizeof(remind_flag),"%d",remind_count+1);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_RECEVIED_REMIND, remind_flag);
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+}
+
+void zUfiSms_CdsRespProc(T_zSms_SmsInd *ptRespData)
+{
+ unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
+ T_zUfiSms_DbStoreData tDbStoreData = { 0 };
+ int isPushSms = 0;
+
+ // ¶ÌÐÅÄÚÈÝΪ¿Õ
+ if (strcmp(ptRespData->pdu,"") == 0)
+ {
+ CHAR srState[50]={0};
+ sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
+ if(0 != strcmp(srState, "sr_receiving"))
+ {
+ //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ }
+ else
+ {
+ // ±¨¸æÊÕµ½
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ }
+ return;
+ }
+
+ zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
+ (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
+
+ /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ */
+ if(5 == ptRespData->stat)
+ {
+ (void)zUfiSms_HandleReport(acFormatPdu);
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ zUfiSms_Ack_new_msg(TRUE);
+ return ;
+ }
+
+ return;
+}
+
+int zUfiSms_CheckIfWholeSms(T_zUfiSms_DbStoreData *data, SMS_MSG_INFO *pmsg)
+{
+ if(data->concat_sms != 1)
+ {
+ return 0;
+ }
+
+ zUfiSms_GetCurrentRecvTotalSeq(data, pmsg);
+
+ at_print(LOG_DEBUG, "[SMS][traffic] zUfiSms_CheckIfWholeSms id = %s, totalSeq = %d,ref =%d,total =%d, seq=%d\n", pmsg->id, atoi(pmsg->total_seq),data->concat_info[0],data->concat_info[1],data->concat_info[2]);
+ if(data->concat_info[1] == atoi(pmsg->total_seq))
+ {
+ return 0;
+ }
+
+ return -1;
+}
+
+void zUfiSms_TrafficChangeSmsTag(T_zUfiSms_DbStoreData *data)
+{
+ CHAR smsNumber[50]={0};
+ sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber));
+ if(0 == strcmp(smsNumber, data->number))
+ {
+ data->tag = WMS_TAG_TYPE_MT_READ_V01;
+ data->msg_displaymode = 1;
+ }
+}
+
+void zUfiSms_HandleTrafficSms(T_zUfiSms_DbStoreData *data)
+{
+ int iSmsId = 0;
+ SMS_MSG_INFO msg = {0};
+ CHAR smsNumber[50]={0};
+ sc_cfg_get(NV_TRAFFIC_SMS_NUMBER,smsNumber,sizeof(smsNumber));
+
+ at_print(LOG_DEBUG, "[SMS][traffic] tDbStoreData.number = %s, traffic_sms_number = %s\n", data->number,smsNumber);
+ if(0 == strcmp(smsNumber, data->number))
+ {
+ if(0 != zUfiSms_CheckIfWholeSms(data, &msg))
+ {
+ at_print(LOG_DEBUG,"[SMS][traffic] cmt ind, recv sms, but not whole sms, wait to recv next seg\n");
+ return;
+ }
+
+ sc_cfg_set(NV_TRAFFIC_RECV_SMS_ID, msg.id);
+ sc_cfg_set(NV_TRAFFIC_SMS_NUMBER, "0");
+ at_print(LOG_DEBUG, "[SMS][traffic] zUfiSms_HandleTrafficSms traffic_recv_sms_id = %s\n", msg.id);
+ }
+
+}
+
+void zUfiSms_CmtRespProc(T_zSms_SmsInd *ptRespData)
+{
+ zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
+ unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
+ T_zUfiSms_DbStoreData tDbStoreData;
+ int isPushSms = 0;
+ SMS_PARAM one_sms = { 0 };
+ int unread_sms_before_recv_new_sms = 0;
+
+ memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
+ at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);
+
+ // ¶ÌÐÅÄÚÈÝΪ¿Õ
+ if (strcmp(ptRespData->pdu,"") == 0 )
+ {
+ CHAR srState[50]={0};
+ sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
+ if(0 != strcmp(srState, "sr_receiving"))
+ {
+ //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ }
+ else
+ {
+ // ±¨¸æÊÕµ½
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ }
+ return;
+ }
+
+ //sleep(1);
+ isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
+ at_print(LOG_DEBUG, "[sms]zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
+ if(SMS_NOTIFICATION == isPushSms) //notification
+ {
+ BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
+ zte_fota_notifyPushMsg(0);
+ }
+
+ if(SMS_NO_PUSH != isPushSms)
+ {
+ /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
+ at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
+ at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
+ at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
+ at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
+
+ //zUfiSms_DelModemSms(one_sms.index);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ zUfiSms_Ack_new_msg(TRUE);
+ return;
+ }
+
+ //»ñȡ״̬
+ zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
+ (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
+
+ /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
+ if(5 == ptRespData->stat)
+ {
+ (void)zUfiSms_HandleReport(acFormatPdu);
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ zUfiSms_Ack_new_msg(TRUE);
+ return ;
+ }
+
+ // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
+ (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
+ WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
+
+ if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
+ {
+ iStorePos = WMS_STORAGE_TYPE_UIM_V01;
+ }
+
+ if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
+ {
+ unread_sms_before_recv_new_sms = 1;
+ }
+ else
+ {
+ unread_sms_before_recv_new_sms = 0;
+ }
+
+ zUfiSms_TrafficChangeSmsTag(&tDbStoreData);
+
+ //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
+ if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
+ {
+ zUfiSms_Ack_new_msg(FALSE);
+ //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
+ //sat_print(LOG_DEBUGg_Zmena_value, "%d", 1);
+ //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
+ //zhangfen for platform
+ //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMENA,1,"1");
+ zSms_SendZmenaReq(1);
+ return;
+ }
+
+ if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
+ {
+ zUfiSms_Ack_new_msg(TRUE);
+ }
+
+ zUfiSms_CmgrNvSet();
+
+ zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_NEW);
+
+ //for traffic sms
+ zUfiSms_HandleTrafficSms(&tDbStoreData);
+ return;
+}
+
+void zUfiSms_ZmgrRespProc(T_zSms_SmsInd *ptRespData)
+{
+ zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
+ unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
+ T_zUfiSms_DbStoreData tDbStoreData;
+ int isPushSms = 0;
+ SMS_PARAM one_sms = { 0 };
+ CHAR defaultStore[50]={0};
+
+ memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
+ at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);
+
+ // ¶ÌÐÅÄÚÈÝΪ¿Õ
+ if (strcmp(ptRespData->pdu,"") == 0 )
+ {
+ CHAR srState[50]={0};
+ sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
+ if(0 != strcmp(srState, "sr_receiving"))
+ {
+ //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ }
+ else
+ {
+ // ±¨¸æÊÕµ½
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ }
+ return;
+ }
+
+ //sleep(1);
+ isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
+ at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms);
+ if(SMS_NOTIFICATION == isPushSms) //notification
+ {
+ BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
+ zte_fota_notifyPushMsg(0);
+ }
+
+ if(SMS_NO_PUSH != isPushSms)
+ {
+ /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
+ at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
+ at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
+ at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
+ at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
+
+ //zUfiSms_DelModemSms(one_sms.index);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ //zUfiSms_Ack_new_msg(TRUE);
+ return;
+ }
+
+ //»ñȡ״̬
+ zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
+ (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
+
+ /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
+ if(5 == ptRespData->stat)
+ {
+ (void)zUfiSms_HandleReport(acFormatPdu);
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ //zUfiSms_Ack_new_msg(TRUE);
+ return ;
+ }
+
+ sc_cfg_get(NV_DEFAULT_STORE,defaultStore,sizeof(defaultStore));
+ if(0 == strcmp(defaultStore, "sim"))
+ {
+ iStorePos = WMS_STORAGE_TYPE_UIM_V01;
+ }
+
+ // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
+ (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
+ WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
+
+ if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
+ {
+ iStorePos = WMS_STORAGE_TYPE_UIM_V01;
+ }
+
+ zUfiSms_TrafficChangeSmsTag(&tDbStoreData);
+
+ //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
+ if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
+ {
+ //zUfiSms_Ack_new_msg(FALSE);
+ //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
+ //sat_print(LOG_DEBUGg_Zmena_value, "%d", 1);
+ //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
+ //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1");
+ return;
+ }
+
+ if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
+ {
+ //zUfiSms_Ack_new_msg(TRUE);
+ }
+
+ zUfiSms_CmgrNvSet();
+
+ zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+
+ //for traffic sms
+ zUfiSms_HandleTrafficSms(&tDbStoreData);
+
+ return;
+}
+
+//unused
+void zUfiSms_CmgrRespProc(T_zSms_SmsInd *ptRespData)
+{
+ zUfiSms_StoreType iStorePos = WMS_STORAGE_TYPE_NV_V01;
+ unsigned char acFormatPdu[ZSMS_PDU_SIZE] = { 0 };
+ T_zUfiSms_DbStoreData tDbStoreData;
+ int isPushSms = 0;
+ SMS_PARAM one_sms = { 0 };
+ int unread_sms_before_recv_new_sms = 0;
+
+ memset(&tDbStoreData,0,sizeof(T_zUfiSms_DbStoreData));
+ at_print(LOG_DEBUG, "[SMS] Enter zUfiSms_CmgrRespProc! index:%d/stat:%d/length:%d/pdu:%s!\n", ptRespData->index,ptRespData->stat,ptRespData->length,ptRespData->pdu);
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_READING);
+ // ¶ÌÐÅÄÚÈÝΪ¿Õ
+ if (strcmp(ptRespData->pdu,"") == 0 )
+ {
+ CHAR srState[50]={0};
+ sc_cfg_get(NV_SR_STATE,srState,sizeof(srState));
+ if(0 != strcmp(srState, "sr_receiving"))
+ {
+ //²»´¦ÓÚÕýÔÚ½ÓÊÕ"¶ÌÐÅ״̬±¨¸æ"µÄ״̬,ÊÕµ½¿Õ¶ÌÐÅ£¬³ö´í
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ }
+ else
+ {
+ // ±¨¸æÊÕµ½
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ }
+ return;
+ }
+
+ //sleep(1);
+ isPushSms=DecodePushPdu(ptRespData->pdu, &one_sms);
+ at_print(LOG_DEBUG, " zUfiSms_CmgrRespProc isPushSms = %d\n",isPushSms);
+ at_print(LOG_DEBUG, "[SMS] zUfiSms_CmgrRespProc isPushSms =%d \n", isPushSms);
+ if(SMS_NOTIFICATION == isPushSms) //notification
+ {
+ BakNotificationSms(one_sms.TP_UD,strlen(one_sms.TP_UD));
+ zte_fota_notifyPushMsg(0);
+ }
+
+ if(SMS_NO_PUSH != isPushSms)
+ {
+ /*ɾ³ýSIM¿¨ÀïµÄ¶ÌÐÅ*/
+ at_print(LOG_DEBUG, " one_sms.index = %d\n",one_sms.index);
+ at_print(LOG_DEBUG, " one_sms.TP_ReferNum = %d\n",one_sms.TP_ReferNum);
+ at_print(LOG_DEBUG, " one_sms.TP_AllPieceNum = %d\n",one_sms.TP_AllPieceNum);
+ at_print(LOG_DEBUG, " one_sms.TP_CurrentPieceNum = %d\n",one_sms.TP_CurrentPieceNum);
+
+ //zUfiSms_DelModemSms(one_sms.index);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ //zUfiSms_Ack_new_msg(TRUE);
+ return;
+ }
+
+ //»ñȡ״̬
+ zUfiSms_GetReportStatus(ptRespData->pdu,&ptRespData->stat);
+ (void)String2Bytes(ptRespData->pdu, acFormatPdu, (int)strlen(ptRespData->pdu));
+
+ /* ÊÕµ½DU_AE ¶ÌÐÅ״̬±¨¸æ,´¦Àí±¨¸æ£¬É¾³ý¶ÔÓ¦¶ÌÐż´¿É */
+ if(5 == ptRespData->stat)
+ {
+ (void)zUfiSms_HandleReport(acFormatPdu);
+ sc_cfg_set(NV_SR_STATE, "sr_received");
+ //zUfiSms_Ack_new_msg(TRUE);
+ return ;
+ }
+
+ // ½«¶ÌÐÅacPdu_Format½âÂë´æÓÚtDb_StoreDataÖÐ
+ (void)zUfiSms_DecodeSmsData(&tDbStoreData, ptRespData->index, iStorePos, (T_SmsStatus)ptRespData->stat,
+ WMS_MESSAGE_FORMAT_GW_PP_V01,ptRespData->length, acFormatPdu);
+
+ if(tDbStoreData.sms_class == WMS_MESSAGE_CLASS_2)
+ {
+ iStorePos = WMS_STORAGE_TYPE_UIM_V01;
+ }
+
+ if(zUfiSms_IsUnreadSms(ZTE_WMS_MEMORY_NV))
+ {
+ unread_sms_before_recv_new_sms = 1;
+ }
+ else
+ {
+ unread_sms_before_recv_new_sms = 0;
+ }
+
+ //дÈëÒ»ÌõжÌÐÅ£¬°üÀ¨Ð´ÈëÒ»¸ö³¤¶ÌÐŵÄseg
+ if(ZTE_WMS_NV_MEMORY_FULL == zUfiSms_WriteSmsToDb(&tDbStoreData,iStorePos,-1))
+ {
+ //zUfiSms_Ack_new_msg(FALSE);
+ //memset(g_Zmena_value,0,sizeof(g_Zmena_value));
+ //sprintf(g_Zmena_value, "%d", 1);
+ //atBase_SendMsgToSelf(ZAT_ZMENA_CMD, g_Zmena_value,sizeof(g_Zmena_value));
+ //zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_LOCAL,MSG_CMD_AT_ZMENA,1,"1");
+ return;
+ }
+
+ if(tDbStoreData.sms_class != WMS_MESSAGE_CLASS_2)
+ {
+ //zUfiSms_Ack_new_msg(TRUE);
+ }
+
+ zUfiSms_CmgrNvSet();
+
+ zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+
+ return;
+}
+
+
+void zUfiSms_CmgsRespProc(VOID)
+{
+ T_zUfiSms_StatusInfo tStatusInfo = {0};
+
+ g_zUfiSms_DbStoreData->msg_displaymode = g_displaymode;
+
+ if(g_zUfiSms_DbStoreData->msg_displaymode != 1)
+ {
+ //²»¹Üʧ°ÜÓë·ñ£¬´æÈë·¢¼þÏ䣬²¢ÉèÖñê¼Ç
+ if(0 == zUfiSms_WriteSmsToDb(&g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1],WMS_STORAGE_TYPE_NV_V01,-1))
+ {
+ g_zUfiSms_MsgRefer++;
+ (void)zUfiSms_SetMaxReference(g_zUfiSms_MsgRefer);
+ }
+ }
+
+ printf("[SMS] atSms_RecvCmgsRsp segNo:%d/TotalNum:%d/FailNum:%d.\n",g_zUfiSms_CurConcatSegNo,g_zUfiSms_ConcatTotalNum,g_zUfiSms_SendFailedCount);
+
+ // ¶ÌÐÅ·¢ËͽáÊø
+ if(g_zUfiSms_CurConcatSegNo == g_zUfiSms_ConcatTotalNum )
+ {
+ g_zUfiSms_CurConcatSegNo = 0;
+
+ memset((void*)&tStatusInfo,0,sizeof(T_zUfiSms_StatusInfo));
+ tStatusInfo.err_code = ZTE_SMS_CMS_NONE;
+ tStatusInfo.send_failed_count = g_zUfiSms_SendFailedCount;
+ tStatusInfo.delete_failed_count = 0;
+ if(g_zUfiSms_SendFailedCount == 0)
+ {
+ tStatusInfo.cmd_status = WMS_CMD_SUCCESS;
+ sc_cfg_set(NV_SMS_SEND_RESULT, "ok");
+ }
+ else
+ {
+ tStatusInfo.cmd_status = WMS_CMD_FAILED;
+ sc_cfg_set(NV_SMS_SEND_RESULT, "fail");
+ }
+ tStatusInfo.cmd = WMS_SMS_CMD_MSG_SEND;
+ (void)zUfiSms_SetCmdStatus(&tStatusInfo);
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+ zUfiSms_CheckMemoryFull(ZTE_WMS_MEMORY_NV);
+ if( g_zUfiSms_MemFullFlag[WMS_STORAGE_TYPE_NV_V01])
+ {
+ zUfiSms_SendSmsStatusInfo(MSG_SMS_DEFAULT);
+ }
+ }
+ else
+ {
+ //¼ÌÐø·¢ËÍÏÂÒ»¸öseg
+ //zUfiSms_SendConcatSms(cid);
+ }
+}
+
+int zte_fota_notifyPushMsg(int cmd)
+{
+ FOTA_MSG_BUF msg = {0};
+ int errs = 0;
+ key_t req_id = ftok("/media/zte/zte_socket/fota_dmapp_msg",1);
+ int msgid=msgget(req_id,0);
+ if (msgid != -1) { //kw 3
+ msg.mtype = 1;
+ msg.mtext[0] = WEBUI_NOTIFY_PUSH_MSG_;
+ errs = msgsnd(msgid, &msg, sizeof(msg)-sizeof(long),0);
+ }
+ return (errs<0?0:1);
+}
+
+#if 0 //ÎÞÓôúÂë
+int atSms_SendCmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ return zSvr_SendAtSyn(ZAT_CMGL_CMD,"AT+CMGL=0\r\n",cid,pAtRst,atRstSize);
+}
+
+VOID atSms_RecvCmglRsp(T_zAt_AtRes *pResLine)
+{
+ return;
+}
#endif
-#if (0x1aa5+1940-0x2239)
-int atSms_SendZmglReq(PSTR pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){int res
-=(0x9cf+952-0xd87);pthread_mutex_lock(&smsdb_mutex);res=zSvr_SendAtSyn(
-ZAT_ZMGL_CMD,"\x41\x54\x2b\x5a\x4d\x47\x4c\x3d\x34" "\r\n",cid,pAtRst,atRstSize)
-;pthread_mutex_unlock(&smsdb_mutex);return res;}VOID atSms_initAtOk(VOID){
-T_zUfiSms_StatusInfo tStatus={(0x374+3933-0x12d1)};sc_cfg_set(NV_SMS_LOAD_RESULT
-,"\x6f\x6b");tStatus.cmd_status=WMS_CMD_SUCCESS;tStatus.cmd=WMS_SMS_CMD_INIT;(
-void)zUfiSms_SetCmdStatus(&tStatus);zUfiSms_ChangeMainState(SMS_STATE_LOADED);}
-int atSms_initAtErr(UINT8*pErrCode){T_zUfiSms_StatusInfo tStatus={
-(0xec4+2318-0x17d2)};sc_cfg_set(NV_SMS_LOAD_RESULT,"\x66\x61\x69\x6c");
-zUfiSms_ChangeMainState(SMS_STATE_LOADED);tStatus.cmd_status=WMS_CMD_FAILED;
-tStatus.cmd=WMS_SMS_CMD_INIT;(void)zUfiSms_SetCmdStatus(&tStatus);return FALSE;}
-VOID atSms_RecvZmglRsp(T_zAt_AtRes*pResLine){static T_zUfiSms_SmsItem tSmsPara={
-(0x157f+1247-0x1a5e)};printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x5a\x6d\x67\x6c\x52\x73\x70\x20\x45\x6e\x74\x65\x72\x20\x70\x64\x75\x46\x6c\x61\x67\x3a\x25\x64\x2f\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2e" "\n"
-,pResLine->pduFlag,pResLine->result);if(pResLine->pduFlag==ZAT_ATRES_PDU_FLAG){
-zUfiSms_CmglRespProc(pResLine,&tSmsPara);}else{memset(&tSmsPara,
-(0x10e5+5423-0x2614),sizeof(T_zUfiSms_SmsItem));(void)zUfiSms_FormatSms(pResLine
-->resParas,sizeof(pResLine->resParas),&tSmsPara,(0x9a5+4514-0x1b46));printf(
-"\x5b\x53\x4d\x53\x5d\x20\x5a\x6d\x67\x6c\x20\x52\x65\x73\x70\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2e" "\n"
-,tSmsPara.index,tSmsPara.stat,tSmsPara.length);}}int atSms_SendCmgrReq(PSTR
-pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){CHAR pAtcmdStr[(0x443+8871-0x26d6)
-]={(0xd5d+4902-0x2083)};iSmsIndex=atoi(pAtCmdPara);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6d\x67\x72\x52\x65\x71\x20\x47\x65\x74\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2e" "\n"
-,iSmsIndex);snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x43\x4d\x47\x52\x3d\x25\x73" "\r\n",pAtCmdPara);return
-zSvr_SendAtSyn(ZAT_CMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}VOID
-atSms_RecvCmgrRsp(T_zAt_AtRes*pResLine){
-#if (0x917+2861-0x1444)
-static T_zUfiSms_SmsItem tSmsPara={(0x172b+1529-0x1d24)};T_zUfiSms_CmgrSetRsp
-tCmgrRsp={(0x150c+400-0x169c)};printf(
-"\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x67\x72\x52\x73\x70\x20\x45\x6e\x74\x65\x72\x20\x70\x64\x75\x46\x6c\x61\x67\x3a\x25\x64\x2f\x50\x61\x72\x61\x73\x3a\x25\x73\x2f\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2e" "\n"
-,pResLine->pduFlag,pResLine->resParas,pResLine->result);if(pResLine->pduFlag==
-ZAT_ATRES_PDU_FLAG){if(ZAT_RESULT_AUTOREPORT!=pResLine->result){printf(
-"\x21\x21\x21\x21\x21\x21\x21\x21\x21\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x67\x72\x52\x73\x70\x20\x67\x65\x74\x20\x72\x65\x73\x75\x6c\x74\x20\x45\x72\x72\x6f\x72\x2e" "\n"
-);return;}tCmgrRsp.index=tSmsPara.index;tCmgrRsp.length=tSmsPara.length;tCmgrRsp
-.stat=tSmsPara.stat;sscanf(pResLine->resParas,"\x25\x35\x30\x30\x73",tCmgrRsp.
-pdu);zUfiSms_CmgrRespProc(&tCmgrRsp);zUfiMmi_SendSmsStatus();sc_cfg_set(
-"\x73\x6d\x73\x5f\x72\x65\x63\x76\x5f\x72\x65\x73\x75\x6c\x74","\x6f\x6b");}else
-{memset(&tSmsPara,(0x1307+4716-0x2573),sizeof(T_zUfiSms_SmsItem));(void)
-zUfiSms_FormatSms(pResLine->resParas,&tSmsPara,(0x733+6534-0x20b7));tSmsPara.
-index=iSmsIndex;printf(
-"\x3d\x3d\x3d\x3d\x3d\x3d\x43\x6d\x67\x72\x20\x52\x65\x73\x70\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2e" "\n"
-,tSmsPara.index,tSmsPara.stat,tSmsPara.length);}
+
+#if 0 //zhangfen for platform
+int atSms_SendZmglReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ int res = 0;
+ pthread_mutex_lock(&smsdb_mutex);
+ res = zSvr_SendAtSyn(ZAT_ZMGL_CMD,"AT+ZMGL=4\r\n",cid,pAtRst,atRstSize);
+ pthread_mutex_unlock(&smsdb_mutex);
+ return res;
+}
+
+
+
+VOID atSms_initAtOk(VOID)
+{
+ T_zUfiSms_StatusInfo tStatus = {0};
+ //´Ë´¦»áµ¼ÖÂcmglÔÙ·¢Ò»´Î¼ÓÔØµ½ME´¦
+ //zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+ sc_cfg_set(NV_SMS_LOAD_RESULT, "ok");
+ tStatus.cmd_status = WMS_CMD_SUCCESS;
+ tStatus.cmd = WMS_SMS_CMD_INIT;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+ zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+}
+
+int atSms_initAtErr(UINT8 *pErrCode)
+{
+ T_zUfiSms_StatusInfo tStatus = {0};
+
+ sc_cfg_set(NV_SMS_LOAD_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_LOADED);
+
+ tStatus.cmd_status = WMS_CMD_FAILED;
+ tStatus.cmd = WMS_SMS_CMD_INIT;
+ (void)zUfiSms_SetCmdStatus(&tStatus);
+ return FALSE;
+}
+
+VOID atSms_RecvZmglRsp(T_zAt_AtRes *pResLine)
+{
+ static T_zUfiSms_SmsItem tSmsPara = {0};
+
+ printf("[SMS] atSms_RecvZmglRsp Enter pduFlag:%d/result:%d.\n",pResLine->pduFlag,pResLine->result);
+ if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
+ {
+ zUfiSms_CmglRespProc(pResLine, &tSmsPara);
+ }
+ else
+ {
+ //ÊÕµ½Ò»ÌõÐÂcmglºó£¬½«+cmgl:1,2,"",152¸ñʽ»¯²¢´æ´¢IndexºÍstatus¡¢length
+ memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
+ (void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,1);
+ printf("[SMS] Zmgl Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
+ }
+}
+
+int atSms_SendCmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ CHAR pAtcmdStr[20] = {0};
+
+ iSmsIndex = atoi(pAtCmdPara);
+ printf("[SMS] atSms_SendCmgrReq Get index:%d.\n",iSmsIndex);
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGR=%s\r\n", pAtCmdPara);
+ return zSvr_SendAtSyn(ZAT_CMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+}
+
+VOID atSms_RecvCmgrRsp(T_zAt_AtRes *pResLine)
+{
+#if 0
+ static T_zUfiSms_SmsItem tSmsPara = {0};
+ T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
+
+ printf("atSms_RecvCmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
+
+ if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
+ {
+
+ if(ZAT_RESULT_AUTOREPORT != pResLine->result)
+ {
+ printf("!!!!!!!!!atSms_RecvCmgrRsp get result Error.\n");
+ return;
+ }
+
+ tCmgrRsp.index = tSmsPara.index;
+ tCmgrRsp.length = tSmsPara.length;
+ tCmgrRsp.stat = tSmsPara.stat;
+ sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
+ //strcpy(tCmgrRsp.pdu, pResLine->resParas);
+
+ zUfiSms_CmgrRespProc(&tCmgrRsp);
+ zUfiMmi_SendSmsStatus();
+ sc_cfg_set("sms_recv_result", "ok");
+ }
+ else
+ {
+ //ÊÕµ½Ò»ÌõÐÂcmgrºó£¬½«+cmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ
+ memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
+
+ (void)zUfiSms_FormatSms(pResLine->resParas, &tSmsPara,2);
+ tSmsPara.index = iSmsIndex;
+ printf("======Cmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
+ }
+ #endif
+}
+
+int atSms_SendZmgrReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ CHAR pAtcmdStr[20] = {0};
+
+ iSmsIndex = atoi(pAtCmdPara);
+ printf("[SMS] atSms_SendZmgrReq Get index:%d.\n",iSmsIndex);
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMGR=%s\r\n", pAtCmdPara);
+ return zSvr_SendAtSyn(ZAT_ZMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+}
+
+VOID atSms_RecvZmgrOk(T_zAt_AtRes *pResLine, UINT8 *nextAt)
+{
+ return;
+}
+
+VOID atSms_RecvZmgrErr(T_zAt_AtRes *pResLine, UINT8 *nextAt)
+{
+ at_print(LOG_DEBUG,"SMS zmgr is fail\n");
+ at_print(LOG_DEBUG"[SMS] atSms_RecvZmgrErr SMS zmgr is fail\n");
+ //if(0 != strcmp(cfg_safe_get("sr_state"), "sr_receiving"))
+ {
+ //¶ÌÐŽÓÊÕʧ°Ü£¬ÓÖ·Ç״̬±¨¸æ×´Ì¬
+ sc_cfg_set(NV_SMS_RECV_RESULT, "fail");
+ zUfiSms_ChangeMainState(SMS_STATE_RECVED);
+ }
+}
+
+VOID atSms_RecvZmgrRsp(T_zAt_AtRes *pResLine)
+{
+ static T_zUfiSms_SmsItem tSmsPara = {0};
+ T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
+
+ printf("[SMS] atSms_RecvZmgrRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
+
+ if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
+ {
+
+ if(ZAT_RESULT_AUTOREPORT != pResLine->result)
+ {
+ printf("[SMS] atSms_RecvZmgrRsp get result Error.\n");
+ return;
+ }
+
+ tCmgrRsp.index = tSmsPara.index;
+ tCmgrRsp.length = tSmsPara.length;
+ tCmgrRsp.stat = tSmsPara.stat;
+ sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
+ //strcpy(tCmgrRsp.pdu, pResLine->resParas);
+
+ zUfiSms_ZmgrRespProc(&tCmgrRsp);
+ zUfiMmi_SendSmsStatus();
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+ }
+ else
+ {
+ //ÊÕµ½Ò»ÌõÐÂzmgrºó£¬½«+zmgr:1,"",68¸ñʽ»¯²¢´æ´¢status¡¢length, ²»Ð¯´øË÷ÒýÖµ
+ memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
+
+ (void)zUfiSms_FormatSms(pResLine->resParas, sizeof(pResLine->resParas), &tSmsPara,2);
+ tSmsPara.index = iSmsIndex;
+ printf("[SMS] Zmgr Resp! index:%d/stat:%d/length:%d.\n", tSmsPara.index,tSmsPara.stat,tSmsPara.length);
+ }
+}
+
+
+int atSms_SendCmgdReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ CHAR pAtcmdStr[20] = {0};
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGD=%s\r\n", pAtCmdPara);
+ return zSvr_SendAtSyn(ZAT_CMGD_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+}
+
+VOID atSms_RecvCmgdOk(VOID)
+{
+ CHAR strUsed[10] = {0};
+ int used = 0;
+
+ sc_cfg_set(NV_SMS_DEL_RESULT, "ok");
+ printf("[SMS] set sim_del_result to OK. \n");
+
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
+ used = atoi(strUsed)-1;
+ if(used < 0)
+ {
+ used = 0;
+ }
+ memset(&strUsed, 0, 10);
+ snprintf(strUsed,sizeof(strUsed),"%d", used);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_USED, strUsed);
+}
+
+VOID atSms_RecvCmgdErr(VOID)
+{
+
+ sc_cfg_set(NV_SMS_DEL_RESULT, "fail");
+ printf("[SMS] set sim_del_result to fail. \n");
+}
+
+VOID atSms_RecvCmgdFinish(VOID)
+{
+ char StrValue[10] = {0};
+ CHAR strTotal[10] = {0};
+ CHAR strUsed[10] = {0};
+ int total = 0;
+ int used = 0;
+ int remain = 0;
+
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));
+ used = atoi(strUsed);
+ sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strTotal,sizeof(strTotal));
+ total = atoi(strTotal);
+ remain = total - used;
+ if(remain < 0)
+ {
+ remain = 0;
+ }
+
+ memset(&StrValue, 0, 10);
+ snprintf(StrValue,sizeof(StrValue),"%d", remain);
+ sc_cfg_set(ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue);
+ printf("[SMS] zUfiSms_DeleteSimSms used=%d,remain=%d,total=%d\n",used,remain,total);
+ zUfiSms_ChangeMainState(SMS_STATE_DELED);
+ sc_cfg_set(NV_SMS_DB_CHANGE,"1");
+}
+
+
+int atSms_SendCmgsReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ int atRes = 0;
+ CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0};
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CMGS=%d\r\n", g_zUfiSms_FinalCmgsBuf.length);
+ atRes = zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+ if(atRes != ZAT_RESULT_SMS)
+ {
+ return atRes;
+ }
+
+ memset(pAtcmdStr, 0, ZSMS_PDU_SIZE);
+ //assert(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE);
+ //Áôһλ¸ø½áβ·û
+ if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)< ZSMS_PDU_SIZE-1)
+ {
+ memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, strlen(g_zUfiSms_FinalCmgsBuf.pdu));
+ }
+ else
+ {
+ printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",g_zUfiSms_FinalCmgsBuf.pdu);
+ memcpy(pAtcmdStr, g_zUfiSms_FinalCmgsBuf.pdu, ZSMS_PDU_SIZE-2);
+ }
+ // Ìí¼Ó½áβ·û
+ *(pAtcmdStr + strlen(g_zUfiSms_FinalCmgsBuf.pdu)) = ZSMS_CTRL_Z_CHAR;
+ memset(pAtRst, 0, atRstSize);
+ return zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+}
+
+
+VOID atSms_RecvCmgsOk(UINT8 *pResLine, int cid)
+{
+ at_print(LOG_DEBUG,"sms sended success. \n");
+ g_zUfiSms_CurConcatSegNo++;
+
+ if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ return;
+ }
+
+ //·¢Ëͳɹ¦Ò»½Ú
+ g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_SENT_V01;
+
+ zUfiSms_CmgsRespProc(cid);
+}
+
+VOID atSms_RecvCmgsErr(UINT8 *pResLine, int cid)
+{
+ at_print(LOG_DEBUG,"sms sended fail. \n");
+ g_zUfiSms_CurConcatSegNo++;
+ if(g_zUfiSms_CurConcatSegNo > ZTE_WMS_CONCAT_SMS_COUNT_MAX)
+ {
+ return;
+ }
+
+ //ʧ°ÜÊýÁ¿£¬×îÖÕдÈëÊý¾Ý¿â
+ g_zUfiSms_SendFailedCount++;
+
+ at_print(LOG_DEBUG,"send sms failed,so write sms to draftbox.\n");
+ g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-1].tag = WMS_TAG_TYPE_MO_NOT_SENT_V01;
+ if(g_zUfiSms_ConcatTotalNum > 1)
+ {
+ // ³¤¶ÌÐÅ·¢ËÍʧ°Ü£¬ÖÃΪfalse
+ g_zUfiSms_IsConcatSendSuc = FALSE;
+ }
+
+ zUfiSms_CmgsRespProc(cid);
+}
+
+
+VOID atSms_RecvCmgsRsp(T_zAt_AtRes *pResLine)
+{
+ return;
+}
+
+
+VOID atSms_RecvCmtRsp(T_zAt_AtRes *pResLine)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+
+ static T_zUfiSms_SmsItem tSmsPara = {0};
+ T_zUfiSms_CmtSetRsp tCmtRsp = {0};
+
+ if(NULL == pResLine)
+ {
+ return;
+ }
+
+ printf("[SMS] atSms_RecvCmtRsp Enter pduFlag:%d/Paras:%s/result:%d.\n",pResLine->pduFlag,pResLine->resParas,pResLine->result);
+
+ if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
+ {
+
+ if(ZAT_RESULT_AUTOREPORT != pResLine->result)
+ {
+ printf("[SMS] atSms_RecvCmtRsp get result Error.\n");
+ return;
+ }
+
+ tCmtRsp.length = tSmsPara.length;
+ sscanf(pResLine->resParas,"%500s", tCmtRsp.pdu);
+
+ pthread_mutex_lock(&smsdb_mutex);
+ zUfiSms_CmtRespProc(&tCmtRsp);
+ zUfiMmi_SendSmsStatus();
+ pthread_mutex_unlock(&smsdb_mutex);
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+ }
+ else
+ {
+ memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
+ atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas));
+ printf("[SMS] cmt ind! pResLine->resParas:%s.\n", pResLine->resParas);
+ sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length);
+ printf("[SMS] cmt ind! length:%d.\n", tSmsPara.length);
+ }
+}
+
+VOID atSms_RecvCmtiRsp(T_zAt_AtRes *pResLine)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ char sms_Main_state[30]={0};
+ char * memory = NULL;
+
+ printf("[SMS] atSms_RecvCmtiRsp enter %s.\n",pResLine->resParas);
+
+ if(NULL == pResLine)
+ {
+ return;
+ }
+
+ if(ZAT_CMTI_CMD != pResLine->atCmdId)
+ {
+ return;
+ }
+
+ //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
+ sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
+ if(strcmp(sms_Main_state,"sms_deling")==0)
+ {
+ printf("[SMS] atSms_RecvCmtiRsp: sms_deling\n");
+ return;
+ }
+
+ // ÉèÖöÌÐÅ´æ´¢ÇøÓò£¬ZMGRÈ¥¶ÁÈ¡
+ memory = strstr(pResLine->resParas,"\"");
+ if(NULL != memory)
+ {
+ memory++;
+ }
+
+ if(0 == strncmp("SM", memory, 2))
+ {
+ zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVING);
+ memory += 4;
+ printf("[SMS] send cmgr: %s\n",memory);
+ zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory);
+ }
+ else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
+ {
+ printf("[SMS] atSms_RecvCmtiRsp :store location not SM.\n");
+ }
+ sc_cfg_set(NV_SMS_RECV_RESULT, "");
+}
+
+VOID atSms_RecvCdsRsp(T_zAt_AtRes *pResLine)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ static T_zUfiSms_SmsItem tSmsPara = {0};
+ T_zUfiSms_CmgrSetRsp tCmgrRsp = {0};
+
+ if(NULL == pResLine)
+ {
+ return;
+ }
+
+ if(pResLine->pduFlag == ZAT_ATRES_PDU_FLAG)
+ {
+
+ if(ZAT_RESULT_AUTOREPORT != pResLine->result)
+ {
+ printf("[SMS] atSms_RecvCdsRsp get result Error.\n");
+ return;
+ }
+
+ tCmgrRsp.length = tSmsPara.length;
+ sscanf(pResLine->resParas,"%500s", tCmgrRsp.pdu);
+
+ pthread_mutex_lock(&smsdb_mutex);
+ zUfiSms_CdsRespProc(&tCmgrRsp);
+ zUfiMmi_SendSmsStatus();
+ pthread_mutex_unlock(&smsdb_mutex);
+ sc_cfg_set(NV_SMS_RECV_RESULT, "ok");
+ }
+ else
+ {
+ memset(&tSmsPara,0,sizeof(T_zUfiSms_SmsItem));
+ atBase_PreProcRes(pResLine->resParas, sizeof(pResLine->resParas));
+ printf("[SMS] cds ind! pResLine->resParas:%s.\n", pResLine->resParas);
+ sscanf(pResLine->resParas,"%s %d", tSmsPara.alpha, &tSmsPara.length);
+ printf("[SMS] atSms_RecvCdsRsp cds ind! length:%d.\n", tSmsPara.length);
+ }
+}
+
+VOID atSms_RecvCdsiRsp(T_zAt_AtRes *pResLine)
+{
+ //ÅжÏÊÇ·ñÖ§³ÖSMS
+ //added by wenqin 2016-5-18
+ CHAR needSMS[50] = {0};
+ sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));
+ if(0 == strcmp(needSMS, "no"))
+ {
+ printf("[SMS]atSms_RecvCmtRsp needSMS=no!");
+ return;
+ }
+
+ char sms_Main_state[30]={0};
+ char * memory = NULL;
+
+ printf("[SMS] atSms_RecvCdsiRsp enter %s.\n",pResLine->resParas);
+
+ if(NULL == pResLine)
+ {
+ return;
+ }
+
+ if(ZAT_CDSI_CMD != pResLine->atCmdId)
+ {
+ return;
+ }
+
+ //ɾ³ý¹ý³ÌÖв»½ÓÊÜжÌÐÅ
+ sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
+ if(strcmp(sms_Main_state,"sms_deling")==0)
+ {
+ printf("[SMS] atSms_RecvCdsiRsp: sms_deling\n");
+ return;
+ }
+
+ memory = strstr(pResLine->resParas,"\"");
+ if(NULL != memory)
+ {
+ memory++;
+ }
+ printf("[SMS] atSms_RecvCdsiRsp: memory = %s\n", memory);
+ if(0 == strncmp("SM", memory, 2))
+ {
+ zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);
+ zUfiSms_ChangeMainState(SMS_STATE_RECVING);
+ memory += 4;
+ printf("[SMS] send cmgr: %s\n",memory);
+ zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,MSG_CMD_AT_ZMGR,strlen(memory),memory);
+ }
+ else //Ä£¿éÔÚÖØÆôºó¾³£³öÏÖ¶ÌÐŴ洢λÖÃΪSRµÄÇé¿ö
+ {
+ printf("[SMS] atSms_RecvCdsiRsp :store location not SM.\n");
+ }
+ sc_cfg_set(NV_SMS_RECV_RESULT, "");
+}
+
+int atSms_SendZmenaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ CHAR pAtcmdStr[20] = {0};
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+ZMENA=%s\r\n", pAtCmdPara);
+ return zSvr_SendAtSyn(ZAT_ZMENA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+}
+
+VOID atSms_RecvZmenaOk(VOID)
+{
+ g_Zmena_rsp = TRUE;
+ return;
+}
+
+VOID atSms_RecvZmenaErr(VOID)
+{
+ g_Zmena_rsp = FALSE;
+ return;
+}
+
+
+int atSms_SendCnmaReq(PSTR pAtCmdPara, int cid, PSTR pAtRst, int atRstSize)
+{
+ int atRes = 0;
+ CHAR pAtcmdStr[ZSMS_PDU_SIZE] = {0};
+ CHAR ackPduStr[50] = {0};
+
+ if(atoi(pAtCmdPara) == 1)
+ {
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s\r\n", pAtCmdPara);
+ atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+ printf("[SMS] atSms_SendCnmaReq 111111 ack ok = %s.\n", pAtcmdStr);
+ return 0;
+ }
+ else
+ {
+ zUfiSms_EncodePdu_DeliverReport(ackPduStr, 0xD3);
+
+ snprintf(pAtcmdStr, sizeof(pAtcmdStr),"AT+CNMA=%s,%d\r\n", pAtCmdPara, strlen(ackPduStr)/2);
+ atRes = zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+ if(atRes != ZAT_RESULT_SMS)
+ {
+ return atRes;
+ }
+ printf("[SMS] atSms_SendCnmaReq = %s.\n", pAtcmdStr);
+
+ memset(pAtcmdStr, 0, ZSMS_PDU_SIZE);
+
+ if(strlen(ackPduStr)< ZSMS_PDU_SIZE-1)
+ {
+ memcpy(pAtcmdStr, ackPduStr, strlen(ackPduStr));
+ }
+ else
+ {
+ printf("[SMS] atSms_SendCmgsReq pdu too long:%s\n",ackPduStr);
+ memcpy(pAtcmdStr, ackPduStr, ZSMS_PDU_SIZE-2);
+ }
+
+ // Ìí¼Ó½áβ·û
+ *(pAtcmdStr + strlen(ackPduStr)) = ZSMS_CTRL_Z_CHAR;
+ printf("[SMS] atSms_SendCnmaReq. pdu= %s\n", pAtcmdStr);
+ memset(pAtRst, 0, atRstSize);
+ return zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);
+ }
+
+}
+
+VOID atSms_RecvCnmaRsp(T_zAt_AtRes *pResLine)
+{
+ return;
+}
+
+
+VOID atUnsoli_Delete_Sim_Sms(UINT8 *pDatabuf, int cid)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+
+ if(pDatabuf == NULL)
+ {
+ return;
+ }
+ atRes = atSms_SendCmgdReq(pDatabuf, cid, errCode, ZSVR_AT_RES_CODE_LEN);
+ if(atRes == ZSMS_RESULT_OK)
+ {
+ atSms_RecvCmgdOk();
+ }
+ else
+ {
+ atSms_RecvCmgdErr();
+ }
+ atSms_RecvCmgdFinish();
+}
+
+
+VOID atUnsoli_Report_Cnma(UINT8 *pDatabuf, int cid)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ if(pDatabuf == NULL)
+ {
+ printf("[SMS] atUnsoli_Report_Cnma null");
+ return;
+ }
+ atSms_SendCnmaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
+}
+
+
+VOID atUnsoli_Report_Zmena(UINT8 *pDatabuf, int cid)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ int atRes = 0;
+
+ if(pDatabuf == NULL)
+ {
+ printf("[SMS] atUnsoli_Report_Zmena null");
+ return;
+ }
+
+ atRes = atSms_SendZmenaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
+ if(atRes == ZSMS_RESULT_OK)
+ {
+ atSms_RecvZmenaOk();
+ }
+ else
+ {
+ atSms_RecvZmenaErr();
+ }
+}
+
+VOID atUnsoli_Report_Zmgr(UINT8 *pDatabuf, int cid)
+{
+ CHAR errCode[ZSVR_AT_RES_CODE_LEN] = {0};
+ if(pDatabuf == NULL)
+ {
+ printf("[SMS] atUnsoli_Report_Zmgr null");
+ return;
+ }
+ atSms_SendZmgrReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);
+}
#endif
-}int atSms_SendZmgrReq(PSTR pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){CHAR
-pAtcmdStr[(0x12ec+4760-0x2570)]={(0x1e5a+1155-0x22dd)};iSmsIndex=atoi(pAtCmdPara
-);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x5a\x6d\x67\x72\x52\x65\x71\x20\x47\x65\x74\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2e" "\n"
-,iSmsIndex);snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x5a\x4d\x47\x52\x3d\x25\x73" "\r\n",pAtCmdPara);return
-zSvr_SendAtSyn(ZAT_ZMGR_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}VOID
-atSms_RecvZmgrOk(T_zAt_AtRes*pResLine,UINT8*nextAt){return;}VOID
-atSms_RecvZmgrErr(T_zAt_AtRes*pResLine,UINT8*nextAt){at_print(LOG_DEBUG,
-"\x53\x4d\x53\x20\x7a\x6d\x67\x72\x20\x69\x73\x20\x66\x61\x69\x6c" "\n");
-at_print(LOG_DEBUG
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x5a\x6d\x67\x72\x45\x72\x72\x20\x20\x53\x4d\x53\x20\x7a\x6d\x67\x72\x20\x69\x73\x20\x66\x61\x69\x6c" "\n"
-);{sc_cfg_set(NV_SMS_RECV_RESULT,"\x66\x61\x69\x6c");zUfiSms_ChangeMainState(
-SMS_STATE_RECVED);}}VOID atSms_RecvZmgrRsp(T_zAt_AtRes*pResLine){static
-T_zUfiSms_SmsItem tSmsPara={(0x753+3546-0x152d)};T_zUfiSms_CmgrSetRsp tCmgrRsp={
-(0x1ef3+1207-0x23aa)};printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x5a\x6d\x67\x72\x52\x73\x70\x20\x45\x6e\x74\x65\x72\x20\x70\x64\x75\x46\x6c\x61\x67\x3a\x25\x64\x2f\x50\x61\x72\x61\x73\x3a\x25\x73\x2f\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2e" "\n"
-,pResLine->pduFlag,pResLine->resParas,pResLine->result);if(pResLine->pduFlag==
-ZAT_ATRES_PDU_FLAG){if(ZAT_RESULT_AUTOREPORT!=pResLine->result){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x5a\x6d\x67\x72\x52\x73\x70\x20\x67\x65\x74\x20\x72\x65\x73\x75\x6c\x74\x20\x45\x72\x72\x6f\x72\x2e" "\n"
-);return;}tCmgrRsp.index=tSmsPara.index;tCmgrRsp.length=tSmsPara.length;tCmgrRsp
-.stat=tSmsPara.stat;sscanf(pResLine->resParas,"\x25\x35\x30\x30\x73",tCmgrRsp.
-pdu);zUfiSms_ZmgrRespProc(&tCmgrRsp);zUfiMmi_SendSmsStatus();sc_cfg_set(
-NV_SMS_RECV_RESULT,"\x6f\x6b");}else{memset(&tSmsPara,(0x164+6948-0x1c88),sizeof
-(T_zUfiSms_SmsItem));(void)zUfiSms_FormatSms(pResLine->resParas,sizeof(pResLine
-->resParas),&tSmsPara,(0x1d1b+2531-0x26fc));tSmsPara.index=iSmsIndex;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x5a\x6d\x67\x72\x20\x52\x65\x73\x70\x21\x20\x69\x6e\x64\x65\x78\x3a\x25\x64\x2f\x73\x74\x61\x74\x3a\x25\x64\x2f\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2e" "\n"
-,tSmsPara.index,tSmsPara.stat,tSmsPara.length);}}int atSms_SendCmgdReq(PSTR
-pAtCmdPara,int cid,PSTR pAtRst,int atRstSize){CHAR pAtcmdStr[(0x27d+4796-0x1525)
-]={(0x97d+1670-0x1003)};snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x43\x4d\x47\x44\x3d\x25\x73" "\r\n",pAtCmdPara);return
-zSvr_SendAtSyn(ZAT_CMGD_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}VOID
-atSms_RecvCmgdOk(VOID){CHAR strUsed[(0x1690+1574-0x1cac)]={(0x913+4519-0x1aba)};
-int used=(0x1bd3+2499-0x2596);sc_cfg_set(NV_SMS_DEL_RESULT,"\x6f\x6b");printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x74\x20\x73\x69\x6d\x5f\x64\x65\x6c\x5f\x72\x65\x73\x75\x6c\x74\x20\x74\x6f\x20\x4f\x4b\x2e\x20" "\n"
-);sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));used=atoi(
-strUsed)-(0x9c0+3095-0x15d6);if(used<(0x1763+1318-0x1c89)){used=
-(0x114c+1414-0x16d2);}memset(&strUsed,(0x7c+677-0x321),(0x152f+1998-0x1cf3));
-snprintf(strUsed,sizeof(strUsed),"\x25\x64",used);sc_cfg_set(
-ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed);}VOID atSms_RecvCmgdErr(VOID){sc_cfg_set
-(NV_SMS_DEL_RESULT,"\x66\x61\x69\x6c");printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x74\x20\x73\x69\x6d\x5f\x64\x65\x6c\x5f\x72\x65\x73\x75\x6c\x74\x20\x74\x6f\x20\x66\x61\x69\x6c\x2e\x20" "\n"
-);}VOID atSms_RecvCmgdFinish(VOID){char StrValue[(0x206f+386-0x21e7)]={
-(0xacb+3889-0x19fc)};CHAR strTotal[(0x156b+799-0x1880)]={(0x192c+1325-0x1e59)};
-CHAR strUsed[(0xa58+4353-0x1b4f)]={(0x34c+8283-0x23a7)};int total=
-(0x1064+5727-0x26c3);int used=(0xe0d+3097-0x1a26);int remain=(0x430+258-0x532);
-sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_USED,strUsed,sizeof(strUsed));used=atoi(
-strUsed);sc_cfg_get(ZTE_WMS_NVCONFIG_SIM_CARD_TOTAL,strTotal,sizeof(strTotal));
-total=atoi(strTotal);remain=total-used;if(remain<(0xa0+7377-0x1d71)){remain=
-(0xf35+1527-0x152c);}memset(&StrValue,(0x1482+3767-0x2339),(0x4c+8372-0x20f6));
-snprintf(StrValue,sizeof(StrValue),"\x25\x64",remain);sc_cfg_set(
-ZTE_WMS_NVCONFIG_SIM_CARD_REMAIN,StrValue);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x7a\x55\x66\x69\x53\x6d\x73\x5f\x44\x65\x6c\x65\x74\x65\x53\x69\x6d\x53\x6d\x73\x20\x75\x73\x65\x64\x3d\x25\x64\x2c\x72\x65\x6d\x61\x69\x6e\x3d\x25\x64\x2c\x74\x6f\x74\x61\x6c\x3d\x25\x64" "\n"
-,used,remain,total);zUfiSms_ChangeMainState(SMS_STATE_DELED);sc_cfg_set(
-NV_SMS_DB_CHANGE,"\x31");}int atSms_SendCmgsReq(PSTR pAtCmdPara,int cid,PSTR
-pAtRst,int atRstSize){int atRes=(0xe4b+3483-0x1be6);CHAR pAtcmdStr[ZSMS_PDU_SIZE
-]={(0xba+3074-0xcbc)};snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x43\x4d\x47\x53\x3d\x25\x64" "\r\n",g_zUfiSms_FinalCmgsBuf.length)
-;atRes=zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);if(atRes!=
-ZAT_RESULT_SMS){return atRes;}memset(pAtcmdStr,(0x190c+644-0x1b90),ZSMS_PDU_SIZE
-);if(strlen(g_zUfiSms_FinalCmgsBuf.pdu)<ZSMS_PDU_SIZE-(0x12dc+1160-0x1763)){
-memcpy(pAtcmdStr,g_zUfiSms_FinalCmgsBuf.pdu,strlen(g_zUfiSms_FinalCmgsBuf.pdu));
-}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6d\x67\x73\x52\x65\x71\x20\x70\x64\x75\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x25\x73" "\n"
-,g_zUfiSms_FinalCmgsBuf.pdu);memcpy(pAtcmdStr,g_zUfiSms_FinalCmgsBuf.pdu,
-ZSMS_PDU_SIZE-(0x610+601-0x867));}*(pAtcmdStr+strlen(g_zUfiSms_FinalCmgsBuf.pdu)
-)=ZSMS_CTRL_Z_CHAR;memset(pAtRst,(0xb7+1731-0x77a),atRstSize);return
-zSvr_SendAtSyn(ZAT_CMGS_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}VOID
-atSms_RecvCmgsOk(UINT8*pResLine,int cid){at_print(LOG_DEBUG,
-"\x73\x6d\x73\x20\x73\x65\x6e\x64\x65\x64\x20\x73\x75\x63\x63\x65\x73\x73\x2e\x20" "\n"
-);g_zUfiSms_CurConcatSegNo++;if(g_zUfiSms_CurConcatSegNo>
-ZTE_WMS_CONCAT_SMS_COUNT_MAX){return;}g_zUfiSms_DbStoreData[
-g_zUfiSms_CurConcatSegNo-(0x17d+9261-0x25a9)].tag=WMS_TAG_TYPE_MO_SENT_V01;
-zUfiSms_CmgsRespProc(cid);}VOID atSms_RecvCmgsErr(UINT8*pResLine,int cid){
-at_print(LOG_DEBUG,
-"\x73\x6d\x73\x20\x73\x65\x6e\x64\x65\x64\x20\x66\x61\x69\x6c\x2e\x20" "\n");
-g_zUfiSms_CurConcatSegNo++;if(g_zUfiSms_CurConcatSegNo>
-ZTE_WMS_CONCAT_SMS_COUNT_MAX){return;}g_zUfiSms_SendFailedCount++;at_print(
-LOG_DEBUG,
-"\x73\x65\x6e\x64\x20\x73\x6d\x73\x20\x66\x61\x69\x6c\x65\x64\x2c\x73\x6f\x20\x77\x72\x69\x74\x65\x20\x73\x6d\x73\x20\x74\x6f\x20\x64\x72\x61\x66\x74\x62\x6f\x78\x2e" "\n"
-);g_zUfiSms_DbStoreData[g_zUfiSms_CurConcatSegNo-(0x5bc+3822-0x14a9)].tag=
-WMS_TAG_TYPE_MO_NOT_SENT_V01;if(g_zUfiSms_ConcatTotalNum>(0x1198+3115-0x1dc2)){
-g_zUfiSms_IsConcatSendSuc=FALSE;}zUfiSms_CmgsRespProc(cid);}VOID
-atSms_RecvCmgsRsp(T_zAt_AtRes*pResLine){return;}VOID atSms_RecvCmtRsp(
-T_zAt_AtRes*pResLine){CHAR needSMS[(0x10b5+773-0x1388)]={(0x209+3612-0x1025)};
-sc_cfg_get(NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0xe41+3041-0x1a22)==
-strcmp(needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}static T_zUfiSms_SmsItem tSmsPara={(0x19d9+2833-0x24ea)};
-T_zUfiSms_CmtSetRsp tCmtRsp={(0xab0+4246-0x1b46)};if(NULL==pResLine){return;}
-printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x45\x6e\x74\x65\x72\x20\x70\x64\x75\x46\x6c\x61\x67\x3a\x25\x64\x2f\x50\x61\x72\x61\x73\x3a\x25\x73\x2f\x72\x65\x73\x75\x6c\x74\x3a\x25\x64\x2e" "\n"
-,pResLine->pduFlag,pResLine->resParas,pResLine->result);if(pResLine->pduFlag==
-ZAT_ATRES_PDU_FLAG){if(ZAT_RESULT_AUTOREPORT!=pResLine->result){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x67\x65\x74\x20\x72\x65\x73\x75\x6c\x74\x20\x45\x72\x72\x6f\x72\x2e" "\n"
-);return;}tCmtRsp.length=tSmsPara.length;sscanf(pResLine->resParas,
-"\x25\x35\x30\x30\x73",tCmtRsp.pdu);pthread_mutex_lock(&smsdb_mutex);
-zUfiSms_CmtRespProc(&tCmtRsp);zUfiMmi_SendSmsStatus();pthread_mutex_unlock(&
-smsdb_mutex);sc_cfg_set(NV_SMS_RECV_RESULT,"\x6f\x6b");}else{memset(&tSmsPara,
-(0xb79+3209-0x1802),sizeof(T_zUfiSms_SmsItem));atBase_PreProcRes(pResLine->
-resParas,sizeof(pResLine->resParas));printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x6d\x74\x20\x69\x6e\x64\x21\x20\x70\x52\x65\x73\x4c\x69\x6e\x65\x2d\x3e\x72\x65\x73\x50\x61\x72\x61\x73\x3a\x25\x73\x2e" "\n"
-,pResLine->resParas);sscanf(pResLine->resParas,"\x25\x73\x20\x25\x64",tSmsPara.
-alpha,&tSmsPara.length);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x6d\x74\x20\x69\x6e\x64\x21\x20\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2e" "\n"
-,tSmsPara.length);}}VOID atSms_RecvCmtiRsp(T_zAt_AtRes*pResLine){CHAR needSMS[
-(0x3a+4255-0x10a7)]={(0x1997+2178-0x2219)};sc_cfg_get(NV_NEED_SUPPORT_SMS,
-needSMS,sizeof(needSMS));if((0x1f9+9003-0x2524)==strcmp(needSMS,"\x6e\x6f")){
-printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}char sms_Main_state[(0xe6f+3877-0x1d76)]={(0x12b9+2632-0x1d01)};char*
-memory=NULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x69\x52\x73\x70\x20\x65\x6e\x74\x65\x72\x20\x25\x73\x2e" "\n"
-,pResLine->resParas);if(NULL==pResLine){return;}if(ZAT_CMTI_CMD!=pResLine->
-atCmdId){return;}sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
-if(strcmp(sms_Main_state,"\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67")==
-(0x1246+1277-0x1743)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x69\x52\x73\x70\x3a\x20\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67" "\n"
-);return;}memory=strstr(pResLine->resParas,"\"");if(NULL!=memory){memory++;}if(
-(0x7+3385-0xd40)==strncmp("\x53\x4d",memory,(0x14e2+4183-0x2537))){
-zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);zUfiSms_ChangeMainState(
-SMS_STATE_RECVING);memory+=(0x682+7316-0x2312);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x6e\x64\x20\x63\x6d\x67\x72\x3a\x20\x25\x73" "\n"
-,memory);zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,
-MSG_CMD_AT_ZMGR,strlen(memory),memory);}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x69\x52\x73\x70\x20\x3a\x73\x74\x6f\x72\x65\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x6e\x6f\x74\x20\x53\x4d\x2e" "\n"
-);}sc_cfg_set(NV_SMS_RECV_RESULT,"");}VOID atSms_RecvCdsRsp(T_zAt_AtRes*pResLine
-){CHAR needSMS[(0x1429+2746-0x1eb1)]={(0x519+4865-0x181a)};sc_cfg_get(
-NV_NEED_SUPPORT_SMS,needSMS,sizeof(needSMS));if((0x1537+3158-0x218d)==strcmp(
-needSMS,"\x6e\x6f")){printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}static T_zUfiSms_SmsItem tSmsPara={(0x1867+1625-0x1ec0)};
-T_zUfiSms_CmgrSetRsp tCmgrRsp={(0x276+5695-0x18b5)};if(NULL==pResLine){return;}
-if(pResLine->pduFlag==ZAT_ATRES_PDU_FLAG){if(ZAT_RESULT_AUTOREPORT!=pResLine->
-result){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x52\x73\x70\x20\x67\x65\x74\x20\x72\x65\x73\x75\x6c\x74\x20\x45\x72\x72\x6f\x72\x2e" "\n"
-);return;}tCmgrRsp.length=tSmsPara.length;sscanf(pResLine->resParas,
-"\x25\x35\x30\x30\x73",tCmgrRsp.pdu);pthread_mutex_lock(&smsdb_mutex);
-zUfiSms_CdsRespProc(&tCmgrRsp);zUfiMmi_SendSmsStatus();pthread_mutex_unlock(&
-smsdb_mutex);sc_cfg_set(NV_SMS_RECV_RESULT,"\x6f\x6b");}else{memset(&tSmsPara,
-(0x1472+4760-0x270a),sizeof(T_zUfiSms_SmsItem));atBase_PreProcRes(pResLine->
-resParas,sizeof(pResLine->resParas));printf(
-"\x5b\x53\x4d\x53\x5d\x20\x63\x64\x73\x20\x69\x6e\x64\x21\x20\x70\x52\x65\x73\x4c\x69\x6e\x65\x2d\x3e\x72\x65\x73\x50\x61\x72\x61\x73\x3a\x25\x73\x2e" "\n"
-,pResLine->resParas);sscanf(pResLine->resParas,"\x25\x73\x20\x25\x64",tSmsPara.
-alpha,&tSmsPara.length);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x52\x73\x70\x20\x63\x64\x73\x20\x69\x6e\x64\x21\x20\x6c\x65\x6e\x67\x74\x68\x3a\x25\x64\x2e" "\n"
-,tSmsPara.length);}}VOID atSms_RecvCdsiRsp(T_zAt_AtRes*pResLine){CHAR needSMS[
-(0x1fdf+312-0x20e5)]={(0x14b8+3005-0x2075)};sc_cfg_get(NV_NEED_SUPPORT_SMS,
-needSMS,sizeof(needSMS));if((0x506+2099-0xd39)==strcmp(needSMS,"\x6e\x6f")){
-printf(
-"\x5b\x53\x4d\x53\x5d\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x6d\x74\x52\x73\x70\x20\x6e\x65\x65\x64\x53\x4d\x53\x3d\x6e\x6f\x21"
-);return;}char sms_Main_state[(0x1419+153-0x1494)]={(0x182b+2074-0x2045)};char*
-memory=NULL;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x20\x65\x6e\x74\x65\x72\x20\x25\x73\x2e" "\n"
-,pResLine->resParas);if(NULL==pResLine){return;}if(ZAT_CDSI_CMD!=pResLine->
-atCmdId){return;}sc_cfg_get(NV_SMS_STATE,sms_Main_state,sizeof(sms_Main_state));
-if(strcmp(sms_Main_state,"\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67")==
-(0xb88+3843-0x1a8b)){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x3a\x20\x73\x6d\x73\x5f\x64\x65\x6c\x69\x6e\x67" "\n"
-);return;}memory=strstr(pResLine->resParas,"\"");if(NULL!=memory){memory++;}
-printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x3a\x20\x6d\x65\x6d\x6f\x72\x79\x20\x3d\x20\x25\x73" "\n"
-,memory);if((0x672+5749-0x1ce7)==strncmp("\x53\x4d",memory,(0x2400+403-0x2591)))
-{zUfiSms_SetSmsLocation(SMS_LOCATION_SIM);zUfiSms_ChangeMainState(
-SMS_STATE_RECVING);memory+=(0x18d4+1384-0x1e38);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x73\x65\x6e\x64\x20\x63\x6d\x67\x72\x3a\x20\x25\x73" "\n"
-,memory);zSvr_InnerSendMsg(ZUFI_MODULE_ID_AT_LOCAL,ZUFI_MODULE_ID_AT_UNSOLI,
-MSG_CMD_AT_ZMGR,strlen(memory),memory);}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x52\x65\x63\x76\x43\x64\x73\x69\x52\x73\x70\x20\x3a\x73\x74\x6f\x72\x65\x20\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x20\x6e\x6f\x74\x20\x53\x4d\x2e" "\n"
-);}sc_cfg_set(NV_SMS_RECV_RESULT,"");}int atSms_SendZmenaReq(PSTR pAtCmdPara,int
- cid,PSTR pAtRst,int atRstSize){CHAR pAtcmdStr[(0x10fc+656-0x1378)]={
-(0xe0f+5854-0x24ed)};snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x5a\x4d\x45\x4e\x41\x3d\x25\x73" "\r\n",pAtCmdPara);return
-zSvr_SendAtSyn(ZAT_ZMENA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}VOID
-atSms_RecvZmenaOk(VOID){g_Zmena_rsp=TRUE;return;}VOID atSms_RecvZmenaErr(VOID){
-g_Zmena_rsp=FALSE;return;}int atSms_SendCnmaReq(PSTR pAtCmdPara,int cid,PSTR
-pAtRst,int atRstSize){int atRes=(0x68a+4025-0x1643);CHAR pAtcmdStr[ZSMS_PDU_SIZE
-]={(0x7f2+1008-0xbe2)};CHAR ackPduStr[(0x172c+1885-0x1e57)]={(0x3c3+4472-0x153b)
-};if(atoi(pAtCmdPara)==(0x6e9+7538-0x245a)){snprintf(pAtcmdStr,sizeof(pAtcmdStr)
-,"\x41\x54\x2b\x43\x4e\x4d\x41\x3d\x25\x73" "\r\n",pAtCmdPara);atRes=
-zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6e\x6d\x61\x52\x65\x71\x20\x31\x31\x31\x31\x31\x31\x20\x61\x63\x6b\x20\x6f\x6b\x20\x3d\x20\x25\x73\x2e" "\n"
-,pAtcmdStr);return(0xd2a+4658-0x1f5c);}else{zUfiSms_EncodePdu_DeliverReport(
-ackPduStr,(0xcef+5558-0x21d2));snprintf(pAtcmdStr,sizeof(pAtcmdStr),
-"\x41\x54\x2b\x43\x4e\x4d\x41\x3d\x25\x73\x2c\x25\x64" "\r\n",pAtCmdPara,strlen(
-ackPduStr)/(0xe50+3389-0x1b8b));atRes=zSvr_SendAtSyn(ZAT_CNMA_CMD,pAtcmdStr,cid,
-pAtRst,atRstSize);if(atRes!=ZAT_RESULT_SMS){return atRes;}printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6e\x6d\x61\x52\x65\x71\x20\x3d\x20\x25\x73\x2e" "\n"
-,pAtcmdStr);memset(pAtcmdStr,(0x412+1275-0x90d),ZSMS_PDU_SIZE);if(strlen(
-ackPduStr)<ZSMS_PDU_SIZE-(0x353+5295-0x1801)){memcpy(pAtcmdStr,ackPduStr,strlen(
-ackPduStr));}else{printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6d\x67\x73\x52\x65\x71\x20\x70\x64\x75\x20\x74\x6f\x6f\x20\x6c\x6f\x6e\x67\x3a\x25\x73" "\n"
-,ackPduStr);memcpy(pAtcmdStr,ackPduStr,ZSMS_PDU_SIZE-(0xe0b+1562-0x1423));}*(
-pAtcmdStr+strlen(ackPduStr))=ZSMS_CTRL_Z_CHAR;printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x53\x6d\x73\x5f\x53\x65\x6e\x64\x43\x6e\x6d\x61\x52\x65\x71\x2e\x20\x70\x64\x75\x3d\x20\x25\x73" "\n"
-,pAtcmdStr);memset(pAtRst,(0x6aa+8231-0x26d1),atRstSize);return zSvr_SendAtSyn(
-ZAT_CNMA_CMD,pAtcmdStr,cid,pAtRst,atRstSize);}}VOID atSms_RecvCnmaRsp(
-T_zAt_AtRes*pResLine){return;}VOID atUnsoli_Delete_Sim_Sms(UINT8*pDatabuf,int
-cid){CHAR errCode[ZSVR_AT_RES_CODE_LEN]={(0x19a7+2215-0x224e)};int atRes=
-(0x196c+196-0x1a30);if(pDatabuf==NULL){return;}atRes=atSms_SendCmgdReq(pDatabuf,
-cid,errCode,ZSVR_AT_RES_CODE_LEN);if(atRes==ZSMS_RESULT_OK){atSms_RecvCmgdOk();}
-else{atSms_RecvCmgdErr();}atSms_RecvCmgdFinish();}VOID atUnsoli_Report_Cnma(
-UINT8*pDatabuf,int cid){CHAR errCode[ZSVR_AT_RES_CODE_LEN]={(0x131c+1462-0x18d2)
-};if(pDatabuf==NULL){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x55\x6e\x73\x6f\x6c\x69\x5f\x52\x65\x70\x6f\x72\x74\x5f\x43\x6e\x6d\x61\x20\x6e\x75\x6c\x6c"
-);return;}atSms_SendCnmaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);}VOID
-atUnsoli_Report_Zmena(UINT8*pDatabuf,int cid){CHAR errCode[ZSVR_AT_RES_CODE_LEN]
-={(0x11f7+2543-0x1be6)};int atRes=(0xb9a+4471-0x1d11);if(pDatabuf==NULL){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x55\x6e\x73\x6f\x6c\x69\x5f\x52\x65\x70\x6f\x72\x74\x5f\x5a\x6d\x65\x6e\x61\x20\x6e\x75\x6c\x6c"
-);return;}atRes=atSms_SendZmenaReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);if
-(atRes==ZSMS_RESULT_OK){atSms_RecvZmenaOk();}else{atSms_RecvZmenaErr();}}VOID
-atUnsoli_Report_Zmgr(UINT8*pDatabuf,int cid){CHAR errCode[ZSVR_AT_RES_CODE_LEN]=
-{(0x1b04+672-0x1da4)};if(pDatabuf==NULL){printf(
-"\x5b\x53\x4d\x53\x5d\x20\x61\x74\x55\x6e\x73\x6f\x6c\x69\x5f\x52\x65\x70\x6f\x72\x74\x5f\x5a\x6d\x67\x72\x20\x6e\x75\x6c\x6c"
-);return;}atSms_SendZmgrReq(pDatabuf,cid,errCode,ZSVR_AT_RES_CODE_LEN);}
-#endif
-
+
diff --git a/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c b/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
index 9c4237d..57bf408 100755
--- a/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
+++ b/ap/app/zte_comm/zte_audio_ctrl/audio_res_ctrl.c
@@ -332,16 +332,15 @@
slog(RTC_PRINT, SLOG_NORMAL, "%s:%s: LINE(%d), moduleId(%x), type(%x), using_type(%d), releasing_type(%d)\n", __FILE__, __FUNCTION__, __LINE__, rel_ind_data->moduleId, rel_ind_data->type, using_type, releasing_type);
}
-//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
static void unregister_exist_app(int moduleId, int type)
{
T_exist_applist *tmp = NULL;
T_exist_applist *node = exist_apphead;
slog(RTC_PRINT, SLOG_NORMAL, "unregister_exist_app: moduleId(%x) type(%d) \n", moduleId, type);
-
+
while (node != NULL)
- {
+ {
if (node->tempSrcId == moduleId && node->type == type)
{
if(NULL != tmp)
@@ -360,7 +359,6 @@
node = node->next;
}
}
-
static void unregister_exist_app_proc(MSG_BUF *msg)
{
T_audio_ExitInd *exitIndData = (T_audio_ExitInd*)(msg->aucDataBuf);
@@ -368,9 +366,8 @@
if(EXIT_AUDIO_REQ == msg->usMsgCmd) {
if (0 > platform_send_msg(MODULE_ID_CODEC, exitIndData->moduleId, EXIT_AUDIO_RSP, 0, NULL))
softap_assert("unregister_exist_app_proc function: send USE_AUDIO_RSP msg error\n");
- }
+ }
}
-//LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
/*******************************************************************************
* È«¾Öº¯Êý¶¨Òå *
@@ -434,10 +431,8 @@
break;
case EXIT_AUDIO_IND:
- //LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_START
case EXIT_AUDIO_REQ:
unregister_exist_app_proc(&msg);
- //LYNQ_MODIFY_ZXW_BUG_340_202410260E4E4183_END
break;
default:
slog(RTC_PRINT, SLOG_NORMAL, "%s: %s LINE(%d) other msg: MsgCmd(%d), srcId(%d), dstId(%d)\n", __FILE__, __FUNCTION__, __LINE__, msg.usMsgCmd, msg.src_id, msg.dst_id);
diff --git a/ap/lib/libatreg/atreg.c b/ap/lib/libatreg/atreg.c
index c3f1a50..21eefde 100755
--- a/ap/lib/libatreg/atreg.c
+++ b/ap/lib/libatreg/atreg.c
@@ -281,20 +281,20 @@
* @note ÎÞ
* @warning ÎÞ
*/
-static void atreg_ser_allocation_proc(void* patreg_ser_instance)
+static int atreg_ser_allocation_proc(void* patreg_ser_instance)
{
int i,j;
pthread_mutex_lock(&atreg_ser_ctx.at_ser_idpool_lock);
- for (i =0; i < ATREG_SER_ID_MAX; i++) {
+ for (i = 0; i < ATREG_SER_ID_MAX; i++) {
for (j = 7; j >= 0; j--) {
- if (0 == atreg_ser_dynamic_idpool[i] & (1 << j)) {
+ if (0 == (int)(atreg_ser_dynamic_idpool[i] & (1 << j))) {
((struct atreg_ser_instance_t *)patreg_ser_instance)->req_msg_id = 8 * (i + 1) - (j + 1);
((struct atreg_ser_instance_t *)patreg_ser_instance)->rsp_msg_id = 8 * (i + 1) - (j + 1) + 1;
atreg_ser_dynamic_idpool[i] = atreg_ser_dynamic_idpool[i] | (1 << j);
atreg_ser_dynamic_idpool[i] = atreg_ser_dynamic_idpool[i] | (1 << (j - 1));
pthread_mutex_unlock(&atreg_ser_ctx.at_ser_idpool_lock);
- return;
+ return 0;
}
}
}
@@ -302,7 +302,7 @@
slog(ATREG_PRINT, SLOG_ERR, "Err: atreg_ser_allocation_proc id pool is FULL\n");
- return;
+ return -1;
}
@@ -313,18 +313,18 @@
* @note ÎÞ
* @warning ÎÞ
*/
-static void atreg_info_allocation_proc(void* patreg_info_instance)
+static int atreg_info_allocation_proc(void* patreg_info_instance)
{
int i,j;
pthread_mutex_lock(&atreg_info_ctx.at_info_idpool_lock);
for (i = 0; i < ATREG_INFO_ID_MAX; i++) {
for (j = 7; j >= 0; j--) {
- if (0 == atreg_info_dynamic_idpool[i] & (1 << j)) {
+ if (0 == (int)(atreg_info_dynamic_idpool[i] & (1 << j))) {
((struct atreg_info_instance_t *)patreg_info_instance)->req_msg_id = 8 * (i + 1) - (j + 1) + 512;
atreg_info_dynamic_idpool[i] = atreg_info_dynamic_idpool[i] | (1 << j);
pthread_mutex_unlock(&atreg_info_ctx.at_info_idpool_lock);
- return;
+ return 0;
}
}
}
@@ -332,7 +332,7 @@
slog(ATREG_PRINT, SLOG_ERR, "Err: atreg_info_allocation_proc id pool is FULL\n");
- return;
+ return -1;
}
@@ -344,20 +344,25 @@
* @note ÎÞ
* @warning ÎÞ
*/
-static void atreg_dynamic_id_allocation(void* patreg_instance, int atreg_type)
+static int atreg_dynamic_id_allocation(void* patreg_instance, int atreg_type)
{
+ int ret = -1;
+
switch (atreg_type) {
case AT_REG_SER:
- atreg_ser_allocation_proc(patreg_instance);
+ ret = atreg_ser_allocation_proc(patreg_instance);
break;
case AT_REG_INFO:
- atreg_info_allocation_proc(patreg_instance);
+ ret = atreg_info_allocation_proc(patreg_instance);
break;
default:
+ slog(ATREG_PRINT, SLOG_ERR, "Err: atreg_dynamic_id_allocation type invalid\n");
break;
}
+
+ return ret;
}
@@ -387,7 +392,11 @@
}
/* ¶¯Ì¬·ÖÅäreq_msg_idÓërsp_msg_id */
- atreg_dynamic_id_allocation((void *)patreg_ser_instance, AT_REG_SER);
+ if (0 != atreg_dynamic_id_allocation((void *)patreg_ser_instance, AT_REG_SER))
+ {
+ slog(ATREG_PRINT, SLOG_ERR, "Err: serv atreg_dynamic_id_allocation fail\n");
+ return -1;
+ }
/* »º´æatʵÀý */
pthread_mutex_lock(&atreg_ser_ctx.at_ser_lock_tmp);
@@ -480,7 +489,11 @@
}
/* ¶¯Ì¬·ÖÅäreq_msg_id */
- atreg_dynamic_id_allocation((void *)patreg_info_instance, AT_REG_INFO);
+ if (0 != atreg_dynamic_id_allocation((void *)patreg_info_instance, AT_REG_INFO))
+ {
+ slog(ATREG_PRINT, SLOG_ERR, "Err: info atreg_dynamic_id_allocation fail\n");
+ return -1;
+ }
/* »º´æatʵÀý */
pthread_mutex_lock(&atreg_info_ctx.at_info_lock_tmp);
diff --git a/ap/lib/liblpa/libes10.a b/ap/lib/liblpa/libes10.a
index 66d79b1..e87178f 100755
--- a/ap/lib/liblpa/libes10.a
+++ b/ap/lib/liblpa/libes10.a
Binary files differ
diff --git a/ap/lib/libnvram/libnvram.a b/ap/lib/libnvram/libnvram.a
index baf9cb2..1454f24 100755
--- a/ap/lib/libnvram/libnvram.a
+++ b/ap/lib/libnvram/libnvram.a
Binary files differ
diff --git a/ap/lib/libnvram/libnvram.so b/ap/lib/libnvram/libnvram.so
index c682cc1..199b514 100755
--- a/ap/lib/libnvram/libnvram.so
+++ b/ap/lib/libnvram/libnvram.so
Binary files differ
diff --git a/ap/lib/libnvram/libnvram_sc.a b/ap/lib/libnvram/libnvram_sc.a
index cbb52ed..e0e3d4d 100755
--- a/ap/lib/libnvram/libnvram_sc.a
+++ b/ap/lib/libnvram/libnvram_sc.a
Binary files differ
diff --git a/ap/lib/libnvram/libnvram_sc.so b/ap/lib/libnvram/libnvram_sc.so
index 162bdd7..817cf4c 100755
--- a/ap/lib/libnvram/libnvram_sc.so
+++ b/ap/lib/libnvram/libnvram_sc.so
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/amt/amt.a b/ap/lib/libps/220A1_vehicle_dc/amt/amt.a
index 84c72e7..9732042 100755
--- a/ap/lib/libps/220A1_vehicle_dc/amt/amt.a
+++ b/ap/lib/libps/220A1_vehicle_dc/amt/amt.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.a b/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.a
index 07df78b..5952da8 100755
--- a/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.a
+++ b/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.o b/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.o
index 732ddd3..f4c27cc 100755
--- a/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.o
+++ b/ap/lib/libps/220A1_vehicle_dc/appstart/appstart.o
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/amr.a b/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
index 187ec92..cb556d7 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/amr.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a b/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
index 86f1c59..24b65fb 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/audio_base.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/chip.a b/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
index 3db7692..ae5600d 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/chip.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a b/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
index dc9d1da..e98dcfc 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/drv_sdk.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/public.a b/ap/lib/libps/220A1_vehicle_dc/drv/public.a
index 9d314de..c0f7cc3 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/public.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/public.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a b/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
index 4f66fb5..3be1810 100755
--- a/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
+++ b/ap/lib/libps/220A1_vehicle_dc/drv/webrtc.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/gsml1/dwddrv.a b/ap/lib/libps/220A1_vehicle_dc/gsml1/dwddrv.a
index 8b9934d..2a7b83b 100755
--- a/ap/lib/libps/220A1_vehicle_dc/gsml1/dwddrv.a
+++ b/ap/lib/libps/220A1_vehicle_dc/gsml1/dwddrv.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/gsml1/l1g.a b/ap/lib/libps/220A1_vehicle_dc/gsml1/l1g.a
index a79497a..a9b9ef7 100755
--- a/ap/lib/libps/220A1_vehicle_dc/gsml1/l1g.a
+++ b/ap/lib/libps/220A1_vehicle_dc/gsml1/l1g.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_crypto.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_crypto.a
index 5fb42fc..3dcfa6a 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_crypto.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_crypto.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_mbedtls.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_mbedtls.a
index 5f7c974..8a8146f 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_mbedtls.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_mbedtls.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_ta.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_ta.a
index f7e3731..2e5980e 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_ta.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_ta.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_tee.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_tee.a
index 6e1d75a..a58c507 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_tee.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_tee.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_tomcrypt.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_tomcrypt.a
index 643cfe8..9f89fff 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_tomcrypt.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_tomcrypt.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_utee.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_utee.a
index e6427f5..2d08af3 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_utee.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_utee.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/optee/optee_utils.a b/ap/lib/libps/220A1_vehicle_dc/optee/optee_utils.a
index 078684a..09268a6 100755
--- a/ap/lib/libps/220A1_vehicle_dc/optee/optee_utils.a
+++ b/ap/lib/libps/220A1_vehicle_dc/optee/optee_utils.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/phy/phy.a b/ap/lib/libps/220A1_vehicle_dc/phy/phy.a
index 221fb21..192a307 100755
--- a/ap/lib/libps/220A1_vehicle_dc/phy/phy.a
+++ b/ap/lib/libps/220A1_vehicle_dc/phy/phy.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_osa_linux.a b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_osa_linux.a
index 3deb800..bb1ee8b 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_osa_linux.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_osa_linux.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_psm.a b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_psm.a
index f8c8246..e1e504b 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_psm.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_psm.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_sup.a b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_sup.a
index 9859e8e..26516bf 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_sup.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/armv7-a/GCC/plat_sup.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/plat_osa_linux.a b/ap/lib/libps/220A1_vehicle_dc/plat/plat_osa_linux.a
index 3deb800..bb1ee8b 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/plat_osa_linux.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/plat_osa_linux.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/plat_psm.a b/ap/lib/libps/220A1_vehicle_dc/plat/plat_psm.a
index f8c8246..e1e504b 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/plat_psm.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/plat_psm.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/plat/plat_sup.a b/ap/lib/libps/220A1_vehicle_dc/plat/plat_sup.a
index 9859e8e..26516bf 100755
--- a/ap/lib/libps/220A1_vehicle_dc/plat/plat_sup.a
+++ b/ap/lib/libps/220A1_vehicle_dc/plat/plat_sup.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/as_com.a b/ap/lib/libps/220A1_vehicle_dc/ps/as_com.a
index 182a36e..a3a295c 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/as_com.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/as_com.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/as_gsm.a b/ap/lib/libps/220A1_vehicle_dc/ps/as_gsm.a
index 01ec57f..cbd8e40 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/as_gsm.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/as_gsm.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/ati.a b/ap/lib/libps/220A1_vehicle_dc/ps/ati.a
index dd7a54e..ca8f01d 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/ati.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/ati.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/com.a b/ap/lib/libps/220A1_vehicle_dc/ps/com.a
index 9ca0119..3fb0155 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/com.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/com.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/el2_up.a b/ap/lib/libps/220A1_vehicle_dc/ps/el2_up.a
index 8c969c2..b411dac 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/el2_up.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/el2_up.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/eudbg.a b/ap/lib/libps/220A1_vehicle_dc/ps/eudbg.a
index b5aaf50..277180e 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/eudbg.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/eudbg.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/eurrc.a b/ap/lib/libps/220A1_vehicle_dc/ps/eurrc.a
index 4ec205c..3ea07e2 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/eurrc.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/eurrc.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/l1e.a b/ap/lib/libps/220A1_vehicle_dc/ps/l1e.a
index 8ecc6eb..57984d1 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/l1e.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/l1e.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/nas.a b/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
index d0d3d03..c21f362 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/ul1t.a b/ap/lib/libps/220A1_vehicle_dc/ps/ul1t.a
index 9d101b3..177e56c 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/ul1t.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/ul1t.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/ul2_up.a b/ap/lib/libps/220A1_vehicle_dc/ps/ul2_up.a
index e337c09..80c428c 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/ul2_up.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/ul2_up.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/urrc.a b/ap/lib/libps/220A1_vehicle_dc/ps/urrc.a
index 891317a..bda9b4d 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/urrc.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/urrc.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/wl1w.a b/ap/lib/libps/220A1_vehicle_dc/ps/wl1w.a
index 3ceb9e6..f512e8f 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/wl1w.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/wl1w.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/wl2_up.a b/ap/lib/libps/220A1_vehicle_dc/ps/wl2_up.a
index 2da16c2..c65a888 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/wl2_up.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/wl2_up.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/psbase/base.a b/ap/lib/libps/220A1_vehicle_dc/psbase/base.a
index 6f8efc7..d5e6986 100755
--- a/ap/lib/libps/220A1_vehicle_dc/psbase/base.a
+++ b/ap/lib/libps/220A1_vehicle_dc/psbase/base.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ref/com.a b/ap/lib/libps/220A1_vehicle_dc/ref/com.a
index 978c340..e8c331c 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ref/com.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ref/com.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ref/ref_drv.a b/ap/lib/libps/220A1_vehicle_dc/ref/ref_drv.a
index 10376c2..c066615 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ref/ref_drv.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ref/ref_drv.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/tools/tools.a b/ap/lib/libps/220A1_vehicle_dc/tools/tools.a
index a584bc6..9b8fa5a 100755
--- a/ap/lib/libps/220A1_vehicle_dc/tools/tools.a
+++ b/ap/lib/libps/220A1_vehicle_dc/tools/tools.a
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/usat/usat.a b/ap/lib/libps/220A1_vehicle_dc/usat/usat.a
index dc69ed0..b7bbf8e 100755
--- a/ap/lib/libps/220A1_vehicle_dc/usat/usat.a
+++ b/ap/lib/libps/220A1_vehicle_dc/usat/usat.a
Binary files differ
diff --git a/ap/lib/libsoft_timer/libsoft_timer.a b/ap/lib/libsoft_timer/libsoft_timer.a
index ee18acd..6f70a4c 100755
--- a/ap/lib/libsoft_timer/libsoft_timer.a
+++ b/ap/lib/libsoft_timer/libsoft_timer.a
Binary files differ
diff --git a/ap/lib/libsoft_timer/libsoft_timer.so b/ap/lib/libsoft_timer/libsoft_timer.so
index ade6a44..24406d0 100755
--- a/ap/lib/libsoft_timer/libsoft_timer.so
+++ b/ap/lib/libsoft_timer/libsoft_timer.so
Binary files differ
diff --git a/ap/lib/libsoft_timer/libsoft_timer_sc.a b/ap/lib/libsoft_timer/libsoft_timer_sc.a
index e760be6..91040fc 100755
--- a/ap/lib/libsoft_timer/libsoft_timer_sc.a
+++ b/ap/lib/libsoft_timer/libsoft_timer_sc.a
Binary files differ
diff --git a/ap/lib/libsoft_timer/libsoft_timer_sc.so b/ap/lib/libsoft_timer/libsoft_timer_sc.so
index e17f7f3..49e4777 100755
--- a/ap/lib/libsoft_timer/libsoft_timer_sc.so
+++ b/ap/lib/libsoft_timer/libsoft_timer_sc.so
Binary files differ
diff --git a/ap/lib/libupi_ab/libupi_ab.a b/ap/lib/libupi_ab/libupi_ab.a
index 4b115d9..2ebfcac 100755
--- a/ap/lib/libupi_ab/libupi_ab.a
+++ b/ap/lib/libupi_ab/libupi_ab.a
Binary files differ
diff --git a/ap/lib/libupi_ab/libupi_ab.so b/ap/lib/libupi_ab/libupi_ab.so
index 80ff56a..1de287f 100755
--- a/ap/lib/libupi_ab/libupi_ab.so
+++ b/ap/lib/libupi_ab/libupi_ab.so
Binary files differ
diff --git a/ap/lib/libzcore/min/libbitmap_font.a b/ap/lib/libzcore/min/libbitmap_font.a
index b11ae2f..85ad7f5 100755
--- a/ap/lib/libzcore/min/libbitmap_font.a
+++ b/ap/lib/libzcore/min/libbitmap_font.a
Binary files differ
diff --git a/ap/lib/libzcore/min/libttf_font.a b/ap/lib/libzcore/min/libttf_font.a
index de24bdb..4313916 100755
--- a/ap/lib/libzcore/min/libttf_font.a
+++ b/ap/lib/libzcore/min/libttf_font.a
Binary files differ
diff --git a/ap/lib/libzcore/min/libzcore.a b/ap/lib/libzcore/min/libzcore.a
index 61f9b82..827a8a2 100755
--- a/ap/lib/libzcore/min/libzcore.a
+++ b/ap/lib/libzcore/min/libzcore.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/app_fw.a b/ap/lib/libzcore/std/lib/lib/fwp/app_fw.a
index b64ed91..ff56a86 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/app_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/app_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/bl_psa.a b/ap/lib/libzcore/std/lib/lib/fwp/bl_psa.a
index 16df320..2b7553a 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/bl_psa.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/bl_psa.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/bl_svr.a b/ap/lib/libzcore/std/lib/lib/fwp/bl_svr.a
index 5390259..bc4a9d6 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/bl_svr.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/bl_svr.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/font/libbitmap_font.a b/ap/lib/libzcore/std/lib/lib/fwp/font/libbitmap_font.a
index 76684fe..4cd1a8e 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/font/libbitmap_font.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/font/libbitmap_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/font/libttf_font.a b/ap/lib/libzcore/std/lib/lib/fwp/font/libttf_font.a
index 034cf88..5f43a52 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/font/libttf_font.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/font/libttf_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/framework.a b/ap/lib/libzcore/std/lib/lib/fwp/framework.a
index 6fdcba2..50b46dd 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/framework.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/framework.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/fwkernel.a b/ap/lib/libzcore/std/lib/lib/fwp/fwkernel.a
index aa11d65..96671ee 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/fwkernel.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/fwkernel.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/gui.a b/ap/lib/libzcore/std/lib/lib/fwp/gui.a
index d8156d5..72f13ec 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/gui.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/gui.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/msm.a b/ap/lib/libzcore/std/lib/lib/fwp/msm.a
index 1b80133..691822b 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/msm.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/msm.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/fwp/ui_fw.a b/ap/lib/libzcore/std/lib/lib/fwp/ui_fw.a
index 41361e7..44850fb 100755
--- a/ap/lib/libzcore/std/lib/lib/fwp/ui_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/fwp/ui_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libplatadapt_com.a b/ap/lib/libzcore/std/lib/lib/libplatadapt_com.a
index b9d7aed..ffdd513 100755
--- a/ap/lib/libzcore/std/lib/lib/libplatadapt_com.a
+++ b/ap/lib/libzcore/std/lib/lib/libplatadapt_com.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libplatadapt_fwp.a b/ap/lib/libzcore/std/lib/lib/libplatadapt_fwp.a
index 21bd376..287ef4e 100755
--- a/ap/lib/libzcore/std/lib/lib/libplatadapt_fwp.a
+++ b/ap/lib/libzcore/std/lib/lib/libplatadapt_fwp.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libplatadapt_phone.a b/ap/lib/libzcore/std/lib/lib/libplatadapt_phone.a
index 6ff3965..cbb30c4 100755
--- a/ap/lib/libzcore/std/lib/lib/libplatadapt_phone.a
+++ b/ap/lib/libzcore/std/lib/lib/libplatadapt_phone.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libplatadapt_poc.a b/ap/lib/libzcore/std/lib/lib/libplatadapt_poc.a
index 0b4a08c..72b6864 100755
--- a/ap/lib/libzcore/std/lib/lib/libplatadapt_poc.a
+++ b/ap/lib/libzcore/std/lib/lib/libplatadapt_poc.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libplatadapt_watch.a b/ap/lib/libzcore/std/lib/lib/libplatadapt_watch.a
index 97996dc..e5575a9 100755
--- a/ap/lib/libzcore/std/lib/lib/libplatadapt_watch.a
+++ b/ap/lib/libzcore/std/lib/lib/libplatadapt_watch.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libzcore_fwp.a b/ap/lib/libzcore/std/lib/lib/libzcore_fwp.a
index 3ad6290..a0f1ac2 100755
--- a/ap/lib/libzcore/std/lib/lib/libzcore_fwp.a
+++ b/ap/lib/libzcore/std/lib/lib/libzcore_fwp.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libzcore_phone.a b/ap/lib/libzcore/std/lib/lib/libzcore_phone.a
index 68f8bfd..776dc2a 100755
--- a/ap/lib/libzcore/std/lib/lib/libzcore_phone.a
+++ b/ap/lib/libzcore/std/lib/lib/libzcore_phone.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libzcore_poc.a b/ap/lib/libzcore/std/lib/lib/libzcore_poc.a
index 1664eb0..ab8a4e5 100755
--- a/ap/lib/libzcore/std/lib/lib/libzcore_poc.a
+++ b/ap/lib/libzcore/std/lib/lib/libzcore_poc.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/libzcore_watch.a b/ap/lib/libzcore/std/lib/lib/libzcore_watch.a
index 2e8bbc3..dde191a 100755
--- a/ap/lib/libzcore/std/lib/lib/libzcore_watch.a
+++ b/ap/lib/libzcore/std/lib/lib/libzcore_watch.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/app_fw.a b/ap/lib/libzcore/std/lib/lib/phone/app_fw.a
index 3e96b49..d655d39 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/app_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/app_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/bl_psa.a b/ap/lib/libzcore/std/lib/lib/phone/bl_psa.a
index 2eec3d4..7d56e03 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/bl_psa.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/bl_psa.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/bl_svr.a b/ap/lib/libzcore/std/lib/lib/phone/bl_svr.a
index 1812257..b78ceeb 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/bl_svr.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/bl_svr.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/font/libbitmap_font.a b/ap/lib/libzcore/std/lib/lib/phone/font/libbitmap_font.a
index b8dbfb6..1c1ace6 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/font/libbitmap_font.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/font/libbitmap_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/font/libttf_font.a b/ap/lib/libzcore/std/lib/lib/phone/font/libttf_font.a
index 731f553..605dfaf 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/font/libttf_font.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/font/libttf_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/framework.a b/ap/lib/libzcore/std/lib/lib/phone/framework.a
index 61c2fc8..481e93e 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/framework.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/framework.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/fwkernel.a b/ap/lib/libzcore/std/lib/lib/phone/fwkernel.a
index ebe51a4..bb52507 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/fwkernel.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/fwkernel.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/gui.a b/ap/lib/libzcore/std/lib/lib/phone/gui.a
index d7e26cf..a1e7763 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/gui.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/gui.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/msm.a b/ap/lib/libzcore/std/lib/lib/phone/msm.a
index 8ecb30b..475e3c3 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/msm.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/msm.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/phone/ui_fw.a b/ap/lib/libzcore/std/lib/lib/phone/ui_fw.a
index ec24b96..a8e75bc 100755
--- a/ap/lib/libzcore/std/lib/lib/phone/ui_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/phone/ui_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/app_fw.a b/ap/lib/libzcore/std/lib/lib/poc/app_fw.a
index 5daac86..554bc8b 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/app_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/app_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/bl_psa.a b/ap/lib/libzcore/std/lib/lib/poc/bl_psa.a
index 7e920e0..2017f49 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/bl_psa.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/bl_psa.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/bl_svr.a b/ap/lib/libzcore/std/lib/lib/poc/bl_svr.a
index 0ef927a..cb8c788 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/bl_svr.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/bl_svr.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/font/libbitmap_font.a b/ap/lib/libzcore/std/lib/lib/poc/font/libbitmap_font.a
index fe0cae8..d7b75aa 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/font/libbitmap_font.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/font/libbitmap_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/font/libttf_font.a b/ap/lib/libzcore/std/lib/lib/poc/font/libttf_font.a
index 66a810b..a873f1b 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/font/libttf_font.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/font/libttf_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/framework.a b/ap/lib/libzcore/std/lib/lib/poc/framework.a
index a549ac9..9d987ab 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/framework.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/framework.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/fwkernel.a b/ap/lib/libzcore/std/lib/lib/poc/fwkernel.a
index a4af08d..9131cf1 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/fwkernel.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/fwkernel.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/gui.a b/ap/lib/libzcore/std/lib/lib/poc/gui.a
index 022fdd2..efc0347 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/gui.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/gui.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/msm.a b/ap/lib/libzcore/std/lib/lib/poc/msm.a
index f27e2b0..6e5c320 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/msm.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/msm.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/poc/ui_fw.a b/ap/lib/libzcore/std/lib/lib/poc/ui_fw.a
index ea0c537..c700806 100755
--- a/ap/lib/libzcore/std/lib/lib/poc/ui_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/poc/ui_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/app_fw.a b/ap/lib/libzcore/std/lib/lib/watch/app_fw.a
index 2c19f90..1585196 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/app_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/app_fw.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/bl_psa.a b/ap/lib/libzcore/std/lib/lib/watch/bl_psa.a
index 81cc0d5..e822a42 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/bl_psa.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/bl_psa.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/bl_svr.a b/ap/lib/libzcore/std/lib/lib/watch/bl_svr.a
index a4caa8c..f29d269 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/bl_svr.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/bl_svr.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/font/libbitmap_font.a b/ap/lib/libzcore/std/lib/lib/watch/font/libbitmap_font.a
index 3c068ec..98cb2a3 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/font/libbitmap_font.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/font/libbitmap_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/font/libttf_font.a b/ap/lib/libzcore/std/lib/lib/watch/font/libttf_font.a
index a82420f..0ef627c 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/font/libttf_font.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/font/libttf_font.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/framework.a b/ap/lib/libzcore/std/lib/lib/watch/framework.a
index 25be5d3..2a92777 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/framework.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/framework.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/fwkernel.a b/ap/lib/libzcore/std/lib/lib/watch/fwkernel.a
index 2599957..0af7a2e 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/fwkernel.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/fwkernel.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/gui.a b/ap/lib/libzcore/std/lib/lib/watch/gui.a
index 6e551e3..94de20b 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/gui.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/gui.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/msm.a b/ap/lib/libzcore/std/lib/lib/watch/msm.a
index f41efc8..63fc787 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/msm.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/msm.a
Binary files differ
diff --git a/ap/lib/libzcore/std/lib/lib/watch/ui_fw.a b/ap/lib/libzcore/std/lib/lib/watch/ui_fw.a
index a4eff10..ffe3677 100755
--- a/ap/lib/libzcore/std/lib/lib/watch/ui_fw.a
+++ b/ap/lib/libzcore/std/lib/lib/watch/ui_fw.a
Binary files differ
diff --git a/ap/lib/libzte_vsim/libzte_vsim.a b/ap/lib/libzte_vsim/libzte_vsim.a
index b442331..bcf725f 100755
--- a/ap/lib/libzte_vsim/libzte_vsim.a
+++ b/ap/lib/libzte_vsim/libzte_vsim.a
Binary files differ
diff --git a/ap/libc/glibc/glibc-2.23/bits/typesizes.h b/ap/libc/glibc/glibc-2.23/bits/typesizes.h
index a8c4904..53047b8 100755
--- a/ap/libc/glibc/glibc-2.23/bits/typesizes.h
+++ b/ap/libc/glibc/glibc-2.23/bits/typesizes.h
@@ -47,7 +47,7 @@
#define __FSWORD_T_TYPE __SWORD_TYPE
#define __ID_T_TYPE __U32_TYPE
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
-#define __TIME_T_TYPE __ULONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __S32_TYPE
diff --git a/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/adjtime.c b/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/adjtime.c
index d37cfa1..555d82f 100755
--- a/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/adjtime.c
+++ b/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/adjtime.c
@@ -58,11 +58,11 @@
struct TIMEVAL tmp;
/* We will do some check here. */
- tmp.tv_sec = (signed long)itv->tv_sec + itv->tv_usec / 1000000L;
+ tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L;
tmp.tv_usec = itv->tv_usec % 1000000L;
- if ((signed long)tmp.tv_sec > (signed long)MAX_SEC || (signed long)tmp.tv_sec < (signed long)MIN_SEC)
+ if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC)
return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
- tntx.offset = tmp.tv_usec + (signed long)tmp.tv_sec * 1000000L;
+ tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
tntx.modes = ADJ_OFFSET_SINGLESHOT;
}
else
diff --git a/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index 9b7265f..c31bba2 100755
--- a/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/ap/libc/glibc/glibc-2.23/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -48,7 +48,7 @@
#define __FSWORD_T_TYPE __SWORD_TYPE
#define __ID_T_TYPE __U32_TYPE
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
-#define __TIME_T_TYPE __ULONGWORD_TYPE
+#define __TIME_T_TYPE __SLONGWORD_TYPE
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __S32_TYPE
diff --git a/ap/libc/glibc/glibc-2.23/time/offtime.c b/ap/libc/glibc/glibc-2.23/time/offtime.c
index 42ef7d5..b540b2f 100644
--- a/ap/libc/glibc/glibc-2.23/time/offtime.c
+++ b/ap/libc/glibc/glibc-2.23/time/offtime.c
@@ -28,7 +28,7 @@
int
__offtime (const time_t *t, long int offset, struct tm *tp)
{
- long long days, rem, y;
+ time_t days, rem, y;
const unsigned short int *ip;
days = *t / SECS_PER_DAY;
@@ -60,7 +60,7 @@
while (days < 0 || days >= (__isleap (y) ? 366 : 365))
{
/* Guess a corrected year, assuming 365 days per year. */
- long long yg = y + days / 365 - (days % 365 < 0);
+ time_t yg = y + days / 365 - (days % 365 < 0);
/* Adjust DAYS and Y to match the guessed year. */
days -= ((yg - y) * 365
diff --git a/ap/libc/glibc/glibc-2.23/time/tzfile.c b/ap/libc/glibc/glibc-2.23/time/tzfile.c
index d38e5a3..9049878 100755
--- a/ap/libc/glibc/glibc-2.23/time/tzfile.c
+++ b/ap/libc/glibc/glibc-2.23/time/tzfile.c
@@ -648,7 +648,7 @@
__tzname[0] = NULL;
__tzname[1] = NULL;
- if (__glibc_unlikely (num_transitions == 0))
+ if (__glibc_unlikely (num_transitions == 0 || timer < transitions[0]))
{
/* TIMER is before any transition (or there are no transitions).
Choose the first non-DST type
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/reset.c b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/reset.c
index 28b8625..aa78d41 100755
--- a/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/reset.c
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/reset.c
@@ -31,6 +31,7 @@
#include <linux/mfd/zx234290.h>
#include <linux/delay.h>
#include <linux/reboot.h>
+#include <linux/sched.h>
#define ZX_RESET_DEV "/dev/zx_reset"
@@ -86,6 +87,7 @@
extern void zx_denali_nand_lock(void);
extern void zx_denali_nand_unlock(void);
+extern void zxic_reset_reason(int reason, const char *cpu, const char *app);
void zx29_restart(char mode, const char *cmd)
@@ -98,6 +100,8 @@
u8 restart_flag = 0;
unsigned char status = USER_RST_UNDEFINE;
+ zxic_reset_reason(2, "ap", current->comm);
+
if (cmd == NULL) {
printk(KERN_INFO"restart:enter reboot :reset to normal\n");
@@ -171,7 +175,7 @@
soft_spin_unlock_psm(I2C2_SFLOCK);
local_irq_enable();
} else {
- ret = Zx234290_SetUserReg_PSM(USER_RST_TO_NORMAL);
+ ret = Zx234290_SetUserReg_PSM(USER_RST_TO_EXCEPT);
if (ret) {
panic("restart:set restar flag error!\n");
}
diff --git a/ap/os/linux/linux-3.4.x/arch/arm/mm/fault.c b/ap/os/linux/linux-3.4.x/arch/arm/mm/fault.c
index 9cef922..cbd0917 100755
--- a/ap/os/linux/linux-3.4.x/arch/arm/mm/fault.c
+++ b/ap/os/linux/linux-3.4.x/arch/arm/mm/fault.c
@@ -1,4 +1,13 @@
-
+/*
+ * linux/arch/arm/mm/fault.c
+ *
+ * Copyright (C) 1995 Linus Torvalds
+ * Modifications for ARM processor (c) 1995-2004 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
#include <linux/module.h>
#include <linux/signal.h>
#include <linux/mm.h>
@@ -10,295 +19,928 @@
#include <linux/sched.h>
#include <linux/highmem.h>
#include <linux/perf_event.h>
+
#include <asm/exception.h>
#include <asm/pgtable.h>
#include <asm/system_misc.h>
#include <asm/system_info.h>
#include <asm/tlbflush.h>
+
#include <asm/mach/map.h>
#include <linux/slab.h>
+
#include "fault.h"
+
#ifdef CONFIG_MMU
+
#ifdef CONFIG_KPROBES
-static inline int notify_page_fault(struct pt_regs*regs,unsigned int fsr){int
-ret=(0xe17+2085-0x163c);if(!user_mode(regs)){preempt_disable();if(kprobe_running
-()&&kprobe_fault_handler(regs,fsr))ret=(0x8c+9569-0x25ec);preempt_enable();}
-return ret;}
-#else
-static inline int notify_page_fault(struct pt_regs*regs,unsigned int fsr){return
-(0x1483+202-0x154d);}
-#endif
-void show_pte(struct mm_struct*mm,unsigned long addr){pgd_t*pgd;if(!mm)mm=&
-init_mm;printk(KERN_ALERT"\x70\x67\x64\x20\x3d\x20\x25\x70" "\n",mm->pgd);pgd=
-pgd_offset(mm,addr);printk(KERN_ALERT
-"\x5b\x25\x30\x38\x6c\x78\x5d\x20\x2a\x70\x67\x64\x3d\x25\x30\x38\x6c\x6c\x78",
-addr,(long long)pgd_val(*pgd));do{pud_t*pud;pmd_t*pmd;pte_t*pte;if(pgd_none(*pgd
-))break;if(pgd_bad(*pgd)){printk("\x28\x62\x61\x64\x29");break;}pud=pud_offset(
-pgd,addr);if(PTRS_PER_PUD!=(0x1643+673-0x18e3))printk(
-"\x2c\x20\x2a\x70\x75\x64\x3d\x25\x30\x38\x6c\x6c\x78",(long long)pud_val(*pud))
-;if(pud_none(*pud))break;if(pud_bad(*pud)){printk("\x28\x62\x61\x64\x29");break;
-}pmd=pmd_offset(pud,addr);if(PTRS_PER_PMD!=(0x2f2+3649-0x1132))printk(
-"\x2c\x20\x2a\x70\x6d\x64\x3d\x25\x30\x38\x6c\x6c\x78",(long long)pmd_val(*pmd))
-;if(pmd_none(*pmd))break;if(pmd_bad(*pmd)){printk("\x28\x62\x61\x64\x29");break;
-}if(PageHighMem(pfn_to_page(pmd_val(*pmd)>>PAGE_SHIFT)))break;pte=pte_offset_map
-(pmd,addr);printk("\x2c\x20\x2a\x70\x74\x65\x3d\x25\x30\x38\x6c\x6c\x78",(long
-long)pte_val(*pte));
-#ifndef CONFIG_ARM_LPAE
-printk("\x2c\x20\x2a\x70\x70\x74\x65\x3d\x25\x30\x38\x6c\x6c\x78",(long long)
-pte_val(pte[PTE_HWTABLE_PTRS]));
-#endif
-pte_unmap(pte);}while((0xd42+2541-0x172f));printk("\n");}
-#else
-void show_pte(struct mm_struct*mm,unsigned long addr){}
-#endif
-static void __do_kernel_fault(struct mm_struct*mm,unsigned long addr,unsigned
-int fsr,struct pt_regs*regs){if(fixup_exception(regs))return;bust_spinlocks(
-(0xc15+4433-0x1d65));printk(KERN_ALERT
-"\x55\x6e\x61\x62\x6c\x65\x20\x74\x6f\x20\x68\x61\x6e\x64\x6c\x65\x20\x6b\x65\x72\x6e\x65\x6c\x20\x25\x73\x20\x61\x74\x20\x76\x69\x72\x74\x75\x61\x6c\x20\x61\x64\x64\x72\x65\x73\x73\x20\x25\x30\x38\x6c\x78" "\n"
-,(addr<PAGE_SIZE)?
-"\x4e\x55\x4c\x4c\x20\x70\x6f\x69\x6e\x74\x65\x72\x20\x64\x65\x72\x65\x66\x65\x72\x65\x6e\x63\x65"
-:"\x70\x61\x67\x69\x6e\x67\x20\x72\x65\x71\x75\x65\x73\x74",addr);show_pte(mm,
-addr);die("\x4f\x6f\x70\x73",regs,fsr);bust_spinlocks((0xd40+5536-0x22e0));
-do_exit(SIGKILL);}static void __do_user_fault(struct task_struct*tsk,unsigned
-long addr,unsigned int fsr,unsigned int sig,int code,struct pt_regs*regs){struct
- siginfo si;
-#ifdef CONFIG_DEBUG_USER
-if(((user_debug&UDBG_SEGV)&&(sig==SIGSEGV))||((user_debug&UDBG_BUS)&&(sig==
-SIGBUS))){printk(KERN_DEBUG
-"\x25\x73\x3a\x20\x75\x6e\x68\x61\x6e\x64\x6c\x65\x64\x20\x70\x61\x67\x65\x20\x66\x61\x75\x6c\x74\x20\x28\x25\x64\x29\x20\x61\x74\x20\x30\x78\x25\x30\x38\x6c\x78\x2c\x20\x63\x6f\x64\x65\x20\x30\x78\x25\x30\x33\x78" "\n"
-,tsk->comm,sig,addr,fsr);show_pte(tsk->mm,addr);show_regs(regs);}
-#endif
-tsk->thread.address=addr;tsk->thread.error_code=fsr;tsk->thread.trap_no=
-(0xbf5+5705-0x2230);si.si_signo=sig;si.si_errno=(0x1d10+1487-0x22df);si.si_code=
-code;si.si_addr=(void __user*)addr;force_sig_info(sig,&si,tsk);}void do_bad_area
-(unsigned long addr,unsigned int fsr,struct pt_regs*regs){struct task_struct*tsk
-=current;struct mm_struct*mm=tsk->active_mm;if(user_mode(regs))__do_user_fault(
-tsk,addr,fsr,SIGSEGV,SEGV_MAPERR,regs);else __do_kernel_fault(mm,addr,fsr,regs);
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
+{
+ int ret = 0;
+
+ if (!user_mode(regs)) {
+ /* kprobe_running() needs smp_processor_id() */
+ preempt_disable();
+ if (kprobe_running() && kprobe_fault_handler(regs, fsr))
+ ret = 1;
+ preempt_enable();
+ }
+
+ return ret;
}
-#ifdef CONFIG_MMU
-#define VM_FAULT_BADMAP 65536
-#define VM_FAULT_BADACCESS 131072
-static inline bool access_error(unsigned int fsr,struct vm_area_struct*vma){
-unsigned int mask=VM_READ|VM_WRITE|VM_EXEC;if(fsr&FSR_WRITE)mask=VM_WRITE;if(fsr
-&FSR_LNX_PF)mask=VM_EXEC;return vma->vm_flags&mask?false:true;}static int
-__kprobes __do_page_fault(struct mm_struct*mm,unsigned long addr,unsigned int
-fsr,unsigned int flags,struct task_struct*tsk){struct vm_area_struct*vma;int
-fault;vma=find_vma(mm,addr);fault=VM_FAULT_BADMAP;if(unlikely(!vma))goto out;if(
-unlikely(vma->vm_start>addr))goto check_stack;good_area:if(access_error(fsr,vma)
-){fault=VM_FAULT_BADACCESS;goto out;}return handle_mm_fault(mm,vma,addr&
-PAGE_MASK,flags);check_stack:if(vma->vm_flags&VM_GROWSDOWN&&addr>=
-FIRST_USER_ADDRESS&&!expand_stack(vma,addr))goto good_area;out:return fault;}
-static int __kprobes do_page_fault(unsigned long addr,unsigned int fsr,struct
-pt_regs*regs){struct task_struct*tsk;struct mm_struct*mm;int fault,sig,code;int
-write=fsr&FSR_WRITE;unsigned int flags=FAULT_FLAG_ALLOW_RETRY|
-FAULT_FLAG_KILLABLE|(write?FAULT_FLAG_WRITE:(0x83+6084-0x1847));if(
-notify_page_fault(regs,fsr))return(0x13b6+3139-0x1ff9);tsk=current;mm=tsk->mm;if
-(interrupts_enabled(regs))local_irq_enable();if(!mm||pagefault_disabled())goto
-no_context;if(!down_read_trylock(&mm->mmap_sem)){if(!user_mode(regs)&&!
-search_exception_tables(regs->ARM_pc))goto no_context;retry:down_read(&mm->
-mmap_sem);}else{might_sleep();
-#ifdef CONFIG_DEBUG_VM
-if(!user_mode(regs)&&!search_exception_tables(regs->ARM_pc))goto no_context;
-#endif
-}fault=__do_page_fault(mm,addr,fsr,flags,tsk);if((fault&VM_FAULT_RETRY)&&
-fatal_signal_pending(current))return(0xea5+2777-0x197e);perf_sw_event(
-PERF_COUNT_SW_PAGE_FAULTS,(0x11ef+2350-0x1b1c),regs,addr);if(!(fault&
-VM_FAULT_ERROR)&&flags&FAULT_FLAG_ALLOW_RETRY){if(fault&VM_FAULT_MAJOR){tsk->
-maj_flt++;perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,(0xa32+629-0xca6),regs,
-addr);}else{tsk->min_flt++;perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
-(0x11a1+4424-0x22e8),regs,addr);}if(fault&VM_FAULT_RETRY){flags&=~
-FAULT_FLAG_ALLOW_RETRY;goto retry;}}up_read(&mm->mmap_sem);if(likely(!(fault&(
-VM_FAULT_ERROR|VM_FAULT_BADMAP|VM_FAULT_BADACCESS))))return(0x143c+1796-0x1b40);
-if(fault&VM_FAULT_OOM){pagefault_out_of_memory();return(0x600+3648-0x1440);}if(!
-user_mode(regs))goto no_context;if(fault&VM_FAULT_SIGBUS){sig=SIGBUS;code=
-BUS_ADRERR;}else{sig=SIGSEGV;code=fault==VM_FAULT_BADACCESS?SEGV_ACCERR:
-SEGV_MAPERR;}__do_user_fault(tsk,addr,fsr,sig,code,regs);return
-(0xac0+3527-0x1887);no_context:__do_kernel_fault(mm,addr,fsr,regs);return
-(0x191a+3158-0x2570);}
-#else
-static int do_page_fault(unsigned long addr,unsigned int fsr,struct pt_regs*regs
-){return(0x255+6734-0x1ca3);}
-#endif
-#ifdef CONFIG_MMU
-static int __kprobes do_translation_fault(unsigned long addr,unsigned int fsr,
-struct pt_regs*regs){unsigned int index;pgd_t*pgd,*pgd_k;pud_t*pud,*pud_k;pmd_t*
-pmd,*pmd_k;if(addr<TASK_SIZE)return do_page_fault(addr,fsr,regs);if(
-interrupts_enabled(regs))local_irq_enable();if(user_mode(regs))goto bad_area;
-index=pgd_index(addr);pgd=cpu_get_pgd()+index;pgd_k=init_mm.pgd+index;if(
-pgd_none(*pgd_k))goto bad_area;if(!pgd_present(*pgd))set_pgd(pgd,*pgd_k);pud=
-pud_offset(pgd,addr);pud_k=pud_offset(pgd_k,addr);if(pud_none(*pud_k))goto
-bad_area;if(!pud_present(*pud))set_pud(pud,*pud_k);pmd=pmd_offset(pud,addr);
-pmd_k=pmd_offset(pud_k,addr);
-#ifdef CONFIG_ARM_LPAE
-index=(0xeef+6127-0x26de);
#else
-index=(addr>>SECTION_SHIFT)&(0x6e5+1582-0xd12);
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
+{
+ return 0;
+}
#endif
-if(pmd_none(pmd_k[index]))goto bad_area;copy_pmd(pmd,pmd_k);return
-(0x1722+1498-0x1cfc);bad_area:do_bad_area(addr,fsr,regs);return
-(0x1cba+276-0x1dce);}
-#else
-static int do_translation_fault(unsigned long addr,unsigned int fsr,struct
-pt_regs*regs){return(0x163f+815-0x196e);}
-#endif
-static int do_sect_fault(unsigned long addr,unsigned int fsr,struct pt_regs*regs
-){if(interrupts_enabled(regs))local_irq_enable();do_bad_area(addr,fsr,regs);
-return(0x11f9+1016-0x15f1);}static int do_bad(unsigned long addr,unsigned int
-fsr,struct pt_regs*regs){return(0x461+8053-0x23d5);}struct fsr_info{int(*fn)(
-unsigned long addr,unsigned int fsr,struct pt_regs*regs);int sig;int code;const
-char*name;};
+
+/*
+ * This is useful to dump out the page tables associated with
+ * 'addr' in mm 'mm'.
+ */
+void show_pte(struct mm_struct *mm, unsigned long addr)
+{
+ pgd_t *pgd;
+
+ if (!mm)
+ mm = &init_mm;
+
+ printk(KERN_ALERT "pgd = %p\n", mm->pgd);
+ pgd = pgd_offset(mm, addr);
+ printk(KERN_ALERT "[%08lx] *pgd=%08llx",
+ addr, (long long)pgd_val(*pgd));
+
+ do {
+ pud_t *pud;
+ pmd_t *pmd;
+ pte_t *pte;
+
+ if (pgd_none(*pgd))
+ break;
+
+ if (pgd_bad(*pgd)) {
+ printk("(bad)");
+ break;
+ }
+
+ pud = pud_offset(pgd, addr);
+ if (PTRS_PER_PUD != 1)
+ printk(", *pud=%08llx", (long long)pud_val(*pud));
+
+ if (pud_none(*pud))
+ break;
+
+ if (pud_bad(*pud)) {
+ printk("(bad)");
+ break;
+ }
+
+ pmd = pmd_offset(pud, addr);
+ if (PTRS_PER_PMD != 1)
+ printk(", *pmd=%08llx", (long long)pmd_val(*pmd));
+
+ if (pmd_none(*pmd))
+ break;
+
+ if (pmd_bad(*pmd)) {
+ printk("(bad)");
+ break;
+ }
+
+ /* We must not map this if we have highmem enabled */
+ if (PageHighMem(pfn_to_page(pmd_val(*pmd) >> PAGE_SHIFT)))
+ break;
+
+ pte = pte_offset_map(pmd, addr);
+ printk(", *pte=%08llx", (long long)pte_val(*pte));
+#ifndef CONFIG_ARM_LPAE
+ printk(", *ppte=%08llx",
+ (long long)pte_val(pte[PTE_HWTABLE_PTRS]));
+#endif
+ pte_unmap(pte);
+ } while(0);
+
+ printk("\n");
+}
+#else /* CONFIG_MMU */
+void show_pte(struct mm_struct *mm, unsigned long addr)
+{ }
+#endif /* CONFIG_MMU */
+
+/*
+ * Oops. The kernel tried to access some page that wasn't present.
+ */
+static void
+__do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
+ struct pt_regs *regs)
+{
+ /*
+ * Are we prepared to handle this kernel fault?
+ */
+ if (fixup_exception(regs))
+ return;
+
+ /*
+ * No handler, we'll have to terminate things with extreme prejudice.
+ */
+ bust_spinlocks(1);
+ printk(KERN_ALERT
+ "Unable to handle kernel %s at virtual address %08lx\n",
+ (addr < PAGE_SIZE) ? "NULL pointer dereference" :
+ "paging request", addr);
+
+ show_pte(mm, addr);
+ die("Oops", regs, fsr);
+ bust_spinlocks(0);
+ do_exit(SIGKILL);
+}
+
+/*
+ * Something tried to access memory that isn't in our memory map..
+ * User mode accesses just cause a SIGSEGV
+ */
+static void
+__do_user_fault(struct task_struct *tsk, unsigned long addr,
+ unsigned int fsr, unsigned int sig, int code,
+ struct pt_regs *regs)
+{
+ struct siginfo si;
+
+#ifdef CONFIG_DEBUG_USER
+ if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) ||
+ ((user_debug & UDBG_BUS) && (sig == SIGBUS))) {
+ printk(KERN_DEBUG "%s: unhandled page fault (%d) at 0x%08lx, code 0x%03x\n",
+ tsk->comm, sig, addr, fsr);
+ show_pte(tsk->mm, addr);
+ show_regs(regs);
+ }
+#endif
+
+ tsk->thread.address = addr;
+ tsk->thread.error_code = fsr;
+ tsk->thread.trap_no = 14;
+ si.si_signo = sig;
+ si.si_errno = 0;
+ si.si_code = code;
+ si.si_addr = (void __user *)addr;
+ force_sig_info(sig, &si, tsk);
+}
+
+void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ struct task_struct *tsk = current;
+ struct mm_struct *mm = tsk->active_mm;
+
+ /*
+ * If we are in kernel mode at this point, we
+ * have no context to handle this fault with.
+ */
+ if (user_mode(regs))
+ __do_user_fault(tsk, addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
+ else
+ __do_kernel_fault(mm, addr, fsr, regs);
+}
+
+#ifdef CONFIG_MMU
+#define VM_FAULT_BADMAP 0x010000
+#define VM_FAULT_BADACCESS 0x020000
+
+/*
+ * Check that the permissions on the VMA allow for the fault which occurred.
+ * If we encountered a write fault, we must have write permission, otherwise
+ * we allow any permission.
+ */
+static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
+{
+ unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+
+ if (fsr & FSR_WRITE)
+ mask = VM_WRITE;
+ if (fsr & FSR_LNX_PF)
+ mask = VM_EXEC;
+
+ return vma->vm_flags & mask ? false : true;
+}
+
+static int __kprobes
+__do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
+ unsigned int flags, struct task_struct *tsk)
+{
+ struct vm_area_struct *vma;
+ int fault;
+
+ vma = find_vma(mm, addr);
+ fault = VM_FAULT_BADMAP;
+ if (unlikely(!vma))
+ goto out;
+ if (unlikely(vma->vm_start > addr))
+ goto check_stack;
+
+ /*
+ * Ok, we have a good vm_area for this
+ * memory access, so we can handle it.
+ */
+good_area:
+ if (access_error(fsr, vma)) {
+ fault = VM_FAULT_BADACCESS;
+ goto out;
+ }
+
+ return handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
+
+check_stack:
+ /* Don't allow expansion below FIRST_USER_ADDRESS */
+ if (vma->vm_flags & VM_GROWSDOWN &&
+ addr >= FIRST_USER_ADDRESS && !expand_stack(vma, addr))
+ goto good_area;
+out:
+ return fault;
+}
+
+static int __kprobes
+do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ struct task_struct *tsk;
+ struct mm_struct *mm;
+ int fault, sig, code;
+ int write = fsr & FSR_WRITE;
+ unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
+ (write ? FAULT_FLAG_WRITE : 0);
+
+ if (notify_page_fault(regs, fsr))
+ return 0;
+
+ tsk = current;
+ mm = tsk->mm;
+
+ /* Enable interrupts if they were enabled in the parent context. */
+ if (interrupts_enabled(regs))
+ local_irq_enable();
+
+ /*
+ * If we're in an interrupt or have no user
+ * context, we must not take the fault..
+ */
+ if (!mm || pagefault_disabled())
+ goto no_context;
+
+ /*
+ * As per x86, we may deadlock here. However, since the kernel only
+ * validly references user space from well defined areas of the code,
+ * we can bug out early if this is from code which shouldn't.
+ */
+ if (!down_read_trylock(&mm->mmap_sem)) {
+ if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
+ goto no_context;
+retry:
+ down_read(&mm->mmap_sem);
+ } else {
+ /*
+ * The above down_read_trylock() might have succeeded in
+ * which case, we'll have missed the might_sleep() from
+ * down_read()
+ */
+ might_sleep();
+#ifdef CONFIG_DEBUG_VM
+ if (!user_mode(regs) &&
+ !search_exception_tables(regs->ARM_pc))
+ goto no_context;
+#endif
+ }
+
+ fault = __do_page_fault(mm, addr, fsr, flags, tsk);
+
+ /* If we need to retry but a fatal signal is pending, handle the
+ * signal first. We do not need to release the mmap_sem because
+ * it would already be released in __lock_page_or_retry in
+ * mm/filemap.c. */
+ if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
+ return 0;
+
+ /*
+ * Major/minor page fault accounting is only done on the
+ * initial attempt. If we go through a retry, it is extremely
+ * likely that the page will be found in page cache at that point.
+ */
+
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
+ if (!(fault & VM_FAULT_ERROR) && flags & FAULT_FLAG_ALLOW_RETRY) {
+ if (fault & VM_FAULT_MAJOR) {
+ tsk->maj_flt++;
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
+ regs, addr);
+ } else {
+ tsk->min_flt++;
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
+ regs, addr);
+ }
+ if (fault & VM_FAULT_RETRY) {
+ /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
+ * of starvation. */
+ flags &= ~FAULT_FLAG_ALLOW_RETRY;
+ goto retry;
+ }
+ }
+
+ up_read(&mm->mmap_sem);
+
+ /*
+ * Handle the "normal" case first - VM_FAULT_MAJOR / VM_FAULT_MINOR
+ */
+ if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
+ return 0;
+
+ if (fault & VM_FAULT_OOM) {
+ /*
+ * We ran out of memory, call the OOM killer, and return to
+ * userspace (which will retry the fault, or kill us if we
+ * got oom-killed)
+ */
+ pagefault_out_of_memory();
+ return 0;
+ }
+
+ /*
+ * If we are in kernel mode at this point, we
+ * have no context to handle this fault with.
+ */
+ if (!user_mode(regs))
+ goto no_context;
+
+ if (fault & VM_FAULT_SIGBUS) {
+ /*
+ * We had some memory, but were unable to
+ * successfully fix up this page fault.
+ */
+ sig = SIGBUS;
+ code = BUS_ADRERR;
+ } else {
+ /*
+ * Something tried to access memory that
+ * isn't in our memory map..
+ */
+ sig = SIGSEGV;
+ code = fault == VM_FAULT_BADACCESS ?
+ SEGV_ACCERR : SEGV_MAPERR;
+ }
+
+ __do_user_fault(tsk, addr, fsr, sig, code, regs);
+ return 0;
+
+no_context:
+ __do_kernel_fault(mm, addr, fsr, regs);
+ return 0;
+}
+#else /* CONFIG_MMU */
+static int
+do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ return 0;
+}
+#endif /* CONFIG_MMU */
+
+/*
+ * First Level Translation Fault Handler
+ *
+ * We enter here because the first level page table doesn't contain
+ * a valid entry for the address.
+ *
+ * If the address is in kernel space (>= TASK_SIZE), then we are
+ * probably faulting in the vmalloc() area.
+ *
+ * If the init_task's first level page tables contains the relevant
+ * entry, we copy the it to this task. If not, we send the process
+ * a signal, fixup the exception, or oops the kernel.
+ *
+ * NOTE! We MUST NOT take any locks for this case. We may be in an
+ * interrupt or a critical region, and should only copy the information
+ * from the master page table, nothing more.
+ */
+#ifdef CONFIG_MMU
+static int __kprobes
+do_translation_fault(unsigned long addr, unsigned int fsr,
+ struct pt_regs *regs)
+{
+ unsigned int index;
+ pgd_t *pgd, *pgd_k;
+ pud_t *pud, *pud_k;
+ pmd_t *pmd, *pmd_k;
+
+ if (addr < TASK_SIZE)
+ return do_page_fault(addr, fsr, regs);
+
+ if (interrupts_enabled(regs))
+ local_irq_enable();
+
+ if (user_mode(regs))
+ goto bad_area;
+
+ index = pgd_index(addr);
+
+ /*
+ * FIXME: CP15 C1 is write only on ARMv3 architectures.
+ */
+ pgd = cpu_get_pgd() + index;
+ pgd_k = init_mm.pgd + index;
+
+ if (pgd_none(*pgd_k))
+ goto bad_area;
+ if (!pgd_present(*pgd))
+ set_pgd(pgd, *pgd_k);
+
+ pud = pud_offset(pgd, addr);
+ pud_k = pud_offset(pgd_k, addr);
+
+ if (pud_none(*pud_k))
+ goto bad_area;
+ if (!pud_present(*pud))
+ set_pud(pud, *pud_k);
+
+ pmd = pmd_offset(pud, addr);
+ pmd_k = pmd_offset(pud_k, addr);
+
+#ifdef CONFIG_ARM_LPAE
+ /*
+ * Only one hardware entry per PMD with LPAE.
+ */
+ index = 0;
+#else
+ /*
+ * On ARM one Linux PGD entry contains two hardware entries (see page
+ * tables layout in pgtable.h). We normally guarantee that we always
+ * fill both L1 entries. But create_mapping() doesn't follow the rule.
+ * It can create inidividual L1 entries, so here we have to call
+ * pmd_none() check for the entry really corresponded to address, not
+ * for the first of pair.
+ */
+ index = (addr >> SECTION_SHIFT) & 1;
+#endif
+ if (pmd_none(pmd_k[index]))
+ goto bad_area;
+
+ copy_pmd(pmd, pmd_k);
+ return 0;
+
+bad_area:
+ do_bad_area(addr, fsr, regs);
+ return 0;
+}
+#else /* CONFIG_MMU */
+static int
+do_translation_fault(unsigned long addr, unsigned int fsr,
+ struct pt_regs *regs)
+{
+ return 0;
+}
+#endif /* CONFIG_MMU */
+
+/*
+ * Some section permission faults need to be handled gracefully.
+ * They can happen due to a __{get,put}_user during an oops.
+ */
+static int
+do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ if (interrupts_enabled(regs))
+ local_irq_enable();
+
+ do_bad_area(addr, fsr, regs);
+ return 0;
+}
+
+/*
+ * This abort handler always returns "fault".
+ */
+static int
+do_bad(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ return 1;
+}
+
+struct fsr_info {
+ int (*fn)(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
+ int sig;
+ int code;
+ const char *name;
+};
+
+/* FSR definition */
#ifdef CONFIG_ARM_LPAE
#include "fsr-3level.c"
#else
#include "fsr-2level.c"
#endif
-void __init hook_fault_code(int nr,int(*fn)(unsigned long,unsigned int,struct
-pt_regs*),int sig,int code,const char*name){if(nr<(0xce5+4250-0x1d7f)||nr>=
-ARRAY_SIZE(fsr_info))BUG();fsr_info[nr].fn=fn;fsr_info[nr].sig=sig;fsr_info[nr].
-code=code;fsr_info[nr].name=name;}
+
+void __init
+hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
+ int sig, int code, const char *name)
+{
+ if (nr < 0 || nr >= ARRAY_SIZE(fsr_info))
+ BUG();
+
+ fsr_info[nr].fn = fn;
+ fsr_info[nr].sig = sig;
+ fsr_info[nr].code = code;
+ fsr_info[nr].name = name;
+}
+
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-static DECLARE_RWSEM(shrinker_rwsem);atomic_t _code_page_count=ATOMIC_INIT(
-(0x64c+3281-0x131d));struct addr_info{struct list_head node;unsigned long vaddr;
-unsigned long kaddr;unsigned long page_index;};enum modem_access_technology{GSM=
-(0x42f+2882-0xf71),UTRAN=(0x1869+204-0x1934),LTE=(0x1735+1609-0x1d7c),COM=
-(0x788+3773-0x1642),NR_MODEM_ACCESS=(0x4b8+5810-0x1b66)};struct list_head
-modem_page_list[NR_MODEM_ACCESS]={LIST_HEAD_INIT(modem_page_list[
-(0x5e7+4772-0x188b)]),LIST_HEAD_INIT(modem_page_list[(0xa89+6078-0x2246)]),
-LIST_HEAD_INIT(modem_page_list[(0x3ad+8939-0x2696)]),LIST_HEAD_INIT(
-modem_page_list[(0x19c3+1240-0x1e98)]),};unsigned int page_used[
-(0x195d+2789-0x241a)];struct completion page_completion[(0x51f+748-0x7e3)*
-(0x42f+1562-0xa29)];static void unmap_pte_range(pmd_t*pmd,unsigned long addr,
-unsigned long end){pte_t*pte;pte=pte_offset_kernel(pmd,addr);do{pte_t ptent=
-ptep_get_and_clear(&init_mm,addr,pte);WARN_ON(!pte_none(ptent)&&!pte_present(
-ptent));}while(pte++,addr+=PAGE_SIZE,addr!=end);}static void unmap_pmd_range(
-pud_t*pud,unsigned long addr,unsigned long end){pmd_t*pmd;unsigned long next;pmd
-=pmd_offset(pud,addr);do{next=pmd_addr_end(addr,end);if(pmd_none_or_clear_bad(
-pmd))continue;unmap_pte_range(pmd,addr,next);}while(pmd++,addr=next,addr!=end);}
-static void unmap_pud_range(pgd_t*pgd,unsigned long addr,unsigned long end){
-pud_t*pud;unsigned long next;pud=pud_offset(pgd,addr);do{next=pud_addr_end(addr,
-end);if(pud_none_or_clear_bad(pud))continue;unmap_pmd_range(pud,addr,next);}
-while(pud++,addr=next,addr!=end);}static void unmap_page_range(unsigned long
-addr,unsigned long end){pgd_t*pgd;unsigned long next;BUG_ON(addr>=end);pgd=
-pgd_offset_k(addr);do{next=pgd_addr_end(addr,end);if(pgd_none_or_clear_bad(pgd))
-continue;unmap_pud_range(pgd,addr,next);}while(pgd++,addr=next,addr!=end);}void
-shrink_modem_mem(unsigned int access_type){int i=(0xfc2+581-0x1207);unsigned
-long vaddr;struct addr_info*addr,*tmp_addr;struct list_head tmp_page_list;for(i=
-(0x5eb+4111-0x15fa);i<NR_MODEM_ACCESS;i++){if(i==access_type)continue;down_write
-(&shrinker_rwsem);list_replace_init(&modem_page_list[i],&tmp_page_list);up_write
-(&shrinker_rwsem);list_for_each_entry_safe(addr,tmp_addr,&tmp_page_list,node){
-list_del_init(&addr->node);page_completion[addr->page_index].done=
-(0x187+7014-0x1ced);page_used[addr->page_index/BITS_PER_LONG]&=~(
-(0x1b0a+2503-0x24d0)<<(addr->page_index%BITS_PER_LONG));vaddr=addr->vaddr&
-PAGE_MASK;if(vaddr<cpps_global_var.cpko_text_start||vaddr>cpps_global_var.
-modem_text_end){panic(
-"\x61\x64\x64\x72\x5f\x69\x6e\x66\x6f\x3a\x20\x25\x30\x38\x78\x20\x69\x73\x20\x20\x64\x65\x73\x74\x72\x6f\x79"
-,addr);}flush_cache_vunmap(vaddr,vaddr+PAGE_SIZE);unmap_page_range(vaddr,vaddr+
-PAGE_SIZE);flush_tlb_kernel_range(vaddr,vaddr+PAGE_SIZE);
+//#define __codetext __attribute__((__section__(".modem.text")))
+
+static DECLARE_RWSEM(shrinker_rwsem);
+atomic_t _code_page_count = ATOMIC_INIT(0);
+
+struct addr_info{
+ struct list_head node;
+ unsigned long vaddr;
+ unsigned long kaddr;
+ unsigned long page_index;
+};
+
+enum modem_access_technology {
+ GSM = 0,
+ UTRAN = 1,
+ LTE = 2,
+ COM = 3,
+ NR_MODEM_ACCESS =4
+};
+struct list_head modem_page_list[NR_MODEM_ACCESS] ={
+ LIST_HEAD_INIT(modem_page_list[0]),
+ LIST_HEAD_INIT(modem_page_list[1]),
+ LIST_HEAD_INIT(modem_page_list[2]),
+ LIST_HEAD_INIT(modem_page_list[3]),
+};
+
+unsigned int page_used[40];
+struct completion page_completion[40*32];
+
+static void unmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
+{
+ pte_t *pte;
+
+ pte = pte_offset_kernel(pmd, addr);
+ do {
+ pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
+ WARN_ON(!pte_none(ptent) && !pte_present(ptent));
+ } while (pte++, addr += PAGE_SIZE, addr != end);
+}
+
+static void unmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
+{
+ pmd_t *pmd;
+ unsigned long next;
+
+ pmd = pmd_offset(pud, addr);
+ do {
+ next = pmd_addr_end(addr, end);
+ if (pmd_none_or_clear_bad(pmd))
+ continue;
+ unmap_pte_range(pmd, addr, next);
+ } while (pmd++, addr = next, addr != end);
+}
+
+static void unmap_pud_range(pgd_t *pgd, unsigned long addr, unsigned long end)
+{
+ pud_t *pud;
+ unsigned long next;
+
+ pud = pud_offset(pgd, addr);
+ do {
+ next = pud_addr_end(addr, end);
+ if (pud_none_or_clear_bad(pud))
+ continue;
+ unmap_pmd_range(pud, addr, next);
+ } while (pud++, addr = next, addr != end);
+}
+
+static void unmap_page_range(unsigned long addr, unsigned long end)
+{
+ pgd_t *pgd;
+ unsigned long next;
+
+ BUG_ON(addr >= end);
+ pgd = pgd_offset_k(addr);
+ do {
+ next = pgd_addr_end(addr, end);
+ if (pgd_none_or_clear_bad(pgd))
+ continue;
+ unmap_pud_range(pgd, addr, next);
+ } while (pgd++, addr = next, addr != end);
+}
+
+void shrink_modem_mem(unsigned int access_type)
+{
+ int i = 0;
+ unsigned long vaddr;
+ struct addr_info *addr, *tmp_addr;
+ struct list_head tmp_page_list;
+
+ for (i= 0; i < NR_MODEM_ACCESS; i++) {
+ if (i == access_type)
+ continue;
+
+ down_write(&shrinker_rwsem);
+ list_replace_init(&modem_page_list[i],&tmp_page_list);
+ up_write(&shrinker_rwsem);
+ list_for_each_entry_safe(addr, tmp_addr, &tmp_page_list, node) {
+ list_del_init(&addr->node);
+ page_completion[addr->page_index].done = 0;
+ page_used[addr->page_index/BITS_PER_LONG] &= ~(1 << (addr->page_index % BITS_PER_LONG));
+ vaddr = addr->vaddr & PAGE_MASK;
+ if(vaddr < cpps_global_var.cpko_text_start || vaddr > cpps_global_var.modem_text_end){
+ panic("addr_info: %08x is destroy",addr);
+ }
+ flush_cache_vunmap(vaddr, vaddr + PAGE_SIZE);
+ unmap_page_range(vaddr, vaddr + PAGE_SIZE);
+ flush_tlb_kernel_range(vaddr, vaddr + PAGE_SIZE);
#ifdef CONFIG_DEBUG_RODATA
-unsigned int flags;local_irq_save(flags);set_memory_rw(addr->kaddr,
-(0x4a0+48-0x4cf));local_irq_restore(flags);
+ unsigned int flags;
+ local_irq_save(flags);
+ set_memory_rw(addr->kaddr,1);
+ local_irq_restore(flags);
#endif
-free_page(addr->kaddr);kfree(addr);atomic_dec(&_code_page_count);};}}
-EXPORT_SYMBOL(shrink_modem_mem);phys_addr_t virt_is_mapping(unsigned long addr){
-pgd_t*pgd;pmd_t*pmd;pte_t*ptep,pte;unsigned long pfn;pgd=pgd_offset_k(addr);if(!
-pgd_none(*pgd)){pmd=pmd_offset(pgd,addr);if(!pmd_none(*pmd)){ptep=pte_offset_map
-(pmd,addr);pte=*ptep;if(pte_present(pte)){pfn=pte_pfn(pte);return __pfn_to_phys(
-pfn);}}}return(0x9d4+475-0xbaf);}static int sync_pgd(unsigned long addr,unsigned
- int fsr,struct pt_regs*regs){unsigned int index;pgd_t*pgd,*pgd_k;pud_t*pud,*
-pud_k;pmd_t*pmd,*pmd_k;index=pgd_index(addr);pgd=cpu_get_pgd()+index;pgd_k=
-init_mm.pgd+index;if(pgd_none(*pgd_k))goto bad_area;if(!pgd_present(*pgd))
-set_pgd(pgd,*pgd_k);pud=pud_offset(pgd,addr);pud_k=pud_offset(pgd_k,addr);if(
-pud_none(*pud_k))goto bad_area;if(!pud_present(*pud))set_pud(pud,*pud_k);pmd=
-pmd_offset(pud,addr);pmd_k=pmd_offset(pud_k,addr);
-#ifdef CONFIG_ARM_LPAE
-index=(0x9fd+4051-0x19d0);
+ free_page(addr->kaddr);
+ kfree(addr);
+
+ atomic_dec(&_code_page_count);/*after reclaim ,need modify this*/
+ };
+
+ }
+}
+EXPORT_SYMBOL(shrink_modem_mem);
+phys_addr_t virt_is_mapping(unsigned long addr)
+{
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *ptep, pte;
+ unsigned long pfn;
+
+ /* check whether we found an entry */
+ pgd = pgd_offset_k(addr);
+
+ if(!pgd_none(*pgd)) {
+ /* get the page middle directory */
+ pmd = pmd_offset(pgd, addr);
+ /* check for a valid entry */
+ if(!pmd_none(*pmd)) {
+ /* get a pointer to the page table entry */
+ ptep = pte_offset_map(pmd, addr);
+ /* get the page table entry itself */
+ pte = *ptep;
+ if (pte_present(pte)) {
+ //ptr_page = pte_page(pte);
+ pfn = pte_pfn(pte);
+ //pte_unmap(ptep);
+ return __pfn_to_phys(pfn);
+ }
+ /* check for a valid page */
+ }
+ }
+ return 0;
+}
+
+static int sync_pgd(unsigned long addr, unsigned int fsr,
+ struct pt_regs *regs)
+{
+ unsigned int index;
+ pgd_t *pgd, *pgd_k;
+ pud_t *pud, *pud_k;
+ pmd_t *pmd, *pmd_k;
+ index = pgd_index(addr);
+
+ /*
+ * FIXME: CP15 C1 is write only on ARMv3 architectures.
+ */
+ pgd = cpu_get_pgd() + index;
+ pgd_k = init_mm.pgd + index;
+
+ if (pgd_none(*pgd_k))
+ goto bad_area;
+ if (!pgd_present(*pgd))
+ set_pgd(pgd, *pgd_k);
+
+ pud = pud_offset(pgd, addr);
+ pud_k = pud_offset(pgd_k, addr);
+
+ if (pud_none(*pud_k))
+ goto bad_area;
+ if (!pud_present(*pud))
+ set_pud(pud, *pud_k);
+
+ pmd = pmd_offset(pud, addr);
+ pmd_k = pmd_offset(pud_k, addr);
+
+ #ifdef CONFIG_ARM_LPAE
+ /*
+ * Only one hardware entry per PMD with LPAE.
+ */
+ index = 0;
#else
-index=(addr>>SECTION_SHIFT)&(0x1525+1755-0x1bff);
+ /*
+ * On ARM one Linux PGD entry contains two hardware entries (see page
+ * tables layout in pgtable.h). We normally guarantee that we always
+ * fill both L1 entries. But create_mapping() doesn't follow the rule.
+ * It can create inidividual L1 entries, so here we have to call
+ * pmd_none() check for the entry really corresponded to address, not
+ * for the first of pair.
+ */
+ index = (addr >> SECTION_SHIFT) & 1;
#endif
-if(pmd_none(pmd_k[index]))goto bad_area;copy_pmd(pmd,pmd_k);return
-(0x222+5515-0x17ad);bad_area:do_bad_area(addr,fsr,regs);return(0x5a9+1791-0xca8)
-;}unsigned long*read_code_file(unsigned long page_index){unsigned long*code_buf;
-ssize_t result;code_buf=get_zeroed_page(GFP_ATOMIC);if(!code_buf)panic(
-"\x6d\x65\x6d\x65\x6f\x72\x79\x20\x6e\x6f\x74\x20\x65\x6e\x6f\x75\x67\x68\x21\x21"
-);atomic_inc(&_code_page_count);if(IS_ERR(cpps_global_var.fp_code)||
-cpps_global_var.fp_code==NULL){panic(
-"\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");}
-mm_segment_t old_fs;old_fs=get_fs();set_fs(KERNEL_DS);loff_t pos;pos=page_index*
-PAGE_SIZE+cpps_global_var.modem_offset;result=vfs_read(cpps_global_var.fp_code,(
-char*)code_buf,PAGE_SIZE,&pos);if(result<(0x261d+202-0x26e7)){panic(
-"\x72\x65\x61\x64\x20\x63\x6f\x64\x65\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n"
-);}
+ if (pmd_none(pmd_k[index]))
+ goto bad_area;
+ copy_pmd(pmd, pmd_k);
+ return 0;
+bad_area:
+ do_bad_area(addr, fsr, regs);
+ return 0;
+}
+
+unsigned long* read_code_file(unsigned long page_index)
+{
+ unsigned long* code_buf;
+ ssize_t result;
+ code_buf = get_zeroed_page(GFP_ATOMIC);
+ if(!code_buf)
+ panic("memeory not enough!!");
+ atomic_inc(&_code_page_count);/*after reclaim ,need modify this*/
+
+ if(IS_ERR(cpps_global_var.fp_code) || cpps_global_var.fp_code == NULL) {
+ panic("open file error\n");
+ }
+ mm_segment_t old_fs;
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ loff_t pos;
+ pos = page_index * PAGE_SIZE + cpps_global_var.modem_offset;
+ result = vfs_read(cpps_global_var.fp_code, (char *)code_buf, PAGE_SIZE, &pos);
+ if(result < 0){
+ panic("read code file error\n");
+ }
#ifdef CONFIG_DEBUG_RODATA
-unsigned int flags;local_irq_save(flags);set_memory_ro((unsigned long)code_buf,
-(0x14db+4276-0x258e));local_irq_restore(flags);
+ unsigned int flags;
+ local_irq_save(flags);
+ set_memory_ro((unsigned long)code_buf,1);
+ local_irq_restore(flags);
#endif
-set_fs(old_fs);return code_buf;}void read_code_mapping(unsigned long addr,
-unsigned int fsr,struct pt_regs*regs){unsigned long offset;unsigned long vaddr;
-const struct mem_type*mtype;unsigned long*vir_codebuf;unsigned long page_index;
-unsigned long page_shift;if(virt_is_mapping(addr&PAGE_MASK)!=(0x28c+598-0x4e2)){
-sync_pgd(addr&PAGE_MASK,fsr,regs);return;}vaddr=addr&PAGE_MASK;offset=vaddr&(~
-cpps_global_var.cpko_text_start);page_index=offset>>PAGE_SHIFT;page_shift=
-page_index%BITS_PER_LONG;if((page_used[page_index/BITS_PER_LONG]>>page_shift)&
-(0x4ef+7834-0x2388)){wait_for_completion(&page_completion[page_index]);sync_pgd(
-vaddr,fsr,regs);return;}else page_used[page_index/BITS_PER_LONG]|=(
-(0xf5f+4169-0x1fa7)<<page_shift);local_irq_enable();vir_codebuf=read_code_file(
-page_index);struct addr_info*addr_info;addr_info=kzalloc(sizeof(struct addr_info
-),GFP_KERNEL);addr_info->kaddr=vir_codebuf;addr_info->vaddr=addr;addr_info->
-page_index=page_index;down_write(&shrinker_rwsem);if(vaddr<cpps_global_var.
-__utran_modem_text_start)list_add(&addr_info->node,&modem_page_list[GSM]);else
-if(vaddr<cpps_global_var.__lte_modem_text_start)list_add(&addr_info->node,&
-modem_page_list[UTRAN]);else if(vaddr<cpps_global_var.__comm_modem_text_start)
-list_add(&addr_info->node,&modem_page_list[LTE]);else list_add(&addr_info->node,
-&modem_page_list[COM]);up_write(&shrinker_rwsem);local_irq_disable();mtype=
-get_mem_type(MT_MEMORY);ioremap_page(vaddr,__pa(vir_codebuf),mtype);sync_pgd(
-vaddr,fsr,regs);flush_icache_range(vaddr,vaddr+PAGE_SIZE);if(waitqueue_active(&
-page_completion[page_index].wait))complete_all(&page_completion[page_index]);
-return;}
+ set_fs(old_fs);
+ return code_buf;
+}
+
+void read_code_mapping(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ unsigned long offset;
+ unsigned long vaddr;
+ const struct mem_type *mtype;
+ unsigned long* vir_codebuf;
+ unsigned long page_index;
+ unsigned long page_shift;
+
+
+ if(virt_is_mapping(addr & PAGE_MASK) != 0) {
+ sync_pgd(addr & PAGE_MASK, fsr, regs);
+ return;
+ }
+
+ vaddr = addr & PAGE_MASK;
+ offset = vaddr & (~cpps_global_var.cpko_text_start);
+ page_index = offset >> PAGE_SHIFT;
+ page_shift = page_index % BITS_PER_LONG;
+
+ if ((page_used[page_index/BITS_PER_LONG] >> page_shift) & 0x1) {
+ wait_for_completion(&page_completion[page_index]);
+ sync_pgd(vaddr,fsr,regs);
+ return;
+ }
+ else
+ page_used[page_index/BITS_PER_LONG] |= (1 << page_shift);
+
+ local_irq_enable();
+ vir_codebuf = read_code_file(page_index);
+
+ /*add vir_codebuf to every list by address*/
+ struct addr_info *addr_info;
+ addr_info = kzalloc(sizeof(struct addr_info), GFP_KERNEL);
+ addr_info->kaddr = vir_codebuf;
+ addr_info->vaddr= addr;
+ addr_info->page_index = page_index;
+ down_write(&shrinker_rwsem);
+ if(vaddr < cpps_global_var.__utran_modem_text_start)
+ list_add(&addr_info->node, &modem_page_list[GSM]);
+ else if(vaddr < cpps_global_var.__lte_modem_text_start)
+ list_add(&addr_info->node, &modem_page_list[UTRAN]);
+ else if(vaddr < cpps_global_var.__comm_modem_text_start)
+ list_add(&addr_info->node, &modem_page_list[LTE]);
+ else
+ list_add(&addr_info->node, &modem_page_list[COM]);
+
+ up_write(&shrinker_rwsem);
+
+ local_irq_disable();
+ mtype = get_mem_type(MT_MEMORY);
+ ioremap_page(vaddr, __pa(vir_codebuf), mtype);
+ sync_pgd(vaddr, fsr, regs);
+ flush_icache_range(vaddr, vaddr + PAGE_SIZE);
+
+ if (waitqueue_active(&page_completion[page_index].wait))
+ complete_all(&page_completion[page_index]);/*after reclaim ,need clear done*/
+ return;
+}
#endif
-asmlinkage void __exception do_DataAbort(unsigned long addr,unsigned int fsr,
-struct pt_regs*regs){const struct fsr_info*inf=fsr_info+fsr_fs(fsr);struct
-siginfo info;
+/*
+ * Dispatch a data abort to the relevant handler.
+ */
+asmlinkage void __exception
+do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
+{
+ const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
+ struct siginfo info;
+
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-if(addr!=(0x2a4+3839-0x11a3)&&addr>=cpps_global_var.cpko_text_start&&addr<=
-cpps_global_var.modem_text_end){read_code_mapping(addr,fsr&~FSR_LNX_PF,regs);
-return;}
-#endif
-if(!inf->fn(addr,fsr&~FSR_LNX_PF,regs))return;printk(KERN_ALERT
-"\x55\x6e\x68\x61\x6e\x64\x6c\x65\x64\x20\x66\x61\x75\x6c\x74\x3a\x20\x25\x73\x20\x28\x30\x78\x25\x30\x33\x78\x29\x20\x61\x74\x20\x30\x78\x25\x30\x38\x6c\x78" "\n"
-,inf->name,fsr,addr);info.si_signo=inf->sig;info.si_errno=(0x1b19+1711-0x21c8);
-info.si_code=inf->code;info.si_addr=(void __user*)addr;arm_notify_die("",regs,&
-info,fsr,(0x1741+937-0x1aea));}void __init hook_ifault_code(int nr,int(*fn)(
-unsigned long,unsigned int,struct pt_regs*),int sig,int code,const char*name){if
-(nr<(0x129+679-0x3d0)||nr>=ARRAY_SIZE(ifsr_info))BUG();ifsr_info[nr].fn=fn;
-ifsr_info[nr].sig=sig;ifsr_info[nr].code=code;ifsr_info[nr].name=name;}
-asmlinkage void __exception do_PrefetchAbort(unsigned long addr,unsigned int
-ifsr,struct pt_regs*regs){const struct fsr_info*inf=ifsr_info+fsr_fs(ifsr);
-struct siginfo info;
-#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-if(addr!=(0x4f8+4535-0x16af)&&addr>=cpps_global_var.cpko_text_start&&addr<=
-cpps_global_var.modem_text_end){read_code_mapping(addr,ifsr|FSR_LNX_PF,regs);
-return;}
-#endif
-if(!inf->fn(addr,ifsr|FSR_LNX_PF,regs))return;printk(KERN_ALERT
-"\x55\x6e\x68\x61\x6e\x64\x6c\x65\x64\x20\x70\x72\x65\x66\x65\x74\x63\x68\x20\x61\x62\x6f\x72\x74\x3a\x20\x25\x73\x20\x28\x30\x78\x25\x30\x33\x78\x29\x20\x61\x74\x20\x30\x78\x25\x30\x38\x6c\x78" "\n"
-,inf->name,ifsr,addr);info.si_signo=inf->sig;info.si_errno=(0x462+8659-0x2635);
-info.si_code=inf->code;info.si_addr=(void __user*)addr;arm_notify_die("",regs,&
-info,ifsr,(0x6fd+655-0x98c));}
-#ifndef CONFIG_ARM_LPAE
-static int __init exceptions_init(void){if(cpu_architecture()>=CPU_ARCH_ARMv6){
-hook_fault_code((0x1609+3919-0x2554),do_translation_fault,SIGSEGV,SEGV_MAPERR,
-"\x49\x2d\x63\x61\x63\x68\x65\x20\x6d\x61\x69\x6e\x74\x65\x6e\x61\x6e\x63\x65\x20\x66\x61\x75\x6c\x74"
-);}if(cpu_architecture()>=CPU_ARCH_ARMv7){hook_fault_code((0xc06+3912-0x1b4b),
-do_bad,SIGSEGV,SEGV_MAPERR,
-"\x73\x65\x63\x74\x69\x6f\x6e\x20\x61\x63\x63\x65\x73\x73\x20\x66\x6c\x61\x67\x20\x66\x61\x75\x6c\x74"
-);hook_fault_code((0xd6b+1748-0x1439),do_bad,SIGSEGV,SEGV_MAPERR,
-"\x73\x65\x63\x74\x69\x6f\x6e\x20\x61\x63\x63\x65\x73\x73\x20\x66\x6c\x61\x67\x20\x66\x61\x75\x6c\x74"
-);}
-#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-int index=(0xaf+2735-0xb5e);for(index=(0xf17+785-0x1228);index<
-(0x3e9+2169-0xc3a)*(0x300+3991-0x1277);index++)init_completion(&page_completion[
-index]);
-#endif
-return(0x715+4575-0x18f4);}arch_initcall(exceptions_init);
+ if(addr != 0 && addr >= cpps_global_var.cpko_text_start && addr <= cpps_global_var.modem_text_end) {
+ read_code_mapping(addr, fsr & ~FSR_LNX_PF, regs);
+ return;
+ }
#endif
+ if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
+ return;
+
+ printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
+ inf->name, fsr, addr);
+
+ info.si_signo = inf->sig;
+ info.si_errno = 0;
+ info.si_code = inf->code;
+ info.si_addr = (void __user *)addr;
+ arm_notify_die("", regs, &info, fsr, 0);
+}
+
+void __init
+hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
+ int sig, int code, const char *name)
+{
+ if (nr < 0 || nr >= ARRAY_SIZE(ifsr_info))
+ BUG();
+
+ ifsr_info[nr].fn = fn;
+ ifsr_info[nr].sig = sig;
+ ifsr_info[nr].code = code;
+ ifsr_info[nr].name = name;
+}
+
+asmlinkage void __exception
+do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
+{
+ const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
+ struct siginfo info;
+
+#ifdef CONFIG_MODEM_CODE_IS_MAPPING
+ if(addr != 0 && addr >= cpps_global_var.cpko_text_start && addr <= cpps_global_var.modem_text_end) {
+ read_code_mapping(addr, ifsr | FSR_LNX_PF, regs);
+ return;
+ }
+
+#endif
+
+ if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
+ return;
+
+ printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
+ inf->name, ifsr, addr);
+
+ info.si_signo = inf->sig;
+ info.si_errno = 0;
+ info.si_code = inf->code;
+ info.si_addr = (void __user *)addr;
+ arm_notify_die("", regs, &info, ifsr, 0);
+}
+
+#ifndef CONFIG_ARM_LPAE
+static int __init exceptions_init(void)
+{
+ if (cpu_architecture() >= CPU_ARCH_ARMv6) {
+ hook_fault_code(4, do_translation_fault, SIGSEGV, SEGV_MAPERR,
+ "I-cache maintenance fault");
+ }
+
+ if (cpu_architecture() >= CPU_ARCH_ARMv7) {
+ /*
+ * TODO: Access flag faults introduced in ARMv6K.
+ * Runtime check for 'K' extension is needed
+ */
+ hook_fault_code(3, do_bad, SIGSEGV, SEGV_MAPERR,
+ "section access flag fault");
+ hook_fault_code(6, do_bad, SIGSEGV, SEGV_MAPERR,
+ "section access flag fault");
+ }
+#ifdef CONFIG_MODEM_CODE_IS_MAPPING
+ int index = 0;
+ for(index = 0;index < 40*32;index++)
+ init_completion(&page_completion[index]);
+#endif
+ return 0;
+}
+
+arch_initcall(exceptions_init);
+#endif
diff --git a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
index 0e87019..48e3eaa 100755
--- a/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/cpko/cpko_main.c
@@ -1,4 +1,3 @@
-
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/proc_fs.h>
@@ -12,205 +11,351 @@
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/device.h>
-MODULE_AUTHOR("\x5a\x54\x45");MODULE_LICENSE(
-"\x50\x72\x6f\x70\x72\x69\x65\x74\x61\x72\x79");extern unsigned int
-zOss_ResetNVFactory(void);extern unsigned int zOss_NvramFlush(void);extern
-unsigned int zOss_NvItemWrite(unsigned int,unsigned char*,unsigned int);extern
-int zDrvNand_Program(unsigned int,unsigned int,unsigned char*);extern void
-zOss_NvItemWriteFactory(unsigned int,unsigned char*,unsigned int);extern int
-zDrvNand_ChangeNvrAttr(unsigned int);extern unsigned int zOss_NvItemRead(
-unsigned int,unsigned char*,unsigned int);extern ssize_t zCatAgt_App_Write(const
- char*,size_t);extern ssize_t zCatAgt_Kernel_Write(const char*,size_t);extern
-void linux_oss_tick_timer_function(void);extern unsigned int
-zOss_GetExceptResetFlag(void);extern int zSys_ExceptReboot(unsigned int);extern
-int zDrvRpMsg_Write(const void*);extern int zDrvRpMsg_CreateChannel(unsigned int
-,unsigned int,unsigned int size);extern int zDrvRpMsg_RegCallBack(unsigned int,
-unsigned int,void*);extern int zAti_CidIsUsed(unsigned char);extern int
-zAti2_Send(unsigned char,unsigned char*,unsigned short,unsigned int);extern
-unsigned char zAti_GetDualCardStat(unsigned char*pbSim1Stat,unsigned char*
-pbSim2Stat,unsigned char*pbIsCardSwitching);extern unsigned char*zPutSkb2Psbuf(
-unsigned char*,unsigned short,unsigned char*,unsigned char*);extern unsigned
-short zGetUpLinkSduSize(void);extern int zAti2_Open(unsigned char);extern
-unsigned int zAt_AutoTestInit(void);extern int zAti2_IsExCid(unsigned char,
-unsigned char*);extern void zUsat_RegisterSendMsgFun(void*);extern int
-zAti2_RegRecvCb(void*);extern void zUsat_SendAtCmd(unsigned int,const unsigned
-char*,unsigned short,unsigned int);extern void AmtAgent_ComposeAndProcess(
-unsigned char*,unsigned int);extern void RegSendDataToAmtAppFunction(void*);
-extern void zDrvLpm_IrqDisable(unsigned int);extern void zDrvLpm_IrqEnable(
-unsigned int);extern void zDrvInt_MaskIrq(unsigned int);extern void
-zDrvInt_UnmaskIrq(unsigned int);extern int zPs_IsTdMasterMode(void);extern int
-zPs_IsLteMasterMode(void);extern int zPs_IsFddMasterMode(void);extern void
-psm_ModemDevSleep(void);extern bool psm_ModemSleepCheck(void);extern unsigned
-int psm_ModemSleepTimeGet(void);extern void psm_GetModemSleepFlagStatus(void);
-extern void psm_TimeCompensate(unsigned int);extern void zFreeDlBuf(unsigned
-char*);extern int zte_modem_start(void);extern unsigned long
-Comm_Read_CP_TO_AP_Data(const char*,unsigned long);extern unsigned long
-Comm_Write_AP_TO_CP_Data(const char*,unsigned long);extern int zDrvVoice_Close(
-void);extern int zDrvVoice_ReadStart(void);extern int zDrvVoice_ReadStop(void);
-extern int zDrvVoice_WriteStart(void);extern int zDrvVoice_WriteStop(void);
-extern int zDrvVoice_Open(void*);extern int zDrvVoice_WriteOneFrame(unsigned
-char*);extern int zDrvVoice_ReadOneFrame(unsigned char*);extern int
-halVoice_SetPathIn(void*);extern int halVoice_SetPathOut(void*);extern int
-halVoice_SetVolOut(void*);extern int halVoice_Enable(void);extern int
-halVoice_Open(void);extern int halVoice_Disable(void);extern int halVoice_Close(
-void);extern int halVoice_Open3G(void);extern int halVoice_Close3G(void);extern
-int zDrv_Audio_Printf(void*,...);extern void zDrvVp_SetDtmfMute_Wrap(void);
-extern int zDrvVp_SetTone_Wrap(int);extern int zDrvVp_SetMute_Wrap(int);extern
-int zDrvVp_GetMute_Wrap(void);extern int zDrvVp_SetRxMute_Wrap(int);extern int
-zDrvVp_GetRxMute_Wrap(void);extern int zDrvVp_SetVol_Wrap(int);extern int
-zDrvVp_GetVol_Wrap(void);extern int zDrvVp_GetTxVol_Wrap(void);extern int
-zDrvVp_SetTxVol_Wrap(int);extern int zDrvVp_SetVol_Gain_Wrap(int);extern int
-zDrvVp_GetVol_Gain_Wrap(void);extern int zDrvVp_SetTxVol_Gain_Wrap(int);extern
-int zDrvVp_GetTxVol_Gain_Wrap(void);extern int zDrvVp_GetPath_Wrap(void);extern
-int zDrvVp_Loop(int);extern int zDrvVp_Soft_Dtmf_Loop(int);extern void
-zDrvDtmf_Detect_RegCallbacks(T_DrvDtmf_Detect_Opt);extern int
-zDrvVp_SetPath_Wrap(int);extern int zDrvVp_GetPath_Wrap(void);extern int
-zDrvVp_GetSlicFlag(void);extern int zDrvVp_SetEchoDelay_Wrap(int val);extern int
- zDrvVp_GetEchoDelay_Wrap(void);extern int zDrvVp_SetTxNsMode_Wrap(int val);
-extern int zDrvVp_GetTxNsMode_Wrap(void);extern int zDrvVp_SetRxNsMode_Wrap(int
-val);extern int zDrvVp_GetRxNsMode_Wrap(void);extern int
-zDrvVp_SetModuleState_Wrap(int*,int);extern int zDrvVp_GetModuleState_Wrap(int*,
-int);extern VOID*mmp_AmrDecOpen(T_zMmp_CodecType codecType);extern VOID*
-mmp_AmrEncOpen(T_zMmp_CodecType codecType,BOOL isDtxEnable);extern UINT16
-mmp_AmrDecode(VOID*pCodecContext,const UINT8*pAmr,UINT16*pPcm);extern UINT16
-mmp_AmrEncode(VOID*pCodecContext,T_zMmp_AmrEncMode mode,const UINT16*pPcm,UINT8*
-pAmr);extern VOID mmp_AmrDecClose(VOID*pCodecContext);extern VOID
-mmp_AmrEncClose(VOID*pCodecContext);extern UINT8 zDrvEdcp_IsBusy(int EdcpNum);
-extern SINT32 zDrvVp_AudioDataWrite(const VOID*pBuf,UINT32 uiLen);extern SINT32
-zDrvVp_AudioDataOpen(UINT32 audioType,UINT32 sampleRate);extern SINT32
-zDrvVp_AudioDataClose(void);extern SINT32 zDrvVp_GetVpLoop_Wrap(VOID);extern
-VOID zDrvVp_Status(UINT32*sample_rate,UINT32*voice_status);extern VOID
-zDrvVp_UpdateVoiceNv(UINT8*voice_nv_update);extern int zDrvVp_SetVoiceProc_Wrap(
-int val);extern int zDrvVp_GetVoiceProc_Wrap(void);extern int
-zDrvVp_SetVoiceBuffer_Wrap(int en,int type);extern void
-zDrvVp_GetVoiceBuffer_Wrap(int*en,int*type);typedef struct cpko_section{unsigned
- int cpko_text_start;unsigned int cpko_rodata_start;unsigned int
-__utran_modem_text_start;unsigned int __lte_modem_text_start;unsigned int
-__comm_modem_text_start;unsigned int modem_text_end;unsigned int cpko_data_start
-;unsigned int cpko_bss_start;unsigned int cpko_text_offset;}cpko_section_layout;
-cpko_section_layout cpko_ps_section;int raise(int signo){return
-(0xbe2+1493-0x11b7);}extern unsigned int SysEntry(void);static int
-ko_Main_Thread(void*data){struct sched_param param={.sched_priority=
-MAX_USER_RT_PRIO/(0x4f+8692-0x2241)-(0xc10+5749-0x2282)};int ret=
-(0x6ec+936-0xa94);sched_setscheduler(current,SCHED_FIFO,¶m);ret=SysEntry();
-if(ret!=(0x1116+3896-0x204e))panic("Main_Thread\n");param.sched_priority=
-MAX_USER_RT_PRIO-(0xd7f+3763-0x1c04);sched_setscheduler(kthreadd_task,SCHED_FIFO
-,¶m);return(0x50b+1822-0xc29);}int zte_modem_ko_start(void){kthread_run(
-ko_Main_Thread,NULL,"\x5a\x54\x45\x4d\x61\x69\x6e\x54\x68\x72\x65\x61\x64");
-return(0xe73+5178-0x22ad);}static void cpko_sectioninfo_set(void){int ret;struct
- file*fp;mm_segment_t old_fs;loff_t cpko_pos=(0x157a+1546-0x1b84);struct
-cpps_globalModem globalVar;fp=filp_open(
-"\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x5f\x73\x65\x63\x69\x6e\x66\x6f\x2e\x62\x69\x6e"
-,(0xb9+3122-0xceb),(0xd77+2874-0x18b1));if(IS_ERR(fp)||fp==NULL)panic(
-"\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");old_fs=
-get_fs();set_fs(KERNEL_DS);ret=vfs_read(fp,(char*)&cpko_ps_section,sizeof(
-cpko_section_layout),&cpko_pos);if(ret<=(0xa3c+5561-0x1ff5))panic(
-"\x72\x65\x61\x64\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");filp_close(
-fp,NULL);
+
+MODULE_AUTHOR("ZTE");
+MODULE_LICENSE("Proprietary");
+
+extern unsigned int zOss_ResetNVFactory(void);
+extern unsigned int zOss_NvramFlush(void);
+extern unsigned int zOss_NvItemWrite(unsigned int,unsigned char *,unsigned int);
+extern int zDrvNand_Program(unsigned int,unsigned int,unsigned char *);
+extern void zOss_NvItemWriteFactory(unsigned int,unsigned char *,unsigned int);
+extern int zDrvNand_ChangeNvrAttr(unsigned int);
+extern unsigned int zOss_NvItemRead(unsigned int,unsigned char *,unsigned int);
+extern ssize_t zCatAgt_App_Write(const char *, size_t);
+extern ssize_t zCatAgt_Kernel_Write(const char *, size_t);
+extern void linux_oss_tick_timer_function(void);
+extern unsigned int zOss_GetExceptResetFlag(void);
+extern int zSys_ExceptReboot(unsigned int);
+extern int zDrvRpMsg_Write(const void *);
+extern int zDrvRpMsg_CreateChannel(unsigned int, unsigned int, unsigned int size);
+extern int zDrvRpMsg_RegCallBack(unsigned int, unsigned int, void *);
+extern int zAti_CidIsUsed(unsigned char);
+//extern unsigned char *zGetpsbufferHead(unsigned char *);
+extern int zAti2_Send(unsigned char , unsigned char *, unsigned short , unsigned int );
+extern unsigned char zAti_GetDualCardStat(unsigned char *pbSim1Stat, unsigned char *pbSim2Stat, unsigned char *pbIsCardSwitching);
+extern unsigned char *zPutSkb2Psbuf(unsigned char *, unsigned short, unsigned char *, unsigned char *);
+extern unsigned short zGetUpLinkSduSize(void);
+extern int zAti2_Open(unsigned char);
+extern unsigned int zAt_AutoTestInit(void);
+extern int zAti2_IsExCid(unsigned char,unsigned char *);
+extern void zUsat_RegisterSendMsgFun(void *);
+extern int zAti2_RegRecvCb(void *);
+extern void zUsat_SendAtCmd(unsigned int, const unsigned char *, unsigned short, unsigned int);
+extern void AmtAgent_ComposeAndProcess(unsigned char *, unsigned int);
+extern void RegSendDataToAmtAppFunction(void *);
+extern void zDrvLpm_IrqDisable(unsigned int);
+extern void zDrvLpm_IrqEnable(unsigned int);
+extern void zDrvInt_MaskIrq(unsigned int);
+extern void zDrvInt_UnmaskIrq(unsigned int);
+extern int zPs_IsTdMasterMode(void);
+extern int zPs_IsLteMasterMode(void);
+extern int zPs_IsFddMasterMode(void);
+extern void psm_ModemDevSleep(void);
+extern bool psm_ModemSleepCheck(void);
+extern unsigned int psm_ModemSleepTimeGet(void);
+extern void psm_GetModemSleepFlagStatus(void);
+extern void psm_TimeCompensate(unsigned int);
+extern void zFreeDlBuf(unsigned char *);
+extern int zte_modem_start(void);
+extern unsigned long Comm_Read_CP_TO_AP_Data(const char *, unsigned long);
+extern unsigned long Comm_Write_AP_TO_CP_Data(const char *, unsigned long);
+extern int zDrvVoice_Close(void);
+extern int zDrvVoice_ReadStart(void);
+extern int zDrvVoice_ReadStop(void);
+extern int zDrvVoice_WriteStart(void);
+extern int zDrvVoice_WriteStop(void);
+extern int zDrvVoice_Open(void *);
+extern int zDrvVoice_WriteOneFrame(unsigned char *);
+extern int zDrvVoice_ReadOneFrame(unsigned char *);
+extern int halVoice_SetPathIn(void *);
+extern int halVoice_SetPathOut(void *);
+extern int halVoice_SetVolOut(void *);
+extern int halVoice_Enable(void);
+extern int halVoice_Open(void);
+extern int halVoice_Disable(void);
+extern int halVoice_Close(void);
+extern int halVoice_Open3G(void);
+extern int halVoice_Close3G(void);
+extern int zDrv_Audio_Printf(void *, ...);
+extern void zDrvVp_SetDtmfMute_Wrap(void);
+extern int zDrvVp_SetTone_Wrap(int);
+extern int zDrvVp_SetMute_Wrap(int);
+extern int zDrvVp_GetMute_Wrap(void);
+extern int zDrvVp_SetRxMute_Wrap(int );
+extern int zDrvVp_GetRxMute_Wrap(void);
+extern int zDrvVp_SetVol_Wrap(int);
+extern int zDrvVp_GetVol_Wrap(void);
+extern int zDrvVp_GetTxVol_Wrap(void);
+extern int zDrvVp_SetTxVol_Wrap(int);
+extern int zDrvVp_SetVol_Gain_Wrap(int);
+extern int zDrvVp_GetVol_Gain_Wrap(void);
+extern int zDrvVp_SetTxVol_Gain_Wrap(int);
+extern int zDrvVp_GetTxVol_Gain_Wrap(void);
+extern int zDrvVp_GetPath_Wrap(void);
+extern int zDrvVp_Loop(int);
+extern int zDrvVp_Soft_Dtmf_Loop(int);
+extern void zDrvDtmf_Detect_RegCallbacks(T_DrvDtmf_Detect_Opt);
+extern int zDrvVp_SetPath_Wrap(int);
+extern int zDrvVp_GetPath_Wrap(void);
+extern int zDrvVp_GetSlicFlag(void);
+extern int zDrvVp_SetEchoDelay_Wrap(int val);
+extern int zDrvVp_GetEchoDelay_Wrap(void);
+extern int zDrvVp_SetTxNsMode_Wrap(int val);
+extern int zDrvVp_GetTxNsMode_Wrap(void);
+extern int zDrvVp_SetRxNsMode_Wrap(int val);
+extern int zDrvVp_GetRxNsMode_Wrap(void);
+extern int zDrvVp_SetModuleState_Wrap(int *,int);
+extern int zDrvVp_GetModuleState_Wrap(int *,int);
+extern VOID* mmp_AmrDecOpen (T_zMmp_CodecType codecType);
+extern VOID* mmp_AmrEncOpen (T_zMmp_CodecType codecType, BOOL isDtxEnable);
+extern UINT16 mmp_AmrDecode (VOID *pCodecContext, const UINT8 *pAmr, UINT16 *pPcm);
+extern UINT16 mmp_AmrEncode (VOID *pCodecContext, T_zMmp_AmrEncMode mode, const UINT16 *pPcm, UINT8 *pAmr);
+extern VOID mmp_AmrDecClose (VOID *pCodecContext);
+extern VOID mmp_AmrEncClose (VOID *pCodecContext);
+extern UINT8 zDrvEdcp_IsBusy(int EdcpNum);
+extern SINT32 zDrvVp_AudioDataWrite(const VOID *pBuf, UINT32 uiLen);
+extern SINT32 zDrvVp_AudioDataOpen(UINT32 audioType, UINT32 sampleRate);
+extern SINT32 zDrvVp_AudioDataClose(void);
+extern SINT32 zDrvVp_GetVpLoop_Wrap(VOID);
+extern VOID zDrvVp_Status(UINT32 *sample_rate, UINT32 *voice_status);
+extern VOID zDrvVp_UpdateVoiceNv(UINT8 *voice_nv_update);
+extern int zDrvVp_SetVoiceProc_Wrap(int val);
+extern int zDrvVp_GetVoiceProc_Wrap(void);
+extern int zDrvVp_SetVoiceBuffer_Wrap(int en,int type);
+extern void zDrvVp_GetVoiceBuffer_Wrap(int *en,int *type);
+
+
+
+
+typedef struct cpko_section {
+ unsigned int cpko_text_start;
+ unsigned int cpko_rodata_start;
+ unsigned int __utran_modem_text_start;
+ unsigned int __lte_modem_text_start;
+ unsigned int __comm_modem_text_start;
+ unsigned int modem_text_end;
+ unsigned int cpko_data_start;
+ unsigned int cpko_bss_start;
+ unsigned int cpko_text_offset;
+} cpko_section_layout;
+cpko_section_layout cpko_ps_section;
+
+
+int raise(int signo)
+{
+ return 0x00;
+}
+
+//__initdata DECLARE_COMPLETION(sysentry_done);
+
+extern unsigned int SysEntry(void);
+static int ko_Main_Thread(void * data)
+{
+ struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO/2 - 3 };
+ int ret = 0;
+
+ sched_setscheduler(current, SCHED_FIFO, ¶m);
+
+ ret = SysEntry();
+ if(ret != 0)
+ panic("Main_Thread\n");
+
+ param.sched_priority = MAX_USER_RT_PRIO - 46;
+ sched_setscheduler(kthreadd_task, SCHED_FIFO, ¶m);
+
+ return 0;
+}
+
+int zte_modem_ko_start(void)
+{
+
+ kthread_run(ko_Main_Thread, NULL, "ZTEMainThread");
+ //wait_for_completion(&sysentry_done);
+
+ return 0;
+}
+static void cpko_sectioninfo_set(void)
+{
+ int ret;
+ struct file *fp;
+ mm_segment_t old_fs;
+ loff_t cpko_pos = 0;
+ struct cpps_globalModem globalVar;
+
+ fp = filp_open("/lib/cpko/cpko_secinfo.bin", 0, 0);
+ if(IS_ERR(fp) || fp == NULL)
+ panic("open file error\n");
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ ret = vfs_read(fp, (char*)&cpko_ps_section, sizeof(cpko_section_layout), &cpko_pos);
+ if (ret <= 0)
+ panic("read file error\n");
+ filp_close(fp, NULL);
+
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-fp=filp_open(
-"\x2f\x6c\x69\x62\x2f\x63\x70\x6b\x6f\x2f\x63\x70\x6b\x6f\x2e\x6b\x6f",
-(0x12d8+3575-0x20cf),(0x11ad+2890-0x1cf7));if(IS_ERR(fp)||fp==NULL)panic(
-"\x6f\x70\x65\x6e\x20\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");fp->f_ra.
-ra_pages=(0xec5+3427-0x1c28);
+ fp = filp_open("/lib/cpko/cpko.ko",0, 0);
+ if(IS_ERR(fp) || fp == NULL)
+ panic("open file error\n");
+ fp->f_ra.ra_pages = 0;
#endif
-if(cpko_ps_section.cpko_text_start){globalVar.cpko_text_start=(unsigned long)
-cpko_ps_section.cpko_text_start;globalVar.cpko_rodata_start=(unsigned long)
-cpko_ps_section.cpko_rodata_start;globalVar.cpko_data_start=(unsigned long)
-cpko_ps_section.cpko_data_start;globalVar.cpko_bss_start=(unsigned long)
-cpko_ps_section.cpko_bss_start;
+
+ if (cpko_ps_section.cpko_text_start){
+ globalVar.cpko_text_start = (unsigned long)cpko_ps_section.cpko_text_start;
+ globalVar.cpko_rodata_start = (unsigned long)cpko_ps_section.cpko_rodata_start;
+ globalVar.cpko_data_start = (unsigned long)cpko_ps_section.cpko_data_start;
+ globalVar.cpko_bss_start = (unsigned long)cpko_ps_section.cpko_bss_start;
+
+
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-globalVar.fp_code=fp;globalVar.__utran_modem_text_start=(unsigned long)
-cpko_ps_section.__utran_modem_text_start;globalVar.__lte_modem_text_start=(
-unsigned long)cpko_ps_section.__lte_modem_text_start;globalVar.
-__comm_modem_text_start=(unsigned long)cpko_ps_section.__comm_modem_text_start;
-globalVar.modem_text_end=(unsigned long)cpko_ps_section.modem_text_end;globalVar
-.modem_offset=cpko_ps_section.cpko_text_offset;
+ globalVar.fp_code = fp;
+ globalVar.__utran_modem_text_start = (unsigned long)cpko_ps_section.__utran_modem_text_start;
+ globalVar.__lte_modem_text_start = (unsigned long)cpko_ps_section.__lte_modem_text_start;
+ globalVar.__comm_modem_text_start = (unsigned long)cpko_ps_section.__comm_modem_text_start;
+ globalVar.modem_text_end = (unsigned long)cpko_ps_section.modem_text_end;
+ globalVar.modem_offset = cpko_ps_section.cpko_text_offset;
#endif
-cpps_globalVar_register(&globalVar);
+ cpps_globalVar_register(&globalVar);
+
#ifdef CONFIG_MODEM_CODE_IS_MAPPING
-vfree_modem_section(globalVar.cpko_text_start,globalVar.modem_text_end);
+ vfree_modem_section(globalVar.cpko_text_start, globalVar.modem_text_end);
#endif
-}else panic("\x66\x69\x6c\x65\x20\x65\x72\x72\x6f\x72" "\n");}static int
-cpko_start(void){struct cpps_callbacks callback={(0x4ea+531-0x6fd)};callback.
-zOss_ResetNVFactory=zOss_ResetNVFactory;callback.zOss_NvramFlush=zOss_NvramFlush
-;callback.zOss_NvItemWrite=zOss_NvItemWrite;callback.zOss_NvItemWriteFactory=
-zOss_NvItemWriteFactory;callback.zOss_NvItemRead=zOss_NvItemRead;callback.
-zCatAgt_App_Write=zCatAgt_App_Write;callback.zCatAgt_Kernel_Write=
-zCatAgt_Kernel_Write;callback.linux_oss_tick_timer_function=
-linux_oss_tick_timer_function;callback.zOss_GetExceptResetFlag=
-zOss_GetExceptResetFlag;callback.zSys_ExceptReboot=zSys_ExceptReboot;callback.
-zDrvRpMsg_Write=zDrvRpMsg_Write;callback.zDrvRpMsg_CreateChannel=
-zDrvRpMsg_CreateChannel;callback.zDrvRpMsg_RegCallBack=zDrvRpMsg_RegCallBack;
-callback.zDrvLpm_IrqDisable=zDrvLpm_IrqDisable;callback.zDrvInt_MaskIrq=
-zDrvInt_MaskIrq;callback.zDrvLpm_IrqEnable=zDrvLpm_IrqEnable;callback.
-zDrvInt_UnmaskIrq=zDrvInt_UnmaskIrq;callback.Comm_Read_CP_TO_AP_Data=
-Comm_Read_CP_TO_AP_Data;callback.Comm_Write_AP_TO_CP_Data=
-Comm_Write_AP_TO_CP_Data;callback.zDrvEdcp_IsBusy=zDrvEdcp_IsBusy;
+ }
+ else
+ panic("file error\n");
+}
+static int cpko_start(void)
+{
+ struct cpps_callbacks callback = {0};
+
+ //memset(&callback, 0 , sizeof(callback));
+
+ callback.zOss_ResetNVFactory = zOss_ResetNVFactory;
+ callback.zOss_NvramFlush = zOss_NvramFlush;
+ callback.zOss_NvItemWrite = zOss_NvItemWrite;
+ callback.zOss_NvItemWriteFactory = zOss_NvItemWriteFactory;
+ callback.zOss_NvItemRead = zOss_NvItemRead;
+ callback.zCatAgt_App_Write = zCatAgt_App_Write;
+ callback.zCatAgt_Kernel_Write = zCatAgt_Kernel_Write;
+ callback.linux_oss_tick_timer_function = linux_oss_tick_timer_function;
+ callback.zOss_GetExceptResetFlag = zOss_GetExceptResetFlag;
+ callback.zSys_ExceptReboot = zSys_ExceptReboot;
+ callback.zDrvRpMsg_Write = zDrvRpMsg_Write;
+ callback.zDrvRpMsg_CreateChannel = zDrvRpMsg_CreateChannel;
+ callback.zDrvRpMsg_RegCallBack = zDrvRpMsg_RegCallBack;
+ callback.zDrvLpm_IrqDisable = zDrvLpm_IrqDisable;
+ callback.zDrvInt_MaskIrq = zDrvInt_MaskIrq;
+ callback.zDrvLpm_IrqEnable = zDrvLpm_IrqEnable;
+ callback.zDrvInt_UnmaskIrq = zDrvInt_UnmaskIrq;
+ callback.Comm_Read_CP_TO_AP_Data = Comm_Read_CP_TO_AP_Data;
+ callback.Comm_Write_AP_TO_CP_Data = Comm_Write_AP_TO_CP_Data;
+ callback.zDrvEdcp_IsBusy = zDrvEdcp_IsBusy;
+
#ifndef _USE_TestHarness
-callback.zAti2_Open=zAti2_Open;callback.zAt_AutoTestInit=zAt_AutoTestInit;
-callback.zAti2_IsExCid=zAti2_IsExCid;callback.zPutSkb2Psbuf=zPutSkb2Psbuf;
-callback.zAti_CidIsUsed=zAti_CidIsUsed;callback.zAti2_Send=zAti2_Send;callback.
-zAti_GetDualCardStat=zAti_GetDualCardStat;callback.zGetUpLinkSduSize=
-zGetUpLinkSduSize;callback.zUsat_RegisterSendMsgFun=zUsat_RegisterSendMsgFun;
-callback.zAti2_RegRecvCb=zAti2_RegRecvCb;callback.zUsat_SendAtCmd=
-zUsat_SendAtCmd;callback.RegSendDataToAmtAppFunction=RegSendDataToAmtAppFunction
-;callback.zFreeDlBuf=zFreeDlBuf;callback.AmtAgent_ComposeAndProcess=
-AmtAgent_ComposeAndProcess;callback.zPs_IsTdMasterMode=zPs_IsTdMasterMode;
-callback.zPs_IsLteMasterMode=zPs_IsLteMasterMode;callback.zPs_IsFddMasterMode=
-zPs_IsFddMasterMode;
+ callback.zAti2_Open = zAti2_Open;
+ callback.zAt_AutoTestInit = zAt_AutoTestInit;
+ callback.zAti2_IsExCid = zAti2_IsExCid;
+ callback.zPutSkb2Psbuf = zPutSkb2Psbuf;
+ //callback.zGetpsbufferHead = zGetpsbufferHead;
+ callback.zAti_CidIsUsed = zAti_CidIsUsed;
+ callback.zAti2_Send = zAti2_Send;
+ callback.zAti_GetDualCardStat = zAti_GetDualCardStat;
+ callback.zGetUpLinkSduSize = zGetUpLinkSduSize;
+ callback.zUsat_RegisterSendMsgFun = zUsat_RegisterSendMsgFun;
+ callback.zAti2_RegRecvCb = zAti2_RegRecvCb;
+ callback.zUsat_SendAtCmd = zUsat_SendAtCmd;
+ callback.RegSendDataToAmtAppFunction = RegSendDataToAmtAppFunction;
+ callback.zFreeDlBuf = zFreeDlBuf;
+ callback.AmtAgent_ComposeAndProcess = AmtAgent_ComposeAndProcess;
+ callback.zPs_IsTdMasterMode = zPs_IsTdMasterMode;
+ callback.zPs_IsLteMasterMode = zPs_IsLteMasterMode;
+ callback.zPs_IsFddMasterMode = zPs_IsFddMasterMode;
#ifdef USE_VOICE_SUPPORT
-callback.zDrvVoice_Close=zDrvVoice_Close;callback.zDrvVoice_ReadStart=
-zDrvVoice_ReadStart;callback.zDrvVoice_ReadStop=zDrvVoice_ReadStop;callback.
-zDrvVoice_WriteStart=zDrvVoice_WriteStart;callback.zDrvVoice_WriteStop=
-zDrvVoice_WriteStop;callback.zDrvVoice_Open=zDrvVoice_Open;callback.
-zDrvVoice_WriteOneFrame=zDrvVoice_WriteOneFrame;callback.zDrvVoice_ReadOneFrame=
-zDrvVoice_ReadOneFrame;callback.halVoice_SetPathIn=halVoice_SetPathIn;callback.
-halVoice_SetPathOut=halVoice_SetPathOut;callback.halVoice_SetVolOut=
-halVoice_SetVolOut;callback.halVoice_Enable=halVoice_Enable;callback.
-halVoice_Open=halVoice_Open;callback.halVoice_Disable=halVoice_Disable;callback.
-halVoice_Close=halVoice_Close;callback.zDrv_Audio_Printf=zDrv_Audio_Printf;
-callback.zDrvVp_SetTone_Wrap=zDrvVp_SetTone_Wrap;callback.zDrvVp_SetMute_Wrap=
-zDrvVp_SetMute_Wrap;callback.zDrvVp_GetMute_Wrap=zDrvVp_GetMute_Wrap;callback.
-zDrvVp_SetRxMute_Wrap=zDrvVp_SetRxMute_Wrap;callback.zDrvVp_GetRxMute_Wrap=
-zDrvVp_GetRxMute_Wrap;callback.zDrvVp_SetVol_Wrap=zDrvVp_SetVol_Wrap;callback.
-zDrvVp_GetVol_Wrap=zDrvVp_GetVol_Wrap;callback.zDrvVp_SetDtmfMute_Wrap=
-zDrvVp_SetDtmfMute_Wrap;callback.zDrvVp_SetTxVol_Wrap=zDrvVp_SetTxVol_Wrap;
-callback.zDrvVp_GetTxVol_Wrap=zDrvVp_GetTxVol_Wrap;callback.
-zDrvVp_SetVol_Gain_Wrap=zDrvVp_SetVol_Gain_Wrap;callback.zDrvVp_GetVol_Gain_Wrap
-=zDrvVp_GetVol_Gain_Wrap;callback.zDrvVp_SetTxVol_Gain_Wrap=
-zDrvVp_SetTxVol_Gain_Wrap;callback.zDrvVp_GetTxVol_Gain_Wrap=
-zDrvVp_GetTxVol_Gain_Wrap;callback.zDrvVp_GetPath_Wrap=zDrvVp_GetPath_Wrap;
-callback.zDrvVp_Loop=zDrvVp_Loop;callback.zDrvVp_GetVpLoop_Wrap=
-zDrvVp_GetVpLoop_Wrap;callback.zDrvVp_Soft_Dtmf_Loop=zDrvVp_Soft_Dtmf_Loop;
-callback.zDrvDtmf_Detect_RegCallbacks=zDrvDtmf_Detect_RegCallbacks;callback.
-zDrvVp_SetPath_Wrap=zDrvVp_SetPath_Wrap;callback.zDrvVp_GetPath_Wrap=
-zDrvVp_GetPath_Wrap;callback.halVoice_Open3G=halVoice_Open3G;callback.
-halVoice_Close3G=halVoice_Close3G;callback.zDrvVp_GetSlicFlag=zDrvVp_GetSlicFlag
-;callback.zDrvVp_SetVoiceProc_Wrap=zDrvVp_SetVoiceProc_Wrap;callback.
-zDrvVp_GetVoiceProc_Wrap=zDrvVp_GetVoiceProc_Wrap;callback.
-zDrvVp_SetVoiceBuffer_Wrap=zDrvVp_SetVoiceBuffer_Wrap;callback.
-zDrvVp_GetVoiceBuffer_Wrap=zDrvVp_GetVoiceBuffer_Wrap;callback.
-zDrvVp_SetEchoDelay_Wrap=zDrvVp_SetEchoDelay_Wrap;callback.
-zDrvVp_GetEchoDelay_Wrap=zDrvVp_GetEchoDelay_Wrap;callback.
-zDrvVp_SetTxNsMode_Wrap=zDrvVp_SetTxNsMode_Wrap;callback.zDrvVp_GetTxNsMode_Wrap
-=zDrvVp_GetTxNsMode_Wrap;callback.zDrvVp_SetRxNsMode_Wrap=
-zDrvVp_SetRxNsMode_Wrap;callback.zDrvVp_GetRxNsMode_Wrap=zDrvVp_GetRxNsMode_Wrap
-;callback.zDrvVp_SetModuleState_Wrap=zDrvVp_SetModuleState_Wrap;callback.
-zDrvVp_GetModuleState_Wrap=zDrvVp_GetModuleState_Wrap;callback.mmp_AmrDecOpen=
-mmp_AmrDecOpen;callback.mmp_AmrEncOpen=mmp_AmrEncOpen;callback.mmp_AmrDecode=
-mmp_AmrDecode;callback.mmp_AmrEncode=mmp_AmrEncode;callback.mmp_AmrDecClose=
-mmp_AmrDecClose;callback.mmp_AmrEncClose=mmp_AmrEncClose;callback.
-zDrvVp_AudioDataOpen=zDrvVp_AudioDataOpen;callback.zDrvVp_AudioDataWrite=
-zDrvVp_AudioDataWrite;callback.zDrvVp_AudioDataClose=zDrvVp_AudioDataClose;
-callback.zDrvVp_Status=zDrvVp_Status;callback.zDrvVp_UpdateVoiceNv=
-zDrvVp_UpdateVoiceNv;
+ callback.zDrvVoice_Close = zDrvVoice_Close;
+ callback.zDrvVoice_ReadStart = zDrvVoice_ReadStart;
+ callback.zDrvVoice_ReadStop = zDrvVoice_ReadStop;
+ callback.zDrvVoice_WriteStart = zDrvVoice_WriteStart;
+ callback.zDrvVoice_WriteStop = zDrvVoice_WriteStop;
+ callback.zDrvVoice_Open = zDrvVoice_Open;
+ callback.zDrvVoice_WriteOneFrame = zDrvVoice_WriteOneFrame;
+ callback.zDrvVoice_ReadOneFrame = zDrvVoice_ReadOneFrame;
+ callback.halVoice_SetPathIn = halVoice_SetPathIn;
+ callback.halVoice_SetPathOut = halVoice_SetPathOut;
+ callback.halVoice_SetVolOut = halVoice_SetVolOut;
+ callback.halVoice_Enable = halVoice_Enable;
+ callback.halVoice_Open = halVoice_Open;
+ callback.halVoice_Disable = halVoice_Disable;
+ callback.halVoice_Close = halVoice_Close;
+ callback.zDrv_Audio_Printf = zDrv_Audio_Printf;
+ callback.zDrvVp_SetTone_Wrap = zDrvVp_SetTone_Wrap;
+ callback.zDrvVp_SetMute_Wrap = zDrvVp_SetMute_Wrap;
+ callback.zDrvVp_GetMute_Wrap = zDrvVp_GetMute_Wrap;
+ callback.zDrvVp_SetRxMute_Wrap = zDrvVp_SetRxMute_Wrap;
+ callback.zDrvVp_GetRxMute_Wrap = zDrvVp_GetRxMute_Wrap;
+ callback.zDrvVp_SetVol_Wrap = zDrvVp_SetVol_Wrap;
+ callback.zDrvVp_GetVol_Wrap = zDrvVp_GetVol_Wrap;
+ callback.zDrvVp_SetDtmfMute_Wrap = zDrvVp_SetDtmfMute_Wrap;
+ callback.zDrvVp_SetTxVol_Wrap = zDrvVp_SetTxVol_Wrap;
+ callback.zDrvVp_GetTxVol_Wrap = zDrvVp_GetTxVol_Wrap;
+ callback.zDrvVp_SetVol_Gain_Wrap = zDrvVp_SetVol_Gain_Wrap;
+ callback.zDrvVp_GetVol_Gain_Wrap = zDrvVp_GetVol_Gain_Wrap;
+ callback.zDrvVp_SetTxVol_Gain_Wrap = zDrvVp_SetTxVol_Gain_Wrap;
+ callback.zDrvVp_GetTxVol_Gain_Wrap = zDrvVp_GetTxVol_Gain_Wrap;
+ callback.zDrvVp_GetPath_Wrap = zDrvVp_GetPath_Wrap;
+ callback.zDrvVp_Loop = zDrvVp_Loop;
+ callback.zDrvVp_GetVpLoop_Wrap = zDrvVp_GetVpLoop_Wrap;
+ callback.zDrvVp_Soft_Dtmf_Loop = zDrvVp_Soft_Dtmf_Loop;
+ callback.zDrvDtmf_Detect_RegCallbacks = zDrvDtmf_Detect_RegCallbacks;
+ callback.zDrvVp_SetPath_Wrap = zDrvVp_SetPath_Wrap;
+ callback.zDrvVp_GetPath_Wrap = zDrvVp_GetPath_Wrap;
+ callback.halVoice_Open3G = halVoice_Open3G;
+ callback.halVoice_Close3G = halVoice_Close3G;
+ callback.zDrvVp_GetSlicFlag = zDrvVp_GetSlicFlag;
+ callback.zDrvVp_SetVoiceProc_Wrap = zDrvVp_SetVoiceProc_Wrap;
+ callback.zDrvVp_GetVoiceProc_Wrap = zDrvVp_GetVoiceProc_Wrap;
+ callback.zDrvVp_SetVoiceBuffer_Wrap = zDrvVp_SetVoiceBuffer_Wrap;
+ callback.zDrvVp_GetVoiceBuffer_Wrap = zDrvVp_GetVoiceBuffer_Wrap;
+ callback.zDrvVp_SetEchoDelay_Wrap = zDrvVp_SetEchoDelay_Wrap;
+ callback.zDrvVp_GetEchoDelay_Wrap = zDrvVp_GetEchoDelay_Wrap;
+ callback.zDrvVp_SetTxNsMode_Wrap = zDrvVp_SetTxNsMode_Wrap;
+ callback.zDrvVp_GetTxNsMode_Wrap = zDrvVp_GetTxNsMode_Wrap;
+ callback.zDrvVp_SetRxNsMode_Wrap = zDrvVp_SetRxNsMode_Wrap;
+ callback.zDrvVp_GetRxNsMode_Wrap = zDrvVp_GetRxNsMode_Wrap;
+ callback.zDrvVp_SetModuleState_Wrap = zDrvVp_SetModuleState_Wrap;
+ callback.zDrvVp_GetModuleState_Wrap = zDrvVp_GetModuleState_Wrap;
+ callback.mmp_AmrDecOpen = mmp_AmrDecOpen;
+ callback.mmp_AmrEncOpen = mmp_AmrEncOpen;
+ callback.mmp_AmrDecode = mmp_AmrDecode;
+ callback.mmp_AmrEncode = mmp_AmrEncode;
+ callback.mmp_AmrDecClose = mmp_AmrDecClose;
+ callback.mmp_AmrEncClose = mmp_AmrEncClose;
+ callback.zDrvVp_AudioDataOpen = zDrvVp_AudioDataOpen;
+ callback.zDrvVp_AudioDataWrite = zDrvVp_AudioDataWrite;
+ callback.zDrvVp_AudioDataClose = zDrvVp_AudioDataClose;
+ callback.zDrvVp_Status = zDrvVp_Status;
+ callback.zDrvVp_UpdateVoiceNv = zDrvVp_UpdateVoiceNv;
#endif
-callback.psm_ModemDevSleep=psm_ModemDevSleep;callback.psm_ModemSleepCheck=
-psm_ModemSleepCheck;callback.psm_ModemSleepTimeGet=psm_ModemSleepTimeGet;
-callback.psm_TimeCompensate=psm_TimeCompensate;callback.
-psm_GetModemSleepFlagStatus=psm_GetModemSleepFlagStatus;
+ callback.psm_ModemDevSleep = psm_ModemDevSleep;
+ callback.psm_ModemSleepCheck = psm_ModemSleepCheck;
+ callback.psm_ModemSleepTimeGet = psm_ModemSleepTimeGet;
+ callback.psm_TimeCompensate = psm_TimeCompensate;
+ callback.psm_GetModemSleepFlagStatus = psm_GetModemSleepFlagStatus;
+
#endif
-cpps_callbacks_register(&callback);cpko_sectioninfo_set();zte_modem_ko_start();
-return(0x78b+3070-0x1389);}static int cpko_stop(void){return(0xe11+1744-0x14e1);
-}module_init(cpko_start);module_exit(cpko_stop);
+
+
+ cpps_callbacks_register(&callback);
+ cpko_sectioninfo_set();
+ zte_modem_ko_start();
+
+ return 0;
+}
+
+static int cpko_stop(void)
+{
+ return 0;
+}
+
+module_init(cpko_start);
+module_exit(cpko_stop);
diff --git a/ap/os/linux/linux-3.4.x/drivers/mtd/mtdcore.c b/ap/os/linux/linux-3.4.x/drivers/mtd/mtdcore.c
index c837507..41e3903 100644
--- a/ap/os/linux/linux-3.4.x/drivers/mtd/mtdcore.c
+++ b/ap/os/linux/linux-3.4.x/drivers/mtd/mtdcore.c
@@ -40,6 +40,8 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/uaccess.h>
+
#include "mtdcore.h"
/*
* backing device capabilities for non-mappable devices (such as NAND flash)
@@ -250,6 +252,17 @@
}
static DEVICE_ATTR(name, S_IRUGO, mtd_name_show, NULL);
+#define MTD_RECORD_NAME_MAX (16)
+struct zxic_mtd_record
+{
+ char name[MTD_RECORD_NAME_MAX];
+ unsigned int erase_times;
+ unsigned int write_times;
+};
+
+static struct zxic_mtd_record g_zxic_mtd_record; //save data
+static int record_mtd_trigger_flag; // 0 stop record, 1 start record
+
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
&dev_attr_flags.attr,
@@ -701,6 +714,9 @@
mtd_erase_callback(instr);
return 0;
}
+
+ if (record_mtd_trigger_flag && (strcmp(mtd->name, g_zxic_mtd_record.name) == 0))
+ g_zxic_mtd_record.erase_times++;
return mtd->_erase(mtd, instr);
}
EXPORT_SYMBOL_GPL(mtd_erase);
@@ -776,6 +792,9 @@
return -EROFS;
if (!len)
return 0;
+ if (record_mtd_trigger_flag && (strcmp(mtd->name, g_zxic_mtd_record.name) == 0))
+ g_zxic_mtd_record.write_times++;
+
return mtd->_write(mtd, to, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_write);
@@ -1092,6 +1111,119 @@
return ret;
}
+/* Started by AICoder, pid:5fc9ey6dc555c241432c0bd800e0358e8d683380 */
+static struct proc_dir_entry *proc_record_mtd_name;
+static struct proc_dir_entry *proc_record_mtd_trigger;
+static struct proc_dir_entry *proc_record_mtd_erase_times;
+
+static ssize_t proc_record_mtd_name_read(struct file *file, char __user *user_buffer, size_t count, loff_t *offset) {
+ if (g_zxic_mtd_record.name[0] != '\0')
+ return simple_read_from_buffer(user_buffer, count, offset, g_zxic_mtd_record.name, strlen(g_zxic_mtd_record.name));
+ else
+ return 0;
+}
+
+static ssize_t proc_record_mtd_name_write(struct file *file, const char __user *user_buffer, size_t count, loff_t *offset) {
+ if (count <= 1 || count >= MTD_RECORD_NAME_MAX) {
+ return -EINVAL;
+ }
+
+ if (copy_from_user(g_zxic_mtd_record.name, user_buffer, count)) {
+ return -EFAULT;
+ }
+
+ g_zxic_mtd_record.name[count-1] = '\0'; // last 1 byte 0x0a
+ g_zxic_mtd_record.erase_times = 0;
+ g_zxic_mtd_record.write_times = 0;
+
+ return count;
+}
+
+static ssize_t proc_record_mtd_trigger_read(struct file *file, char __user *user_buffer, size_t count, loff_t *offset) {
+ if (record_mtd_trigger_flag)
+ return simple_read_from_buffer(user_buffer, count, offset, "start\n", 6);
+ else
+ return simple_read_from_buffer(user_buffer, count, offset, "stop\n", 5);
+}
+
+static ssize_t proc_record_mtd_trigger_write(struct file *file, const char __user *user_buffer, size_t count, loff_t *offset) {
+ char buffer[10];
+
+ if (count < 4 || count > 6)
+ return -EINVAL;
+ if (g_zxic_mtd_record.name[0] == '\0')
+ return -EINVAL; // mtd name not set
+ if (copy_from_user(buffer, user_buffer, count))
+ return -EFAULT;
+
+ buffer[count-1] = '\0'; // last 1 byte 0x0a
+ //printk("record mtd trigger:%s\n", buffer);
+
+ if (memcmp(buffer, "start", 5) == 0) {
+ printk(KERN_WARNING "record mtd erase and write start\n");
+ g_zxic_mtd_record.erase_times = 0;
+ g_zxic_mtd_record.write_times = 0;
+ record_mtd_trigger_flag = 1;
+ } else {
+ if (memcmp(buffer, "stop", 4) == 0)
+ {
+ printk(KERN_WARNING "record mtd erase and write stop\n");
+ record_mtd_trigger_flag = 0;
+ }
+ else
+ {
+ return -EINVAL;
+ }
+ }
+
+ return count;
+}
+
+static int proc_record_mtd_erase_times_show(struct seq_file *m, void *v)
+{
+ seq_printf(m, "mtd:%s\n", g_zxic_mtd_record.name);
+ seq_printf(m, "erase_times:%u\n", g_zxic_mtd_record.erase_times);
+ seq_printf(m, "write_times:%u\n", g_zxic_mtd_record.write_times);
+ return 0;
+}
+
+static int proc_record_mtd_erase_times_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, proc_record_mtd_erase_times_show, NULL);
+}
+
+static const struct file_operations proc_record_mtd_name_fops = {
+ .read = proc_record_mtd_name_read,
+ .write = proc_record_mtd_name_write,
+};
+
+static const struct file_operations proc_record_mtd_trigger_fops = {
+ .read = proc_record_mtd_trigger_read,
+ .write = proc_record_mtd_trigger_write,
+};
+
+static const struct file_operations proc_record_mtd_erase_times_fops = {
+ .open = proc_record_mtd_erase_times_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int zxic_record_proc_init(void)
+{
+ proc_record_mtd_name = proc_create("record_mtd_name", 0666, NULL, &proc_record_mtd_name_fops);
+ if (!proc_record_mtd_name)
+ return -ENOMEM;
+ proc_record_mtd_trigger = proc_create("record_mtd_trigger", 0666, NULL, &proc_record_mtd_trigger_fops);
+ if (!proc_record_mtd_trigger)
+ return -ENOMEM;
+ proc_record_mtd_erase_times = proc_create("record_mtd_erase_times", 0, NULL, &proc_record_mtd_erase_times_fops);
+ if (!proc_record_mtd_erase_times)
+ return -ENOMEM;
+ return 0;
+}
+/* Ended by AICoder, pid:5fc9ey6dc555c241432c0bd800e0358e8d683380 */
+
static int __init init_mtd(void)
{
int ret;
@@ -1111,6 +1243,8 @@
ret = mtd_bdi_init(&mtd_bdi_rw_mappable, "mtd-rwmap");
if (ret)
goto err_bdi3;
+ if (zxic_record_proc_init() < 0)
+ printk(KERN_ERR "zxic_record_proc_init error\n");
#ifdef CONFIG_PROC_FS
proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_driver.c b/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_driver.c
index 3c5fedb..2efcac2 100755
--- a/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_driver.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_driver.c
@@ -59,6 +59,7 @@
#include <mach/zx29_usb.h>
#include <mach/highspeed_debug.h>
+#include <linux/android_notify.h>
#include <mach/pcu.h>
#include <linux/wakelock.h>
@@ -82,6 +83,8 @@
extern void dwc_otg_adp_start(dwc_otg_core_if_t * core_if, uint8_t is_host);
extern void zx297510_usbdev_init(void);
+extern void usb_record_dbginfo(usb_dbginfo_type inf_type, int status, int info_value);
+
/*-------------------------------------------------------------------------*/
/* Encapsulate the module parameter settings */
@@ -561,6 +564,32 @@
return IRQ_RETVAL(retval);
}
extern void dwc_otg_clk_enable(int isOn);
+/* Started by AICoder, pid:n296220457x77611403308a3f08a597015d84c3c */
+static struct workqueue_struct *dwc_otg_powerdown_queue;
+
+static void dwc_otg_powerdown_up(struct work_struct *work)
+{
+ USBHAL_DBG("dwc_otg_suspend_irq");
+ printk("dwc_otg_suspend_irq");
+ // dwc_otg_clk_enable(0);
+ dwc_otg_wakelock(0,1);
+ //usb_printk("%s, %u,wake_unlock, usbclk:0x%08x, USBMODCFG:0x%08x\n", __func__, __LINE__, *(volatile u32 *)(ZX_TOP_CRM_BASE+0x6C), *(volatile u32 *)(ZX29_USB20_MOD_CFG0));
+ zx_cpuidle_set_free(IDLE_FLAG_USB);
+
+ usb_record_dbginfo(USB_USB_SUSPEND, 1, 1);
+}
+static DECLARE_WORK(powerdown_up_work, dwc_otg_powerdown_up);
+
+static void dwc_otg_powerdown_down(struct work_struct *work)
+{
+ dwc_otg_wakelock(1,1);
+ zx_cpuidle_set_busy(IDLE_FLAG_USB);
+ USBHAL_DBG("dwc_otg_wakeup_irq");
+ printk("dwc_otg_wakeup_irq");
+ usb_record_dbginfo(USB_USB_RESUME, 1, 1);
+}
+static DECLARE_WORK(powerdown_down_work, dwc_otg_powerdown_down);
+
static irqreturn_t dwc_otg_suspend_irq(int irq, void *dev)
{
@@ -571,10 +600,11 @@
if(dwc_otg_device->irq_request== 1){
USBHAL_DBG("dwc_otg_suspend_irq");
printk("dwc_otg_suspend_irq");
-// dwc_otg_clk_enable(0);
- dwc_otg_wakelock(0,1);
- //usb_printk("%s, %u,wake_unlock, usbclk:0x%08x, USBMODCFG:0x%08x\n", __func__, __LINE__, *(volatile u32 *)(ZX_TOP_CRM_BASE+0x6C), *(volatile u32 *)(ZX29_USB20_MOD_CFG0));
- zx_cpuidle_set_free(IDLE_FLAG_USB);
+ if(dwc_otg_powerdown_queue){
+ queue_work(dwc_otg_powerdown_queue, &powerdown_up_work);
+ }else{
+ USBHAL_DBG("dwc_otg_wakeup_irq,dwc_otg_powerdown_queue is null, do nothing\n");
+ }
}
else{
USBHAL_DBG("dwc_otg_suspend_irq,clear pending\n");
@@ -591,11 +621,14 @@
// wake_lock(&dwc_otg_wake_lock);
if(dwc_otg_device->irq_request== 1){
- dwc_otg_wakelock(1,1);
- zx_cpuidle_set_busy(IDLE_FLAG_USB);
USBHAL_DBG("dwc_otg_wakeup_irq");
printk("dwc_otg_wakeup_irq");
// dwc_otg_clk_enable(1);
+ if(dwc_otg_powerdown_queue){
+ queue_work(dwc_otg_powerdown_queue, &powerdown_down_work);
+ }else{
+ USBHAL_DBG("dwc_otg_wakeup_irq,dwc_otg_powerdown_queue is null, can't add wakelock\n");
+ }
//usb_printk("%s, %u,wake_lock, usbclk:0x%08x, USBMODCFG:0x%08x\n", __func__, __LINE__, *(volatile u32 *)(ZX_TOP_CRM_BASE+0x6C), *(volatile u32 *)(ZX29_USB20_MOD_CFG0));
}
else{
@@ -604,7 +637,7 @@
}
return IRQ_RETVAL(retval);
}
-
+/* Ended by AICoder, pid:n296220457x77611403308a3f08a597015d84c3c */
extern unsigned int pm_get_usb_pdd_pending(void);
void dwc_otg_powerdown_irq_install(void)
{
@@ -1046,6 +1079,11 @@
/* we init a main wakelock for maintain system on until app start ok! */
wake_lock_init(&dwc_otg_wake_lock.wake_lock, WAKE_LOCK_SUSPEND, "dwc_otg_pm");
+ dwc_otg_powerdown_queue = create_singlethread_workqueue("dwc_otg_powerdown_work");
+ if (dwc_otg_powerdown_queue == NULL) {
+ pr_err("%s: failed to create dwc_otg_powerdown_queue\n", __func__);
+
+ }
return retval;
}
@@ -1064,7 +1102,10 @@
driver_remove_file(&dwc_otg_driver.driver, &driver_attr_version);
platform_driver_unregister(&dwc_otg_driver);
- wake_lock_destroy(&dwc_otg_wake_lock.wake_lock);
+ wake_lock_destroy(&dwc_otg_wake_lock.wake_lock);
+ if(dwc_otg_powerdown_queue){
+ destroy_workqueue(dwc_otg_powerdown_queue);
+ }
usb_printk("%s module removed\n", dwc_driver_name);
}
diff --git a/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c b/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
index ebf9ea2..db7b7f8 100644
--- a/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
+++ b/ap/os/linux/linux-3.4.x/drivers/watchdog/zx_soft_wdt.c
@@ -53,12 +53,70 @@
#define WDT_REBOOT_RECORD_BASE (ZX_IRAM1_BASE+0x2410)
#define START_UP_STATUS_BASE (ZX_IRAM1_BASE+0x2420)
-#define USER_RESERVED_BASE (ZX_IRAM1_BASE+0x2424)
+#define USER_RESERVED_BASE (ZX_IRAM1_BASE+0x2424)
+#define OS_IRAM_STATISTIC_CNT (8)
+#define OS_IRAM_STATISTIC_CNT_C (5)
+#define OS_IRAM_STATISTIC_NAME_LEN (16)
+
+#define BASE_ADDR_STATISTIC_PSCPU (IRAM1_BASE_ADDR+0x2800) //IRAM1_A9_PSM_USE_BASE_ADDR+0x800
+#define BASE_LEN_STATISTIC_PSCPU (0x200UL)
+#define BASE_ADDR_STATISTIC_PHYCPU (BASE_ADDR_STATISTIC_PSCPU + BASE_LEN_STATISTIC_PSCPU)
+#define BASE_LEN_STATISTIC_PHYCPU (0x200UL)
+#define BASE_ADDR_STATISTIC_APCPU (BASE_ADDR_STATISTIC_PHYCPU + BASE_LEN_STATISTIC_PHYCPU)
+#define BASE_LEN_STATISTIC_APCPU (0x400UL)
+
+#define wdt_printk(fmt, args...) \
+{ \
+ printk(fmt, ##args); \
+ sc_debug_info_record(MODULE_ID_AP_REBOOT, fmt, ##args); \
+}
MODULE_AUTHOR("ZTE");
MODULE_LICENSE("GPL");
+typedef volatile struct {
+ unsigned int enable;
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned char name[OS_IRAM_STATISTIC_NAME_LEN];
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT];
+}t_iram_thread_statistic;
+
+typedef volatile struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned int data1;
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT];
+}t_iram_statistic;
+
+typedef volatile struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned char name[OS_IRAM_STATISTIC_NAME_LEN];
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT_C];
+}t_iram_thread_statistic_c;
+
+typedef volatile struct {
+ unsigned int cnt;
+ unsigned int index;
+ struct {
+ unsigned int data1;
+ unsigned int data2;
+ } statistics[OS_IRAM_STATISTIC_CNT_C];
+}t_iram_statistic_c;
+
+typedef struct
+{
+ char ramdump_reason[32]; //比如:ramdump_ap_appname
+ char kernel_reboot[32]; //比如:reboot_ap_appname
+} T_Reset_Reason;
typedef enum _T_WdtId
{
@@ -82,11 +140,29 @@
struct task_struct * current_task;
};
+#define THREAD_SWAPIN_PSCPU (BASE_ADDR_STATISTIC_PSCPU)
+#define IRQ_START_PSCPU (THREAD_SWAPIN_PSCPU + sizeof(t_iram_thread_statistic_c))
+#define IRQ_END_PSCPU (IRQ_START_PSCPU + sizeof(t_iram_statistic_c))
+//#define THREAD_SWAPIN_PHYCPU (BASE_ADDR_STATISTIC_PHYCPU)
+//#define IRQ_START_PHYCPU (THREAD_SWAPIN_PHYCPU + sizeof(t_iram_thread_statistic))
+//#define IRQ_END_PHYCPU (IRQ_START_PHYCPU + sizeof(t_iram_statistic))
+#define THREAD_SWAPIN_APCPU (BASE_ADDR_STATISTIC_APCPU)
+#define IRQ_START_APCPU (THREAD_SWAPIN_APCPU + sizeof(t_iram_thread_statistic))
+#define IRQ_END_APCPU (IRQ_START_APCPU + sizeof(t_iram_statistic))
+
static bool g_wdt_wakeup_flag = false;
static u32 g_wdt_wakeup_min_time = MAX_SLEEP_TIME;
static volatile u32 g_wdt_sleep_pre_time;
static unsigned int g_wdt_nv = 0;
-volatile unsigned int g_wdt_priority = 37;
+static volatile unsigned int g_wdt_priority = 37;
+
+static t_iram_thread_statistic_c *g_iram_swapin_statistic_cap = (t_iram_thread_statistic_c *)THREAD_SWAPIN_PSCPU;
+static t_iram_statistic_c *g_iram_irq_start_statistic_cap = (t_iram_statistic_c *)IRQ_START_PSCPU;
+static t_iram_statistic_c *g_iram_irq_end_statistic_cap = (t_iram_statistic_c *)IRQ_END_PSCPU;
+static t_iram_thread_statistic *g_iram_swapin_statistic_ap = (t_iram_thread_statistic *)THREAD_SWAPIN_APCPU;
+static t_iram_statistic *g_iram_irq_start_statistic_ap = (t_iram_statistic *)IRQ_START_APCPU;
+static t_iram_statistic *g_iram_irq_end_statistic_ap = (t_iram_statistic *)IRQ_END_APCPU;
+static T_Reset_Reason *g_iram_reset_reason_ap = (T_Reset_Reason *)(BASE_ADDR_STATISTIC_APCPU + BASE_LEN_STATISTIC_APCPU - sizeof(T_Reset_Reason));
#ifdef CONFIG_PREEMPT_RT_FULL
@@ -517,9 +593,11 @@
u32 wdt_reason=zx_read_reg(WDT_REBOOT_RECORD_BASE); //set at rpm
u32 status=zx_read_reg(START_UP_STATUS_BASE); //set at uboot
u32 user=zx_read_reg(USER_RESERVED_BASE); //set at uboot
-
+ u32 index=0;
char reason[20] ={0};
+ zx_write_reg(WDT_REBOOT_RECORD_BASE,0);
+
switch (wdt_reason)
{
case PS_WDT:
@@ -539,11 +617,63 @@
break;
}
- sc_debug_info_record(MODULE_ID_AP_REBOOT, "%s\n", reason);
- sc_debug_info_record(MODULE_ID_AP_REBOOT, "START_UP_STATUS:%x; USER_RESERVED:%x\n", status, user);
- printk( "%s", reason);
- printk( "START_UP_STATUS:%x; USER_RESERVED:%x\n", status, user);
+ wdt_printk("%s", reason);
+ wdt_printk("START_UP_STATUS:%x; USER_RESERVED:%x\n", status, user);
+ if (memcmp(g_iram_reset_reason_ap->ramdump_reason, "reset_", 6) == 0)
+ wdt_printk("last %s\n", g_iram_reset_reason_ap->ramdump_reason);
+ if (memcmp(g_iram_reset_reason_ap->kernel_reboot, "reset_", 6) == 0)
+ wdt_printk("last %s\n", g_iram_reset_reason_ap->kernel_reboot);
+
+ if(g_iram_swapin_statistic_cap->index <= OS_IRAM_STATISTIC_CNT_C)
+ {
+ wdt_printk("capcpuThread name, time, index is: %d;\n", g_iram_swapin_statistic_cap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT_C; index++ )
+ {
+ if(strlen(g_iram_swapin_statistic_cap->statistics[index].name))
+ wdt_printk("[NO.%d]%s, %d \n", index, g_iram_swapin_statistic_cap->statistics[index].name, g_iram_swapin_statistic_cap->statistics[index].data2 );
+ }
+
+ wdt_printk("capcpuIrqstart irqid, starttime, index is: %d\n", g_iram_irq_start_statistic_cap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT_C; index++ )
+ {
+ if(g_iram_irq_start_statistic_cap->statistics[index].data2)
+ wdt_printk("[NO.%d]%d, %d \n", index, g_iram_irq_start_statistic_cap->statistics[index].data1, g_iram_irq_start_statistic_cap->statistics[index].data2 );
+ }
+
+ wdt_printk("capcpuIrqend irqid, endtime, index is: %d\n", g_iram_irq_end_statistic_cap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT_C; index++ )
+ {
+ if(g_iram_irq_end_statistic_cap->statistics[index].data2)
+ wdt_printk("[NO.%d]%d, %d \n", index, g_iram_irq_end_statistic_cap->statistics[index].data1, g_iram_irq_end_statistic_cap->statistics[index].data2 );
+ }
+ }
+
+ if((g_iram_swapin_statistic_ap->enable == 1) && (g_iram_swapin_statistic_ap->index <= OS_IRAM_STATISTIC_CNT))
+ {
+ wdt_printk("apcpuThread name, time, index is:%d;\n", g_iram_swapin_statistic_ap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT; index++ )
+ {
+ if(strlen(g_iram_swapin_statistic_ap->statistics[index].name))
+ wdt_printk("[NO.%d]%s, %d \n", index, g_iram_swapin_statistic_ap->statistics[index].name, g_iram_swapin_statistic_ap->statistics[index].data2 );
+ }
+
+ wdt_printk("apcpuIrqstart irqid, starttime, index: %d\n", g_iram_irq_start_statistic_ap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT; index++ )
+ {
+ if(g_iram_irq_start_statistic_ap->statistics[index].data2)
+ wdt_printk("[NO.%d]%d, %d \n", index, g_iram_irq_start_statistic_ap->statistics[index].data1, g_iram_irq_start_statistic_ap->statistics[index].data2 );
+ }
+
+ wdt_printk("apcpuIrqend irqid, endtime, index is: %d\n", g_iram_irq_end_statistic_ap->index);
+ for(index =0; index < OS_IRAM_STATISTIC_CNT; index++ )
+ {
+ if(g_iram_irq_end_statistic_ap->statistics[index].data2)
+ wdt_printk("[NO.%d]%d, %d \n", index, g_iram_irq_end_statistic_ap->statistics[index].data1, g_iram_irq_end_statistic_ap->statistics[index].data2 );
+ }
+ }
+
+ memset((void *)(BASE_ADDR_STATISTIC_PSCPU), 0x0, 0x800);
}
diff --git a/ap/os/linux/linux-3.4.x/include/asm-generic/posix_types.h b/ap/os/linux/linux-3.4.x/include/asm-generic/posix_types.h
index a267e31..91d44bd 100755
--- a/ap/os/linux/linux-3.4.x/include/asm-generic/posix_types.h
+++ b/ap/os/linux/linux-3.4.x/include/asm-generic/posix_types.h
@@ -89,7 +89,7 @@
*/
typedef __kernel_long_t __kernel_off_t;
typedef long long __kernel_loff_t;
-typedef __kernel_ulong_t __kernel_time_t;
+typedef __kernel_long_t __kernel_time_t;
typedef __kernel_long_t __kernel_clock_t;
typedef int __kernel_timer_t;
typedef int __kernel_clockid_t;
diff --git a/ap/os/linux/linux-3.4.x/include/linux/ktime.h b/ap/os/linux/linux-3.4.x/include/linux/ktime.h
index 4d2dc89..76e01ab 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/ktime.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/ktime.h
@@ -48,9 +48,9 @@
#if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
struct {
# ifdef __BIG_ENDIAN
- u32 sec, nsec;
+ s32 sec, nsec;
# else
- u32 nsec, sec;
+ s32 nsec, sec;
# endif
} tv;
#endif
@@ -71,20 +71,13 @@
*
* Return the ktime_t representation of the value
*/
-static inline ktime_t ktime_set(const unsigned long secs, const unsigned long nsecs)
+static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
{
#if (BITS_PER_LONG == 64)
if (unlikely(secs >= KTIME_SEC_MAX))
return (ktime_t){ .tv64 = KTIME_MAX };
#endif
- if (secs == -1)
- {
- return (ktime_t) { .tv64 = (s64)(signed long)secs * NSEC_PER_SEC + (s64)nsecs };
- }
- else
- {
- return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
- }
+ return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
}
/* Subtract two ktime_t variables. rem = lhs -rhs: */
@@ -148,7 +141,7 @@
*/
/* Set a ktime_t variable to a value in sec/nsec representation: */
-static inline ktime_t ktime_set(const unsigned long secs, const unsigned long nsecs)
+static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
{
return (ktime_t) { .tv = { .sec = secs, .nsec = nsecs } };
}
diff --git a/ap/os/linux/linux-3.4.x/include/linux/time.h b/ap/os/linux/linux-3.4.x/include/linux/time.h
index 941e1fd..bf1bb61 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/time.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/time.h
@@ -111,7 +111,7 @@
#if (BITS_PER_LONG == 64)
# define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC)
#else
-# define KTIME_SEC_MAX ULONG_MAX
+# define KTIME_SEC_MAX LONG_MAX
#endif
/*
diff --git a/ap/os/linux/linux-3.4.x/kernel/tracker.c b/ap/os/linux/linux-3.4.x/kernel/tracker.c
index 0b5e76b..3518dee 100755
--- a/ap/os/linux/linux-3.4.x/kernel/tracker.c
+++ b/ap/os/linux/linux-3.4.x/kernel/tracker.c
@@ -60,6 +60,7 @@
#define OS_IRAM_SOFTIRQ_END (OS_IRAM_SOFTIRQ_START + sizeof(t_os_iram_statistic))
#define OS_IRAM_TIMER_START (OS_IRAM_SOFTIRQ_END + sizeof(t_os_iram_statistic))
#define OS_IRAM_TIMER_END (OS_IRAM_TIMER_START + sizeof(t_os_iram_statistic))
+#define OS_IRAM_RESET_REASON_START (OS_STATISTIC_IRAM_BASE + 0x400 - sizeof(T_Reset_Reason))
#endif
#define os_statistic_check() *((volatile unsigned long *)OS_STATISTIC_IRAM_BASE)
@@ -108,6 +109,12 @@
}T_LogIram_Record;
#endif
+typedef struct
+{
+ char ramdump_reason[32]; //±ÈÈ磺ramdump_ap_appname
+ char kernel_reboot[32]; //±ÈÈ磺reboot_ap_appname
+} T_Reset_Reason;
+
/*******************************************************************************
* È«¾Ö±äÁ¿ *
*******************************************************************************/
@@ -144,6 +151,7 @@
static t_os_ddr_statistic *g_os_ddr_softirq_end_statistic;
static t_os_ddr_statistic *g_os_ddr_timer_start_statistic;
static t_os_ddr_statistic *g_os_ddr_timer_end_statistic;
+volatile T_Reset_Reason *g_os_reset_reason;
#endif
#ifndef CONFIG_SYSTEM_CAP
@@ -461,6 +469,32 @@
os_statistic_in_ddr(g_os_ddr_timer_end_statistic, func, time);
os_statistic_info_update();
}
+/*
+reason: 1 for ramdump, 2 for kernel reboot
+cpu: ap/cap/rpm/phy
+app: current->comm
+*/
+/* Started by AICoder, pid:pf139dce4f7776c149ec081b508bae14e6084ede */
+void zxic_reset_reason(int reason, const char *cpu, const char *app)
+{
+ char buffer[32];
+
+ memset(buffer, 0, sizeof(buffer));
+ switch (reason)
+ {
+ case 1:
+ snprintf(buffer, 32, "reset_ramdump_%s_%s", cpu, app);
+ memcpy(g_os_reset_reason->ramdump_reason, buffer, sizeof(buffer));
+ break;
+ case 2:
+ snprintf(buffer, 32, "reset_kreboot_%s_%s", cpu, app);
+ memcpy(g_os_reset_reason->kernel_reboot, buffer, sizeof(buffer));
+ break;
+ default:
+ break;
+ }
+}
+/* Ended by AICoder, pid:pf139dce4f7776c149ec081b508bae14e6084ede */
#ifndef CONFIG_SYSTEM_CAP
@@ -558,6 +592,8 @@
#ifndef CONFIG_SYSTEM_CAP
proc_create("kernel_log_tracker", 0, NULL, &kernel_log_tracker_proc_fops);
#endif
+
+ g_os_reset_reason = (T_Reset_Reason *)OS_IRAM_RESET_REASON_START;
/*
init_timer(&timer);
timer.expires = jiffies + 40*HZ;//msecs_to_jiffies(40*1000);//ÑÓ³Ù40Ãë
diff --git a/ap/os/linux/linux-3.4.x/mm/ramdump/ramdump_trans_server.c b/ap/os/linux/linux-3.4.x/mm/ramdump/ramdump_trans_server.c
index bcf8ad7..2609ba0 100755
--- a/ap/os/linux/linux-3.4.x/mm/ramdump/ramdump_trans_server.c
+++ b/ap/os/linux/linux-3.4.x/mm/ramdump/ramdump_trans_server.c
@@ -138,6 +138,7 @@
extern void emergency_restart(void);
#endif
+extern void zxic_reset_reason(int reason, const char *cpu, const char *app);
extern void zx_wdt_m0_stop(void);
extern struct meminfo meminfo;
#ifdef _USE_VEHICLE_DC
@@ -568,6 +569,7 @@
static void ramdump_icp_msg_from_zsp(void *buf, unsigned int len)
{
ramdump_trans_server_force_panic_flag = RAMDUMP_CLIENT_ZSP;
+ zxic_reset_reason(1, "phy", "zsp");
ramdump_clients_icp_handle(buf, len);
}
@@ -600,6 +602,7 @@
void ramdump_icp_msg_from_m0(void *buf, int len)
{
ramdump_trans_server_force_panic_flag = RAMDUMP_CLIENT_M0;
+ zxic_reset_reason(1, "rpm", "m0");
OSS_PANIC("trans server received forced dump request from M0 client!\n");
}
@@ -716,14 +719,38 @@
* ·µ »Ø Öµ: ÊÇ·ñÌø¹ý
* ÆäËü˵Ã÷: This function is used for judge file is skip or not
*******************************************************************************/
+/* Started by AICoder, pid:z865016281f2eb61401a0bbbf042be1ce3921564 */
bool ramdump_file_skip(unsigned int index)
{
unsigned int cnt = 0;
- ramdump_shm_file_num = sizeof(ramdump_shm_export_file)/sizeof(ramdump_shm_export_file[0]);
+ ramdump_shm_file_num = sizeof(ramdump_shm_export_file) / sizeof(ramdump_shm_export_file[0]);
for (; cnt < ramdump_shm_file_num; cnt++) {
- if(strcmp(ramdump_trans_server_ram_conf[index].name, ramdump_shm_export_file[cnt]) == 0)
+ if (strcmp(ramdump_trans_server_ram_conf[index].name, ramdump_shm_export_file[cnt]) == 0) {
return true;
+ }
+ }
+ return false;
+}
+/* Ended by AICoder, pid:z865016281f2eb61401a0bbbf042be1ce3921564 */
+
+/*******************************************************************************
+* ¹¦ÄÜÃèÊö: ramdump_cmm_script_skip
+* ²ÎÊý˵Ã÷:
+* (´«Èë²ÎÊý) index
+* (´«³ö²ÎÊý) void
+* ·µ »Ø Öµ: ÊÇ·ñÌø¹ý
+* ÆäËü˵Ã÷: This function is used for judge file is skip or not
+*******************************************************************************/
+bool ramdump_cmm_script_skip(unsigned int index)
+{
+ char *ramconf_name = ramdump_trans_server_ram_conf[index].name;
+
+ if((strcmp(ramconf_name, "cap_ddr.bin") == 0)
+ || (strcmp(ramconf_name, "cap.cmm") == 0)
+ || (strcmp(ramconf_name, "cap_err_log.txt") == 0))
+ {
+ return true;
}
return false;
}
@@ -746,7 +773,8 @@
#ifdef _USE_VEHICLE_DC
if ((ramdump_export_mode == RAMDUMP_MODE_EMMC)
|| (ramdump_export_mode == RAMDUMP_MODE_SPINAND)){
- if (ramdump_file_skip(i_ram_conf) == true) {
+ if ((ramdump_file_skip(i_ram_conf) == true)
+ || (ramdump_cmm_script_skip(i_ram_conf) == true)){
i_ram_conf++;
continue;
}
@@ -1236,7 +1264,7 @@
RAMDUMP_CAP_LOG_BUF_ADDR,
RAMDUMP_CAP_LOG_BUF_LEN,
0,
- RAMDUMP_FLAG_LEVEL_LOW,
+ RAMDUMP_FLAG_LEVEL_HIGH,
0);
ramdump_ram_conf_table_add(
"rpmsg_cap.bin",
@@ -1304,6 +1332,8 @@
if (sysctl_ramdump_on_panic == FALSE)
printk(KERN_EMERG "Ramdump info: Ramdump disabled!\n");
printk(KERN_EMERG "Ramdump info: Current Process is: %s, pid is %i!\n", current->comm, current->pid);
+ if (ramdump_trans_server_force_panic_flag == RAMDUMP_FALSE)
+ zxic_reset_reason(1, "ap", current->comm); //ap ramdump
}
/*******************************************************************************
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/adbd.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/adbd.elf
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/adbd.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/adbd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/hostapd_2_10.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/radvd.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/radvd.elf
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/radvd.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/radvd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_bip.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_bip.elf
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_bip.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_bip.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ndp.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ndp.elf
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ndp.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_ndp.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_volte_main.elf b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_volte_main.elf
index 8bfbf31..6809100 100755
--- a/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_volte_main.elf
+++ b/ap/project/zx297520v3/prj_vehicle/bin/220A1/elfs/normalelfs/zte_volte_main.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/adbd b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/adbd
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/adbd
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/adbd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/hostapd b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/hostapd
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/hostapd
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/hostapd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/radvd b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/radvd
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/radvd
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/radvd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/wpa_supplicant b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/wpa_supplicant
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/wpa_supplicant
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/wpa_supplicant
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_bip b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_bip
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_bip
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_bip
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_volte_main b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_volte_main
index 48177c8..2e0d694 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_volte_main
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/bin/zte_volte_main
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/etc/rc b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/etc/rc
index 9923a30..c35b9de 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/etc/rc
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/etc/rc
@@ -17,10 +17,6 @@
/bin/mount -t debugfs none /sys/kernel/debug
#mount -t jffs2 -o ro mtd:nvrofs /mnt/nvrofs
-#mount -t jffs2 mtd:userdata /mnt/userdata
-mdev -s
-fs_check "normal"
-
ab_bootinfo
if [ $? -eq 1 ]; then
mount -t jffs2 -o ro mtd:imagefs /mnt/imagefs
@@ -29,6 +25,9 @@
mount -t jffs2 -o ro mtd:imagefs2 /mnt/imagefs
mount -t jffs2 -o ro mtd:oem2 /mnt/oem
fi
+#mount -t jffs2 mtd:userdata /mnt/userdata
+mdev -s
+fs_check "normal"
insmod /lib/cpko/cpko.ko
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libnvram.so b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libnvram.so
index c682cc1..199b514 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libnvram.so
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libnvram.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libsoft_timer.so b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libsoft_timer.so
index ade6a44..24406d0 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libsoft_timer.so
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/lib/libsoft_timer.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_arp_proxy b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_arp_proxy
index 67e95e8..f07dee3 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_arp_proxy
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_arp_proxy
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_addr_collect b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_slaac b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_slaac
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_slaac
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ipv6_slaac
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ndp b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ndp
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ndp
+++ b/ap/project/zx297520v3/prj_vehicle/fs/normal/rootfs/sbin/zte_ndp
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/adbd.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/adbd.elf
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/adbd.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/adbd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/hostapd_2_10.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/radvd.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/radvd.elf
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/radvd.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/radvd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_bip.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_bip.elf
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_bip.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_bip.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ndp.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ndp.elf
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ndp.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_ndp.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_volte_main.elf b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_volte_main.elf
index 8bfbf31..6809100 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_volte_main.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc/bin/220A1/elfs/normalelfs/zte_volte_main.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/adbd b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/adbd
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/adbd
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/adbd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/hostapd b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/hostapd
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/hostapd
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/hostapd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/radvd b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/radvd
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/radvd
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/radvd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/wpa_supplicant b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/wpa_supplicant
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/wpa_supplicant
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/wpa_supplicant
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_bip b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_bip
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_bip
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_bip
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_volte_main b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_volte_main
index 48177c8..2e0d694 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_volte_main
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/bin/zte_volte_main
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/etc/rc b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/etc/rc
index 3e82311..33d3905 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/etc/rc
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/etc/rc
@@ -17,17 +17,16 @@
/bin/mount -t debugfs none /sys/kernel/debug
#mount -t jffs2 -o ro mtd:nvrofs /mnt/nvrofs
-#mount -t jffs2 mtd:userdata /mnt/userdata
-mdev -s
-fs_check "normal"
-nvro_tool check > /tmp/nvro_check.txt 2>&1
-
ab_bootinfo
if [ $? -eq 1 ]; then
mount -t jffs2 -o ro mtd:imagefs /mnt/imagefs
else
mount -t jffs2 -o ro mtd:imagefs2 /mnt/imagefs
fi
+#mount -t jffs2 mtd:userdata /mnt/userdata
+mdev -s
+fs_check "normal"
+nvro_tool check > /tmp/nvro_check.txt 2>&1
insmod /lib/cpko/cpko.ko
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libnvram.so b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libnvram.so
index c682cc1..199b514 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libnvram.so
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libnvram.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libsoft_timer.so b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libsoft_timer.so
index ade6a44..24406d0 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libsoft_timer.so
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/lib/libsoft_timer.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_arp_proxy b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_arp_proxy
index 67e95e8..f07dee3 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_arp_proxy
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_arp_proxy
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_addr_collect b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_slaac b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_slaac
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_slaac
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ipv6_slaac
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ndp b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ndp
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ndp
+++ b/ap/project/zx297520v3/prj_vehicle_dc/fs/normal/rootfs/sbin/zte_ndp
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/adbd.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/adbd.elf
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/adbd.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/adbd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/hostapd_2_10.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/hostapd_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/radvd.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/radvd.elf
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/radvd.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/radvd.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/wpa_supplicant_2_10.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_bip.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_bip.elf
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_bip.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_bip.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_addr_collect.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ipv6_slaac.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ndp.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ndp.elf
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ndp.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_ndp.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_volte_main.elf b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_volte_main.elf
index 8bfbf31..6809100 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_volte_main.elf
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/bin/220A1/elfs/normalelfs/zte_volte_main.elf
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/adbd b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/adbd
index 4d60d38..ae8bd97 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/adbd
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/adbd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
index bc9c184..c79967a 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/hostapd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/radvd b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/radvd
index 5bcdb55..84079a5 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/radvd
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/radvd
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/wpa_supplicant b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/wpa_supplicant
index f05f932..58deb3b 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/wpa_supplicant
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/wpa_supplicant
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/zte_bip b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/zte_bip
index 6bb5897..d907536 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/zte_bip
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/bin/zte_bip
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
index 3520644..8bb5f11 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/etc/rc
@@ -17,17 +17,16 @@
/bin/mount -t debugfs none /sys/kernel/debug
#mount -t jffs2 -o ro mtd:nvrofs /mnt/nvrofs
-#mount -t jffs2 mtd:userdata /mnt/userdata
-mdev -s
-fs_check "normal"
-nvro_tool check > /tmp/nvro_check.txt 2>&1
-
ab_bootinfo
if [ $? -eq 1 ]; then
mount -t jffs2 -o ro mtd:imagefs /mnt/imagefs
else
mount -t jffs2 -o ro mtd:imagefs2 /mnt/imagefs
fi
+#mount -t jffs2 mtd:userdata /mnt/userdata
+mdev -s
+fs_check "normal"
+nvro_tool check > /tmp/nvro_check.txt 2>&1
insmod /lib/cpko/cpko.ko
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libnvram.so b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libnvram.so
index c682cc1..199b514 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libnvram.so
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libnvram.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libsoft_timer.so b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libsoft_timer.so
index ade6a44..24406d0 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libsoft_timer.so
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/lib/libsoft_timer.so
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_arp_proxy b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_arp_proxy
index 67e95e8..f07dee3 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_arp_proxy
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_arp_proxy
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_addr_collect b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
index 75812cd..a510dd6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_addr_collect
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_slaac b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_slaac
index d7f21f1..45b617f 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_slaac
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ipv6_slaac
Binary files differ
diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ndp b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ndp
index 6863838..712afc6 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ndp
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/fs/normal/rootfs/sbin/zte_ndp
Binary files differ