static void * FetchAndVerifyConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey) { TCHAR * szFileName; void * pvListFile = NULL; // Construct the local file name szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32); if(szFileName != NULL) { // Add the part where the config file path is AppendConfigFilePath(szFileName, pFileKey); // Load and verify the external listfile pvListFile = ListFile_OpenExternal(szFileName); if(pvListFile != NULL) { if(!ListFile_VerifyMD5(pvListFile, pFileKey->pbData)) { ListFile_Free(pvListFile); pvListFile = NULL; } } // Free the file name CASC_FREE(szFileName); } return pvListFile; }
static int FetchAndLoadConfigFile(TCascStorage * hs, PQUERY_KEY pFileKey, PARSEINFOFILE PfnParseProc) { TCHAR * szFileName; void * pvListFile = NULL; int nError = ERROR_CAN_NOT_COMPLETE; // Construct the local file name szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32); if (szFileName != NULL) { // Add the part where the config file path is AppendConfigFilePath(szFileName, pFileKey); // Load and verify the external listfile pvListFile = ListFile_OpenExternal(szFileName); if (pvListFile != NULL) { if (ListFile_VerifyMD5(pvListFile, pFileKey->pbData)) { nError = PfnParseProc(hs, pvListFile); } else { nError = ERROR_FILE_CORRUPT; } ListFile_Free(pvListFile); } else { nError = ERROR_FILE_NOT_FOUND; } CASC_FREE(szFileName); } else { nError = ERROR_NOT_ENOUGH_MEMORY; } return nError; }