[Feature][ZXW-285]merge P56U05 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: Ied657102425a179a89ef41847170152e8a5d437c
diff --git a/ap/app/zte_comm/nvserver/nvserver.c b/ap/app/zte_comm/nvserver/nvserver.c
index b2b41cc..e059121 100755
--- a/ap/app/zte_comm/nvserver/nvserver.c
+++ b/ap/app/zte_comm/nvserver/nvserver.c
@@ -31,74 +31,73 @@
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=
-(0x226+5513-0x17af);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",(0xb7f+2843-0x169a)
-,(0x6d+5801-0x1716),(0x7e1+1338-0xd1b));memset(&rcvBuf,(0x1ceb+131-0x1d6e),
-sizeof(rcvBuf));memset(&sndBuf,(0x56c+5932-0x1c98),sizeof(sndBuf));memset(&
-msgInfo,(0x290+744-0x578),sizeof(msgInfo));msgId=msgget(MODULE_ID_NV,IPC_CREAT|
-(0x1f57+575-0x2016));if(-(0x1952+63-0x1990)==msgId){printf(
+(0xd58+4544-0x1f18);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",(0x4b1+4172-0x14fd)
+,(0x1111+2535-0x1af8),(0xf7a+5057-0x233b));memset(&rcvBuf,(0x1a60+353-0x1bc1),
+sizeof(rcvBuf));memset(&sndBuf,(0xdfb+1453-0x13a8),sizeof(sndBuf));memset(&
+msgInfo,(0x951+5943-0x2088),sizeof(msgInfo));msgId=msgget(MODULE_ID_NV,IPC_CREAT
+|(0x1ad+2938-0xba7));if(-(0x15d3+1067-0x19fd)==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-(0x1bc+1139-0x62e);}if(-(0x19b0+704-0x1c6f)!=msgctl(msgId,
-IPC_STAT,&msgInfo)){msgInfo.msg_qbytes=262144;if(-(0x19cd+145-0x1a5d)==msgctl(
+,errno);return-(0x1c83+2548-0x2676);}if(-(0xa2b+5325-0x1ef7)!=msgctl(msgId,
+IPC_STAT,&msgInfo)){msgInfo.msg_qbytes=262144;if(-(0x133d+3883-0x2267)==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()!=(0x5a5+4947-0x18f8)){printf(
+,errno);}if(nvDirInit()!=(0xc28+128-0xca8)){printf(
"\x6e\x76\x44\x69\x72\x49\x6e\x69\x74\x20\x66\x61\x69\x6c\x65\x21" "\n");return-
-(0x338+2887-0xe7e);}nvConfig();nvInit();while((0x597+6601-0x1f5f)){if(-
-(0xc6+3757-0xf72)==msgrcv(msgId,&rcvBuf,sizeof(T_NV_MSG_INFO)-sizeof(long),
-MSG_TYPE_NV,(0x11cb+2556-0x1bc7))){printf(
+(0xa28+2379-0x1372);}nvConfig();nvInit();while((0x1de8+1167-0x2276)){if(-
+(0x6a+7229-0x1ca6)==msgrcv(msgId,&rcvBuf,sizeof(T_NV_MSG_INFO)-sizeof(long),
+MSG_TYPE_NV,(0x22c+7228-0x1e68))){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(-(0x1b9+4188-0x1214)==msgsnd(
-msgId,&sndBuf,sizeof(T_NV_MSG_RESULT)-sizeof(long),(0x104f+3434-0x1db9))){printf
-(
+,errno);continue;}analyMsg(&rcvBuf,&sndBuf);if(-(0x1f8+8763-0x2432)==msgsnd(
+msgId,&sndBuf,sizeof(T_NV_MSG_RESULT)-sizeof(long),(0x229+7220-0x1e5d))){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((0x353+7865-0x220c));}static void configdir(char*dir){
+,errno);continue;}}return((0x401+950-0x7b7));}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<(0x9dd+489-0xbc6)){fprintf(stderr,
+d_name,&statbuf);if(ret<(0x32d+5899-0x1a38)){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)==(0x1992+1302-0x1ea8)||strcmp("\x2e\x2e",entry->
-d_name)==(0x664+3654-0x14aa))continue;if(!isNvConfiged(entry->d_name)){if(
+strcmp("\x2e",entry->d_name)==(0x297+5022-0x1635)||strcmp("\x2e\x2e",entry->
+d_name)==(0x15a3+4365-0x26b0))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]={(0x170a+106-0x1774)};fp=fopen
+val=NULL;FILE*fp=NULL;char buf[NV_MAX_CONFIG_LEN]={(0x2424+266-0x252e)};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[
-(0x19a9+1680-0x2039)]=='\n'||buf[(0x13df+4240-0x246f)]==
-((char)(0x1682+135-0x16e6)))continue;val=strchr(buf,((char)(0x63a+5480-0x1b65)))
-;if(!val){printf(
+(0x163b+2526-0x2019)]=='\n'||buf[(0x1769+2727-0x2210)]==
+((char)(0x17c6+3876-0x26c7)))continue;val=strchr(buf,((char)(0x730+5296-0x1ba3))
+);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)-(0x925+4846-0x1c12)]='\0';*val++=
-'\0';if(!isCfgConfiged(buf)){if(addConfigFile(val,buf)!=RESULT_SUCCESS)printf(
+,NV_CONFIG_FILE,buf);continue;}buf[strlen(buf)-(0x1027+4827-0x2301)]='\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)!=(0x904+1473-0xec5)){if(mkdir(NV_FS_PATH,(0xf53+673-0x1007))!=
-(0x16d5+3739-0x2570)){printf(
+NV_FS_PATH,F_OK)!=(0xa1b+1768-0x1103)){if(mkdir(NV_FS_PATH,(0x1065+4612-0x207c))
+!=(0x17fb+350-0x1959)){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-(0x15a7+2520-0x1f7e);}if(mkdir(NV_FS_MAIN_PATH,
-(0x254+8851-0x22fa))!=(0x72c+2438-0x10b2)){printf(
+,NV_FS_PATH,errno);return-(0x148b+3120-0x20ba);}if(mkdir(NV_FS_MAIN_PATH,
+(0x505+8532-0x246c))!=(0xee5+1175-0x137c)){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-(0x169+9109-0x24fd);}if(mkdir(NV_FS_BACKUP_PATH,
-(0x6d9+1380-0xa50))!=(0xd47+1685-0x13dc)){printf(
+,NV_FS_MAIN_PATH,errno);return-(0x1a61+1686-0x20f6);}if(mkdir(NV_FS_BACKUP_PATH,
+(0xb05+1560-0xf30))!=(0x3fd+6673-0x1e0e)){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-(0x5fd+3815-0x14e3);}}else{if(access(
-NV_FS_MAIN_PATH,F_OK)!=(0xdb+3179-0xd46)){if(mkdir(NV_FS_MAIN_PATH,
-(0x10a5+3919-0x1e07))!=(0x1128+207-0x11f7)){printf(
+,NV_FS_BACKUP_PATH,errno);return-(0x34+5944-0x176b);}}else{if(access(
+NV_FS_MAIN_PATH,F_OK)!=(0x2f1+8054-0x2267)){if(mkdir(NV_FS_MAIN_PATH,
+(0x29b+682-0x358))!=(0x281+3279-0xf50)){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-(0x1473+1993-0x1c3b);}}if(access(
-NV_FS_BACKUP_PATH,F_OK)!=(0x1839+3391-0x2578)){if(mkdir(NV_FS_BACKUP_PATH,
-(0x1390+4801-0x2464))!=(0x1d27+2189-0x25b4)){printf(
+,NV_FS_MAIN_PATH,errno);return-(0x54d+2844-0x1068);}}if(access(NV_FS_BACKUP_PATH
+,F_OK)!=(0x9dd+2366-0x131b)){if(mkdir(NV_FS_BACKUP_PATH,(0x8a7+3264-0x137a))!=
+(0x176+1547-0x781)){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-(0x89+4253-0x1125);}}}return(0x3eb+2482-0xd9d);
+,NV_FS_BACKUP_PATH,errno);return-(0xed1+3677-0x1d2d);}}}return(0xc4f+615-0xeb6);
}static void nvInit(){T_NV_NODE*list=NULL;char nvMainFile[NV_PATH_LEN]={
-(0x73b+6309-0x1fe0)};char nvBackupFile[NV_PATH_LEN]={(0x12c+942-0x4da)};
+(0x170+3682-0xfd2)};char nvBackupFile[NV_PATH_LEN]={(0x2da+5726-0x1938)};
#ifdef FOTA_AB
-T_FLAGS_INFO flags_info={(0xb4+9508-0x25d8)};int ret=(0x290+4418-0x13d2);
+T_FLAGS_INFO flags_info={(0x66f+7608-0x2427)};int ret=(0xec8+4771-0x216b);
#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,
@@ -106,73 +105,73 @@
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()==(0x1263+2299-0x1b5c)){
+if(!strcmp(list->nvFile,NV_CFG)&&get_update_status()==(0x153+6736-0x1ba1)){
reloadFactroyParam(list);delete_not_needed(list);nvcommit(list->nvFile);
#ifdef FOTA_AB
ret=flags_get(&flags_info);flags_info.boot_fota_flag.fota_status=
-(0xad8+1305-0xff1);ret=flags_set(&flags_info);
+(0xd12+2242-0x15d4);ret=flags_set(&flags_info);
#endif
-}}}uint hash(const char*s){uint hash=(0x516+1843-0xc49);while(*s){hash=
+}}}uint hash(const char*s){uint hash=(0x714+4028-0x16d0);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]={
-(0x1497+633-0x1710)};for(config=list->fileList;config;config=config->next){fp=
+(0x219+9004-0x2545)};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[(0x25ac+325-0x26f1)]=='\n'||buf[(0x163c+3559-0x2423)
-]==((char)(0x8f2+4290-0x1991)))continue;val=strchr(buf,
-((char)(0x4a5+1461-0xa1d)));if(!val){printf(
+NV_MAX_ITEM_LEN,fp)){if(buf[(0x86a+6224-0x20ba)]=='\n'||buf[(0x7cd+4687-0x1a1c)]
+==((char)(0x1d5+666-0x44c)))continue;val=strchr(buf,((char)(0x234+7091-0x1daa)))
+;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)-(0x1317+4964-0x267a)]==
-'\n')buf[strlen(buf)-(0xcc5+1726-0x1382)]='\0';*val++='\0';nvset(list->nvFile,
-buf,val,(0x18+919-0x3ae));}printf(
+,config->configFile,buf);continue;}if(buf[strlen(buf)-(0x14c0+4063-0x249e)]==
+'\n')buf[strlen(buf)-(0x18a7+1583-0x1ed5)]='\0';*val++='\0';nvset(list->nvFile,
+buf,val,(0x14bc+476-0x1697));}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=(0x7d0+4610-0x19d2);int cnt=(0x1481+3008-0x2041);FILE*fp=NULL
-;char*buf=NULL;struct stat statbuff={(0x637+8261-0x267c)};if(stat(file,&statbuff
-)<(0x1530+1476-0x1af4))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=(0x142a+347-0x1585);while(cnt<len){cnt=
-cnt+fread(buf+cnt,(0x1372+1590-0x19a7),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[(0x1a12+3067-0x160d)];ssize_t nread;int ret=-(0x704+7546-0x247d);
-fd_from=open(from,O_RDONLY);if(fd_from<(0x1a42+2806-0x2538))return-
-(0xc85+6726-0x26c9);fd_to=open(to,O_RDWR|O_CREAT|O_TRUNC|O_SYNC,
-(0xea1+1637-0x1366));if(fd_to<(0x543+7123-0x2116)){ret=-(0x14d1+1307-0x19e9);
-goto out_error;}while((0xb73+6285-0x23ff)){char*out_ptr;ssize_t nwritten;nread=
-read(fd_from,buf,sizeof(buf));if(nread==(0x1054+3199-0x1cd3)){break;}else{if(
-nread<(0x488+6514-0x1dfa)){if(errno==EINTR||errno==EAGAIN){continue;}else{ret=-
-(0xbc6+2467-0x1565);goto out_error;}}}out_ptr=buf;do{nwritten=write(fd_to,
-out_ptr,nread);if(nwritten>(0x1303+2255-0x1bd2)){nread-=nwritten;out_ptr+=
-nwritten;}else{if(nwritten<(0x836+4042-0x1800)){if(errno==EINTR||errno==EAGAIN){
-continue;}else{ret=-(0x1323+1829-0x1a43);goto out_error;}}}}while(nread>
-(0x508+5315-0x19cb));}ret=fsync(fd_to);if(ret<(0x66a+3584-0x146a)){printf(
+char*file){int len=(0x1c51+2081-0x2472);int cnt=(0x1434+3906-0x2376);FILE*fp=
+NULL;char*buf=NULL;struct stat statbuff={(0x9fa+3639-0x1831)};if(stat(file,&
+statbuff)<(0x114d+3978-0x20d7))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=(0xb5b+1427-0x10ee);
+while(cnt<len){cnt=cnt+fread(buf+cnt,(0x37c+7472-0x20ab),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[(0x25a9+2954-0x2133)];ssize_t nread;int ret=-
+(0x12cc+5161-0x26f4);fd_from=open(from,O_RDONLY);if(fd_from<(0x1dc7+2241-0x2688)
+)return-(0x1caa+2593-0x26c9);fd_to=open(to,O_RDWR|O_CREAT|O_TRUNC|O_SYNC,
+(0x1099+4681-0x2142));if(fd_to<(0xc45+3137-0x1886)){ret=-(0xda7+6342-0x266a);
+goto out_error;}while((0x12eb+373-0x145f)){char*out_ptr;ssize_t nwritten;nread=
+read(fd_from,buf,sizeof(buf));if(nread==(0x141+7769-0x1f9a)){break;}else{if(
+nread<(0x2229+59-0x2264)){if(errno==EINTR||errno==EAGAIN){continue;}else{ret=-
+(0x6af+1126-0xb11);goto out_error;}}}out_ptr=buf;do{nwritten=write(fd_to,out_ptr
+,nread);if(nwritten>(0x1f0b+1089-0x234c)){nread-=nwritten;out_ptr+=nwritten;}
+else{if(nwritten<(0xbba+4451-0x1d1d)){if(errno==EINTR||errno==EAGAIN){continue;}
+else{ret=-(0x5d1+4293-0x1691);goto out_error;}}}}while(nread>(0xb0a+1408-0x108a)
+);}ret=fsync(fd_to);if(ret<(0xa4f+5612-0x203b)){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)<(0xc7+3735-0xf5e)){fd_to=-
-(0x858+973-0xc24);ret=-(0xb65+4800-0x1e1f);goto out_error;}close(fd_from);return
-(0x1640+2455-0x1fd7);out_error:printf(
+,strerror(errno),to);goto out_error;}if(close(fd_to)<(0x68c+5647-0x1c9b)){fd_to=
+-(0x1331+2183-0x1bb7);ret=-(0xe7f+3474-0x1c0b);goto out_error;}close(fd_from);
+return(0x17b+2218-0xa25);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>=(0x518+1133-0x985))close(fd_to);return
+,from,to,ret);close(fd_from);if(fd_to>=(0x156c+3240-0x2214))close(fd_to);return
ret;}static int restoreNvFs(char*dstFile,char*srcFile){if(copyfile(srcFile,
-dstFile)!=(0x579+6556-0x1f15))return RESULT_FAIL;return RESULT_SUCCESS;}static
-int loadNvFs(char*file){int len=(0x14b5+3999-0x2454);int cnt=(0x20fc+283-0x2217)
+dstFile)!=(0xb8a+2569-0x1593))return RESULT_FAIL;return RESULT_SUCCESS;}static
+int loadNvFs(char*file){int len=(0x1f27+1055-0x2346);int cnt=(0x9bf+5664-0x1fdf)
;FILE*fp=NULL;char*buf=NULL;char*name=NULL;char*value=NULL;char*eq=NULL;struct
-stat statbuff={(0x60d+1161-0xa96)};char nvFile[NV_PATH_LEN]={(0xd98+2148-0x15fc)
-};sprintf(nvFile,"\x25\x73\x2f\x25\x73",NV_FS_MAIN_PATH,file);if(stat(nvFile,&
-statbuff)<(0x522+2567-0xf29))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+
-(0x1f0c+886-0x2281));if(!buf){fclose(fp);return RESULT_MALLOC_FAIL;}memset(buf,
-(0xc4+5569-0x1685),len+(0x7ff+1773-0xeeb));cnt=(0xd8f+3621-0x1bb4);while(cnt<len
-){cnt=cnt+fread(buf+cnt,(0x6db+3690-0x1544),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)(0x3f4+7000-0x1f0f))))){break;}*eq='\0';value=eq+
-(0xce9+1168-0x1178);nvset(file,name,value,(0x4c6+459-0x690));*eq=
-((char)(0x798+5650-0x1d6d));name=value+strlen(value)+(0xf79+1442-0x151a);}free(
+stat statbuff={(0x1a0a+2810-0x2504)};char nvFile[NV_PATH_LEN]={
+(0x383+6530-0x1d05)};sprintf(nvFile,"\x25\x73\x2f\x25\x73",NV_FS_MAIN_PATH,file)
+;if(stat(nvFile,&statbuff)<(0x20a0+155-0x213b))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+
+(0x1e59+2170-0x26d2));if(!buf){fclose(fp);return RESULT_MALLOC_FAIL;}memset(buf,
+(0x2277+682-0x2521),len+(0x1541+2966-0x20d6));cnt=(0xeb1+3045-0x1a96);while(cnt<
+len){cnt=cnt+fread(buf+cnt,(0x6b9+4144-0x16e8),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)(0x14a4+187-0x1522))))){break;}*eq='\0';value=
+eq+(0x74f+3569-0x153f);nvset(file,name,value,(0xb6+6092-0x1881));*eq=
+((char)(0x10f+9279-0x2511));name=value+strlen(value)+(0x187+8269-0x21d3);}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
@@ -188,16 +187,16 @@
"\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-(0x95+7806-0x1f12));newConfig->configFile[
-NV_PATH_LEN-(0xd44+1793-0x1444)]='\0';newConfig->next=NULL;}for(list=nv_list;
-list;list=list->next){if(strcmp(list->nvFile,nvFile)==(0x10bd+1149-0x153a))break
-;}if(!list){newList=(T_NV_NODE*)malloc(sizeof(T_NV_NODE));if(!newList){if(
+configFile,configFile,NV_PATH_LEN-(0xccc+5621-0x22c0));newConfig->configFile[
+NV_PATH_LEN-(0x5c4+3783-0x148a)]='\0';newConfig->next=NULL;}for(list=nv_list;
+list;list=list->next){if(strcmp(list->nvFile,nvFile)==(0x1e9+5890-0x18eb))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-(0x1226+4797-0x24e2));newList->nvFile[
-NV_PATH_LEN-(0x843+29-0x85f)]='\0';memset(newList->nvTable,(0xa7+6194-0x18d9),
-NV_HASH_LEN*(0x43d+252-0x535));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;
+newList->nvFile,nvFile,NV_PATH_LEN-(0x446+5992-0x1bad));newList->nvFile[
+NV_PATH_LEN-(0xec+1395-0x65e)]='\0';memset(newList->nvTable,(0x6a9+6666-0x20b3),
+NV_HASH_LEN*(0xc42+3112-0x1866));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->
@@ -205,87 +204,86 @@
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=
-(0x1345+4669-0x2582);char*data=(char*)s;while(len-- >(0x335+5356-0x1821)){sum+=(
+(0x110a+1420-0x1696);char*data=(char*)s;while(len-- >(0x407+6724-0x1e4b)){sum+=(
*data++);}return sum;}static int saveNvFs(char*nvName,char*nvFile){int i=
-(0x139c+4763-0x2637);int sum=(0xa44+284-0xb60);int bufSize=(0x2613+154-0x26ad);
-int itemSize=(0x1334+539-0x154f);int ret=(0x1730+3881-0x2659);int fp=
-(0xfd9+2041-0x17d2);char*buf=NULL;T_NV_NODE*list=NULL;T_NV_ITEM*item=NULL;for(
+(0x1332+1560-0x194a);int sum=(0x65b+852-0x9af);int bufSize=(0xfc0+339-0x1113);
+int itemSize=(0x190b+1954-0x20ad);int ret=(0xa98+6423-0x23af);int fp=
+(0x1b87+2442-0x2511);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,(0x370+1350-0x716));if(fp==-
-(0x1ed8+954-0x2291)){printf(
+open(nvFile,O_SYNC|O_RDWR|O_CREAT|O_TRUNC,(0x1312+798-0x1490));if(fp==-
+(0x1059+3153-0x1ca9)){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=(0x15dd+566-0x1813);i<
+(!buf){close(fp);return RESULT_MALLOC_FAIL;}for(i=(0xa22+6029-0x21af);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)+(0x13cd+4461-0x2538);if(bufSize+itemSize>NV_BLOCK_SIZE){if(write(fp
-,buf,bufSize)<(0x909+1894-0x106f)){printf(
+item->value)+(0xbf7+690-0xea7);if(bufSize+itemSize>NV_BLOCK_SIZE){if(write(fp,
+buf,bufSize)<(0x1387+3972-0x230b)){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=(0xaf+2160-0x91f);}sprintf(buf+bufSize,
++=getSum(buf,bufSize);bufSize=(0x1d58+653-0x1fe5);}sprintf(buf+bufSize,
"\x25\x73\x3d\x25\x73",item->key,item->value);bufSize+=itemSize;}}if(bufSize!=
-(0xf4b+3603-0x1d5e)){if(write(fp,buf,bufSize)<(0x129+6211-0x196c)){printf(
+(0x159b+2780-0x2077)){if(write(fp,buf,bufSize)<(0xa1f+6096-0x21ef)){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)<(0xbba+5552-0x216a))
-{printf(
+bufSize);}sum+=NV_FILE_FLAG;if(write(fp,&sum,NV_CHECK_SIZE)<(0x1a42+3106-0x2664)
+){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<(0xe2f+5536-0x23cf)){printf(
+buf);close(fp);if(ret<(0xbb2+1544-0x11ba)){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=
-(0xd67+6010-0x24e1);T_NV_NODE*list=NULL;T_NV_ITEM*item=NULL;for(list=nv_list;
+(0x1ed4+279-0x1feb);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-(0xb01+3902-0x1a3e));
-value[NV_MAX_VAL_LEN-(0x404+3527-0x11ca)]='\0';return RESULT_SUCCESS;}}return
+key,key))continue;strncpy(value,item->value,NV_MAX_VAL_LEN-(0xf7c+5663-0x259a));
+value[NV_MAX_VAL_LEN-(0xe9f+3428-0x1c02)]='\0';return RESULT_SUCCESS;}}return
RESULT_NO_ITEM;}static int nvset(char*file,const char*key,const char*value,int
-saveFlag){int index=(0xc13+5383-0x211a);int ret=(0xff9+1338-0x1533);int
-key_buf_len=(0x562+8039-0x24c9);int value_buf_len=(0x1bcd+1117-0x202a);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)+(0x482+2890-0xfcb);value_buf_len=
-strlen(value)+(0x5a4+6769-0x2014);for(list=nv_list;list;list=list->next){if(
+saveFlag){int index=(0x46c+5559-0x1a23);int ret=(0x1a1d+2597-0x2442);int
+key_buf_len=(0xed+3112-0xd15);int value_buf_len=(0x2148+230-0x222e);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)+(0x1a1a+1696-0x20b9);value_buf_len=
+strlen(value)+(0x1ce7+1640-0x234e);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-
-(0xaac+4577-0x1c8c));item->value[value_buf_len-(0x839+3254-0x14ee)]='\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(
+(0x906+3734-0x179b));item->value[value_buf_len-(0x1001+1775-0x16ef)]='\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-(0x464+603-0x6be));
-newItem->key[key_buf_len-(0x1768+2920-0x22cf)]='\0';strncpy(newItem->value,value
-,value_buf_len-(0xac2+3133-0x16fe));newItem->value[value_buf_len-
-(0x9b9+1327-0xee7)]='\0';newItem->next=NULL;newItem->saveFlag=saveFlag;newItem->
-update_flag=(0x1d3c+601-0x1f95);if(!list->nvTable[index])list->nvTable[index]=
+RESULT_MALLOC_FAIL;}strncpy(newItem->key,key,key_buf_len-(0x17d2+3083-0x23dc));
+newItem->key[key_buf_len-(0x1117+671-0x13b5)]='\0';strncpy(newItem->value,value,
+value_buf_len-(0x2244+367-0x23b2));newItem->value[value_buf_len-
+(0xd1a+1947-0x14b4)]='\0';newItem->next=NULL;newItem->saveFlag=saveFlag;newItem
+->update_flag=(0xbfa+1519-0x11e9);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=(0xe2a+3910-0x1d70);T_NV_NODE*list=NULL;
+ nvunset(char*file,char*key){int index=(0x1af+2269-0xa8c);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=(0xd1+9135-0x2480);
+RESULT_NO_ITEM;}static int nvreset(char*file){int ret=(0x2060+1279-0x255f);
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=(0x2217+333-0x2364);
-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=
-(0x9ef+4861-0x1cec);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=(0x6a5+1475-0xc68);char nvMainFile[NV_PATH_LEN]={
-(0x678+2490-0x1032)};char nvBackupFile[NV_PATH_LEN]={(0x984+3623-0x17ab)};
-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);}
+}return RESULT_NO_FILE;}static int nvclear(char*file){int i=(0x1201+3447-0x1f78)
+;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=
+(0x72f+893-0xaac);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=(0x176a+1080-0x1ba2);char nvMainFile[NV_PATH_LEN]={(0x256+8035-0x21b9)};
+char nvBackupFile[NV_PATH_LEN]={(0x36f+3074-0xf71)};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);}
#ifdef __cplusplus
}
#endif