Beispiel #1
0
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;
}
Beispiel #2
0
// Checks whether there is a ".agent.db". If yes, the function
// sets "szRootPath" and "szDataPath" in the storage structure
// and returns ERROR_SUCCESS
int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory)
{
    QUERY_KEY AgentFile;
    TCHAR * szFilePath;
    size_t nLength = 0;
    char * szValue;
    int nError = ERROR_FILE_NOT_FOUND;

    // Create the full name of the .agent.db file
    szFilePath = CombinePath(szDirectory, _T(".agent.db"));
    if(szFilePath != NULL)
    {
        // Load the file to memory
        nError = LoadTextFile(szFilePath, &AgentFile);
        if(nError == ERROR_SUCCESS)
        {
            // Extract the data directory from the ".agent.db" file
            szValue = ExtractStringVariable(&AgentFile, "data_dir", &nLength);
            if(szValue != NULL)
            {
                hs->szRootPath = CascNewStr(szDirectory, 0);
                hs->szDataPath = CombinePathAndString(szDirectory, szValue, nLength);
                nError = (hs->szDataPath != NULL) ? ERROR_SUCCESS : ERROR_NOT_ENOUGH_MEMORY;
            }

            // Free the loaded blob
            FreeCascBlob(&AgentFile);
        }

        // Freee the file path
        CASC_FREE(szFilePath);
    }

    return nError;
}
Beispiel #3
0
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;
}