Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <io.h>
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <iostream>
- #include <cstdio>
- #include <stack>
- #include <errno.h>
- #include <cerrno>
- #include <cassert>
- #include <assert.h>
- #include <vadefs.h>
- #include <valarray>
- #include <tpcver.h>
- #include <string>
- #include <vector>
- #include <stdbool.h>
- #include <wchar.h>
- #include <sys/types.h>
- #include <sys/timeb.h>
- #include <sys/utime.h>
- #include <sys/stat.h>
- #include <sys/locking.h>
- #include <direct.h>
- #include <regbag.h>
- #include <WinBase.h>
- #include <stdint.h>
- #include <WinSock.h>
- #include <stddef.h>
- #if defined Hattrick
- #error Hattrick symbol is already defined. Try to rename below in Source.cpp file.
- #endif
- #if !defined STATIC
- #define STATIC static
- #endif
- #if !defined NAMESPACE
- #define NAMESPACE namespace
- #endif
- #if !defined FINDDATA
- #define FINDDATA _finddata_t
- #endif
- #if !defined TEMPLATE
- #define TEMPLATE template
- #endif
- #if !defined TYPENAME
- #define TYPENAME typename
- #endif
- #if !defined RETURN
- #define RETURN return
- #endif
- #if !defined SIZEOF
- #define SIZEOF sizeof
- #endif
- #if !defined BREAK
- #define BREAK break
- #endif
- #if !defined CONTINUE
- #define CONTINUE continue
- #endif
- #if !defined ELSE
- #define ELSE else
- #endif
- #if !defined IF
- #define IF if
- #endif
- #if !defined FOR
- #define FOR for
- #endif
- #if !defined WHILE
- #define WHILE while
- #endif
- #if !defined OR
- #define OR ||
- #endif
- #if !defined AND
- #define AND &&
- #endif
- NAMESPACE Hattrick
- {
- STATIC SIZE_T Natives = 0U;
- STATIC SIZE_T Forwards = 0U;
- STATIC SIZE_T Stocks = 0U;
- STATIC SIZE_T Definitions = 0U;
- STATIC FILE * Journal = NULL;
- STATIC FILE * Output = NULL;
- STATIC BOOL UnicodeJournal = FALSE;
- VOID OpenJournal(BOOL Unicode)
- {
- IF (!Journal)
- {
- IF (Unicode)
- {
- _wfopen_s(&Journal, L"journal.log", L"a+, ccs=UNICODE");
- }
- ELSE
- {
- fopen_s(&Journal, "journal.log", "a+");
- }
- UnicodeJournal = Unicode;
- }
- }
- VOID CloseJournal(VOID)
- {
- IF (Journal)
- {
- fclose(Journal);
- Journal = NULL;
- }
- }
- VOID Log(PWCHAR Format, ...)
- {
- IF (Format)
- {
- STATIC WCHAR String[1024U] = { (WCHAR)L'\0' };
- STATIC PCHAR Handle = NULL;
- va_start(Handle, Format);
- _vsnwprintf_s(String, SIZEOF(String), SIZEOF(String) / SIZEOF(WCHAR), Format, Handle);
- va_end(Handle);
- IF (Journal)
- {
- IF (!UnicodeJournal)
- {
- CloseJournal();
- OpenJournal(TRUE);
- IF (!Journal)
- {
- RETURN;
- }
- }
- fwprintf_s(Journal, L"%ls\n", String);
- }
- }
- }
- VOID Log(PCHAR Format, ...)
- {
- IF (Format)
- {
- STATIC CHAR String[1024U] = { '\0' };
- STATIC PCHAR Handle = NULL;
- va_start(Handle, Format);
- _vsnprintf_s(String, SIZEOF(String), SIZEOF(String) / SIZEOF(CHAR), Format, Handle);
- va_end(Handle);
- IF (Journal)
- {
- IF (UnicodeJournal)
- {
- CloseJournal();
- OpenJournal(FALSE);
- IF (!Journal)
- {
- RETURN;
- }
- }
- fprintf_s(Journal, "%s\n", String);
- }
- }
- }
- VOID StringAppend(PCHAR Destination, SIZE_T DestinationSize, PCHAR Source)
- {
- IF (Destination AND Source)
- {
- _snprintf_s(Destination, DestinationSize, DestinationSize / SIZEOF(CHAR), "%s%s", Destination, Source);
- }
- }
- VOID StringAppend(PWCHAR Destination, SIZE_T DestinationSize, PWCHAR Source)
- {
- IF (Destination AND Source)
- {
- _snwprintf_s(Destination, DestinationSize, DestinationSize / SIZEOF(WCHAR), L"%ls%ls", Destination, Source);
- }
- }
- VOID StringToLower(PWCHAR Destination, SIZE_T DestinationSize)
- {
- IF (Destination)
- {
- _wcslwr_s(Destination, DestinationSize);
- }
- }
- VOID StringToLower(PCHAR Destination, SIZE_T DestinationSize)
- {
- IF (Destination)
- {
- _strlwr_s(Destination, DestinationSize);
- }
- }
- BOOL FileHasExtension(PWCHAR Destination, SIZE_T DestinationSize, PWCHAR Extension)
- {
- IF (Destination AND Extension)
- {
- STATIC SIZE_T DestinationLength = 0U;
- STATIC SIZE_T ExtensionLength = 0U;
- DestinationLength = wcslen(Destination);
- ExtensionLength = wcslen(Extension);
- IF (DestinationLength > ExtensionLength + 1U AND _wcsicmp(&Destination[DestinationLength - ExtensionLength], Extension) == 0U)
- {
- RETURN TRUE;
- }
- }
- RETURN FALSE;
- }
- BOOL FileHasExtension(PCHAR Destination, SIZE_T DestinationSize, PCHAR Extension)
- {
- IF (Destination AND Extension)
- {
- STATIC SIZE_T DestinationLength = 0U;
- STATIC SIZE_T ExtensionLength = 0U;
- DestinationLength = strlen(Destination);
- ExtensionLength = strlen(Extension);
- IF (DestinationLength > ExtensionLength + 1U AND _stricmp(&Destination[DestinationLength - ExtensionLength], Extension) == 0U)
- {
- RETURN TRUE;
- }
- }
- RETURN FALSE;
- }
- VOID StringTruncateRight(PWCHAR Destination, WCHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = wcslen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (Destination[Iterator] == Character)
- {
- Destination[Iterator] = (WCHAR)L'\0';
- BREAK;
- }
- }
- }
- }
- VOID StringTruncateRight(PCHAR Destination, CHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = strlen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (Destination[Iterator] == Character)
- {
- Destination[Iterator] = '\0';
- BREAK;
- }
- }
- }
- }
- VOID StringTruncateLeft(PWCHAR Destination, WCHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < wcslen(Destination); Iterator++)
- {
- IF (Destination[Iterator] == Character)
- {
- Destination[Iterator] = (WCHAR)L'\0';
- BREAK;
- }
- }
- }
- }
- VOID StringTruncateLeft(PCHAR Destination, CHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < strlen(Destination); Iterator++)
- {
- IF (Destination[Iterator] == Character)
- {
- Destination[Iterator] = '\0';
- BREAK;
- }
- }
- }
- }
- INT GetFirstCharacterPositionInString(PCHAR Destination, WCHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < strlen(Destination); Iterator++)
- {
- IF (Destination[Iterator] == Character)
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- INT GetFirstCharacterPositionInString(PWCHAR Destination, WCHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < wcslen(Destination); Iterator++)
- {
- IF (Destination[Iterator] == Character)
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- INT GetLastCharacterPositionInString(PCHAR Destination, CHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = strlen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (Destination[Iterator] == Character)
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- INT GetLastCharacterPositionInString(PWCHAR Destination, WCHAR Character)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = wcslen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (Destination[Iterator] == Character)
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- INT GetFirstEligibleCharacterPositionInString(PCHAR Destination)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < strlen(Destination); Iterator++)
- {
- IF (isprint(Destination[Iterator]))
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- INT GetFirstEligibleCharacterPositionInString(PWCHAR Destination)
- {
- IF (Destination)
- {
- STATIC SIZE_T Iterator = 0U;
- FOR (Iterator = 0U; Iterator < wcslen(Destination); Iterator++)
- {
- IF (iswprint(Destination[Iterator]))
- {
- RETURN Iterator;
- }
- }
- }
- RETURN -1;
- }
- PCHAR Trim(PCHAR Destination)
- {
- IF (Destination)
- {
- STATIC INT EligibleCharacterPosition = 0U;
- STATIC SIZE_T Iterator = 0U;
- STATIC std::string String = "";
- WHILE (*Destination AND (isspace(*Destination) OR *Destination == '\n' OR *Destination == '\0' OR *Destination == ' ' \
- OR *Destination == '\r' OR *Destination == '\t' OR *Destination == '\f' OR *Destination == '\v' OR *Destination == '#'))
- {
- Destination++;
- }
- FOR (Iterator = strlen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (isspace(Destination[Iterator]) OR Destination[Iterator] == '\n' OR Destination[Iterator] == '\0' \
- OR Destination[Iterator] == ' ' OR Destination[Iterator] == '\r' OR Destination[Iterator] == '\t' \
- OR Destination[Iterator] == '\f' OR Destination[Iterator] == '\v' OR Destination[Iterator] == '=')
- {
- Destination[Iterator] = '\0';
- }
- ELSE
- {
- BREAK;
- }
- }
- EligibleCharacterPosition = GetFirstEligibleCharacterPositionInString(Destination);
- IF (EligibleCharacterPosition >= 0U)
- {
- String.assign(&Destination[EligibleCharacterPosition]);
- RETURN (PCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PWCHAR Trim(PWCHAR Destination)
- {
- IF (Destination)
- {
- STATIC INT EligibleCharacterPosition = 0U;
- STATIC SIZE_T Iterator = 0U;
- STATIC std::wstring String = L"";
- WHILE (*Destination AND (iswspace(*Destination) OR *Destination == (WCHAR)L'\n' OR *Destination == (WCHAR)L'\0' OR \
- *Destination == (WCHAR)L' ' OR *Destination == (WCHAR)L'\r' OR *Destination == (WCHAR)L'\t' OR \
- *Destination == (WCHAR)L'\f' OR *Destination == (WCHAR)L'\v') OR *Destination == (WCHAR)L'#')
- {
- Destination++;
- }
- FOR (Iterator = wcslen(Destination) - 1U; Iterator >= 0U; Iterator--)
- {
- IF (iswspace(Destination[Iterator]) OR Destination[Iterator] == (WCHAR)L'\n' OR \
- Destination[Iterator] == (WCHAR)L'\0' OR Destination[Iterator] == (WCHAR)L' ' \
- OR Destination[Iterator] == (WCHAR)L'\r' OR Destination[Iterator] == (WCHAR)L'\t' \
- OR Destination[Iterator] == (WCHAR)L'\f' OR Destination[Iterator] == (WCHAR)L'\v' \
- OR Destination[Iterator] == (WCHAR)L'=')
- {
- Destination[Iterator] = (WCHAR)L'\0';
- }
- ELSE
- {
- BREAK;
- }
- }
- EligibleCharacterPosition = GetFirstEligibleCharacterPositionInString(Destination);
- IF (EligibleCharacterPosition >= 0U)
- {
- String.assign(&Destination[EligibleCharacterPosition]);
- RETURN (PWCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- BOOL IsFolder(PWCHAR File)
- {
- IF (File)
- {
- STATIC DWORD Attributes = 0U;
- Attributes = GetFileAttributesW(File);
- IF (Attributes == INVALID_FILE_ATTRIBUTES OR !(Attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- RETURN FALSE;
- }
- RETURN TRUE;
- }
- RETURN FALSE;
- }
- BOOL IsFolder(PCHAR File)
- {
- IF (File)
- {
- STATIC DWORD Attributes = 0U;
- Attributes = GetFileAttributesA(File);
- IF (Attributes == INVALID_FILE_ATTRIBUTES OR !(Attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- RETURN FALSE;
- }
- RETURN TRUE;
- }
- RETURN FALSE;
- }
- BOOL EnumerateFiles(LPARAM Flag, PWCHAR Directory, PWCHAR Extension, VOID Function(PWCHAR, LPARAM))
- {
- IF (Directory AND Extension AND Function)
- {
- STATIC INT_PTR Handle = NULL;
- STATIC _wfinddata_t Data;
- Handle = _wfindfirst(Directory, &Data);
- IF (Handle == -1L)
- {
- RETURN FALSE;
- }
- do
- {
- IF (FileHasExtension(Data.name, SIZEOF(Data.name), Extension))
- {
- Function(Data.name, Flag);
- }
- }
- WHILE (!_wfindnext(Handle, &Data));
- }
- RETURN FALSE;
- }
- BOOL EnumerateFiles(LPARAM Flag, PCHAR Directory, PCHAR Extension, VOID Function(PCHAR, LPARAM))
- {
- IF (Directory AND Extension AND Function)
- {
- STATIC INT_PTR Handle = NULL;
- STATIC FINDDATA Data;
- Handle = _findfirst(Directory, &Data);
- IF (Handle == -1L)
- {
- RETURN FALSE;
- }
- do
- {
- IF (FileHasExtension(Data.name, SIZEOF(Data.name), Extension))
- {
- Function(Data.name, Flag);
- }
- }
- WHILE (!_findnext(Handle, &Data));
- }
- RETURN FALSE;
- }
- PCHAR StripFirstWordFromBuffer(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string String = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC SIZE_T Try = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- StartCopy = FALSE;
- IsComment = FALSE;
- IsSpace = FALSE;
- String = "";
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IsSpace = isspace(Buffer[Iterator]) OR Buffer[Iterator] == ' ' OR Buffer[Iterator] == '\t' ? TRUE : FALSE;
- IF (IsSpace)
- {
- StartCopy = TRUE;
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator + 1U] == '*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PWCHAR StripFirstWordFromBuffer(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring String = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- StartCopy = FALSE;
- IsComment = FALSE;
- IsSpace = FALSE;
- String = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IsSpace = iswspace(Buffer[Iterator]) OR Buffer[Iterator] == (WCHAR)L' ' OR Buffer[Iterator] == (WCHAR)L'\t' ? TRUE : FALSE;
- IF (IsSpace)
- {
- StartCopy = TRUE;
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator + 1U] == (WCHAR)L'*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PWCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PCHAR StripFirstWordFromBufferStock(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string String = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- StartCopy = FALSE;
- IsComment = FALSE;
- IsSpace = FALSE;
- HasBrackets = strchr(Buffer, '(') OR strchr(Buffer, ')') ? TRUE : FALSE;
- String = "";
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IsSpace = isspace(Buffer[Iterator]) OR Buffer[Iterator] == ' ' OR Buffer[Iterator] == '\t' ? TRUE : FALSE;
- IF ((!HasBrackets AND (Buffer[Iterator] == '=' OR Buffer[Iterator] == '[')) OR Buffer[Iterator] == ';')
- {
- BREAK;
- }
- ELSE IF (IsSpace)
- {
- StartCopy = TRUE;
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator + 1U] == '*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PWCHAR StripFirstWordFromBufferStock(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring String = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- StartCopy = FALSE;
- IsSpace = FALSE;
- IsComment = FALSE;
- HasBrackets = wcschr(Buffer, (WCHAR)L'(') OR wcschr(Buffer, (WCHAR)L')') ? TRUE : FALSE;
- String = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IsSpace = iswspace(Buffer[Iterator]) OR Buffer[Iterator] == (WCHAR)L' ' OR Buffer[Iterator] == (WCHAR)L'\t' ? TRUE : FALSE;
- IF ((!HasBrackets AND (Buffer[Iterator] == (WCHAR)L'=' OR Buffer[Iterator] == (WCHAR)L'[')) OR Buffer[Iterator] == (WCHAR)L';')
- {
- BREAK;
- }
- ELSE IF (IsSpace)
- {
- StartCopy = TRUE;
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator + 1U] == (WCHAR)L'*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PWCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PCHAR StripFirstWordFromBufferDefinition(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string String = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- StartCopy = FALSE;
- IsComment = FALSE;
- IsSpace = FALSE;
- HasBrackets = FALSE;
- String = "";
- IF (strchr(Buffer, '%') AND ((strchr(Buffer, ')') AND strchr(Buffer, '(')) OR (strchr(Buffer, ']') AND strchr(Buffer, '['))))
- {
- HasBrackets = TRUE;
- }
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IsSpace = isspace(Buffer[Iterator]) OR Buffer[Iterator] == ' ' OR Buffer[Iterator] == '\t' ? TRUE : FALSE;
- IF (IsSpace)
- {
- StartCopy = TRUE;
- IF (!HasBrackets AND String.length())
- {
- BREAK;
- }
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator + 1U] == '*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PWCHAR StripFirstWordFromBufferDefinition(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring String = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL StartCopy = FALSE;
- STATIC BOOL IsComment = FALSE;
- STATIC BOOL IsSpace = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- StartCopy = FALSE;
- IsComment = FALSE;
- IsSpace = FALSE;
- HasBrackets = FALSE;
- String = L"";
- IF (wcschr(Buffer, (WCHAR)L'%') AND ((wcschr(Buffer, (WCHAR)L')') AND wcschr(Buffer, (WCHAR)L'(')) OR (wcschr(Buffer, (WCHAR)L']') AND wcschr(Buffer, (WCHAR)L'['))))
- {
- HasBrackets = TRUE;
- }
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IsSpace = iswspace(Buffer[Iterator]) OR Buffer[Iterator] == (WCHAR)L' ' OR Buffer[Iterator] == (WCHAR)L'\t' ? TRUE : FALSE;
- IF (IsSpace)
- {
- StartCopy = TRUE;
- IF (!HasBrackets AND String.length())
- {
- BREAK;
- }
- String += Buffer[Iterator];
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator + 1U] == (WCHAR)L'*')
- {
- IsComment = TRUE;
- CONTINUE;
- }
- ELSE IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'*')
- {
- IsComment = FALSE;
- CONTINUE;
- }
- ELSE IF (StartCopy AND !IsComment)
- {
- String += Buffer[Iterator];
- }
- }
- IF (String.length())
- {
- RETURN (PWCHAR)String.c_str();
- }
- }
- RETURN NULL;
- }
- PCHAR GetFunctionName(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string Function = "";
- STATIC SIZE_T Iterator = 0U;
- Function = "";
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] != '(' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PWCHAR GetFunctionName(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring Function = L"";
- STATIC SIZE_T Iterator = 0U;
- Function = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] != (WCHAR)L'(' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PWCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PCHAR GetFunctionNameStock(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string Function = "";
- STATIC SIZE_T Iterator = 0U;
- Function = "";
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] != '(' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PWCHAR GetFunctionNameStock(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring Function = L"";
- STATIC SIZE_T Iterator = 0U;
- Function = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] != (WCHAR)L'(' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PWCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PCHAR GetFunctionNameDefinition(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::string Function = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL HasRightBrackets = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- STATIC BOOL UseRightBrackets = FALSE;
- STATIC BOOL HasSlash = FALSE;
- STATIC INT OpenRightBracketPosition = 0U;
- STATIC INT CloseRightBracketPosition = 0U;
- STATIC INT OpenBracketPosition = 0U;
- STATIC INT CloseBracketPosition = 0U;
- STATIC INT SlashPosition = 0U;
- HasRightBrackets = FALSE;
- HasBrackets = FALSE;
- UseRightBrackets = FALSE;
- HasSlash = strchr(Buffer, '/') ? TRUE : FALSE;
- SlashPosition = GetFirstCharacterPositionInString(Buffer, '/');
- IF (strchr(Buffer, '[') AND strchr(Buffer, ']'))
- {
- HasRightBrackets = TRUE;
- OpenRightBracketPosition = GetFirstCharacterPositionInString(Buffer, '[');
- CloseRightBracketPosition = GetFirstCharacterPositionInString(Buffer, ']');
- IF (HasSlash)
- {
- IF (SlashPosition != -1 AND SlashPosition < OpenRightBracketPosition)
- {
- HasRightBrackets = FALSE;
- }
- }
- }
- IF (strchr(Buffer, ')') AND strchr(Buffer, '('))
- {
- HasBrackets = TRUE;
- OpenBracketPosition = GetFirstCharacterPositionInString(Buffer, '(');
- CloseBracketPosition = GetFirstCharacterPositionInString(Buffer, ')');
- IF (HasSlash)
- {
- IF (SlashPosition != -1 AND SlashPosition < OpenBracketPosition)
- {
- HasBrackets = FALSE;
- }
- }
- }
- IF (HasBrackets AND !HasRightBrackets)
- {
- UseRightBrackets = FALSE;
- }
- ELSE IF (!HasBrackets AND HasRightBrackets)
- {
- UseRightBrackets = TRUE;
- }
- ELSE IF (!HasSlash)
- {
- IF (OpenRightBracketPosition < OpenBracketPosition AND CloseRightBracketPosition < CloseBracketPosition)
- {
- UseRightBrackets = TRUE;
- }
- ELSE
- {
- UseRightBrackets = FALSE;
- }
- }
- Function = "";
- IF (UseRightBrackets)
- {
- IF (strchr(Buffer, '[') AND strchr(Buffer, ']'))
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != '[' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE IF (strchr(Buffer, '(') AND strchr(Buffer, ')'))
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != '(' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (isprint(Buffer[Iterator]))
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- Function += Buffer[Iterator];
- }
- }
- }
- }
- ELSE
- {
- IF (strchr(Buffer, '(') AND strchr(Buffer, ')'))
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != '(' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE IF (strchr(Buffer, '[') AND strchr(Buffer, ']'))
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != '[' AND isprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE
- {
- FOR (Iterator = 0U; Iterator < strlen(Buffer); Iterator++)
- {
- IF (isprint(Buffer[Iterator]))
- {
- IF (Buffer[Iterator] == '/' AND Buffer[Iterator - 1U] == '/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == '/' AND Buffer[Iterator] == '/')
- {
- BREAK;
- }
- Function += Buffer[Iterator];
- }
- }
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PWCHAR GetFunctionNameDefinition(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC std::wstring Function = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL HasRightBrackets = FALSE;
- STATIC BOOL HasBrackets = FALSE;
- STATIC BOOL UseRightBrackets = FALSE;
- STATIC BOOL HasSlash = FALSE;
- STATIC INT OpenRightBracketPosition = 0U;
- STATIC INT CloseRightBracketPosition = 0U;
- STATIC INT OpenBracketPosition = 0U;
- STATIC INT CloseBracketPosition = 0U;
- STATIC INT SlashPosition = 0U;
- HasRightBrackets = FALSE;
- HasBrackets = FALSE;
- UseRightBrackets = FALSE;
- HasSlash = wcschr(Buffer, (WCHAR)L'/') ? TRUE : FALSE;
- SlashPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'/');
- IF (wcschr(Buffer, (WCHAR)L'[') AND wcschr(Buffer, (WCHAR)L']'))
- {
- HasRightBrackets = TRUE;
- OpenRightBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'[');
- CloseRightBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L']');
- IF (HasSlash)
- {
- IF (SlashPosition != -1 AND SlashPosition < OpenRightBracketPosition)
- {
- HasRightBrackets = FALSE;
- }
- }
- }
- IF (wcschr(Buffer, (WCHAR)L')') AND wcschr(Buffer, (WCHAR)L'('))
- {
- HasBrackets = TRUE;
- OpenBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'(');
- CloseBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L')');
- IF (HasSlash)
- {
- IF (SlashPosition != -1 AND SlashPosition < OpenBracketPosition)
- {
- HasBrackets = FALSE;
- }
- }
- }
- IF (HasBrackets AND !HasRightBrackets)
- {
- UseRightBrackets = FALSE;
- }
- ELSE IF (!HasBrackets AND HasRightBrackets)
- {
- UseRightBrackets = TRUE;
- }
- ELSE IF (!HasSlash)
- {
- IF (OpenRightBracketPosition < OpenBracketPosition AND CloseRightBracketPosition < CloseBracketPosition)
- {
- UseRightBrackets = TRUE;
- }
- ELSE
- {
- UseRightBrackets = FALSE;
- }
- }
- Function = L"";
- IF (UseRightBrackets)
- {
- IF (wcschr(Buffer, (WCHAR)L'[') AND wcschr(Buffer, (WCHAR)L']'))
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != (WCHAR)L'[' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE IF (wcschr(Buffer, (WCHAR)L'(') AND wcschr(Buffer, (WCHAR)L')'))
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != (WCHAR)L'(' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (iswprint(Buffer[Iterator]))
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- Function += Buffer[Iterator];
- }
- }
- }
- }
- ELSE
- {
- IF (wcschr(Buffer, (WCHAR)L'(') AND wcschr(Buffer, (WCHAR)L')'))
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != (WCHAR)L'(' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE IF (wcschr(Buffer, (WCHAR)L'[') AND wcschr(Buffer, (WCHAR)L']'))
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator] != (WCHAR)L'[' AND iswprint(Buffer[Iterator]))
- {
- Function += Buffer[Iterator];
- }
- ELSE
- {
- BREAK;
- }
- }
- }
- ELSE
- {
- FOR (Iterator = 0U; Iterator < wcslen(Buffer); Iterator++)
- {
- IF (iswprint(Buffer[Iterator]))
- {
- IF (Buffer[Iterator] == (WCHAR)L'/' AND Buffer[Iterator - 1U] == (WCHAR)L'/')
- {
- BREAK;
- }
- ELSE IF (Buffer[Iterator + 1U] == (WCHAR)L'/' AND Buffer[Iterator] == (WCHAR)L'/')
- {
- BREAK;
- }
- Function += Buffer[Iterator];
- }
- }
- }
- }
- IF (Function.length())
- {
- RETURN Trim((PWCHAR)Function.c_str());
- }
- }
- RETURN NULL;
- }
- PWCHAR GetParametersDefinition(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC BOOL UseNormalBrackets = FALSE;
- STATIC BOOL RightBracketsFound = FALSE;
- STATIC BOOL BracketsFound = FALSE;
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- STATIC INT OpeningRightBracketPosition = 0U;
- STATIC INT ClosingRightBracketPosition = 0U;
- UseNormalBrackets = FALSE;
- RightBracketsFound = FALSE;
- BracketsFound = FALSE;
- IF (wcschr(Buffer, (WCHAR)L'[') AND wcschr(Buffer, (WCHAR)L']'))
- {
- OpeningRightBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'[');
- ClosingRightBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L']');
- RightBracketsFound = TRUE;
- }
- IF (wcschr(Buffer, (WCHAR)L'(') AND wcschr(Buffer, (WCHAR)L')'))
- {
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L')');
- BracketsFound = TRUE;
- }
- IF (RightBracketsFound AND !BracketsFound)
- {
- UseNormalBrackets = FALSE;
- }
- ELSE IF (BracketsFound AND !RightBracketsFound)
- {
- UseNormalBrackets = TRUE;
- }
- ELSE IF (BracketsFound AND RightBracketsFound)
- {
- IF (OpeningBracketPosition < OpeningRightBracketPosition AND ClosingBracketPosition < ClosingRightBracketPosition)
- {
- UseNormalBrackets = TRUE;
- }
- ELSE
- {
- UseNormalBrackets = FALSE;
- }
- }
- IF (BracketsFound OR RightBracketsFound)
- {
- STATIC std::wstring Parameters = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC SIZE_T Start = 0U;
- STATIC SIZE_T Finish = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = L"";
- IF (UseNormalBrackets)
- {
- Start = (SIZE_T)OpeningBracketPosition + 1U;
- Finish = (SIZE_T)ClosingBracketPosition;
- }
- ELSE
- {
- Start = (SIZE_T)OpeningRightBracketPosition + 1U;
- Finish = (SIZE_T)ClosingRightBracketPosition;
- }
- FOR (Iterator = Start; Iterator < Finish; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == (WCHAR)L'{')
- {
- Parameters += (WCHAR)L'{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L'}')
- {
- Parameters += (WCHAR)L'}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L',')
- {
- Parameters += (WCHAR)L'@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PWCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- PCHAR GetParametersDefinition(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC BOOL UseNormalBrackets = FALSE;
- STATIC BOOL RightBracketsFound = FALSE;
- STATIC BOOL BracketsFound = FALSE;
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- STATIC INT OpeningRightBracketPosition = 0U;
- STATIC INT ClosingRightBracketPosition = 0U;
- UseNormalBrackets = FALSE;
- RightBracketsFound = FALSE;
- BracketsFound = FALSE;
- IF (strchr(Buffer, '[') AND strchr(Buffer, ']'))
- {
- OpeningRightBracketPosition = GetFirstCharacterPositionInString(Buffer, '[');
- ClosingRightBracketPosition = GetFirstCharacterPositionInString(Buffer, ']');
- RightBracketsFound = TRUE;
- }
- IF (strchr(Buffer, '(') AND strchr(Buffer, ')'))
- {
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, '(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, ')');
- BracketsFound = TRUE;
- }
- IF (RightBracketsFound AND !BracketsFound)
- {
- UseNormalBrackets = FALSE;
- }
- ELSE IF (BracketsFound AND !RightBracketsFound)
- {
- UseNormalBrackets = TRUE;
- }
- ELSE IF (BracketsFound AND RightBracketsFound)
- {
- IF (OpeningBracketPosition < OpeningRightBracketPosition AND ClosingBracketPosition < ClosingRightBracketPosition)
- {
- UseNormalBrackets = TRUE;
- }
- ELSE
- {
- UseNormalBrackets = FALSE;
- }
- }
- IF (BracketsFound OR RightBracketsFound)
- {
- STATIC std::string Parameters = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC SIZE_T Start = 0U;
- STATIC SIZE_T Finish = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = "";
- IF (UseNormalBrackets)
- {
- Start = (SIZE_T)OpeningBracketPosition + 1U;
- Finish = (SIZE_T)ClosingBracketPosition;
- }
- ELSE
- {
- Start = (SIZE_T)OpeningRightBracketPosition + 1U;
- Finish = (SIZE_T)ClosingRightBracketPosition;
- }
- FOR (Iterator = Start; Iterator < Finish; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == '{')
- {
- Parameters += '{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == '}')
- {
- Parameters += '}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == ',')
- {
- Parameters += '@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- PCHAR GetParameters(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, '(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, ')');
- IF (OpeningBracketPosition != -1 AND ClosingBracketPosition != -1)
- {
- STATIC std::string Parameters = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = "";
- FOR (Iterator = (SIZE_T)OpeningBracketPosition + 1U; Iterator < (SIZE_T)ClosingBracketPosition; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == '{')
- {
- Parameters += '{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == '}')
- {
- Parameters += '}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == ',')
- {
- Parameters += '@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- PWCHAR GetParameters(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L')');
- IF (OpeningBracketPosition != -1 AND ClosingBracketPosition != -1)
- {
- STATIC std::wstring Parameters = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = L"";
- FOR (Iterator = (SIZE_T)OpeningBracketPosition + 1U; Iterator < (SIZE_T)ClosingBracketPosition; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == (WCHAR)L'{')
- {
- Parameters += (WCHAR)L'{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L'}')
- {
- Parameters += (WCHAR)L'}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L',')
- {
- Parameters += (WCHAR)L'@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PWCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- PCHAR GetParametersStock(PCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, '(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, ')');
- IF (OpeningBracketPosition != -1 AND ClosingBracketPosition != -1)
- {
- STATIC std::string Parameters = "";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = "";
- FOR (Iterator = (SIZE_T)OpeningBracketPosition + 1U; Iterator < (SIZE_T)ClosingBracketPosition; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == '"' OR Buffer[Iterator] == '\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == '{')
- {
- Parameters += '{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == '}')
- {
- Parameters += '}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == ',')
- {
- Parameters += '@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- PWCHAR GetParametersStock(PWCHAR Buffer)
- {
- IF (Buffer)
- {
- STATIC INT OpeningBracketPosition = 0U;
- STATIC INT ClosingBracketPosition = 0U;
- OpeningBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L'(');
- ClosingBracketPosition = GetFirstCharacterPositionInString(Buffer, (WCHAR)L')');
- IF (OpeningBracketPosition != -1 AND ClosingBracketPosition != -1)
- {
- STATIC std::wstring Parameters = L"";
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL Quotes = FALSE;
- STATIC BOOL BigBrackets = FALSE;
- Quotes = FALSE;
- BigBrackets = FALSE;
- Parameters = L"";
- FOR (Iterator = (SIZE_T)OpeningBracketPosition + 1U; Iterator < (SIZE_T)ClosingBracketPosition; Iterator++)
- {
- IF (!Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = TRUE;
- CONTINUE;
- }
- ELSE IF (Quotes AND (Buffer[Iterator] == (WCHAR)L'"' OR Buffer[Iterator] == (WCHAR)L'\''))
- {
- Quotes = FALSE;
- CONTINUE;
- }
- ELSE IF (!BigBrackets AND Buffer[Iterator] == (WCHAR)L'{')
- {
- Parameters += (WCHAR)L'{';
- BigBrackets = TRUE;
- CONTINUE;
- }
- ELSE IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L'}')
- {
- Parameters += (WCHAR)L'}';
- BigBrackets = FALSE;
- CONTINUE;
- }
- ELSE IF (!Quotes)
- {
- IF (BigBrackets AND Buffer[Iterator] == (WCHAR)L',')
- {
- Parameters += (WCHAR)L'@';
- CONTINUE;
- }
- Parameters += Buffer[Iterator];
- }
- }
- IF (Parameters.length())
- {
- RETURN Trim((PWCHAR)Parameters.c_str());
- }
- }
- }
- RETURN NULL;
- }
- VOID PushNativeToFile(FILE * File, PCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PCHAR Function = NULL;
- Function = StripFirstWordFromBuffer(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PCHAR FunctionName = NULL;
- FunctionName = GetFunctionName(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PCHAR Parameters = NULL;
- STATIC PCHAR Context = NULL;
- STATIC PCHAR FunctionType = NULL;
- IF (strchr(FunctionName, ':'))
- {
- FunctionType = Trim(strtok_s(FunctionName, ":", &Context));
- FunctionName = strtok_s(NULL, ":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fprintf_s(File, "\t\t<KeyWord name=\"%s\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log("Processing '%s' native, named '%s'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log("Processing native, named '%s'...", FunctionName);
- }
- Natives++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParameters(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::string GoodParameter = "";
- STATIC PCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = strtok_s(Parameters, ",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = "";
- FOR (Iterator = 0U; Iterator < strlen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == '@')
- {
- GoodParameter += ',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fprintf_s(File, "\t\t\t\t<Param name=\"%s\" />\n", GoodParameter.c_str());
- Parameter = strtok_s(NULL, ",", &Context);
- }
- }
- fprintf_s(File, "\t\t\t</Overload>\n");
- fprintf_s(File, "\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushNativeToFile(FILE * File, PWCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PWCHAR Function = NULL;
- Function = StripFirstWordFromBuffer(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PWCHAR FunctionName = NULL;
- FunctionName = GetFunctionName(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PWCHAR Parameters = NULL;
- STATIC PWCHAR Context = NULL;
- STATIC PWCHAR FunctionType = NULL;
- IF (wcschr(FunctionName, (WCHAR)L':'))
- {
- FunctionType = Trim(wcstok_s(FunctionName, L":", &Context));
- FunctionName = wcstok_s(NULL, L":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fwprintf_s(File, L"\t\t<KeyWord name=\"%ls\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log(L"Processing '%ls' native, named '%ls'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log(L"Processing native, named '%ls'...", FunctionName);
- }
- Natives++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParameters(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::wstring GoodParameter = L"";
- STATIC PWCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = wcstok_s(Parameters, L",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == (WCHAR)L'@')
- {
- GoodParameter += (WCHAR)L',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fwprintf_s(File, L"\t\t\t\t<Param name=\"%ls\" />\n", GoodParameter.c_str());
- Parameter = wcstok_s(NULL, L",", &Context);
- }
- }
- fwprintf_s(File, L"\t\t\t</Overload>\n");
- fwprintf_s(File, L"\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushForwardToFile(FILE * File, PCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PCHAR Function = NULL;
- Function = StripFirstWordFromBuffer(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PCHAR FunctionName = NULL;
- FunctionName = GetFunctionName(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PCHAR Parameters = NULL;
- STATIC PCHAR Context = NULL;
- STATIC PCHAR FunctionType = NULL;
- IF (strchr(FunctionName, ':'))
- {
- FunctionType = Trim(strtok_s(FunctionName, ":", &Context));
- FunctionName = strtok_s(NULL, ":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fprintf_s(File, "\t\t<KeyWord name=\"%s\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log("Processing '%s' forward, named '%s'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log("Processing forward, named '%s'...", FunctionName);
- }
- Forwards++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParameters(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::string GoodParameter = "";
- STATIC PCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = strtok_s(Parameters, ",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = "";
- FOR (Iterator = 0U; Iterator < strlen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == '@')
- {
- GoodParameter += ',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fprintf_s(File, "\t\t\t\t<Param name=\"%s\" />\n", GoodParameter.c_str());
- Parameter = strtok_s(NULL, ",", &Context);
- }
- }
- fprintf_s(File, "\t\t\t</Overload>\n");
- fprintf_s(File, "\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushForwardToFile(FILE * File, PWCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PWCHAR Function = NULL;
- Function = StripFirstWordFromBuffer(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PWCHAR FunctionName = NULL;
- FunctionName = GetFunctionName(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PWCHAR Parameters = NULL;
- STATIC PWCHAR Context = NULL;
- STATIC PWCHAR FunctionType = NULL;
- IF (wcschr(FunctionName, (WCHAR)L':'))
- {
- FunctionType = Trim(wcstok_s(FunctionName, L":", &Context));
- FunctionName = wcstok_s(NULL, L":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fwprintf_s(File, L"\t\t<KeyWord name=\"%ls\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log(L"Processing '%ls' forward, named '%ls'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log(L"Processing forward, named '%ls'...", FunctionName);
- }
- Forwards++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParameters(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::wstring GoodParameter = L"";
- STATIC PWCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = wcstok_s(Parameters, L",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == (WCHAR)L'@')
- {
- GoodParameter += (WCHAR)L',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fwprintf_s(File, L"\t\t\t\t<Param name=\"%ls\" />\n", GoodParameter.c_str());
- Parameter = wcstok_s(NULL, L",", &Context);
- }
- }
- fwprintf_s(File, L"\t\t\t</Overload>\n");
- fwprintf_s(File, L"\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushStockToFile(FILE * File, PCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PCHAR Function = NULL;
- Function = StripFirstWordFromBufferStock(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PCHAR FunctionName = NULL;
- FunctionName = GetFunctionNameStock(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PCHAR Parameters = NULL;
- STATIC PCHAR Context = NULL;
- STATIC PCHAR FunctionType = NULL;
- IF (strchr(FunctionName, ':'))
- {
- FunctionType = Trim(strtok_s(FunctionName, ":", &Context));
- FunctionName = strtok_s(NULL, ":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fprintf_s(File, "\t\t<KeyWord name=\"%s\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log("Processing '%s' stock, named '%s'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log("Processing stock, named '%s'...", FunctionName);
- }
- Stocks++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParametersStock(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::string GoodParameter = "";
- STATIC PCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = strtok_s(Parameters, ",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = "";
- FOR (Iterator = 0U; Iterator < strlen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == '@')
- {
- GoodParameter += ',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fprintf_s(File, "\t\t\t\t<Param name=\"%s\" />\n", GoodParameter.c_str());
- Parameter = strtok_s(NULL, ",", &Context);
- }
- }
- fprintf_s(File, "\t\t\t</Overload>\n");
- fprintf_s(File, "\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushStockToFile(FILE * File, PWCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PWCHAR Function = NULL;
- Function = StripFirstWordFromBufferStock(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PWCHAR FunctionName = NULL;
- FunctionName = GetFunctionNameStock(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PWCHAR Parameters = NULL;
- STATIC PWCHAR Context = NULL;
- STATIC PWCHAR FunctionType = NULL;
- IF (wcschr(FunctionName, (WCHAR)L':'))
- {
- FunctionType = Trim(wcstok_s(FunctionName, L":", &Context));
- FunctionName = wcstok_s(NULL, L":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fwprintf_s(File, L"\t\t<KeyWord name=\"%ls\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log(L"Processing '%ls' stock, named '%ls'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log(L"Processing stock, named '%ls'...", FunctionName);
- }
- Stocks++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParametersStock(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::wstring GoodParameter = L"";
- STATIC PWCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = wcstok_s(Parameters, L",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == (WCHAR)L'@')
- {
- GoodParameter += (WCHAR)L',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fwprintf_s(File, L"\t\t\t\t<Param name=\"%ls\" />\n", GoodParameter.c_str());
- Parameter = wcstok_s(NULL, L",", &Context);
- }
- }
- fwprintf_s(File, L"\t\t\t</Overload>\n");
- fwprintf_s(File, L"\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushDefinitionToFile(FILE * File, PWCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PWCHAR Function = NULL;
- Function = StripFirstWordFromBufferDefinition(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PWCHAR FunctionName = NULL;
- FunctionName = GetFunctionNameDefinition(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PWCHAR Parameters = NULL;
- STATIC PWCHAR Context = NULL;
- STATIC PWCHAR FunctionType = NULL;
- IF (wcschr(FunctionName, (WCHAR)L':'))
- {
- FunctionType = Trim(wcstok_s(FunctionName, L":", &Context));
- FunctionName = wcstok_s(NULL, L":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fwprintf_s(File, L"\t\t<KeyWord name=\"%ls\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log(L"Processing '%ls' definition, named '%ls'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log(L"Processing definition, named '%ls'...", FunctionName);
- }
- Definitions++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParametersDefinition(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::wstring GoodParameter = L"";
- STATIC PWCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = wcstok_s(Parameters, L",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = L"";
- FOR (Iterator = 0U; Iterator < wcslen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == '@')
- {
- GoodParameter += ',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fwprintf_s(File, L"\t\t\t\t<Param name=\"%ls\" />\n", GoodParameter.c_str());
- Parameter = wcstok_s(NULL, L",", &Context);
- }
- }
- fwprintf_s(File, L"\t\t\t</Overload>\n");
- fwprintf_s(File, L"\t\t</KeyWord>\n");
- }
- }
- }
- }
- VOID PushDefinitionToFile(FILE * File, PCHAR Buffer)
- {
- IF (File AND Buffer)
- {
- STATIC PCHAR Function = NULL;
- Function = StripFirstWordFromBufferDefinition(Buffer);
- IF (Function AND Function[0U])
- {
- STATIC PCHAR FunctionName = NULL;
- FunctionName = GetFunctionNameDefinition(Function);
- IF (FunctionName AND FunctionName[0U])
- {
- STATIC PCHAR Parameters = NULL;
- STATIC PCHAR Context = NULL;
- STATIC PCHAR FunctionType = NULL;
- IF (strchr(FunctionName, ':'))
- {
- FunctionType = Trim(strtok_s(FunctionName, ":", &Context));
- FunctionName = strtok_s(NULL, ":", &Context);
- }
- ELSE
- {
- FunctionType = NULL;
- }
- fprintf_s(File, "\t\t<KeyWord name=\"%s\" func=\"yes\">\n", FunctionName);
- IF (FunctionType)
- {
- Hattrick::Log("Processing '%s' definition, named '%s'...", FunctionType, FunctionName);
- }
- ELSE
- {
- Hattrick::Log("Processing definition, named '%s'...", FunctionName);
- }
- Definitions++;
- IF (FunctionType)
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"%s:\" >\n", FunctionType);
- }
- ELSE
- {
- fprintf_s(File, "\t\t\t<Overload retVal=\"\" >\n");
- }
- Parameters = GetParametersDefinition(Function);
- IF (Parameters AND Parameters[0U])
- {
- STATIC std::string GoodParameter = "";
- STATIC PCHAR Parameter = NULL;
- STATIC SIZE_T Iterator = 0U;
- Parameter = strtok_s(Parameters, ",", &Context);
- WHILE (Parameter)
- {
- Parameter = Trim(Parameter);
- GoodParameter = "";
- FOR (Iterator = 0U; Iterator < strlen(Parameter); Iterator++)
- {
- IF (Parameter[Iterator] == '@')
- {
- GoodParameter += ',';
- CONTINUE;
- }
- GoodParameter += Parameter[Iterator];
- }
- fprintf_s(File, "\t\t\t\t<Param name=\"%s\" />\n", GoodParameter.c_str());
- Parameter = strtok_s(NULL, ",", &Context);
- }
- }
- fprintf_s(File, "\t\t\t</Overload>\n");
- fprintf_s(File, "\t\t</KeyWord>\n");
- }
- }
- }
- }
- };
- VOID FilesEnumeration(PWCHAR File, LPARAM Flag)
- {
- STATIC WCHAR FileName[256U] = { (WCHAR)L'\0' };
- STATIC FILE * Handle = NULL;
- Hattrick::StringAppend(FileName, SIZEOF(FileName), L"include\\");
- Hattrick::StringAppend(FileName, SIZEOF(FileName), File);
- _wfopen_s(&Handle, FileName, L"r");
- Hattrick::Log(L"Opening '%ls' file...", File);
- IF (Handle)
- {
- STATIC CHAR Buffer[2048U] = { '\0' };
- STATIC PCHAR CleanBuffer = NULL;
- STATIC SIZE_T Iterator = 0U;
- STATIC BOOL CommentStarted = FALSE;
- Hattrick::Log(L"Opened '%ls' file...", File);
- WHILE (!feof(Handle))
- {
- Buffer[0U] = '\0';
- fgets(Buffer, SIZEOF(Buffer), Handle);
- CleanBuffer = Hattrick::Trim(Buffer);
- IF (CleanBuffer AND CleanBuffer[0U])
- {
- IF (strstr(CleanBuffer, "/*") AND !strstr(CleanBuffer, "*/"))
- {
- CommentStarted = TRUE;
- CONTINUE;
- }
- ELSE IF (strstr(CleanBuffer, "*/"))
- {
- CommentStarted = FALSE;
- }
- IF (CommentStarted)
- {
- CONTINUE;
- }
- ELSE IF (_strnicmp(CleanBuffer, "native", 6U) == 0U)
- {
- Hattrick::PushNativeToFile(Hattrick::Output, CleanBuffer);
- }
- ELSE IF (_strnicmp(CleanBuffer, "forward", 7U) == 0U)
- {
- Hattrick::PushForwardToFile(Hattrick::Output, CleanBuffer);
- }
- ELSE IF (_strnicmp(CleanBuffer, "stock", 5U) == 0U AND !strstr(CleanBuffer, "operator"))
- {
- Hattrick::PushStockToFile(Hattrick::Output, CleanBuffer);
- }
- ELSE IF (_strnicmp(CleanBuffer, "define", 6U) == 0U)
- {
- Hattrick::PushDefinitionToFile(Hattrick::Output, CleanBuffer);
- }
- ELSE IF (isalpha(CleanBuffer[0U]) OR isdigit(CleanBuffer[0U]) OR CleanBuffer[0U] == '_')
- {
- FOR (Iterator = 0U; Iterator < 16U; Iterator++)
- {
- IF (strncmp(&CleanBuffer[Iterator], "FUNC", 4U) == 0U)
- {
- Hattrick::PushStockToFile(Hattrick::Output, CleanBuffer);
- BREAK;
- }
- }
- }
- }
- }
- fclose(Handle);
- Hattrick::Log(L"File '%ls' has been closed...", File);
- }
- ELSE
- {
- Hattrick::Log(L"File '%ls' could not be opened...");
- }
- FileName[0U] = (WCHAR)L'\0';
- }
- BOOL WINAPI WindowsEnumeration(HWND Window, LPARAM Parameter)
- {
- IF (Window)
- {
- STATIC WCHAR Title[1024U] = { (WCHAR)L'\0' };
- GetWindowTextW(Window, Title, SIZEOF(Title) / SIZEOF(WCHAR));
- IF (Title[0U] AND wcsstr(Title, L"AMXX Natives' Parser for Notepad++.exe") AND !wcsstr(Title, L"Visual Studio"))
- {
- Hattrick::Log(L"Found '%ls' window, hiding...", Title);
- SetWindowPos(Window, NULL, 200U, 200U, 200U, 200U, SWP_HIDEWINDOW | SWP_ASYNCWINDOWPOS);
- }
- }
- RETURN TRUE;
- }
- INT main(VOID)
- {
- STATIC WCHAR Directory[1024U] = { (WCHAR)L'\0' };
- _wunlink(L"journal.log");
- Hattrick::OpenJournal(TRUE);
- Hattrick::Log(L"Starting program...");
- Hattrick::Log(L"Opening journal...");
- Hattrick::Log(L"Enumerating windows to hide program's window...");
- EnumWindows(WindowsEnumeration, NULL);
- Hattrick::Log(L"Finished enumerating windows...");
- Hattrick::Log(L"Getting current directory...");
- GetModuleFileNameW(NULL, Directory, SIZEOF(Directory) / SIZEOF(WCHAR));
- Hattrick::Log(L"Truncating current directory by the last '%ls' character...", L"\\");
- Hattrick::StringTruncateRight(Directory, (WCHAR)L'\\');
- Hattrick::Log(L"Appending '%ls' string to the current directory...", L"\\include");
- Hattrick::StringAppend(Directory, SIZEOF(Directory), L"\\include");
- Hattrick::Log(L"Checking for '%ls' directory...", Directory);
- IF (!Hattrick::IsFolder(Directory))
- {
- Hattrick::Log(L"Creating '%ls' directory...", Directory);
- _wmkdir(Directory);
- Hattrick::Log(L"Exiting with 'EXIT_FAILURE' code...");
- Hattrick::Log(L"Closing journal...");
- Hattrick::CloseJournal();
- RETURN EXIT_FAILURE;
- }
- Hattrick::Log(L"Folder '%ls' is alright...", Directory);
- fopen_s(&Hattrick::Output, "sma.xml", "w+");
- Hattrick::Log(L"Opening 'sma.xml' file...");
- IF (Hattrick::Output)
- {
- Hattrick::Log(L"File 'sma.xml' has been opened...");
- Hattrick::Log(L"Writing basics to 'sma.xml' file...");
- Hattrick::StringAppend(Directory, SIZEOF(Directory), L"\\*");
- fprintf_s(Hattrick::Output, "<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>\n");
- fprintf_s(Hattrick::Output, "<NotepadPlus>\n");
- fprintf_s(Hattrick::Output, "\t<AutoComplete language=\"SMA\">\n");
- fprintf_s(Hattrick::Output, "\t\t<Environment ignoreCase=\"no\" startFunc=\"(\" stopFunc=\")\" paramSeparator=\", \" terminal=\"; \" additionalWordChar=\"\"/>\n");
- Hattrick::Log(L"Enumerating all 'INC' files from folder...");
- Hattrick::EnumerateFiles(NULL, Directory, L"INC", FilesEnumeration);
- fprintf_s(Hattrick::Output, "\t</AutoComplete>\n");
- fprintf_s(Hattrick::Output, "</NotepadPlus>");
- Hattrick::Log(L"Got %d natives...", Hattrick::Natives);
- Hattrick::Log(L"Got %d stocks...", Hattrick::Stocks);
- Hattrick::Log(L"Got %d forwards...", Hattrick::Forwards);
- Hattrick::Log(L"Got %d definitions...", Hattrick::Definitions);
- fclose(Hattrick::Output);
- Hattrick::Log(L"File 'sma.xml' has been closed...");
- _wunlink(L"C:\\Program Files\\Notepad++\\plugins\\APIs\\sma.xml");
- _wunlink(L"C:\\Program Files (x86)\\Notepad++\\plugins\\APIs\\sma.xml");
- _wunlink(L"D:\\Program Files\\Notepad++\\plugins\\APIs\\sma.xml");
- _wunlink(L"D:\\Program Files (x86)\\Notepad++\\plugins\\APIs\\sma.xml");
- Hattrick::Log(L"Tried to erase existing 'sma.xml' file to Notepad++'s location...");
- CopyFileA("sma.xml", "C:\\Program Files\\Notepad++\\plugins\\APIs\\sma.xml", FALSE);
- CopyFileA("sma.xml", "C:\\Program Files (x86)\\Notepad++\\plugins\\APIs\\sma.xml", FALSE);
- CopyFileA("sma.xml", "D:\\Program Files\\Notepad++\\plugins\\APIs\\sma.xml", FALSE);
- CopyFileA("sma.xml", "D:\\Program Files (x86)\\Notepad++\\plugins\\APIs\\sma.xml", FALSE);
- Hattrick::Log(L"Tried to transfer 'sma.xml' file to the Notepad++'s location...");
- Hattrick::Log(L"Exiting with 'EXIT_SUCCESS' code...");
- Hattrick::Log(L"Closing journal...");
- Hattrick::CloseJournal();
- RETURN EXIT_SUCCESS;
- }
- Hattrick::Log(L"Failed to open 'sma.xml' file...");
- Hattrick::Log(L"Exiting with 'EXIT_FAILURE' code...");
- Hattrick::CloseJournal();
- RETURN EXIT_FAILURE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement