blob: 9442602341582983b9fe9918063d6ca4a1ca85d1 [file] [log] [blame]
xf.libfc6e712025-02-07 01:54:34 -08001
2#include <errno.h>
3#include <sys/msg.h>
4#include <semaphore.h>
5#include "pb_com.h"
6typedef VOID(*pAtWeb_PbMsgProc)(UINT8*pDatabuf);typedef struct{UINT32 msg_id;
7VOID(*func_ptr)(UINT8*pDatabuf);BOOL need_block;}T_zPbHandleTable;VOID
8atWeb_AddOneContact(UINT8*pDatabuf);VOID atWeb_DelOneContact(UINT8*pDatabuf);
9VOID atWeb_DelMultiContact(UINT8*pDatabuf);VOID atWeb_DelAllContact(UINT8*
10pDatabuf);T_zPb_optRsp g_PbOptRsp={(0xc13+6886-0x26f9)};sem_t g_Pb_sem_id={
11(0x1aa5+97-0x1b06)};int g_zPb_MsqId=-(0xde9+4652-0x2014);int g_zPb_LocalMsqId=-
12(0x3e8+8013-0x2334);VOID atWeb_AddOneContact(UINT8*pDatabuf){T_zPb_WebContact*
13webPbContact=NULL;if(pDatabuf==NULL){printf(
14"\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"
15);return;}webPbContact=(T_zPb_WebContact*)pDatabuf;atWeb_AddOnePb(webPbContact,
16g_Pb_sem_id);}VOID atWeb_DelOneContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord=
17NULL;if(pDatabuf==NULL){printf(
18"\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"
19);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelOnepb(delRecord,
20g_Pb_sem_id);}VOID atWeb_DelMultiContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord
21=NULL;if(pDatabuf==NULL){printf(
22"\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"
23);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelMultPb(delRecord,
24g_Pb_sem_id);}VOID atWeb_DelAllContact(UINT8*pDatabuf){T_zPb_DelInfo*delRecord=
25NULL;if(pDatabuf==NULL){printf(
26"\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"
27);return;}delRecord=(T_zPb_DelInfo*)pDatabuf;atWeb_DelAllpb(delRecord,
28g_Pb_sem_id);}VOID zPb_RecvScpbrInd(UINT8*pDatabuf){T_zPb_AtScpbrTestRes*
29scpbsInd=NULL;if(pDatabuf==NULL){return;}scpbsInd=(T_zPb_AtScpbrTestRes*)
30pDatabuf;atPb_ScpbrTestRsp(scpbsInd);}VOID zPb_RecvScpbrReadInd(UINT8*pDatabuf){
31T_zPb_ScpbrSetRes*scpbsReadInd=NULL;if(pDatabuf==NULL){return;}scpbsReadInd=(
32T_zPb_ScpbrSetRes*)pDatabuf;atPb_ScpbrSetRsp(scpbsReadInd);}VOID zPb_RecvCpmsInd
33(UINT8*pDatabuf){T_zPb_AtCpbsReadRes*cpbsInd=NULL;if(pDatabuf==NULL){return;}
34cpbsInd=(T_zPb_AtCpbsReadRes*)pDatabuf;atPb_RecvCpbsReadRsp(cpbsInd);}VOID
35zPb_RecvZpbicInd(UINT8*pDatabuf){T_zAt_ZpbicRes*ptPara=ZUFI_NULL;if(pDatabuf==
36NULL){return;}ptPara=(T_zAt_ZpbicRes*)(pDatabuf);printf(
37"\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"
38,ptPara->result,ptPara->opertype);if(((0xd24+2346-0x164d)==ptPara->result)&&(
39(0x48b+6771-0x1efd)==ptPara->opertype)){CHAR needPb[(0x6ef+2128-0xf0d)]={
40(0x50a+4142-0x1538)};sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));if(
41(0x2d6+545-0x4f7)!=strcmp(needPb,"\x6e\x6f")){ipc_send_message(MODULE_ID_PB,
42MODULE_ID_AT_CTL,MSG_CMD_PBINIT_REQ,(0x608+7221-0x223d),NULL,
43(0x151d+1227-0x19e8));}}}VOID zPb_RecvZuslotInd(UINT8*pDatabuf){T_zAt_ZuslotRes*
44ptPara=ZUFI_NULL;if(pDatabuf==NULL){return;}ptPara=(T_zAt_ZuslotRes*)(pDatabuf);
45printf(
46"\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"
47,ptPara->slot,ptPara->slot_state);if(ptPara->slot_state==(0x141f+4389-0x2544)){
48CHAR needPb[(0x520+322-0x630)]={(0xabb+6947-0x25de)};sc_cfg_get(
49NV_NEED_SUPPORT_PB,needPb,sizeof(needPb));if((0x4d4+5028-0x1878)!=strcmp(needPb,
50"\x6e\x6f")){atPb_CfgPbNvInit();atPb_DelAllRecsSimDb();}}}VOID zPb_RecvPbInitRst
51(UINT8*pDatabuf){int pbReadRet=-(0x120b+4522-0x23b4);memcpy(&g_PbOptRsp,pDatabuf
52,sizeof(T_zPb_optRsp));if(g_PbOptRsp.result==-(0x98a+28-0x9a5)){atPb_IintPbErr(
53NULL);return;}pbReadRet=atPb_SendScpbrSet_repeat(g_Pb_sem_id);printf(
54"\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"
55,pbReadRet);sc_cfg_set(ZPB_NV_INIT,ZPB_OPERATE_SUC);}void zPbLocalHandleWebMsg(
56MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
57"\x50\x62\x20\x72\x65\x63\x76\x20\x77\x65\x62\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
58,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_WRITE_PB:
59atWeb_AddOneContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_A_PB:
60atWeb_DelOneContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_MUTI_PB:
61atWeb_DelMultiContact(ptMsgBuf->aucDataBuf);break;case MSG_CMD_DEL_ALL_PB:
62atWeb_DelAllContact(ptMsgBuf->aucDataBuf);break;default:break;}}void
63zPbHandleWebMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
64"\x50\x62\x20\x72\x65\x63\x76\x20\x77\x65\x62\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n"
65,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_WRITE_PB:case
66MSG_CMD_DEL_A_PB:case MSG_CMD_DEL_MUTI_PB:case MSG_CMD_DEL_ALL_PB:
67ipc_send_message(MODULE_ID_PB,MODULE_ID_PB_LOCAL,ptMsgBuf->usMsgCmd,ptMsgBuf->
68usDataLen,(unsigned char*)ptMsgBuf->aucDataBuf,(0xae3+3648-0x1923));break;
69default:break;}}UINT8 zPbMsgCreat(VOID){g_zPb_MsqId=msgget(MODULE_ID_PB,
70IPC_CREAT|(0x4a4+8140-0x22f0));if(g_zPb_MsqId==-(0x1ced+284-0x1e08)){return
71ZUFI_FAIL;}g_zPb_LocalMsqId=msgget(MODULE_ID_PB_LOCAL,IPC_CREAT|
72(0xb03+2724-0x1427));if(g_zPb_LocalMsqId==-(0xe98+6222-0x26e5)){return ZUFI_FAIL
73;}sem_init(&g_Pb_sem_id,(0x40d+6402-0x1d0f),(0x569+2863-0x1098));return
74ZUFI_SUCC;}void detect_modem_state(void){CHAR state[(0x12dd+3914-0x21f5)]={
75(0x4d9+1720-0xb91)};sc_cfg_get(
76"\x6d\x6f\x64\x65\x6d\x5f\x6d\x61\x69\x6e\x5f\x73\x74\x61\x74\x65",state,sizeof(
77state));if((0x17f3+2474-0x219d)==strcmp(state,
78"\x6d\x6f\x64\x65\x6d\x5f\x73\x69\x6d\x5f\x75\x6e\x64\x65\x74\x65\x63\x74\x65\x64"
79)||(0xe0f+3886-0x1d3d)==strcmp(state,
80"\x6d\x6f\x64\x65\x6d\x5f\x73\x69\x6d\x5f\x64\x65\x73\x74\x72\x6f\x79")){
81sc_cfg_set("\x70\x62\x6d\x5f\x69\x6e\x69\x74\x5f\x66\x6c\x61\x67","\x30");}}void
82 zPbLocalHandleAtctlMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
83"\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"
84,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_PBINIT_RSP:
85zPb_RecvPbInitRst(ptMsgBuf->aucDataBuf);break;default:break;}}VOID
86zPbHandleAtctlMsg(MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
87"\x50\x62\x20\x72\x65\x63\x76\x20\x6d\x73\x67\x20\x63\x6d\x64\x3a\x25\x64" "\n",
88ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_DELETE_PB_RSP:case
89MSG_CMD_ADD_MODIFY_PB_RSP:case MSG_CMD_READ_PB_RSP:{memcpy(&g_PbOptRsp,ptMsgBuf
90->aucDataBuf,sizeof(T_zPb_optRsp));sem_post(&g_Pb_sem_id);}break;case
91MSG_CMD_CPBS_IND:zPb_RecvCpmsInd(ptMsgBuf->aucDataBuf);break;case
92MSG_CMD_SCPBR_IND:zPb_RecvScpbrInd(ptMsgBuf->aucDataBuf);break;case
93MSG_CMD_SCPBR_READ_IND:zPb_RecvScpbrReadInd(ptMsgBuf->aucDataBuf);break;case
94MSG_CMD_ZPBIC_IND:zPb_RecvZpbicInd(ptMsgBuf->aucDataBuf);break;case
95MSG_CMD_ZUSLOT_IND:zPb_RecvZuslotInd(ptMsgBuf->aucDataBuf);break;case
96MSG_CMD_PBINIT_RSP:ipc_send_message(MODULE_ID_PB,MODULE_ID_PB_LOCAL,ptMsgBuf->
97usMsgCmd,ptMsgBuf->usDataLen,(unsigned char*)ptMsgBuf->aucDataBuf,
98(0x1b1c+2464-0x24bc));break;default:break;}}VOID zPbHandleResetToFactory(){CHAR
99clearPb[(0x21a0+988-0x254a)]={(0x111d+2882-0x1c5f)};sc_cfg_get(
100NV_CLEAR_PB_WHEN_RESTORE,clearPb,sizeof(clearPb));printf(
101"\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"
102);printf(
103"\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"
104,clearPb);if(strcmp(clearPb,"\x79\x65\x73")==(0x235+3478-0xfcb)){atPb_DropDb();}
105ipc_send_message(MODULE_ID_PB,MODULE_ID_MAIN_CTRL,MSG_CMD_RESET_RSP,
106(0x103f+2866-0x1b71),NULL,(0x175a+885-0x1acf));}void zPbHandleMainCtrlMsg(
107MSG_BUF*ptMsgBuf){assert(ptMsgBuf!=NULL);printf(
108"\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"
109,ptMsgBuf->usMsgCmd);switch(ptMsgBuf->usMsgCmd){case MSG_CMD_RESET_NOTIFY:
110zPbHandleResetToFactory(ptMsgBuf->aucDataBuf);break;default:break;}}void
111pb_msg_thread_proc(void*arg){int iRet=(0x17ff+3491-0x25a2);MSG_BUF stMsg={
112(0x1105+5001-0x248e)};int msgSize=sizeof(MSG_BUF)-sizeof(SINT32);int queueId=*((
113int*)arg);prctl(PR_SET_NAME,"\x70\x62\x5f\x6c\x6f\x63\x61\x6c",
114(0xf7f+4472-0x20f7),(0x35b+6231-0x1bb2),(0x23a+9284-0x267e));while(
115(0xc4c+2934-0x17c1)){iRet=(0x1bdd+17-0x1bee);memset(&stMsg,(0xff9+649-0x1282),
116sizeof(MSG_BUF));iRet=msgrcv(queueId,&stMsg,msgSize,(0x7b+2412-0x9e7),
117(0x3b5+4689-0x1606));printf(
118"\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"
119,stMsg.src_id,stMsg.usMsgCmd,MODULE_ID_AT_CTL);if(iRet>=(0x2041+658-0x22d3)){
120switch(stMsg.src_id){case MODULE_ID_WEB_CGI:{zPbHandleWebMsg(&stMsg);break;}case
121 MODULE_ID_AT_CTL:{zPbHandleAtctlMsg(&stMsg);break;}case MODULE_ID_PB:{
122zPbLocalHandleWebMsg(&stMsg);zPbLocalHandleAtctlMsg(&stMsg);break;}case
123MODULE_ID_MAIN_CTRL:{zPbHandleMainCtrlMsg(&stMsg);break;}default:{break;}}}else{
124printf(
125"\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"
126,errno,strerror(errno));}}}int phonebook_main(int argc,char*argv[]){pthread_t
127recv_thread_tid=(0xc24+2678-0x169a);MSG_BUF msgBuf={(0x184+7485-0x1ec1)};CHAR
128needPb[(0xadc+4263-0x1b51)]={(0x1f6+3015-0xdbd)};prctl(PR_SET_NAME,
129"\x70\x62\x5f\x6d\x61\x69\x6e",(0xf75+359-0x10dc),(0xe42+4078-0x1e30),
130(0x9c4+1634-0x1026));loglevel_init();sc_cfg_get(NV_NEED_SUPPORT_PB,needPb,sizeof
131(needPb));if((0x23ed+769-0x26ee)!=strcmp(needPb,"\x6e\x6f")){
132#ifdef WEBS_SECURITY
133if(access(ZPB_DB_PATH,F_OK)!=(0x1146+681-0x13ef)){if(access(ZPB_TMP_PATH,F_OK)==
134(0x913+1803-0x101e)){if(remove(ZPB_SEC_PATH)!=(0x15ec+2408-0x1f54)){slog(
135PB_PRINT,SLOG_ERR,
136"\x72\x65\x6d\x6f\x76\x65\x20\x5a\x50\x42\x5f\x53\x45\x43\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
137);}if(rename(ZPB_TMP_PATH,ZPB_SEC_PATH)!=(0x16f6+3785-0x25bf)){slog(PB_PRINT,
138SLOG_ERR,
139"\x72\x65\x6e\x61\x6d\x65\x20\x5a\x50\x42\x5f\x54\x4d\x50\x5f\x50\x41\x54\x48\x20\x66\x61\x69\x6c"
140);}}if(access(ZPB_SEC_PATH,F_OK)==(0x376+3721-0x11ff)){char rnum_buf[
141(0x12e3+3012-0x1e8f)]={(0x8cd+4648-0x1af5)};char cmd[(0xb36+3206-0x173c)]={
142(0x3d0+7585-0x2171)};sc_cfg_get("\x72\x6e\x75\x6d\x5f\x61\x74",rnum_buf,sizeof(
143rnum_buf));snprintf(cmd,sizeof(cmd),
144"\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"
145,ZPB_SEC_PATH,ZPB_DB_PATH,rnum_buf);zxic_system(cmd);}}
146#endif
147zPbMsgCreat();atPb_Init();}else{return-(0x50+284-0x16b);}printf(
148"\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"
149,g_zPb_MsqId);if(pthread_create(&recv_thread_tid,NULL,pb_msg_thread_proc,(void*)
150(&g_zPb_LocalMsqId))==-(0x4b5+5588-0x1a88)){assert((0x22c+8869-0x24d1));}
151detect_modem_state();pb_msg_thread_proc(&g_zPb_MsqId);return(0x107a+1824-0x179a)
152;}