size_t sk_fgetsize(SkFILE* f) { FileInfo fileInfo; IFILE_GetInfo((IFile*)f, &fileInfo); return fileInfo.dwSize; }
/*======================================================================= Function: Loc_ReadGPSSettings() Description: Reads the GPS configuration settings from the configuration file. =======================================================================*/ static uint32 Loc_ReadGPSSettings(IFile * pIFile, AEEGPSConfig *gpsConfig) { char *pszBuf = NULL; char *pszTok = NULL; char *pszSvr = NULL; char *pszDelimiter = ";"; int32 nResult = 0; FileInfo fiInfo; if (pIFile == NULL || gpsConfig == NULL) return EFAILED; if ( SUCCESS != IFILE_GetInfo( pIFile, &fiInfo ) ) { return EFAILED; } if ( fiInfo.dwSize == 0 ) { return EFAILED; } // Allocate enough memory to read the full text into memory pszBuf = MALLOC( fiInfo.dwSize ); nResult = IFILE_Read( pIFile, pszBuf, fiInfo.dwSize ); if ( (uint32)nResult < fiInfo.dwSize ) { FREE( pszBuf ); return EFAILED; } // Check for an optimization mode setting in the file: pszTok = STRSTR( pszBuf, LOC_CONFIG_OPT_STRING ); if ( pszTok ) { pszTok = pszTok + STRLEN( LOC_CONFIG_OPT_STRING ); gpsConfig->optim = (AEEGPSOpt)STRTOUL( pszTok, &pszDelimiter, 10 ); } // Check for a QoS setting in the file: pszTok = STRSTR( pszBuf, LOC_CONFIG_QOS_STRING ); if ( pszTok ) { pszTok = pszTok + STRLEN( LOC_CONFIG_QOS_STRING ); gpsConfig->qos = (AEEGPSQos)STRTOUL( pszTok, &pszDelimiter, 10 ); } // Check for a server type setting in the file: pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_TYPE_STRING ); if ( pszTok ) { pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_TYPE_STRING ); gpsConfig->server.svrType = STRTOUL( pszTok, &pszDelimiter, 10 ); // If the server type is IP, we need to find the ip address and the port number if ( AEEGPS_SERVER_IP == gpsConfig->server.svrType ) { pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_IP_STRING ); if ( pszTok ) { pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_IP_STRING ); nResult = DistToSemi( pszTok ); pszSvr = MALLOC( nResult+1 ); STRNCPY( pszSvr, pszTok, nResult ); *(pszSvr+nResult) = 0; // Need to manually NULL-terminate the string if ( !INET_ATON( pszSvr, &gpsConfig->server.svr.ipsvr.addr ) ) { FREE( pszBuf ); FREE( pszSvr ); return EFAILED; } FREE( pszSvr ); } pszTok = STRSTR( pszBuf, LOC_CONFIG_SVR_PORT_STRING ); if ( pszTok ) { pszTok = pszTok + STRLEN( LOC_CONFIG_SVR_PORT_STRING ); gpsConfig->server.svr.ipsvr.port = AEE_htons((INPort)STRTOUL( pszTok, &pszDelimiter, 10 )); } } } FREE( pszBuf ); return SUCCESS; }
int AEEStaticMod_New(int16 nSize, IShell *pIShell, void *ph, IModule **ppMod,PFNMODCREATEINST pfnMC,PFNFREEMODDATA pfnMF) { IFileMgr *pFileMgr = NULL; IFile *pFile = NULL; byte *pData = NULL; FileInfo fileinfo ; RunLoadMod pFun = NULL; int nResult = 0; char name[128]; char path[128]; DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); MEMSET(name,0,128*sizeof(char)); MEMSET(path,0,128*sizeof(char)); if(!(SUCCESS == ISHELL_CreateInstance( pIShell , AEECLSID_FILEMGR, (void **) &pFileMgr)) ) goto TagFailModLoader; /* pFile = IFILEMGR_OpenFile( pFileMgr , AEEFS_SHARED_DIR"run.app" ,_OFM_READWRITE); if ( NULL == pFile ){ DBGPRINTF( "Open run.app EFAILED"); IFILEMGR_Release( pFileMgr ); goto TagFailModLoader;} else{ DBGPRINTF( "Open run.app OK"); } IFILE_Read(pFile, name, 128); IFILE_Release(pFile); STRCPY(path,AEEFS_SHARED_DIR); STRCAT(path,name); DBGPRINTF("Load Mod Path:%s",path); DBGPRINTF("Load Mod Name:%s",name);*/ //pFile = IFILEMGR_OpenFile( pFileMgr , "helloworld.bin" ,_OFM_READWRITE);//打开读 和写。 pFile = IFILEMGR_OpenFile( pFileMgr , "flyvideo.mod" ,_OFM_READWRITE);//打开读 和写。 if ( NULL == pFile ){ DBGPRINTF( "Open Mod File EFAILED"); IFILEMGR_Release( pFileMgr ); goto TagFailModLoader;} else{ DBGPRINTF( "Open Mod File OK"); } IFILE_GetInfo(pFile, &fileinfo); pData = (byte *)MALLOC( 4 * fileinfo.dwSize + 5);//pData不用释放,由AEE环境释放 MEMSET( pData , 0x00 , 4 * fileinfo.dwSize + 5); MEMCPY( pData , &ph , 4 ); DBGPRINTF( "Open File OK:%d" , fileinfo.dwSize ); IFILE_Read( pFile , pData + 4 , fileinfo.dwSize ); DBGPRINTF( "Read File OK" ); IFILE_Release( pFile ); IFILEMGR_Release( pFileMgr ); DBGPRINTF("Before RunLoadMod"); pFun = (RunLoadMod)(pData + 4); nResult = pFun(pIShell,ph,ppMod); (*ppMod)->pvt->FreeResources = AEEMod_FreeResources; DBGPRINTF("After RunLoadMod"); DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); return nResult; TagFailModLoader: DBGPRINTF("AEEMod_Load EFAILED"); DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); return EFAILED; }