TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CascFiles.cpp File Reference
#include "CascLib.h"
#include "CascCommon.h"
+ Include dependency graph for CascFiles.cpp:

Classes

struct  TBuildFileInfo
 
struct  TGameIdString
 

Macros

#define __CASCLIB_SELF__
 

Typedefs

typedef int(* PARSEINFOFILE )(TCascStorage *hs, void *pvListFile)
 

Functions

static bool IsValueSeparator (const char *szVarValue)
 
static bool IsCharDigit (BYTE OneByte)
 
static DWORD GetLocaleMask (const char *szTag)
 
static bool IsInfoVariable (const char *szLineBegin, const char *szLineEnd, const char *szVarName, const char *szVarType)
 
static const char * SkipInfoVariable (const char *szLineBegin, const char *szLineEnd)
 
static TCHARCheckForIndexDirectory (TCascStorage *hs, const TCHAR *szSubDir)
 
TCHARAppendBlobText (TCHAR *szBuffer, LPBYTE pbData, DWORD cbData, TCHAR chSeparator)
 
static const char * CheckLineVariable (const char *szLineBegin, const char *szLineEnd, const char *szVarName)
 
static int LoadInfoVariable (PQUERY_KEY pVarBlob, const char *szLineBegin, const char *szLineEnd, bool bHexaValue)
 
static void AppendConfigFilePath (TCHAR *szFileName, PQUERY_KEY pFileKey)
 
static DWORD GetBlobCount (const char *szLineBegin, const char *szLineEnd)
 
static int LoadBlobArray (PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwMaxBlobs)
 
static int LoadMultipleBlobs (PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwBlobCount)
 
static int LoadMultipleBlobs (PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd)
 
static int LoadSingleBlob (PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd)
 
static int GetGameType (TCascStorage *hs, const char *szVarBegin, const char *szLineEnd)
 
static int GetBuildNumber (TCascStorage *hs, const char *szVarBegin, const char *szLineEnd)
 
static int GetDefaultLocaleMask (TCascStorage *hs, PQUERY_KEY pTagsString)
 
static void * FetchAndVerifyConfigFile (TCascStorage *hs, PQUERY_KEY pFileKey)
 
static int ParseFile_BuildInfo (TCascStorage *hs, void *pvListFile)
 
static int ParseFile_BuildDb (TCascStorage *hs, void *pvListFile)
 
static int LoadCdnConfigFile (TCascStorage *hs, void *pvListFile)
 
static int LoadCdnBuildFile (TCascStorage *hs, void *pvListFile)
 
static int CheckDataDirectory (TCascStorage *hs, TCHAR *szDirectory)
 
int LoadBuildInfo (TCascStorage *hs)
 
int CheckGameDirectory (TCascStorage *hs, TCHAR *szDirectory)
 
int GetRootVariableIndex (const char *szLinePtr, const char *szLineEnd, const char *szVariableName, int *PtrIndex)
 
int ParseRootFileLine (const char *szLinePtr, const char *szLineEnd, int nFileNameIndex, PQUERY_KEY PtrEncodingKey, char *szFileName, size_t nMaxChars)
 

Variables

static const TBuildFileInfo BuildTypes []
 
static const TCHARDataDirs []
 
static const TGameIdString GameIds []
 

Macro Definition Documentation

#define __CASCLIB_SELF__

Typedef Documentation

typedef int(* PARSEINFOFILE)(TCascStorage *hs, void *pvListFile)

Function Documentation

TCHAR* AppendBlobText ( TCHAR szBuffer,
LPBYTE  pbData,
DWORD  cbData,
TCHAR  chSeparator 
)
194 {
195  // Put the separator, if any
196  if(chSeparator != 0)
197  *szBuffer++ = chSeparator;
198 
199  // Copy the blob data as text
200  for(DWORD i = 0; i < cbData; i++)
201  {
202  *szBuffer++ = IntToHexChar[pbData[0] >> 0x04];
203  *szBuffer++ = IntToHexChar[pbData[0] & 0x0F];
204  pbData++;
205  }
206 
207  // Terminate the string
208  *szBuffer = 0;
209 
210  // Return new buffer position
211  return szBuffer;
212 }
unsigned char IntToHexChar[]
Definition: Common.cpp:62
unsigned int DWORD
Definition: CascPort.h:139

+ Here is the caller graph for this function:

