static void InitFaceGroup(void) { TSearchHandle sh; PUser gUser; int cnt=0; int group=gOptions.DefFaceGroup; int i,j; char buf[200]; printf("MAX group %d , MAX user %d \n", gFaceGroupNum, gFaceGroupCnt); int len=0; char* buffer=NULL; sh.ContentType=FCT_USER; sh.buffer=(char*)&gUser; SearchFirst(&sh); len=lseek(sh.fd,0,SEEK_END); j=len/(sizeof(TUser)); buffer=MALLOC(len); if(buffer==NULL) return ; lseek(sh.fd,0,SEEK_SET); if(read(sh.fd,(void*)buffer, len) != len) { FREE(buffer); return ; } gUser=(PUser)buffer; for(i=0; i<j; i++) { printf(" init group pin=%d , group=%d %d \n",gUser[i].PIN, group,gUser[i].Group); if(gUser[i].PIN > 0) { gUser[i].Group=group; cnt++; } else continue; if(group == gOptions.DefFaceGroup && cnt >= gFaceDefGroupCnt) { group++; cnt=0; } else if(group != gOptions.DefFaceGroup && cnt >= gFaceGroupCnt) { group++; cnt=0; } } sh.fd = TruncFDAndSaveAs(sh.fd, GetEnvFilePath("USERDATAPATH", "ssruser.dat", buf), NULL, 0); write(sh.fd,(void*)buffer, len); return; }
BYTE *LoadFile(char *FileName, int *FileSize) { int fp; char buf[64], tmp[64]; BYTE *DataBuf=NULL; int len=0; sprintf(tmp, "font//%s", FileName); if((fp=open(GetEnvFilePath("USERDATAPATH", tmp, buf), O_RDONLY))==-1) return NULL; len=lseek(fp, 0, SEEK_END); if(len) { DataBuf=malloc(len); lseek(fp, 0, SEEK_SET); if(read(fp, DataBuf, len)!=len) { free(DataBuf); DataBuf=NULL; } } close(fp); if(FileSize) *FileSize=len; return DataBuf; }