static void AppendConfigFilePath ( TCHAR szFileName,
PQUERY_KEY  pFileKey 
)
static
288 {
289  size_t nLength = _tcslen(szFileName);
290 
291  // If there is no slash, append if
292  if(nLength > 0 && szFileName[nLength - 1] != '\\' && szFileName[nLength - 1] != '/')
293  szFileName[nLength++] = _T('/');
294 
295  // Get to the end of the file name
296  szFileName = szFileName + nLength;
297 
298  // Append the "config" directory
299  _tcscpy(szFileName, _T("config"));
300  szFileName += 6;
301 
302  // Append the first level directory
303  szFileName = AppendBlobText(szFileName, pFileKey->pbData, 1, _T('/'));
304  szFileName = AppendBlobText(szFileName, pFileKey->pbData + 1, 1, _T('/'));
305  szFileName = AppendBlobText(szFileName, pFileKey->pbData, pFileKey->cbData, _T('/'));
306 }
#define _T(x)
Definition: CascPort.h:171
DWORD cbData
Definition: CascLib.h:141
#define _tcslen
Definition: CascPort.h:172
#define _tcscpy
Definition: CascPort.h:173
LPBYTE pbData
Definition: CascLib.h:140
TCHAR * AppendBlobText(TCHAR *szBuffer, LPBYTE pbData, DWORD cbData, TCHAR chSeparator)
Definition: CascFiles.cpp:193

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int CheckDataDirectory ( TCascStorage hs,
TCHAR szDirectory 
)
static
796 {
797  TCHAR * szDataPath;
798  int nError = ERROR_FILE_NOT_FOUND;
799 
800  // Try all known subdirectories
801  for(size_t i = 0; DataDirs[i] != NULL; i++)
802  {
803  // Create the eventual data path
804  szDataPath = CombinePath(szDirectory, DataDirs[i]);
805  if(szDataPath != NULL)
806  {
807  // Does that directory exist?
808  if(DirectoryExists(szDataPath))
809  {
810  hs->szDataPath = szDataPath;
811  return ERROR_SUCCESS;
812  }
813 
814  // Free the data path
815  CASC_FREE(szDataPath);
816  }
817  }
818 
819  return nError;
820 }
bool DirectoryExists(const TCHAR *szDirectory)
Definition: Directory.cpp:18
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
TCHAR * CombinePath(const TCHAR *szDirectory, const TCHAR *szSubDir)
Definition: Common.cpp:157
#define ERROR_FILE_NOT_FOUND
Definition: CascPort.h:205
TCHAR * szDataPath
Definition: CascCommon.h:191
static const TCHAR * DataDirs[]
Definition: CascFiles.cpp:44
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static TCHAR* CheckForIndexDirectory ( TCascStorage hs,
const TCHAR szSubDir 
)
static
178 {
179  TCHAR * szIndexPath;
180 
181  // Cpmbine the index path
182  szIndexPath = CombinePath(hs->szDataPath, szSubDir);
183  if(DirectoryExists(szIndexPath))
184  {
185  hs->szIndexPath = szIndexPath;
186  return hs->szIndexPath;
187  }
188 
189  CASC_FREE(szIndexPath);
190  return NULL;
191 }
bool DirectoryExists(const TCHAR *szDirectory)
Definition: Directory.cpp:18
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
TCHAR * CombinePath(const TCHAR *szDirectory, const TCHAR *szSubDir)
Definition: Common.cpp:157
TCHAR * szIndexPath
Definition: CascCommon.h:193
TCHAR * szDataPath
Definition: CascCommon.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int CheckGameDirectory ( TCascStorage hs,
TCHAR szDirectory 
)
910 {
911  TFileStream * pStream;
912  TCHAR * szBuildFile;
913  int nError = ERROR_FILE_NOT_FOUND;
914 
915  // Try to find any of the root files used in the history
916  for(size_t i = 0; BuildTypes[i].szFileName != NULL; i++)
917  {
918  // Create the full name of the .agent.db file
919  szBuildFile = CombinePath(szDirectory, BuildTypes[i].szFileName);
920  if(szBuildFile != NULL)
921  {
922  // Attempt to open the file
923  pStream = FileStream_OpenFile(szBuildFile, 0);
924  if(pStream != NULL)
925  {
926  // Free the stream
927  FileStream_Close(pStream);
928 
929  // Check for the data directory
930  nError = CheckDataDirectory(hs, szDirectory);
931  if(nError == ERROR_SUCCESS)
932  {
933  hs->szBuildFile = szBuildFile;
935  return ERROR_SUCCESS;
936  }
937  }
938 
939  CASC_FREE(szBuildFile);
940  }
941  }
942 
943  return nError;
944 }
CBLD_TYPE BuildFileType
Definition: CascCommon.h:201
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
const TCHAR * szFileName
Definition: CascFiles.cpp:26
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
TCHAR * CombinePath(const TCHAR *szDirectory, const TCHAR *szSubDir)
Definition: Common.cpp:157
#define ERROR_FILE_NOT_FOUND
Definition: CascPort.h:205
static const TBuildFileInfo BuildTypes[]
Definition: CascFiles.cpp:37
TCHAR * szBuildFile
Definition: CascCommon.h:192
void FileStream_Close(TFileStream *pStream)
Definition: FileStream.cpp:2707
TFileStream * FileStream_OpenFile(const TCHAR *szFileName, DWORD dwStreamFlags)
Definition: FileStream.cpp:2384
CBLD_TYPE BuildFileType
Definition: CascFiles.cpp:27
static int CheckDataDirectory(TCascStorage *hs, TCHAR *szDirectory)
Definition: CascFiles.cpp:795
Definition: FileStream.h:153
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* CheckLineVariable ( const char *  szLineBegin,
const char *  szLineEnd,
const char *  szVarName 
)
static
215 {
216  size_t nLineLength = (size_t)(szLineEnd - szLineBegin);
217  size_t nNameLength = strlen(szVarName);
218 
219  // If the line longer than the variable name?
220  if(nLineLength > nNameLength)
221  {
222  if(!_strnicmp((const char *)szLineBegin, szVarName, nNameLength))
223  {
224  // Skip the variable name
225  szLineBegin += nNameLength;
226 
227  // Skip the separator(s)
228  while(szLineBegin < szLineEnd && IsValueSeparator(szLineBegin))
229  szLineBegin++;
230 
231  // Check if there is "="
232  if(szLineBegin >= szLineEnd || szLineBegin[0] != '=')
233  return NULL;
234  szLineBegin++;
235 
236  // Skip the separator(s)
237  while(szLineBegin < szLineEnd && IsValueSeparator(szLineBegin))
238  szLineBegin++;
239 
240  // Check if there is "="
241  if(szLineBegin >= szLineEnd)
242  return NULL;
243 
244  // Return the begin of the variable
245  return szLineBegin;
246  }
247  }
248 
249  return NULL;
250 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define _strnicmp
Definition: CascPort.h:186
static bool IsValueSeparator(const char *szVarValue)
Definition: CascFiles.cpp:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* FetchAndVerifyConfigFile ( TCascStorage hs,
PQUERY_KEY  pFileKey 
)
static
490 {
491  TCHAR * szFileName;
492  void * pvListFile = NULL;
493 
494  // Construct the local file name
495  szFileName = CascNewStr(hs->szDataPath, 8 + 3 + 3 + 32);
496  if(szFileName != NULL)
497  {
498  // Add the part where the config file path is
499  AppendConfigFilePath(szFileName, pFileKey);
500 
501  // Load and verify the external listfile
502  pvListFile = ListFile_OpenExternal(szFileName);
503  if(pvListFile != NULL)
504  {
505  if(!ListFile_VerifyMD5(pvListFile, pFileKey->pbData))
506  {
507  ListFile_Free(pvListFile);
508  pvListFile = NULL;
509  }
510  }
511 
512  // Free the file name
513  CASC_FREE(szFileName);
514  }
515 
516  return pvListFile;
517 }
void * ListFile_OpenExternal(const TCHAR *szListFile)
Definition: ListFile.cpp:52
void ListFile_Free(void *pvListFile)
Definition: ListFile.cpp:201
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
#define CASC_FREE(ptr)
Definition: CascCommon.h:303
LPBYTE pbData
Definition: CascLib.h:140
TCHAR * szDataPath
Definition: CascCommon.h:191
static void AppendConfigFilePath(TCHAR *szFileName, PQUERY_KEY pFileKey)
Definition: CascFiles.cpp:287
bool ListFile_VerifyMD5(void *pvListFile, LPBYTE pbHashMD5)
Definition: ListFile.cpp:100
char * CascNewStr(const char *szString, size_t nCharsToReserve)
Definition: Common.cpp:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DWORD GetBlobCount ( const char *  szLineBegin,
const char *  szLineEnd 
)
static
309 {
310  DWORD dwBlobCount = 0;
311 
312  // Until we find an end of the line
313  while(szLineBegin < szLineEnd)
314  {
315  // Skip the blob
316  while(szLineBegin < szLineEnd && IsValueSeparator(szLineBegin) == false)
317  szLineBegin++;
318 
319  // Increment the number of blobs
320  dwBlobCount++;
321 
322  // Skip the separator
323  while(szLineBegin < szLineEnd && IsValueSeparator(szLineBegin))
324  szLineBegin++;
325  }
326 
327  return dwBlobCount;
328 }
unsigned int DWORD
Definition: CascPort.h:139
static bool IsValueSeparator(const char *szVarValue)
Definition: CascFiles.cpp:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int GetBuildNumber ( TCascStorage hs,
const char *  szVarBegin,
const char *  szLineEnd 
)
static
434 {
435  DWORD dwBuildNumber = 0;
436 
437  // Skip all non-digit characters
438  while(szVarBegin < szLineEnd)
439  {
440  // There must be at least three digits (build 99 anyone?)
441  if(IsCharDigit(szVarBegin[0]) && IsCharDigit(szVarBegin[1]) && IsCharDigit(szVarBegin[2]))
442  {
443  // Convert the build number string to value
444  while(szVarBegin < szLineEnd && IsCharDigit(szVarBegin[0]))
445  dwBuildNumber = (dwBuildNumber * 10) + (*szVarBegin++ - '0');
446  break;
447  }
448 
449  // Move to the next
450  szVarBegin++;
451  }
452 
453  assert(dwBuildNumber != 0);
454  hs->dwBuildNumber = dwBuildNumber;
455  return (dwBuildNumber != 0) ? ERROR_SUCCESS : ERROR_BAD_FORMAT;
456 }
static bool IsCharDigit(BYTE OneByte)
Definition: CascFiles.cpp:72
unsigned int DWORD
Definition: CascPort.h:139
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
DWORD dwBuildNumber
Definition: CascCommon.h:197
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int GetDefaultLocaleMask ( TCascStorage hs,
PQUERY_KEY  pTagsString 
)
static
459 {
460  char * szTagEnd = (char *)pTagsString->pbData + pTagsString->cbData;
461  char * szTagPtr = (char *)pTagsString->pbData;
462  char * szNext;
463  DWORD dwLocaleMask = 0;
464 
465  while(szTagPtr < szTagEnd)
466  {
467  // Get the next part
468  szNext = strchr(szTagPtr, ' ');
469  if(szNext != NULL)
470  *szNext++ = 0;
471 
472  // Check whether the current tag is a language identifier
473  dwLocaleMask = dwLocaleMask | GetLocaleMask(szTagPtr);
474 
475  // Get the next part
476  if(szNext == NULL)
477  break;
478 
479  // Skip spaces
480  while(szNext < szTagEnd && szNext[0] == ' ')
481  szNext++;
482  szTagPtr = szNext;
483  }
484 
485  hs->dwDefaultLocale = dwLocaleMask;
486  return ERROR_SUCCESS;
487 }
DWORD dwDefaultLocale
Definition: CascCommon.h:199
arena_t NULL
Definition: jemalloc_internal.h:624
DWORD cbData
Definition: CascLib.h:141
LPBYTE pbData
Definition: CascLib.h:140
unsigned int DWORD
Definition: CascPort.h:139
static DWORD GetLocaleMask(const char *szTag)
Definition: CascFiles.cpp:77
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int GetGameType ( TCascStorage hs,
const char *  szVarBegin,
const char *  szLineEnd 
)
static
408 {
409  // Go through all games that we support
410  for(size_t i = 0; GameIds[i].szGameInfo != NULL; i++)
411  {
412  // Check the length of the variable
413  if((size_t)(szLineEnd - szVarBegin) == GameIds[i].cchGameInfo)
414  {
415  // Check the string
416  if(!_strnicmp(szVarBegin, GameIds[i].szGameInfo, GameIds[i].cchGameInfo))
417  {
418  hs->dwGameInfo = GameIds[i].dwGameInfo;
419  return ERROR_SUCCESS;
420  }
421  }
422  }
423 
424  // Unknown/unsupported game
425  assert(false);
426  return ERROR_BAD_FORMAT;
427 }
arena_t NULL
Definition: jemalloc_internal.h:624
DWORD dwGameInfo
Definition: CascFiles.cpp:34
DWORD dwGameInfo
Definition: CascCommon.h:196
const char * szGameInfo
Definition: CascFiles.cpp:32
#define _strnicmp
Definition: CascPort.h:186
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
static const TGameIdString GameIds[]
Definition: CascFiles.cpp:54
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the caller graph for this function:

static DWORD GetLocaleMask ( const char *  szTag)
static
78 {
79  if(!strcmp(szTag, "enUS"))
80  return CASC_LOCALE_ENUS;
81 
82  if(!strcmp(szTag, "koKR"))
83  return CASC_LOCALE_KOKR;
84 
85  if(!strcmp(szTag, "frFR"))
86  return CASC_LOCALE_FRFR;
87 
88  if(!strcmp(szTag, "deDE"))
89  return CASC_LOCALE_DEDE;
90 
91  if(!strcmp(szTag, "zhCN"))
92  return CASC_LOCALE_ZHCN;
93 
94  if(!strcmp(szTag, "esES"))
95  return CASC_LOCALE_ESES;
96 
97  if(!strcmp(szTag, "zhTW"))
98  return CASC_LOCALE_ZHTW;
99 
100  if(!strcmp(szTag, "enGB"))
101  return CASC_LOCALE_ENGB;
102 
103  if(!strcmp(szTag, "enCN"))
104  return CASC_LOCALE_ENCN;
105 
106  if(!strcmp(szTag, "enTW"))
107  return CASC_LOCALE_ENTW;
108 
109  if(!strcmp(szTag, "esMX"))
110  return CASC_LOCALE_ESMX;
111 
112  if(!strcmp(szTag, "ruRU"))
113  return CASC_LOCALE_RURU;
114 
115  if(!strcmp(szTag, "ptBR"))
116  return CASC_LOCALE_PTBR;
117 
118  if(!strcmp(szTag, "itIT"))
119  return CASC_LOCALE_ITIT;
120 
121  if(!strcmp(szTag, "ptPT"))
122  return CASC_LOCALE_PTPT;
123 
124  return 0;
125 }
#define CASC_LOCALE_ESES
Definition: CascLib.h:73
#define CASC_LOCALE_DEDE
Definition: CascLib.h:71
#define CASC_LOCALE_KOKR
Definition: CascLib.h:68
#define CASC_LOCALE_FRFR
Definition: CascLib.h:70
#define CASC_LOCALE_ENUS
Definition: CascLib.h:67
#define CASC_LOCALE_ZHCN
Definition: CascLib.h:72
#define CASC_LOCALE_ZHTW
Definition: CascLib.h:74
#define CASC_LOCALE_ESMX
Definition: CascLib.h:78
#define CASC_LOCALE_RURU
Definition: CascLib.h:79
#define CASC_LOCALE_ENCN
Definition: CascLib.h:76
#define CASC_LOCALE_ITIT
Definition: CascLib.h:81
#define CASC_LOCALE_ENTW
Definition: CascLib.h:77
#define CASC_LOCALE_PTBR
Definition: CascLib.h:80
#define CASC_LOCALE_ENGB
Definition: CascLib.h:75
#define CASC_LOCALE_PTPT
Definition: CascLib.h:82

+ Here is the caller graph for this function:

int GetRootVariableIndex ( const char *  szLinePtr,
const char *  szLineEnd,
const char *  szVariableName,
int *  PtrIndex 
)
954 {
955  size_t nLength = strlen(szVariableName);
956  int nIndex = 0;
957 
958  while(szLinePtr < szLineEnd)
959  {
960  // Check the variable there
961  if(!_strnicmp(szLinePtr, szVariableName, nLength))
962  {
963  // Does the length match?
964  if(szLinePtr[nLength] == '|' || szLinePtr[nLength] == '0')
965  {
966  PtrIndex[0] = nIndex;
967  return ERROR_SUCCESS;
968  }
969  }
970 
971  // Get the next variable
972  szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
973  if(szLinePtr == NULL)
974  break;
975  nIndex++;
976  }
977 
978  return ERROR_BAD_FORMAT;
979 }
static const char * SkipInfoVariable(const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:164
arena_t NULL
Definition: jemalloc_internal.h:624
#define _strnicmp
Definition: CascPort.h:186
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool IsCharDigit ( BYTE  OneByte)
static
73 {
74  return ('0' <= OneByte && OneByte <= '9');
75 }

+ Here is the caller graph for this function:

static bool IsInfoVariable ( const char *  szLineBegin,
const char *  szLineEnd,
const char *  szVarName,
const char *  szVarType 
)
static
128 {
129  size_t nLength;
130 
131  // Check the variable name
132  nLength = strlen(szVarName);
133  if((size_t)(szLineEnd - szLineBegin) > nLength)
134  {
135  // Check the variable name
136  if(!_strnicmp(szLineBegin, szVarName, nLength))
137  {
138  // Skip variable name and the exclamation mark
139  szLineBegin += nLength;
140  if(szLineBegin < szLineEnd && szLineBegin[0] == '!')
141  {
142  // Skip the exclamation mark
143  szLineBegin++;
144 
145  // Check the variable type
146  nLength = strlen(szVarType);
147  if((size_t)(szLineEnd - szLineBegin) > nLength)
148  {
149  // Check the variable name
150  if(!_strnicmp(szLineBegin, szVarType, nLength))
151  {
152  // Skip variable type and the doublecolon
153  szLineBegin += nLength;
154  return (szLineBegin < szLineEnd && szLineBegin[0] == ':');
155  }
156  }
157  }
158  }
159  }
160 
161  return false;
162 }
#define _strnicmp
Definition: CascPort.h:186

+ Here is the caller graph for this function:

static bool IsValueSeparator ( const char *  szVarValue)
inlinestatic
68 {
69  return ((0 <= szVarValue[0] && szVarValue[0] <= 0x20) || (szVarValue[0] == '|'));
70 }

+ Here is the caller graph for this function:

static int LoadBlobArray ( PQUERY_KEY  pBlob,
const char *  szLineBegin,
const char *  szLineEnd,
DWORD  dwMaxBlobs 
)
static
335 {
336  LPBYTE pbBufferEnd = pBlob->pbData + pBlob->cbData;
337  LPBYTE pbBuffer = pBlob->pbData;
338  int nError = ERROR_SUCCESS;
339 
340  // Sanity check
341  assert(pBlob->pbData != NULL);
342  assert(pBlob->cbData != 0);
343 
344  // Until we find an end of the line
345  while(szLineBegin < szLineEnd && dwMaxBlobs > 0)
346  {
347  const char * szBlobEnd = szLineBegin;
348 
349  // Find the end of the text blob
350  while(szBlobEnd < szLineEnd && IsValueSeparator(szBlobEnd) == false)
351  szBlobEnd++;
352 
353  // Verify the length of the found blob
354  if((szBlobEnd - szLineBegin) != MD5_STRING_SIZE)
355  return ERROR_BAD_FORMAT;
356 
357  // Verify if there is enough space in the buffer
358  if((pbBufferEnd - pbBuffer) < MD5_HASH_SIZE)
360 
361  // Perform the conversion
362  nError = ConvertStringToBinary(szLineBegin, MD5_STRING_SIZE, pbBuffer);
363  if(nError != ERROR_SUCCESS)
364  return nError;
365 
366  // Move pointers
367  pbBuffer += MD5_HASH_SIZE;
368  dwMaxBlobs--;
369 
370  // Skip the separator
371  while(szBlobEnd < szLineEnd && IsValueSeparator(szBlobEnd))
372  szBlobEnd++;
373  szLineBegin = szBlobEnd;
374  }
375 
376  return nError;
377 }
int ConvertStringToBinary(const char *szString, size_t nMaxDigits, LPBYTE pbBinary)
Definition: Common.cpp:338
#define ERROR_NOT_ENOUGH_MEMORY
Definition: CascPort.h:208
arena_t NULL
Definition: jemalloc_internal.h:624
BYTE * LPBYTE
Definition: CascPort.h:152
DWORD cbData
Definition: CascLib.h:141
#define MD5_HASH_SIZE
Definition: CascLib.h:105
LPBYTE pbData
Definition: CascLib.h:140
static bool IsValueSeparator(const char *szVarValue)
Definition: CascFiles.cpp:67
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
#define MD5_STRING_SIZE
Definition: CascLib.h:106
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int LoadBuildInfo ( TCascStorage hs)
827 {
828  PARSEINFOFILE PfnParseProc = NULL;
829  void * pvListFile;
830  int nError = ERROR_SUCCESS;
831 
832  switch(hs->BuildFileType)
833  {
834  case CascBuildInfo:
835  PfnParseProc = ParseFile_BuildInfo;
836  break;
837 
838  case CascBuildDb:
839  PfnParseProc = ParseFile_BuildDb;
840  break;
841 
842  default:
843  nError = ERROR_NOT_SUPPORTED;
844  break;
845  }
846 
847  // Parse the appropriate build file
848  if(nError == ERROR_SUCCESS)
849  {
850  pvListFile = ListFile_OpenExternal(hs->szBuildFile);
851  if(pvListFile != NULL)
852  {
853  // Parse the info file
854  nError = PfnParseProc(hs, pvListFile);
855  ListFile_Free(pvListFile);
856  }
857  else
858  nError = ERROR_FILE_NOT_FOUND;
859  }
860 
861  // If the .build.info OR .build.db file has been loaded,
862  // proceed with loading the CDN config file and CDN build file
863  if(nError == ERROR_SUCCESS)
864  {
865  // Load the configuration file
866  pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnConfigKey);
867  if(pvListFile != NULL)
868  {
869  nError = LoadCdnConfigFile(hs, pvListFile);
870  ListFile_Free(pvListFile);
871  }
872  else
873  nError = ERROR_FILE_NOT_FOUND;
874  }
875 
876  // Load the build file
877  if(nError == ERROR_SUCCESS)
878  {
879  pvListFile = FetchAndVerifyConfigFile(hs, &hs->CdnBuildKey);
880  if(pvListFile != NULL)
881  {
882  nError = LoadCdnBuildFile(hs, pvListFile);
883  ListFile_Free(pvListFile);
884  }
885  else
886  nError = ERROR_FILE_NOT_FOUND;
887  }
888 
889  // Fill the index directory
890  if(nError == ERROR_SUCCESS)
891  {
892  // First, check for more common "data" subdirectory
893  if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("data"))) != NULL)
894  return ERROR_SUCCESS;
895 
896  // Second, try the "darch" subdirectory (older builds of HOTS - Alpha)
897  if((hs->szIndexPath = CheckForIndexDirectory(hs, _T("darch"))) != NULL)
898  return ERROR_SUCCESS;
899 
900  nError = ERROR_FILE_NOT_FOUND;
901  }
902 
903  return nError;
904 }
static int ParseFile_BuildDb(TCascStorage *hs, void *pvListFile)
Definition: CascFiles.cpp:618
void * ListFile_OpenExternal(const TCHAR *szListFile)
Definition: ListFile.cpp:52
static int ParseFile_BuildInfo(TCascStorage *hs, void *pvListFile)
Definition: CascFiles.cpp:519
void ListFile_Free(void *pvListFile)
Definition: ListFile.cpp:201
static TCHAR * CheckForIndexDirectory(TCascStorage *hs, const TCHAR *szSubDir)
Definition: CascFiles.cpp:177
CBLD_TYPE BuildFileType
Definition: CascCommon.h:201
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CascCommon.h:92
QUERY_KEY CdnBuildKey
Definition: CascCommon.h:204
#define _T(x)
Definition: CascPort.h:171
static void * FetchAndVerifyConfigFile(TCascStorage *hs, PQUERY_KEY pFileKey)
Definition: CascFiles.cpp:489
int(* PARSEINFOFILE)(TCascStorage *hs, void *pvListFile)
Definition: CascFiles.cpp:19
#define ERROR_FILE_NOT_FOUND
Definition: CascPort.h:205
Definition: CascCommon.h:93
QUERY_KEY CdnConfigKey
Definition: CascCommon.h:203
TCHAR * szIndexPath
Definition: CascCommon.h:193
TCHAR * szBuildFile
Definition: CascCommon.h:192
#define ERROR_NOT_SUPPORTED
Definition: CascPort.h:209
static int LoadCdnBuildFile(TCascStorage *hs, void *pvListFile)
Definition: CascFiles.cpp:719
#define ERROR_SUCCESS
Definition: CascPort.h:204
static int LoadCdnConfigFile(TCascStorage *hs, void *pvListFile)
Definition: CascFiles.cpp:665

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int LoadCdnBuildFile ( TCascStorage hs,
void *  pvListFile 
)
static
720 {
721  const char * szLineBegin;
722  const char * szVarBegin;
723  const char * szLineEnd = NULL;
724  int nError = ERROR_SUCCESS;
725 
726  for(;;)
727  {
728  // Get the next line
729  if(!ListFile_GetNextLine(pvListFile, &szLineBegin, &szLineEnd))
730  break;
731 
732  // Game name
733  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "build-product");
734  if(szVarBegin != NULL)
735  {
736  GetGameType(hs, szVarBegin, szLineEnd);
737  continue;
738  }
739 
740  // Game build number
741  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "build-name");
742  if(szVarBegin != NULL)
743  {
744  GetBuildNumber(hs, szVarBegin, szLineEnd);
745  continue;
746  }
747 
748  // Root
749  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "root");
750  if(szVarBegin != NULL)
751  {
752  LoadSingleBlob(&hs->RootKey, szVarBegin, szLineEnd);
753  continue;
754  }
755 
756  // Patch
757  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "patch");
758  if(szVarBegin != NULL)
759  {
760  LoadSingleBlob(&hs->PatchKey, szVarBegin, szLineEnd);
761  continue;
762  }
763 
764  // Download
765  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "download");
766  if(szVarBegin != NULL)
767  {
768  LoadSingleBlob(&hs->DownloadKey, szVarBegin, szLineEnd);
769  continue;
770  }
771 
772  // Install
773  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "install");
774  if(szVarBegin != NULL)
775  {
776  LoadSingleBlob(&hs->InstallKey, szVarBegin, szLineEnd);
777  continue;
778  }
779 
780  // Encoding keys
781  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "encoding");
782  if(szVarBegin != NULL)
783  {
784  nError = LoadMultipleBlobs(&hs->EncodingKey, szVarBegin, szLineEnd, 2);
785  continue;
786  }
787  }
788 
789  // Check the encoding keys
790  if(hs->EncodingKey.pbData == NULL || hs->EncodingKey.cbData != MD5_HASH_SIZE * 2)
791  return ERROR_BAD_FORMAT;
792  return nError;
793 }
QUERY_KEY RootKey
Definition: CascCommon.h:208
static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwBlobCount)
Definition: CascFiles.cpp:379
QUERY_KEY DownloadKey
Definition: CascCommon.h:210
arena_t NULL
Definition: jemalloc_internal.h:624
static int LoadSingleBlob(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:402
DWORD cbData
Definition: CascLib.h:141
#define MD5_HASH_SIZE
Definition: CascLib.h:105
static int GetBuildNumber(TCascStorage *hs, const char *szVarBegin, const char *szLineEnd)
Definition: CascFiles.cpp:433
size_t ListFile_GetNextLine(void *pvListFile, const char **pszLineBegin, const char **pszLineEnd)
Definition: ListFile.cpp:111
static int GetGameType(TCascStorage *hs, const char *szVarBegin, const char *szLineEnd)
Definition: CascFiles.cpp:407
LPBYTE pbData
Definition: CascLib.h:140
QUERY_KEY EncodingKey
Definition: CascCommon.h:212
static const char * CheckLineVariable(const char *szLineBegin, const char *szLineEnd, const char *szVarName)
Definition: CascFiles.cpp:214
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
QUERY_KEY PatchKey
Definition: CascCommon.h:209
QUERY_KEY InstallKey
Definition: CascCommon.h:211
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int LoadCdnConfigFile ( TCascStorage hs,
void *  pvListFile 
)
static
666 {
667  const char * szLineBegin;
668  const char * szVarBegin;
669  const char * szLineEnd;
670  int nError = ERROR_SUCCESS;
671 
672  // Keep parsing the listfile while there is something in there
673  for(;;)
674  {
675  // Get the next line
676  if(!ListFile_GetNextLine(pvListFile, &szLineBegin, &szLineEnd))
677  break;
678 
679  // Archive group
680  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "archive-group");
681  if(szVarBegin != NULL)
682  {
683  nError = LoadSingleBlob(&hs->ArchivesGroup, szVarBegin, szLineEnd);
684  continue;
685  }
686 
687  // Archives
688  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "archives");
689  if(szVarBegin != NULL)
690  {
691  nError = LoadMultipleBlobs(&hs->ArchivesKey, szVarBegin, szLineEnd);
692  continue;
693  }
694 
695  // Patch archive group
696  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "patch-archive-group");
697  if(szVarBegin != NULL)
698  {
699  LoadSingleBlob(&hs->PatchArchivesKey, szVarBegin, szLineEnd);
700  continue;
701  }
702 
703  // Patch archives
704  szVarBegin = CheckLineVariable(szLineBegin, szLineEnd, "patch-archives");
705  if(szVarBegin != NULL)
706  {
707  nError = LoadMultipleBlobs(&hs->PatchArchivesKey, szVarBegin, szLineEnd);
708  continue;
709  }
710  }
711 
712  // Check if all required fields are present
713  if(hs->ArchivesKey.pbData == NULL || hs->ArchivesKey.cbData == 0)
714  return ERROR_BAD_FORMAT;
715 
716  return nError;
717 }
static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwBlobCount)
Definition: CascFiles.cpp:379
QUERY_KEY ArchivesKey
Definition: CascCommon.h:206
arena_t NULL
Definition: jemalloc_internal.h:624
QUERY_KEY ArchivesGroup
Definition: CascCommon.h:205
static int LoadSingleBlob(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:402
DWORD cbData
Definition: CascLib.h:141
size_t ListFile_GetNextLine(void *pvListFile, const char **pszLineBegin, const char **pszLineEnd)
Definition: ListFile.cpp:111
QUERY_KEY PatchArchivesKey
Definition: CascCommon.h:207
LPBYTE pbData
Definition: CascLib.h:140
static const char * CheckLineVariable(const char *szLineBegin, const char *szLineEnd, const char *szVarName)
Definition: CascFiles.cpp:214
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int LoadInfoVariable ( PQUERY_KEY  pVarBlob,
const char *  szLineBegin,
const char *  szLineEnd,
bool  bHexaValue 
)
static
253 {
254  const char * szLinePtr = szLineBegin;
255 
256  // Sanity checks
257  assert(pVarBlob->pbData == NULL);
258  assert(pVarBlob->cbData == 0);
259 
260  // Check length of the variable
261  while(szLinePtr < szLineEnd && szLinePtr[0] != '|')
262  szLinePtr++;
263 
264  // Allocate space for the blob
265  if(bHexaValue)
266  {
267  // Initialize the blob
268  pVarBlob->pbData = CASC_ALLOC(BYTE, (szLinePtr - szLineBegin) / 2);
269  pVarBlob->cbData = (DWORD)((szLinePtr - szLineBegin) / 2);
270  return ConvertStringToBinary(szLineBegin, (size_t)(szLinePtr - szLineBegin), pVarBlob->pbData);
271  }
272 
273  // Initialize the blob
274  pVarBlob->pbData = CASC_ALLOC(BYTE, (szLinePtr - szLineBegin) + 1);
275  pVarBlob->cbData = (DWORD)(szLinePtr - szLineBegin);
276 
277  // Check for success
278  if(pVarBlob->pbData == NULL)
280 
281  // Copy the string
282  memcpy(pVarBlob->pbData, szLineBegin, pVarBlob->cbData);
283  pVarBlob->pbData[pVarBlob->cbData] = 0;
284  return ERROR_SUCCESS;
285 }
#define CASC_ALLOC(type, count)
Definition: CascCommon.h:302
int ConvertStringToBinary(const char *szString, size_t nMaxDigits, LPBYTE pbBinary)
Definition: Common.cpp:338
#define ERROR_NOT_ENOUGH_MEMORY
Definition: CascPort.h:208
arena_t NULL
Definition: jemalloc_internal.h:624
DWORD cbData
Definition: CascLib.h:141
LPBYTE pbData
Definition: CascLib.h:140
unsigned int DWORD
Definition: CascPort.h:139
unsigned char BYTE
Definition: CascPort.h:136
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int LoadMultipleBlobs ( PQUERY_KEY  pBlob,
const char *  szLineBegin,
const char *  szLineEnd,
DWORD  dwBlobCount 
)
static
380 {
381  size_t nLength = (szLineEnd - szLineBegin);
382 
383  // We expect each blob to have length of the encoding key and one space between
384  if(nLength > (dwBlobCount * MD5_STRING_SIZE) + ((dwBlobCount - 1) * sizeof(char)))
386 
387  // Allocate the blob buffer
388  pBlob->pbData = CASC_ALLOC(BYTE, dwBlobCount * MD5_HASH_SIZE);
389  if(pBlob->pbData == NULL)
391 
392  // Set the buffer size and load the blob array
393  pBlob->cbData = dwBlobCount * MD5_HASH_SIZE;
394  return LoadBlobArray(pBlob, szLineBegin, szLineEnd, dwBlobCount);
395 }
#define CASC_ALLOC(type, count)
Definition: CascCommon.h:302
#define ERROR_NOT_ENOUGH_MEMORY
Definition: CascPort.h:208
arena_t NULL
Definition: jemalloc_internal.h:624
DWORD cbData
Definition: CascLib.h:141
#define MD5_HASH_SIZE
Definition: CascLib.h:105
LPBYTE pbData
Definition: CascLib.h:140
static int LoadBlobArray(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwMaxBlobs)
Definition: CascFiles.cpp:330
#define ERROR_INVALID_PARAMETER
Definition: CascPort.h:210
unsigned char BYTE
Definition: CascPort.h:136
#define MD5_STRING_SIZE
Definition: CascLib.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int LoadMultipleBlobs ( PQUERY_KEY  pBlob,
const char *  szLineBegin,
const char *  szLineEnd 
)
static
398 {
399  return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, GetBlobCount(szLineBegin, szLineEnd));
400 }
static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwBlobCount)
Definition: CascFiles.cpp:379
static DWORD GetBlobCount(const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:308

+ Here is the call graph for this function:

static int LoadSingleBlob ( PQUERY_KEY  pBlob,
const char *  szLineBegin,
const char *  szLineEnd 
)
static
403 {
404  return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, 1);
405 }
static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char *szLineBegin, const char *szLineEnd, DWORD dwBlobCount)
Definition: CascFiles.cpp:379

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int ParseFile_BuildDb ( TCascStorage hs,
void *  pvListFile 
)
static
619 {
620  const char * szLinePtr;
621  const char * szLineEnd;
622  char szOneLine[0x200];
623  size_t nLength;
624  int nError;
625 
626  // Load the single line from the text file
627  nLength = ListFile_GetNextLine(pvListFile, szOneLine, _maxchars(szOneLine));
628  if(nLength == 0)
629  return ERROR_BAD_FORMAT;
630 
631  // Set the line range
632  szLinePtr = szOneLine;
633  szLineEnd = szOneLine + nLength;
634 
635  // Extract the CDN build key
636  nError = LoadInfoVariable(&hs->CdnBuildKey, szLinePtr, szLineEnd, true);
637  if(nError == ERROR_SUCCESS)
638  {
639  // Skip the variable
640  szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
641 
642  // Load the CDN config hash
643  nError = LoadInfoVariable(&hs->CdnConfigKey, szLinePtr, szLineEnd, true);
644  if(nError == ERROR_SUCCESS)
645  {
646  // Skip the variable
647  szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
648 
649  // Skip the Locale/OS/code variable
650  szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd);
651 
652  // Load the URL
653  hs->szUrlPath = CascNewStrFromAnsi(szLinePtr, szLineEnd);
654  if(hs->szUrlPath == NULL)
655  nError = ERROR_NOT_ENOUGH_MEMORY;
656  }
657  }
658 
659  // Verify all variables
660  if(hs->CdnBuildKey.pbData == NULL || hs->CdnConfigKey.pbData == NULL || hs->szUrlPath == NULL)
661  nError = ERROR_BAD_FORMAT;
662  return nError;
663 }
static const char * SkipInfoVariable(const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:164
#define ERROR_NOT_ENOUGH_MEMORY
Definition: CascPort.h:208
arena_t NULL
Definition: jemalloc_internal.h:624
QUERY_KEY CdnBuildKey
Definition: CascCommon.h:204
TCHAR * szUrlPath
Definition: CascCommon.h:194
static int LoadInfoVariable(PQUERY_KEY pVarBlob, const char *szLineBegin, const char *szLineEnd, bool bHexaValue)
Definition: CascFiles.cpp:252
#define _maxchars(buff)
Definition: CascCommon.h:80
size_t ListFile_GetNextLine(void *pvListFile, const char **pszLineBegin, const char **pszLineEnd)
Definition: ListFile.cpp:111
LPBYTE pbData
Definition: CascLib.h:140
QUERY_KEY CdnConfigKey
Definition: CascCommon.h:203
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
TCHAR * CascNewStrFromAnsi(const char *szBegin, const char *szEnd)
Definition: Common.cpp:140
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int ParseFile_BuildInfo ( TCascStorage hs,
void *  pvListFile 
)
static
520 {
521  QUERY_KEY Active = {NULL, 0};
522  QUERY_KEY TagString = {NULL, 0};
523  QUERY_KEY CdnHost = {NULL, 0};
524  QUERY_KEY CdnPath = {NULL, 0};
525  char szOneLine1[0x200];
526  char szOneLine2[0x400];
527  size_t nLength1;
528  size_t nLength2;
529  int nError = ERROR_BAD_FORMAT;
530 
531  // Extract the first line, cotaining the headers
532  nLength1 = ListFile_GetNextLine(pvListFile, szOneLine1, _maxchars(szOneLine1));
533  if(nLength1 == 0)
534  return ERROR_BAD_FORMAT;
535 
536  // Now parse the second and the next lines. We are looking for line
537  // with "Active" set to 1
538  for(;;)
539  {
540  const char * szLinePtr1 = szOneLine1;
541  const char * szLineEnd1 = szOneLine1 + nLength1;
542  const char * szLinePtr2 = szOneLine2;
543  const char * szLineEnd2;
544 
545  // Read the next line
546  nLength2 = ListFile_GetNextLine(pvListFile, szOneLine2, _maxchars(szOneLine2));
547  if(nLength2 == 0)
548  break;
549  szLineEnd2 = szLinePtr2 + nLength2;
550 
551  // Parse all variables
552  while(szLinePtr1 < szLineEnd1)
553  {
554  // Check for variables we need
555  if(IsInfoVariable(szLinePtr1, szLineEnd1, "Active", "DEC"))
556  LoadInfoVariable(&Active, szLinePtr2, szLineEnd2, false);
557  if(IsInfoVariable(szLinePtr1, szLineEnd1, "Build Key", "HEX"))
558  LoadInfoVariable(&hs->CdnBuildKey, szLinePtr2, szLineEnd2, true);
559  if(IsInfoVariable(szLinePtr1, szLineEnd1, "CDN Key", "HEX"))
560  LoadInfoVariable(&hs->CdnConfigKey, szLinePtr2, szLineEnd2, true);
561  if(IsInfoVariable(szLinePtr1, szLineEnd1, "CDN Hosts", "STRING"))
562  LoadInfoVariable(&CdnHost, szLinePtr2, szLineEnd2, false);
563  if(IsInfoVariable(szLinePtr1, szLineEnd1, "CDN Path", "STRING"))
564  LoadInfoVariable(&CdnPath, szLinePtr2, szLineEnd2, false);
565  if(IsInfoVariable(szLinePtr1, szLineEnd1, "Tags", "STRING"))
566  LoadInfoVariable(&TagString, szLinePtr2, szLineEnd2, false);
567 
568  // Move both line pointers
569  szLinePtr1 = SkipInfoVariable(szLinePtr1, szLineEnd1);
570  if(szLinePtr1 == NULL)
571  break;
572 
573  szLinePtr2 = SkipInfoVariable(szLinePtr2, szLineEnd2);
574  if(szLinePtr2 == NULL)
575  break;
576  }
577 
578  // Stop parsing if found active config
579  if(Active.pbData != NULL && *Active.pbData == '1')
580  break;
581 
582  // Free the blobs
583  FreeCascBlob(&Active);
586  FreeCascBlob(&CdnHost);
587  FreeCascBlob(&CdnPath);
588  FreeCascBlob(&TagString);
589  }
590 
591  // All four must be present
592  if(hs->CdnBuildKey.pbData != NULL &&
593  hs->CdnConfigKey.pbData != NULL &&
594  CdnHost.pbData != NULL &&
595  CdnPath.pbData != NULL)
596  {
597  // Merge the CDN host and CDN path
598  hs->szUrlPath = CASC_ALLOC(TCHAR, CdnHost.cbData + CdnPath.cbData + 1);
599  if(hs->szUrlPath != NULL)
600  {
601  CopyString(hs->szUrlPath, (char *)CdnHost.pbData, CdnHost.cbData);
602  CopyString(hs->szUrlPath + CdnHost.cbData, (char *)CdnPath.pbData, CdnPath.cbData);
603  nError = ERROR_SUCCESS;
604  }
605  }
606 
607  // If we found tags, we can extract language build from it
608  if(TagString.pbData != NULL)
609  GetDefaultLocaleMask(hs, &TagString);
610 
611  FreeCascBlob(&CdnHost);
612  FreeCascBlob(&CdnPath);
613  FreeCascBlob(&TagString);
614  FreeCascBlob(&Active);
615  return nError;
616 }
void CopyString(char *szTarget, const char *szSource, size_t cchLength)
Definition: Common.cpp:84
#define CASC_ALLOC(type, count)
Definition: CascCommon.h:302
static int GetDefaultLocaleMask(TCascStorage *hs, PQUERY_KEY pTagsString)
Definition: CascFiles.cpp:458
static const char * SkipInfoVariable(const char *szLineBegin, const char *szLineEnd)
Definition: CascFiles.cpp:164
Definition: CascLib.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
char TCHAR
Definition: CascPort.h:148
void FreeCascBlob(PQUERY_KEY pBlob)
Definition: CascCommon.cpp:80
QUERY_KEY CdnBuildKey
Definition: CascCommon.h:204
static bool IsInfoVariable(const char *szLineBegin, const char *szLineEnd, const char *szVarName, const char *szVarType)
Definition: CascFiles.cpp:127
TCHAR * szUrlPath
Definition: CascCommon.h:194
DWORD cbData
Definition: CascLib.h:141
static int LoadInfoVariable(PQUERY_KEY pVarBlob, const char *szLineBegin, const char *szLineEnd, bool bHexaValue)
Definition: CascFiles.cpp:252
#define _maxchars(buff)
Definition: CascCommon.h:80
size_t ListFile_GetNextLine(void *pvListFile, const char **pszLineBegin, const char **pszLineEnd)
Definition: ListFile.cpp:111
LPBYTE pbData
Definition: CascLib.h:140
QUERY_KEY CdnConfigKey
Definition: CascCommon.h:203
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int ParseRootFileLine ( const char *  szLinePtr,
const char *  szLineEnd,
int  nFileNameIndex,
PQUERY_KEY  PtrEncodingKey,
char *  szFileName,
size_t  nMaxChars 
)
983 {
984  int nIndex = 0;
985  int nError;
986 
987  // Extract the MD5 (aka encoding key)
988  if(szLinePtr[MD5_STRING_SIZE] != '|')
989  return ERROR_BAD_FORMAT;
990 
991  // Convert the encoding key to binary
992  PtrEncodingKey->cbData = MD5_HASH_SIZE;
993  nError = ConvertStringToBinary(szLinePtr, MD5_STRING_SIZE, PtrEncodingKey->pbData);
994  if(nError != ERROR_SUCCESS)
995  return nError;
996 
997  // Skip the variable
998  szLinePtr += MD5_STRING_SIZE + 1;
999  nIndex = 1;
1000 
1001  // Skip the variables until we find the file name
1002  while(szLinePtr < szLineEnd && nIndex < nFileNameIndex)
1003  {
1004  if(szLinePtr[0] == '|')
1005  nIndex++;
1006  szLinePtr++;
1007  }
1008 
1009  // Extract the file name
1010  while(szLinePtr < szLineEnd && szLinePtr[0] != '|' && nMaxChars > 1)
1011  {
1012  *szFileName++ = *szLinePtr++;
1013  nMaxChars--;
1014  }
1015 
1016  *szFileName = 0;
1017  return ERROR_SUCCESS;
1018 }
int ConvertStringToBinary(const char *szString, size_t nMaxDigits, LPBYTE pbBinary)
Definition: Common.cpp:338
DWORD cbData
Definition: CascLib.h:141
#define MD5_HASH_SIZE
Definition: CascLib.h:105
LPBYTE pbData
Definition: CascLib.h:140
#define ERROR_BAD_FORMAT
Definition: CascPort.h:214
#define MD5_STRING_SIZE
Definition: CascLib.h:106
#define ERROR_SUCCESS
Definition: CascPort.h:204

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* SkipInfoVariable ( const char *  szLineBegin,
const char *  szLineEnd 
)
static
165 {
166  while(szLineBegin < szLineEnd)
167  {
168  if(szLineBegin[0] == '|')
169  return szLineBegin + 1;
170 
171  szLineBegin++;
172  }
173 
174  return NULL;
175 }
arena_t NULL
Definition: jemalloc_internal.h:624

+ Here is the caller graph for this function:

Variable Documentation

const TBuildFileInfo BuildTypes[]
static
Initial value:
=
{
{_T(".build.info"), CascBuildInfo},
{_T(".build.db"), CascBuildDb},
}
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CascCommon.h:92
#define _T(x)
Definition: CascPort.h:171
Definition: CascCommon.h:93
Definition: CascCommon.h:91
const TCHAR* DataDirs[]
static
Initial value:
=
{
_T("SC2Data"),
_T("Data\\Casc"),
_T("Data"),
_T("HeroesData"),
_T("BNTData"),
}
arena_t NULL
Definition: jemalloc_internal.h:624
#define _T(x)
Definition: CascPort.h:171
const TGameIdString GameIds[]
static
Initial value:
=
{
{"Hero", 0x04, CASC_GAME_HOTS},
{"WoW", 0x03, CASC_GAME_WOW6},
{"Diablo3", 0x07, CASC_GAME_DIABLO3},
{"Prometheus", 0x0A, CASC_GAME_OVERWATCH},
{"SC2", 0x03, CASC_GAME_STARCRAFT2},
{NULL, 0, 0},
}
#define CASC_GAME_WOW6
Definition: CascCommon.h:44
#define CASC_GAME_HOTS
Definition: CascCommon.h:43
arena_t NULL
Definition: jemalloc_internal.h:624
#define CASC_GAME_OVERWATCH
Definition: CascCommon.h:46
#define CASC_GAME_STARCRAFT2
Definition: CascCommon.h:47
#define CASC_GAME_DIABLO3
Definition: CascCommon.h:45