mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Convert custom HeadSpin integer types to standard types from stdint.h
This commit is contained in:
@ -63,7 +63,7 @@ namespace Crypt {
|
||||
//============================================================================
|
||||
class KeyBase {
|
||||
public:
|
||||
virtual void Codec (bool encrypt, ARRAY(byte) * dest, unsigned sourceBytes, const void * sourceData) = 0;
|
||||
virtual void Codec (bool encrypt, ARRAY(uint8_t) * dest, unsigned sourceBytes, const void * sourceData) = 0;
|
||||
virtual unsigned GetBlockSize () const = 0;
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*
|
||||
***/
|
||||
|
||||
// hardcoded byte ordering -- Intel only
|
||||
// hardcoded uint8_t ordering -- Intel only
|
||||
#ifdef _M_IX86
|
||||
|
||||
const unsigned kHostClassALoopbackAddr = 0x7f000001; // 127.0.0.1
|
||||
@ -136,17 +136,17 @@ static int NetAddressNodeSortValueHostOrder (NetAddressNode addr) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static NetAddressNode NodeFromString (const wchar * string[]) {
|
||||
static NetAddressNode NodeFromString (const wchar_t * string[]) {
|
||||
// skip leading whitespace
|
||||
const wchar * str = *string;
|
||||
const wchar_t * str = *string;
|
||||
while (iswspace(*str))
|
||||
++str;
|
||||
|
||||
// This function handles partial ip addresses (61.33)
|
||||
// as well as full dotted quads. The address can be
|
||||
// terminated by whitespace or ':' as well as '\0'
|
||||
byte data[4];
|
||||
* (dword *) data = 0;
|
||||
uint8_t data[4];
|
||||
* (uint32_t *) data = 0;
|
||||
for (unsigned i = sizeof(data); i--; ) {
|
||||
if (!iswdigit(*str))
|
||||
return (unsigned)-1;
|
||||
@ -154,12 +154,12 @@ static NetAddressNode NodeFromString (const wchar * string[]) {
|
||||
unsigned value = StrToUnsigned(str, &str, 10);
|
||||
if (value >= 256)
|
||||
return (unsigned)-1;
|
||||
data[i] = (byte) value;
|
||||
data[i] = (uint8_t) value;
|
||||
|
||||
if (!*str || (*str == ':') || iswspace(*str))
|
||||
break;
|
||||
|
||||
static const wchar s_separator[] = L"\0...";
|
||||
static const wchar_t s_separator[] = L"\0...";
|
||||
if (*str++ != s_separator[i])
|
||||
return (unsigned)-1;
|
||||
}
|
||||
@ -202,13 +202,13 @@ unsigned NetAddressHash (const NetAddress & addr) {
|
||||
//===========================================================================
|
||||
void NetAddressToString (
|
||||
const NetAddress & addr,
|
||||
wchar * str,
|
||||
wchar_t * str,
|
||||
unsigned chars,
|
||||
ENetAddressFormat format
|
||||
) {
|
||||
ASSERT(str);
|
||||
|
||||
static const wchar * s_fmts[] = {
|
||||
static const wchar_t * s_fmts[] = {
|
||||
L"%S", // kNetAddressFormatNodeNumber
|
||||
L"%S:%u", // kNetAddressFormatAll
|
||||
};
|
||||
@ -224,7 +224,7 @@ void NetAddressToString (
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool NetAddressFromString (NetAddress * addr, const wchar str[], unsigned defaultPort) {
|
||||
bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defaultPort) {
|
||||
ASSERT(addr);
|
||||
ASSERT(str);
|
||||
|
||||
@ -241,7 +241,7 @@ bool NetAddressFromString (NetAddress * addr, const wchar str[], unsigned defaul
|
||||
|
||||
sockaddr_in * inetaddr = (sockaddr_in *) addr;
|
||||
inetaddr->sin_family = AF_INET;
|
||||
inetaddr->sin_port = htons((word) defaultPort);
|
||||
inetaddr->sin_port = htons((uint16_t) defaultPort);
|
||||
inetaddr->sin_addr.S_un.S_addr = htonl(node);
|
||||
// inetaddr->sin_zero already zeroed
|
||||
|
||||
@ -264,7 +264,7 @@ void NetAddressSetPort (
|
||||
unsigned port,
|
||||
NetAddress * addr
|
||||
) {
|
||||
((sockaddr_in *) addr)->sin_port = htons((word) port);
|
||||
((sockaddr_in *) addr)->sin_port = htons((uint16_t) port);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
@ -282,13 +282,13 @@ void NetAddressFromNode (
|
||||
sockaddr_in * inetaddr = (sockaddr_in *) addr;
|
||||
inetaddr->sin_family = AF_INET;
|
||||
inetaddr->sin_addr.S_un.S_addr = htonl(node);
|
||||
inetaddr->sin_port = htons((word) port);
|
||||
inetaddr->sin_port = htons((uint16_t) port);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void NetAddressNodeToString (
|
||||
NetAddressNode node,
|
||||
wchar * str,
|
||||
wchar_t * str,
|
||||
unsigned chars
|
||||
) {
|
||||
in_addr addr;
|
||||
@ -298,8 +298,8 @@ void NetAddressNodeToString (
|
||||
|
||||
//===========================================================================
|
||||
NetAddressNode NetAddressNodeFromString (
|
||||
const wchar string[],
|
||||
const wchar * endPtr[]
|
||||
const wchar_t string[],
|
||||
const wchar_t * endPtr[]
|
||||
) {
|
||||
if (!endPtr)
|
||||
endPtr = &string;
|
||||
@ -341,12 +341,12 @@ unsigned NetAddressGetLocal (
|
||||
host = gethostbyname(host->h_name);
|
||||
if (!host)
|
||||
break;
|
||||
if (host->h_length != sizeof(dword))
|
||||
if (host->h_length != sizeof(uint32_t))
|
||||
break;
|
||||
|
||||
// Count total number of addresses
|
||||
unsigned found = 0;
|
||||
const dword ** addr = (const dword **) host->h_addr_list;
|
||||
const uint32_t ** addr = (const uint32_t **) host->h_addr_list;
|
||||
for (; *addr; ++addr)
|
||||
++found;
|
||||
if (!found)
|
||||
@ -360,7 +360,7 @@ unsigned NetAddressGetLocal (
|
||||
dst = addresses;
|
||||
|
||||
// Fill address buffer
|
||||
const dword * src = * (const dword **) host->h_addr_list;
|
||||
const uint32_t * src = * (const uint32_t **) host->h_addr_list;
|
||||
for (unsigned index = 0; index < found; ++index)
|
||||
dst[index] = ntohl(src[index]);
|
||||
|
||||
|
@ -62,12 +62,12 @@ static MEMORYSTATUSEX s_memstatus;
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
const wchar * AppGetCommandLine () {
|
||||
const wchar_t * AppGetCommandLine () {
|
||||
return GetCommandLineW();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void MachineGetName (wchar *computerName, unsigned int length) {
|
||||
void MachineGetName (wchar_t *computerName, unsigned int length) {
|
||||
DWORD len = length;
|
||||
GetComputerNameW(computerName, &len);
|
||||
}
|
||||
@ -84,7 +84,7 @@ void MemoryGetStatus (MemoryStatus * status) {
|
||||
mem.dwLength = sizeof(mem);
|
||||
GlobalMemoryStatusEx(&mem);
|
||||
|
||||
const qword BYTES_PER_MB = 1024 * 1024;
|
||||
const uint64_t BYTES_PER_MB = 1024 * 1024;
|
||||
status->totalPhysMB = unsigned(mem.ullTotalPhys / BYTES_PER_MB);
|
||||
status->availPhysMB = unsigned(mem.ullAvailPhys / BYTES_PER_MB);
|
||||
status->totalPageFileMB = unsigned(mem.ullTotalPageFile / BYTES_PER_MB);
|
||||
@ -101,7 +101,7 @@ void DiskGetStatus (ARRAY(DiskStatus) * disks) {
|
||||
if (!length || length > 2048)
|
||||
break;
|
||||
|
||||
wchar * buffer = ALLOCA(wchar, length + 1);
|
||||
wchar_t * buffer = ALLOCA(wchar_t, length + 1);
|
||||
if (!GetLogicalDriveStringsW(length, buffer))
|
||||
break;
|
||||
|
||||
@ -118,7 +118,7 @@ void DiskGetStatus (ARRAY(DiskStatus) * disks) {
|
||||
DiskStatus status;
|
||||
StrCopy(status.name, buffer, arrsize(status.name));
|
||||
|
||||
const qword BYTES_PER_MB = 1024 * 1024;
|
||||
const uint64_t BYTES_PER_MB = 1024 * 1024;
|
||||
status.totalSpaceMB = unsigned(totalBytes.QuadPart / BYTES_PER_MB);
|
||||
status.freeSpaceMB = unsigned(freeBytes.QuadPart / BYTES_PER_MB);
|
||||
|
||||
@ -131,13 +131,13 @@ void DiskGetStatus (ARRAY(DiskStatus) * disks) {
|
||||
//============================================================================
|
||||
// Loosely taken from MS's cpuid code sample
|
||||
void CpuGetInfo (
|
||||
word * cpuCaps,
|
||||
dword * cpuVendor,
|
||||
word * cpuSignature
|
||||
uint16_t * cpuCaps,
|
||||
uint32_t * cpuVendor,
|
||||
uint16_t * cpuSignature
|
||||
) {
|
||||
dword signature = 0;
|
||||
dword extended = 0;
|
||||
dword flags[2] = { 0, 0 };
|
||||
uint32_t signature = 0;
|
||||
uint32_t extended = 0;
|
||||
uint32_t flags[2] = { 0, 0 };
|
||||
cpuVendor[0] = 0;
|
||||
|
||||
_asm {
|
||||
@ -189,9 +189,9 @@ DONE:
|
||||
|
||||
// Decode capability flags
|
||||
const static struct CpuCap {
|
||||
word cpuFlag;
|
||||
byte field;
|
||||
byte bit;
|
||||
uint16_t cpuFlag;
|
||||
uint8_t field;
|
||||
uint8_t bit;
|
||||
} s_caps[] = {
|
||||
// feature field bit
|
||||
// ------- ----- ---
|
||||
@ -212,7 +212,7 @@ DONE:
|
||||
}
|
||||
|
||||
// Copy signature
|
||||
*cpuSignature = word(signature & 0xfff);
|
||||
*cpuSignature = uint16_t(signature & 0xfff);
|
||||
|
||||
// If this is an AMD CPU, check for 3DNow support
|
||||
const char * vendorAmd = "AuthenticAMD";
|
||||
|
@ -60,22 +60,22 @@ COMPILER_ASSERT(MAX_PATH >= _MAX_PATH);
|
||||
|
||||
|
||||
//===========================================================================
|
||||
static inline bool IsSlash (wchar c) {
|
||||
static inline bool IsSlash (wchar_t c) {
|
||||
return (c == L'\\') || (c == L'/');
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static inline wchar ConvertSlash (wchar c) {
|
||||
static inline wchar_t ConvertSlash (wchar_t c) {
|
||||
return c != L'/' ? c : L'\\';
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static inline bool IsUncPath (const wchar path[]) {
|
||||
static inline bool IsUncPath (const wchar_t path[]) {
|
||||
return IsSlash(path[0]) && IsSlash(path[1]);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static const wchar * SkipUncDrive (const wchar path[]) {
|
||||
static const wchar_t * SkipUncDrive (const wchar_t path[]) {
|
||||
// UNC drive: "//server/share"
|
||||
|
||||
// skip over leading "//"
|
||||
@ -102,7 +102,7 @@ static const wchar * SkipUncDrive (const wchar path[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static wchar * PathSkipOverSeparator (wchar * path) {
|
||||
static wchar_t * PathSkipOverSeparator (wchar_t * path) {
|
||||
for (; *path; ++path) {
|
||||
if (IsSlash(*path))
|
||||
return path + 1;
|
||||
@ -113,18 +113,18 @@ static wchar * PathSkipOverSeparator (wchar * path) {
|
||||
|
||||
//===========================================================================
|
||||
static unsigned CommonPrefixLength (
|
||||
const wchar src1[],
|
||||
const wchar src2[]
|
||||
const wchar_t src1[],
|
||||
const wchar_t src2[]
|
||||
) {
|
||||
ASSERT(src1);
|
||||
ASSERT(src2);
|
||||
|
||||
wchar const * const base = src1;
|
||||
const wchar * common = nil;
|
||||
wchar_t const * const base = src1;
|
||||
const wchar_t * common = nil;
|
||||
for (;;) {
|
||||
// Are the next components equal in length?
|
||||
const wchar * next1 = PathSkipOverSeparator(const_cast<wchar *>(src1));
|
||||
const wchar * next2 = PathSkipOverSeparator(const_cast<wchar *>(src2));
|
||||
const wchar_t * next1 = PathSkipOverSeparator(const_cast<wchar_t *>(src1));
|
||||
const wchar_t * next2 = PathSkipOverSeparator(const_cast<wchar_t *>(src2));
|
||||
const int componentLen = next1 - src1;
|
||||
if (componentLen != (next2 - src2))
|
||||
break;
|
||||
@ -158,7 +158,7 @@ static unsigned CommonPrefixLength (
|
||||
//===========================================================================
|
||||
static void GetProgramName (
|
||||
void * instance,
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -179,7 +179,7 @@ static void GetProgramName (
|
||||
|
||||
//===========================================================================
|
||||
void PathGetModuleName (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
GetProgramName(ModuleGetInstance(), dst, dstChars);
|
||||
@ -187,7 +187,7 @@ void PathGetModuleName (
|
||||
|
||||
//===========================================================================
|
||||
void PathGetProgramName (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
GetProgramName(nil, dst, dstChars);
|
||||
@ -195,8 +195,8 @@ void PathGetProgramName (
|
||||
|
||||
//===========================================================================
|
||||
bool PathFromString (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -205,7 +205,7 @@ bool PathFromString (
|
||||
|
||||
for (;;) {
|
||||
// enable src and dst to be the same buffer
|
||||
wchar temp[MAX_PATH];
|
||||
wchar_t temp[MAX_PATH];
|
||||
if (dst == src) {
|
||||
StrCopy(temp, src, arrsize(temp));
|
||||
src = temp;
|
||||
@ -228,16 +228,16 @@ bool PathFromString (
|
||||
|
||||
//===========================================================================
|
||||
bool PathFromString (
|
||||
wchar * dst, // ASSERT(dst);
|
||||
const wchar src[], // ASSERT(src);
|
||||
wchar_t * dst, // ASSERT(dst);
|
||||
const wchar_t src[], // ASSERT(src);
|
||||
unsigned dstChars, // ASSERT(dstChars);
|
||||
const wchar baseDir[] // ASSERT(baseDir);
|
||||
const wchar_t baseDir[] // ASSERT(baseDir);
|
||||
) {
|
||||
ASSERT(baseDir);
|
||||
ASSERT(dstChars);
|
||||
|
||||
// Save current directory
|
||||
wchar curr[MAX_PATH];
|
||||
wchar_t curr[MAX_PATH];
|
||||
PathGetCurrentDirectory(curr, arrsize(curr));
|
||||
|
||||
// Perform string conversion from specified directory
|
||||
@ -257,11 +257,11 @@ bool PathFromString (
|
||||
// but has been updated to support UNC paths and to avoid blasting off the end
|
||||
// of the buffers.
|
||||
void PathSplitPath (
|
||||
const wchar path[],
|
||||
wchar * drive,
|
||||
wchar * dir,
|
||||
wchar * fname,
|
||||
wchar * ext
|
||||
const wchar_t path[],
|
||||
wchar_t * drive,
|
||||
wchar_t * dir,
|
||||
wchar_t * fname,
|
||||
wchar_t * ext
|
||||
) {
|
||||
ASSERT(path);
|
||||
ASSERT(path != drive);
|
||||
@ -271,7 +271,7 @@ void PathSplitPath (
|
||||
|
||||
// check for UNC path
|
||||
if (IsUncPath(path)) {
|
||||
const wchar * pathStart = path;
|
||||
const wchar_t * pathStart = path;
|
||||
path = SkipUncDrive(path);
|
||||
|
||||
if (drive)
|
||||
@ -298,7 +298,7 @@ void PathSplitPath (
|
||||
// '\' path separator character. If none is found, there is no path.
|
||||
// We will also note the last '.' character found, if any, to aid in
|
||||
// handling the extension.
|
||||
const wchar *last_slash = nil, *last_dot = nil, *p = path;
|
||||
const wchar_t *last_slash = nil, *last_dot = nil, *p = path;
|
||||
for (; *p; p++) {
|
||||
if (IsSlash(*p))
|
||||
last_slash = p + 1; // point to one beyond for later copy
|
||||
@ -335,12 +335,12 @@ void PathSplitPath (
|
||||
|
||||
//===========================================================================
|
||||
void PathMakePath (
|
||||
wchar * path,
|
||||
wchar_t * path,
|
||||
unsigned chars,
|
||||
const wchar drive[],
|
||||
const wchar dir[],
|
||||
const wchar fname[],
|
||||
const wchar ext[]
|
||||
const wchar_t drive[],
|
||||
const wchar_t dir[],
|
||||
const wchar_t fname[],
|
||||
const wchar_t ext[]
|
||||
) {
|
||||
ASSERT(path);
|
||||
ASSERT(path != drive);
|
||||
@ -400,11 +400,11 @@ void PathMakePath (
|
||||
|
||||
//===========================================================================
|
||||
bool PathMakeRelative (
|
||||
wchar *dst,
|
||||
wchar_t *dst,
|
||||
unsigned fromFlags, // 0 or kPathFlagDirectory
|
||||
const wchar from[],
|
||||
const wchar_t from[],
|
||||
unsigned toFlags, // 0 or kPathFlagDirectory
|
||||
const wchar to[],
|
||||
const wchar_t to[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -417,26 +417,26 @@ bool PathMakeRelative (
|
||||
if (!prefixLength)
|
||||
return false;
|
||||
|
||||
wchar fromBuf[MAX_PATH];
|
||||
wchar_t fromBuf[MAX_PATH];
|
||||
if (fromFlags & kPathFlagDirectory)
|
||||
StrCopy(fromBuf, from, arrsize(fromBuf));
|
||||
else
|
||||
PathRemoveFilename(fromBuf, from, arrsize(fromBuf));
|
||||
|
||||
wchar toBuf[MAX_PATH];
|
||||
wchar_t toBuf[MAX_PATH];
|
||||
if (toFlags & kPathFlagDirectory)
|
||||
StrCopy(toBuf, to, arrsize(toBuf));
|
||||
else
|
||||
PathRemoveFilename(toBuf, to, arrsize(toBuf));
|
||||
|
||||
const wchar * curr = fromBuf + prefixLength;
|
||||
const wchar_t * curr = fromBuf + prefixLength;
|
||||
if (*curr) {
|
||||
// build ..\.. part of the path
|
||||
if (IsSlash(*curr))
|
||||
curr++; // skip slash
|
||||
|
||||
while (*curr) {
|
||||
curr = PathSkipOverSeparator(const_cast<wchar *>(curr));
|
||||
curr = PathSkipOverSeparator(const_cast<wchar_t *>(curr));
|
||||
StrPack(dst, *curr ? L"..\\" : L"..", dstChars);
|
||||
}
|
||||
}
|
||||
@ -458,7 +458,7 @@ bool PathMakeRelative (
|
||||
|
||||
//===========================================================================
|
||||
bool PathIsRelative (
|
||||
const wchar src[]
|
||||
const wchar_t src[]
|
||||
) {
|
||||
ASSERT(src);
|
||||
if (!src[0])
|
||||
@ -471,16 +471,16 @@ bool PathIsRelative (
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * PathFindFilename (
|
||||
const wchar path[]
|
||||
const wchar_t * PathFindFilename (
|
||||
const wchar_t path[]
|
||||
) {
|
||||
ASSERT(path);
|
||||
|
||||
if (IsUncPath(path))
|
||||
path = SkipUncDrive(path);
|
||||
|
||||
const wchar * last_slash = path;
|
||||
for (const wchar * p = path; *p; p++) {
|
||||
const wchar_t * last_slash = path;
|
||||
for (const wchar_t * p = path; *p; p++) {
|
||||
if ((*p == L'/') || (*p == L'\\') || (*p == L':'))
|
||||
last_slash = p + 1;
|
||||
}
|
||||
@ -489,13 +489,13 @@ const wchar * PathFindFilename (
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * PathFindExtension (
|
||||
const wchar path[]
|
||||
const wchar_t * PathFindExtension (
|
||||
const wchar_t path[]
|
||||
) {
|
||||
ASSERT(path);
|
||||
|
||||
const wchar * last_dot = 0;
|
||||
const wchar * p = PathFindFilename(path);
|
||||
const wchar_t * last_dot = 0;
|
||||
const wchar_t * p = PathFindFilename(path);
|
||||
for ( ; *p; p++) {
|
||||
if (*p == L'.')
|
||||
last_dot = p;
|
||||
@ -506,7 +506,7 @@ const wchar * PathFindExtension (
|
||||
|
||||
//===========================================================================
|
||||
void PathGetCurrentDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -521,7 +521,7 @@ void PathGetCurrentDirectory (
|
||||
|
||||
//===========================================================================
|
||||
void PathGetTempDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -534,13 +534,13 @@ void PathGetTempDirectory (
|
||||
|
||||
//============================================================================
|
||||
void PathGetUserDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar temp[MAX_PATH]; // GetSpecialFolder path requires a buffer of MAX_PATH size or larger
|
||||
wchar_t temp[MAX_PATH]; // GetSpecialFolder path requires a buffer of MAX_PATH size or larger
|
||||
if (SHGetSpecialFolderPathW(NULL, temp, CSIDL_LOCAL_APPDATA, TRUE) == FALSE)
|
||||
StrCopy(temp, L"C:\\", arrsize(temp));
|
||||
|
||||
@ -554,7 +554,7 @@ void PathGetUserDirectory (
|
||||
|
||||
//============================================================================
|
||||
void PathGetLogDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -567,7 +567,7 @@ void PathGetLogDirectory (
|
||||
|
||||
//============================================================================
|
||||
void PathGetInitDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -580,7 +580,7 @@ void PathGetInitDirectory (
|
||||
|
||||
//===========================================================================
|
||||
bool PathSetCurrentDirectory (
|
||||
const wchar path[]
|
||||
const wchar_t path[]
|
||||
) {
|
||||
ASSERT(path);
|
||||
return SetCurrentDirectoryW(path) != 0;
|
||||
@ -588,7 +588,7 @@ bool PathSetCurrentDirectory (
|
||||
|
||||
//===========================================================================
|
||||
void PathSetProgramDirectory () {
|
||||
wchar dir[MAX_PATH];
|
||||
wchar_t dir[MAX_PATH];
|
||||
PathGetProgramDirectory(dir, arrsize(dir));
|
||||
PathSetCurrentDirectory(dir);
|
||||
}
|
||||
@ -596,7 +596,7 @@ void PathSetProgramDirectory () {
|
||||
//===========================================================================
|
||||
void PathFindFiles (
|
||||
ARRAY(PathFind) * paths,
|
||||
const wchar fileSpec[],
|
||||
const wchar_t fileSpec[],
|
||||
unsigned pathFlags
|
||||
) {
|
||||
ASSERT(paths);
|
||||
@ -604,7 +604,7 @@ void PathFindFiles (
|
||||
|
||||
HANDLE find;
|
||||
WIN32_FIND_DATAW fd;
|
||||
wchar directory[MAX_PATH];
|
||||
wchar_t directory[MAX_PATH];
|
||||
PathRemoveFilename(directory, fileSpec, arrsize(directory));
|
||||
if (INVALID_HANDLE_VALUE == (find = FindFirstFileW(fileSpec, &fd))) {
|
||||
DWORD err = GetLastError();
|
||||
@ -648,8 +648,8 @@ void PathFindFiles (
|
||||
// add this one to the list of found files
|
||||
PathFind * pf = paths->New();
|
||||
pf->flags = fileFlags;
|
||||
pf->fileLength = ((qword) fd.nFileSizeHigh << 32) | fd.nFileSizeLow;
|
||||
pf->lastWriteTime = * (const qword *) &fd.ftLastWriteTime;
|
||||
pf->fileLength = ((uint64_t) fd.nFileSizeHigh << 32) | fd.nFileSizeLow;
|
||||
pf->lastWriteTime = * (const uint64_t *) &fd.ftLastWriteTime;
|
||||
PathAddFilename(pf->name, directory, fd.cFileName, arrsize(pf->name));
|
||||
} while (FindNextFileW(find, &fd));
|
||||
FindClose(find);
|
||||
@ -663,7 +663,7 @@ void PathFindFiles (
|
||||
return;
|
||||
}
|
||||
|
||||
wchar dirSpec[MAX_PATH];
|
||||
wchar_t dirSpec[MAX_PATH];
|
||||
PathAddFilename(dirSpec, directory, L"*", arrsize(dirSpec));
|
||||
if (INVALID_HANDLE_VALUE == (find = FindFirstFileW(dirSpec, &fd))) {
|
||||
DWORD err = GetLastError();
|
||||
@ -673,7 +673,7 @@ void PathFindFiles (
|
||||
}
|
||||
|
||||
// find all the directories in the current directory
|
||||
const wchar * spec = PathFindFilename(fileSpec);
|
||||
const wchar_t * spec = PathFindFilename(fileSpec);
|
||||
do {
|
||||
if (! (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
continue;
|
||||
@ -705,17 +705,17 @@ void PathFindFiles (
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
EPathCreateDirError PathCreateDirectory (const wchar path[], unsigned flags) {
|
||||
EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
|
||||
ASSERT(path);
|
||||
|
||||
// convert from relative path to full path
|
||||
wchar dir[MAX_PATH];
|
||||
wchar_t dir[MAX_PATH];
|
||||
if (!PathFromString(dir, path, arrsize(dir))) {
|
||||
return kPathCreateDirErrInvalidPath;
|
||||
}
|
||||
|
||||
// are we going to build the entire directory tree?
|
||||
wchar * dirEnd;
|
||||
wchar_t * dirEnd;
|
||||
if (flags & kPathCreateDirFlagEntireTree) {
|
||||
dirEnd = dir;
|
||||
|
||||
@ -732,7 +732,7 @@ EPathCreateDirError PathCreateDirectory (const wchar path[], unsigned flags) {
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
for (wchar saveChar = L' '; saveChar; *dirEnd++ = saveChar) {
|
||||
for (wchar_t saveChar = L' '; saveChar; *dirEnd++ = saveChar) {
|
||||
// find the end of the current directory string and terminate it
|
||||
dirEnd = PathSkipOverSeparator(dirEnd);
|
||||
saveChar = *dirEnd;
|
||||
@ -773,19 +773,19 @@ EPathCreateDirError PathCreateDirectory (const wchar path[], unsigned flags) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathDeleteDirectory (const wchar path[], unsigned flags) {
|
||||
void PathDeleteDirectory (const wchar_t path[], unsigned flags) {
|
||||
ASSERT(path);
|
||||
|
||||
// convert from relative path to full path
|
||||
wchar dir[MAX_PATH];
|
||||
wchar_t dir[MAX_PATH];
|
||||
if (!PathFromString(dir, path, arrsize(dir)))
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
// Important: in order to ensure that we don't delete NTFS
|
||||
// partition links, we must ensure that this is a directory!
|
||||
dword attributes = GetFileAttributesW(dir);
|
||||
if (attributes == (dword) -1)
|
||||
uint32_t attributes = GetFileAttributesW(dir);
|
||||
if (attributes == (uint32_t) -1)
|
||||
break;
|
||||
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
break;
|
||||
@ -798,7 +798,7 @@ void PathDeleteDirectory (const wchar path[], unsigned flags) {
|
||||
if ((flags & kPathCreateDirFlagEntireTree) == 0)
|
||||
break;
|
||||
|
||||
wchar * filename = PathFindFilename(dir);
|
||||
wchar_t * filename = PathFindFilename(dir);
|
||||
if (!filename)
|
||||
break;
|
||||
|
||||
@ -813,9 +813,9 @@ void PathDeleteDirectory (const wchar path[], unsigned flags) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool PathDoesFileExist (const wchar fileName[]) {
|
||||
dword attributes = GetFileAttributesW(fileName);
|
||||
if (attributes == (dword) -1)
|
||||
bool PathDoesFileExist (const wchar_t fileName[]) {
|
||||
uint32_t attributes = GetFileAttributesW(fileName);
|
||||
if (attributes == (uint32_t) -1)
|
||||
return false;
|
||||
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return false;
|
||||
@ -823,9 +823,9 @@ bool PathDoesFileExist (const wchar fileName[]) {
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool PathDoesDirectoryExist (const wchar directory[]) {
|
||||
dword attributes = GetFileAttributesW(directory);
|
||||
if (attributes == (dword) -1)
|
||||
bool PathDoesDirectoryExist (const wchar_t directory[]) {
|
||||
uint32_t attributes = GetFileAttributesW(directory);
|
||||
if (attributes == (uint32_t) -1)
|
||||
return false;
|
||||
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return true;
|
||||
@ -834,23 +834,23 @@ bool PathDoesDirectoryExist (const wchar directory[]) {
|
||||
|
||||
//===========================================================================
|
||||
bool PathDeleteFile (
|
||||
const wchar file[]
|
||||
const wchar_t file[]
|
||||
) {
|
||||
return DeleteFileW(file) != 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool PathMoveFile (
|
||||
const wchar src[],
|
||||
const wchar dst[]
|
||||
const wchar_t src[],
|
||||
const wchar_t dst[]
|
||||
) {
|
||||
return MoveFileW(src, dst) != 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool PathCopyFile (
|
||||
const wchar src[],
|
||||
const wchar dst[]
|
||||
const wchar_t src[],
|
||||
const wchar_t dst[]
|
||||
) {
|
||||
return CopyFileW(src, dst, FALSE) != 0;
|
||||
}
|
||||
|
@ -56,12 +56,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
***/
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToAnsi (char * dest, const wchar source[], unsigned destChars) {
|
||||
unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars) {
|
||||
return StrToAnsi(dest, source, destChars, CP_ACP);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToAnsi (char * dest, const wchar source[], unsigned destChars, unsigned codePage) {
|
||||
unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars, unsigned codePage) {
|
||||
ASSERT(destChars != (unsigned)-1);
|
||||
ASSERT(dest != nil);
|
||||
|
||||
@ -77,12 +77,12 @@ unsigned StrToAnsi (char * dest, const wchar source[], unsigned destChars, unsig
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToUnicode (wchar * dest, const char source[], unsigned destChars) {
|
||||
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars) {
|
||||
return StrToUnicode(dest, source, destChars, CP_ACP);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToUnicode (wchar * dest, const char source[], unsigned destChars, unsigned codePage) {
|
||||
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage) {
|
||||
ASSERT(destChars != (unsigned)-1);
|
||||
ASSERT(dest != nil);
|
||||
|
||||
|
@ -57,13 +57,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//============================================================================
|
||||
static void FormatTime (
|
||||
qword time,
|
||||
wchar const dateFmt[],
|
||||
wchar const timeFmt[],
|
||||
uint64_t time,
|
||||
wchar_t const dateFmt[],
|
||||
wchar_t const timeFmt[],
|
||||
unsigned chars,
|
||||
wchar * buffer
|
||||
wchar_t * buffer
|
||||
) {
|
||||
COMPILER_ASSERT(sizeof(FILETIME) == sizeof(qword));
|
||||
COMPILER_ASSERT(sizeof(FILETIME) == sizeof(uint64_t));
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
FileTimeToSystemTime((FILETIME *)&time, &sysTime);
|
||||
@ -108,13 +108,13 @@ static void FormatTime (
|
||||
|
||||
//===========================================================================
|
||||
void TimeGetDesc (
|
||||
qword time,
|
||||
uint64_t time,
|
||||
TimeDesc * desc
|
||||
) {
|
||||
ASSERT(desc);
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
COMPILER_ASSERT(sizeof(qword) == sizeof(FILETIME));
|
||||
COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
|
||||
FileTimeToSystemTime((FILETIME *) &time, &sysTime);
|
||||
|
||||
desc->year = sysTime.wYear;
|
||||
@ -127,17 +127,17 @@ void TimeGetDesc (
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
qword TimeGetTime () {
|
||||
qword time;
|
||||
COMPILER_ASSERT(sizeof(qword) == sizeof(FILETIME));
|
||||
uint64_t TimeGetTime () {
|
||||
uint64_t time;
|
||||
COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
|
||||
GetSystemTimeAsFileTime((FILETIME *) &time);
|
||||
return time;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
qword TimeGetLocalTime () {
|
||||
qword time;
|
||||
COMPILER_ASSERT(sizeof(qword) == sizeof(FILETIME));
|
||||
uint64_t TimeGetLocalTime () {
|
||||
uint64_t time;
|
||||
COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
|
||||
GetSystemTimeAsFileTime((FILETIME *) &time);
|
||||
FileTimeToLocalFileTime((FILETIME *) &time, (FILETIME *) &time);
|
||||
return time;
|
||||
@ -145,9 +145,9 @@ qword TimeGetLocalTime () {
|
||||
|
||||
//============================================================================
|
||||
void TimePrettyPrint (
|
||||
qword time,
|
||||
uint64_t time,
|
||||
unsigned chars,
|
||||
wchar * buffer
|
||||
wchar_t * buffer
|
||||
) {
|
||||
FormatTime(
|
||||
time,
|
||||
|
@ -134,9 +134,9 @@ void GuidClear (Uuid * uuid) {
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool GuidFromString (const wchar str[], Uuid * uuid) {
|
||||
bool GuidFromString (const wchar_t str[], Uuid * uuid) {
|
||||
ASSERT(uuid);
|
||||
COMPILER_ASSERT(sizeof(wchar) == sizeof(unsigned short));
|
||||
COMPILER_ASSERT(sizeof(wchar_t) == sizeof(unsigned short));
|
||||
return RPC_S_OK == UuidFromStringW((unsigned short *) str, (GUID *) uuid);
|
||||
}
|
||||
|
||||
@ -159,8 +159,8 @@ bool GuidIsNil (const Uuid & uuid) {
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
const wchar * GuidToString (const Uuid & uuid, wchar * dst, unsigned chars) {
|
||||
wchar * src;
|
||||
const wchar_t * GuidToString (const Uuid & uuid, wchar_t * dst, unsigned chars) {
|
||||
wchar_t * src;
|
||||
RPC_STATUS s;
|
||||
s = UuidToStringW( (GUID *) &uuid, (RPC_WSTR*)&src );
|
||||
if (RPC_S_OK == s)
|
||||
@ -173,7 +173,7 @@ const wchar * GuidToString (const Uuid & uuid, wchar * dst, unsigned chars) {
|
||||
|
||||
//============================================================================
|
||||
const char * GuidToString (const Uuid & uuid, char * dst, unsigned chars) {
|
||||
byte * src;
|
||||
uint8_t * src;
|
||||
RPC_STATUS s;
|
||||
s = UuidToStringA( (GUID *) &uuid, &src );
|
||||
if (RPC_S_OK == s)
|
||||
|
@ -59,7 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
|
||||
struct NetAddress {
|
||||
byte data[24];
|
||||
uint8_t data[24];
|
||||
};
|
||||
|
||||
typedef unsigned NetAddressNode;
|
||||
@ -116,7 +116,7 @@ inline bool NetAddressEqual (const NetAddress & a1, const NetAddress & a2) {
|
||||
|
||||
void NetAddressToString (
|
||||
const NetAddress & addr,
|
||||
wchar * str,
|
||||
wchar_t * str,
|
||||
unsigned chars,
|
||||
ENetAddressFormat format
|
||||
);
|
||||
@ -125,7 +125,7 @@ void NetAddressToString (
|
||||
// - names which require DNS lookup will cause the function to return false
|
||||
bool NetAddressFromString (
|
||||
NetAddress * addr,
|
||||
const wchar str[],
|
||||
const wchar_t str[],
|
||||
unsigned defaultPort
|
||||
);
|
||||
|
||||
@ -139,12 +139,12 @@ void NetAddressSetPort (
|
||||
|
||||
void NetAddressNodeToString (
|
||||
NetAddressNode node,
|
||||
wchar * str,
|
||||
wchar_t * str,
|
||||
unsigned chars
|
||||
);
|
||||
NetAddressNode NetAddressNodeFromString (
|
||||
const wchar string[],
|
||||
const wchar * endPtr[]
|
||||
const wchar_t string[],
|
||||
const wchar_t * endPtr[]
|
||||
);
|
||||
|
||||
NetAddressNode NetAddressGetNode (
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
inline void Clear ();
|
||||
inline unsigned Count () const;
|
||||
inline T * Detach ();
|
||||
inline void Fill (byte value);
|
||||
inline void Fill (uint8_t value);
|
||||
inline T * Ptr ();
|
||||
inline const T * Ptr () const;
|
||||
inline void Set (const T * source, unsigned count);
|
||||
@ -217,7 +217,7 @@ T * TBuffer<T>::Detach () {
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void TBuffer<T>::Fill (byte value) {
|
||||
void TBuffer<T>::Fill (uint8_t value) {
|
||||
if (m_data)
|
||||
MemSet(m_data, value, Bytes());
|
||||
}
|
||||
@ -265,7 +265,7 @@ void TBuffer<T>::Zero () {
|
||||
MemZero(m_data, Bytes());
|
||||
}
|
||||
|
||||
typedef TBuffer<byte> CBuffer;
|
||||
typedef TBuffer<uint8_t> CBuffer;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@ -420,7 +420,7 @@ public:
|
||||
inline void Clear ();
|
||||
inline unsigned Count () const;
|
||||
inline T * Detach ();
|
||||
inline void Fill (byte value);
|
||||
inline void Fill (uint8_t value);
|
||||
inline T * Ptr ();
|
||||
inline const T * Ptr () const;
|
||||
inline void Set (const T * source, unsigned count);
|
||||
@ -610,7 +610,7 @@ T * TFArray<T,C>::Detach () {
|
||||
|
||||
//===========================================================================
|
||||
template<class T, class C>
|
||||
void TFArray<T,C>::Fill (byte value) {
|
||||
void TFArray<T,C>::Fill (uint8_t value) {
|
||||
C::Destruct(m_data, m_count);
|
||||
MemSet(m_data, value, m_count * sizeof(T));
|
||||
C::Construct(m_data, m_count);
|
||||
@ -991,8 +991,8 @@ void TArray<T,C>::Trim () {
|
||||
template<class T, class C, class K, unsigned OFFSET>
|
||||
class TSortArray : public TArray<T,C> {
|
||||
private:
|
||||
inline static K & SortKey (T & rec) { return *(K *)((byte *)&rec + OFFSET); }
|
||||
inline static const K & SortKey (const T & rec) { return *(const K *)((const byte *)&rec + OFFSET); }
|
||||
inline static K & SortKey (T & rec) { return *(K *)((uint8_t *)&rec + OFFSET); }
|
||||
inline static const K & SortKey (const T & rec) { return *(const K *)((const uint8_t *)&rec + OFFSET); }
|
||||
|
||||
public:
|
||||
inline bool Delete (K sortKey);
|
||||
|
@ -99,7 +99,7 @@ static const char kFillchar = '=';
|
||||
//============================================================================
|
||||
unsigned Base64Encode (
|
||||
unsigned srcChars,
|
||||
const byte srcData[],
|
||||
const uint8_t srcData[],
|
||||
unsigned dstChars,
|
||||
char * dstData
|
||||
) {
|
||||
@ -108,7 +108,7 @@ unsigned Base64Encode (
|
||||
ASSERT(dstData);
|
||||
|
||||
const char * dstBase = dstData;
|
||||
const byte * srcTerm = srcData + srcChars;
|
||||
const uint8_t * srcTerm = srcData + srcChars;
|
||||
for (;;) switch (srcTerm - srcData) {
|
||||
case 0:
|
||||
*dstData++ = 0;
|
||||
@ -145,17 +145,17 @@ unsigned Base64Decode (
|
||||
unsigned srcChars,
|
||||
const char srcData[],
|
||||
unsigned dstChars,
|
||||
byte * dstData
|
||||
uint8_t * dstData
|
||||
) {
|
||||
ASSERT(srcData);
|
||||
ASSERT(dstChars >= Base64DecodeSize(srcChars, srcData));
|
||||
ASSERT(dstData);
|
||||
|
||||
const byte * dstBase = dstData;
|
||||
const uint8_t * dstBase = dstData;
|
||||
const char * srcTerm = srcData + srcChars;
|
||||
while (srcTerm - srcData >= 4) {
|
||||
|
||||
*dstData++ = (byte) (
|
||||
*dstData++ = (uint8_t) (
|
||||
(kDecode64[srcData[0]] << 2 & 0xfc)
|
||||
+(kDecode64[srcData[1]] >> 4 & 0x03)
|
||||
);
|
||||
@ -163,7 +163,7 @@ unsigned Base64Decode (
|
||||
if (kDecode64[srcData[2]] == kTerminator)
|
||||
break;
|
||||
|
||||
*dstData++ = (byte) (
|
||||
*dstData++ = (uint8_t) (
|
||||
(kDecode64[srcData[1]] << 4 & 0xf0)
|
||||
+(kDecode64[srcData[2]] >> 2 & 0x0f)
|
||||
);
|
||||
@ -171,7 +171,7 @@ unsigned Base64Decode (
|
||||
if (kDecode64[srcData[3]] == kTerminator)
|
||||
break;
|
||||
|
||||
*dstData++ = (byte) (
|
||||
*dstData++ = (uint8_t) (
|
||||
(kDecode64[srcData[2]] << 6 & 0xc0)
|
||||
+(kDecode64[srcData[3]])
|
||||
);
|
||||
|
@ -67,7 +67,7 @@ inline unsigned Base64EncodeSize (unsigned srcChars) {
|
||||
}
|
||||
unsigned Base64Encode (
|
||||
unsigned srcChars,
|
||||
const byte srcData[],
|
||||
const uint8_t srcData[],
|
||||
unsigned dstChars,
|
||||
char * dstData
|
||||
);
|
||||
@ -81,5 +81,5 @@ unsigned Base64Decode (
|
||||
unsigned srcChars,
|
||||
const char srcData[],
|
||||
unsigned dstChars,
|
||||
byte * dstData
|
||||
uint8_t * dstData
|
||||
);
|
||||
|
@ -102,7 +102,7 @@ BigNum::~BigNum ()
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
int BigNum::Compare (dword a) const {
|
||||
int BigNum::Compare (uint32_t a) const {
|
||||
// -1 if (this < a)
|
||||
// 0 if (this == a)
|
||||
// 1 if (this > a)
|
||||
@ -110,7 +110,7 @@ int BigNum::Compare (dword a) const {
|
||||
if (BN_is_word(&m_number, a))
|
||||
return 0;
|
||||
|
||||
// This returns 0xFFFFFFFFL if the number is bigger than one word, so
|
||||
// This returns 0xFFFFFFFFL if the number is bigger than one uint16_t, so
|
||||
// it doesn't need any size check
|
||||
if (BN_get_word(&m_number) < a)
|
||||
return -1;
|
||||
@ -153,9 +153,9 @@ void BigNum::Rand (unsigned bits, BigNum * seed)
|
||||
{
|
||||
// this = random number with bits or fewer bits
|
||||
|
||||
unsigned seedBytes;
|
||||
unsigned char * seedData = seed->GetData_BE(&seedBytes);
|
||||
RAND_seed(seedData, seedBytes);
|
||||
unsigned seedbytes;
|
||||
unsigned char * seedData = seed->GetData_BE(&seedbytes);
|
||||
RAND_seed(seedData, seedbytes);
|
||||
BN_rand(&m_number, bits, 0, 0);
|
||||
delete [] seedData;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
BigNum ();
|
||||
BigNum (const BigNum & a);
|
||||
BigNum (unsigned a);
|
||||
BigNum (unsigned bytes, const void * data, bool le=false);
|
||||
BigNum (unsigned bytess, const void * data, bool le=false);
|
||||
~BigNum ();
|
||||
|
||||
BigNum & operator= (const BigNum & a)
|
||||
@ -87,7 +87,7 @@ public:
|
||||
// Constant parameters need not be distinct from the destination or from
|
||||
// each other
|
||||
|
||||
void Add (const BigNum & a, dword b)
|
||||
void Add (const BigNum & a, uint32_t b)
|
||||
{
|
||||
// this = a + b
|
||||
BN_copy(&m_number, &a.m_number);
|
||||
@ -100,7 +100,7 @@ public:
|
||||
BN_add(&m_number, &a.m_number, &b.m_number);
|
||||
}
|
||||
|
||||
int Compare (dword a) const;
|
||||
int Compare (uint32_t a) const;
|
||||
int Compare (const BigNum & a) const
|
||||
{
|
||||
return BN_cmp(&m_number, &a.m_number);
|
||||
@ -110,11 +110,11 @@ public:
|
||||
return BN_is_zero(&m_number);
|
||||
}
|
||||
|
||||
void Div (const BigNum & a, dword b, dword * remainder)
|
||||
void Div (const BigNum & a, uint32_t b, uint32_t * remainder)
|
||||
{
|
||||
// this = a / b, remainder = a % b
|
||||
BN_copy(&m_number, &a.m_number);
|
||||
*remainder = (dword)BN_div_word(&m_number, b);
|
||||
*remainder = (uint32_t)BN_div_word(&m_number, b);
|
||||
}
|
||||
|
||||
void Div (const BigNum & a, const BigNum & b, BigNum * remainder)
|
||||
@ -125,15 +125,15 @@ public:
|
||||
&a.m_number, &b.m_number, GetContext());
|
||||
}
|
||||
|
||||
void FromData_BE (unsigned bytes, const void * data)
|
||||
void FromData_BE (unsigned bytess, const void * data)
|
||||
{
|
||||
BN_bin2bn((const unsigned char *)data, bytes, &m_number);
|
||||
BN_bin2bn((const unsigned char *)data, bytess, &m_number);
|
||||
}
|
||||
|
||||
void FromData_LE (unsigned bytes, const void * data);
|
||||
void FromData_LE (unsigned bytess, const void * data);
|
||||
|
||||
unsigned char * GetData_BE (unsigned * bytes) const;
|
||||
unsigned char * GetData_LE (unsigned * bytes) const;
|
||||
unsigned char * GetData_BE (unsigned * bytess) const;
|
||||
unsigned char * GetData_LE (unsigned * bytess) const;
|
||||
|
||||
bool IsPrime () const
|
||||
{
|
||||
@ -148,7 +148,7 @@ public:
|
||||
BN_div(nil, &m_number, &a.m_number, &b.m_number, GetContext());
|
||||
}
|
||||
|
||||
void Mul (const BigNum & a, dword b)
|
||||
void Mul (const BigNum & a, uint32_t b)
|
||||
{
|
||||
// this = a * b
|
||||
BN_copy(&m_number, &a.m_number);
|
||||
@ -161,7 +161,7 @@ public:
|
||||
BN_mul(&m_number, &a.m_number, &b.m_number, GetContext());
|
||||
}
|
||||
|
||||
void PowMod (dword a, const BigNum & b, const BigNum & c)
|
||||
void PowMod (uint32_t a, const BigNum & b, const BigNum & c)
|
||||
{
|
||||
// this = a ^ b % c
|
||||
PowMod(BigNum(a), b, c);
|
||||
@ -176,7 +176,7 @@ public:
|
||||
void Rand (const BigNum & a, BigNum * seed)
|
||||
{
|
||||
// this = random number less than a
|
||||
unsigned bits = BN_num_bits(&a.m_number);
|
||||
int bits = BN_num_bits(&a.m_number);
|
||||
do
|
||||
Rand(bits, seed);
|
||||
while (Compare(a) >= 0);
|
||||
@ -214,7 +214,7 @@ public:
|
||||
BN_rshift(&m_number, &a.m_number, b);
|
||||
}
|
||||
|
||||
void Sub (const BigNum & a, dword b)
|
||||
void Sub (const BigNum & a, uint32_t b)
|
||||
{
|
||||
// this = a - b
|
||||
BN_copy(&m_number, &a.m_number);
|
||||
|
@ -69,10 +69,10 @@ struct CmdArgData {
|
||||
bool boolVal;
|
||||
float floatVal;
|
||||
int intVal;
|
||||
const wchar * strVal;
|
||||
const wchar_t * strVal;
|
||||
unsigned unsignedVal;
|
||||
} val;
|
||||
wchar * buffer;
|
||||
wchar_t * buffer;
|
||||
unsigned nameChars;
|
||||
bool isSpecified;
|
||||
|
||||
@ -96,18 +96,18 @@ private:
|
||||
FARRAY(unsigned) m_unflaggedArray;
|
||||
|
||||
inline bool CheckFlag (unsigned flags, unsigned flag, unsigned mask) const;
|
||||
void Error (const CmdTokState * state, ECmdError errorCode, const wchar arg[], const wchar value[]) const;
|
||||
bool LookupFlagged (const wchar ** name, unsigned * lastIndex) const;
|
||||
bool ProcessValue (CmdTokState * state, unsigned index, const wchar str[]);
|
||||
void Error (const CmdTokState * state, ECmdError errorCode, const wchar_t arg[], const wchar_t value[]) const;
|
||||
bool LookupFlagged (const wchar_t ** name, unsigned * lastIndex) const;
|
||||
bool ProcessValue (CmdTokState * state, unsigned index, const wchar_t str[]);
|
||||
void SetDefaultValue (CmdArgData & arg);
|
||||
bool TokenizeFlags (CmdTokState * state, const wchar str[]);
|
||||
bool TokenizeFlags (CmdTokState * state, const wchar_t str[]);
|
||||
|
||||
public:
|
||||
CICmdParser (const CmdArgDef def[], unsigned defCount);
|
||||
bool CheckAllRequiredArguments (CmdTokState * state);
|
||||
const CmdArgData * FindArgById (unsigned id) const;
|
||||
const CmdArgData * FindArgByName (const wchar name[]) const;
|
||||
bool Tokenize (CmdTokState * state, const wchar str[]);
|
||||
const CmdArgData * FindArgByName (const wchar_t name[]) const;
|
||||
bool Tokenize (CmdTokState * state, const wchar_t str[]);
|
||||
|
||||
};
|
||||
|
||||
@ -185,14 +185,14 @@ CICmdParser::CICmdParser (const CmdArgDef def[], unsigned defCount) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CICmdParser::Error (const CmdTokState * state, ECmdError errorCode, const wchar arg[], const wchar value[]) const {
|
||||
void CICmdParser::Error (const CmdTokState * state, ECmdError errorCode, const wchar_t arg[], const wchar_t value[]) const {
|
||||
|
||||
// Compose the error text
|
||||
// (This text is only provided as a shortcut for trivial applications that
|
||||
// don't want to compose their own text. Normally, an application would
|
||||
// compose error text using its own localized strings.)
|
||||
unsigned chars = 256 + (arg ? StrLen(arg) : 0) + (value ? StrLen(value) : 0);
|
||||
wchar * buffer = (wchar *)ALLOC(chars * sizeof(wchar));
|
||||
wchar_t * buffer = (wchar_t *)ALLOC(chars * sizeof(wchar_t));
|
||||
switch (errorCode) {
|
||||
|
||||
case kCmdErrorInvalidArg:
|
||||
@ -245,7 +245,7 @@ const CmdArgData * CICmdParser::FindArgById (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const CmdArgData * CICmdParser::FindArgByName (const wchar name[]) const {
|
||||
const CmdArgData * CICmdParser::FindArgByName (const wchar_t name[]) const {
|
||||
|
||||
// Search for an argument with this name
|
||||
unsigned index = (unsigned)-1;
|
||||
@ -258,7 +258,7 @@ const CmdArgData * CICmdParser::FindArgByName (const wchar name[]) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CICmdParser::LookupFlagged (const wchar ** name, unsigned * lastIndex) const {
|
||||
bool CICmdParser::LookupFlagged (const wchar_t ** name, unsigned * lastIndex) const {
|
||||
unsigned argCount = m_argArray.Count();
|
||||
unsigned chars = StrLen(*name);
|
||||
unsigned bestIndex = (unsigned)-1;
|
||||
@ -313,7 +313,7 @@ bool CICmdParser::LookupFlagged (const wchar ** name, unsigned * lastIndex) cons
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CICmdParser::ProcessValue (CmdTokState * state, unsigned index, const wchar str[]) {
|
||||
bool CICmdParser::ProcessValue (CmdTokState * state, unsigned index, const wchar_t str[]) {
|
||||
CmdArgData & arg = m_argArray[index];
|
||||
arg.isSpecified = true;
|
||||
unsigned argType = arg.def.flags & kCmdMaskType;
|
||||
@ -332,7 +332,7 @@ bool CICmdParser::ProcessValue (CmdTokState * state, unsigned index, const wchar
|
||||
|
||||
case kCmdTypeFloat:
|
||||
{
|
||||
const wchar * endPtr;
|
||||
const wchar_t * endPtr;
|
||||
arg.val.floatVal = StrToFloat(str, &endPtr);
|
||||
if (*endPtr)
|
||||
Error(state, kCmdErrorInvalidValue, arg.def.name, str);
|
||||
@ -341,7 +341,7 @@ bool CICmdParser::ProcessValue (CmdTokState * state, unsigned index, const wchar
|
||||
|
||||
case kCmdTypeInt:
|
||||
{
|
||||
const wchar * endPtr;
|
||||
const wchar_t * endPtr;
|
||||
arg.val.intVal = StrToInt(str, &endPtr);
|
||||
if (*endPtr)
|
||||
Error(state, kCmdErrorInvalidValue, arg.def.name, str);
|
||||
@ -357,7 +357,7 @@ bool CICmdParser::ProcessValue (CmdTokState * state, unsigned index, const wchar
|
||||
|
||||
case kCmdTypeUnsigned:
|
||||
{
|
||||
const wchar * endPtr;
|
||||
const wchar_t * endPtr;
|
||||
arg.val.unsignedVal = StrToUnsigned(str, &endPtr, 10);
|
||||
if (*endPtr)
|
||||
Error(state, kCmdErrorInvalidValue, arg.def.name, str);
|
||||
@ -401,8 +401,8 @@ void CICmdParser::SetDefaultValue (CmdArgData & arg) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CICmdParser::Tokenize (CmdTokState * state, const wchar str[]) {
|
||||
wchar buffer[kMaxTokenLength];
|
||||
bool CICmdParser::Tokenize (CmdTokState * state, const wchar_t str[]) {
|
||||
wchar_t buffer[kMaxTokenLength];
|
||||
bool result = true;
|
||||
while (result && StrTokenize(&str, buffer, arrsize(buffer), WHITESPACE)) {
|
||||
|
||||
@ -438,10 +438,10 @@ bool CICmdParser::Tokenize (CmdTokState * state, const wchar str[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CICmdParser::TokenizeFlags (CmdTokState * state, const wchar str[]) {
|
||||
bool CICmdParser::TokenizeFlags (CmdTokState * state, const wchar_t str[]) {
|
||||
|
||||
// Process each separately flagged token within the string
|
||||
wchar buffer[kMaxTokenLength];
|
||||
wchar_t buffer[kMaxTokenLength];
|
||||
bool result = true;
|
||||
while (result && StrTokenize(&str, buffer, arrsize(buffer), ALL)) {
|
||||
if (!buffer[0])
|
||||
@ -449,7 +449,7 @@ bool CICmdParser::TokenizeFlags (CmdTokState * state, const wchar str[]) {
|
||||
|
||||
// Process each flag within the token
|
||||
unsigned lastIndex = (unsigned)-1;
|
||||
const wchar * bufferPtr = buffer;
|
||||
const wchar_t * bufferPtr = buffer;
|
||||
while (result) {
|
||||
|
||||
// Lookup the argument name
|
||||
@ -485,7 +485,7 @@ bool CICmdParser::TokenizeFlags (CmdTokState * state, const wchar str[]) {
|
||||
|
||||
// Check for a value provided with a toggle
|
||||
if (*str && StrChr(TOGGLES, *str)) {
|
||||
wchar tempStr[] = {*str, 0};
|
||||
wchar_t tempStr[] = {*str, 0};
|
||||
result = ProcessValue(state, lastIndex, tempStr);
|
||||
++str;
|
||||
continue;
|
||||
@ -548,7 +548,7 @@ bool CCmdParser::GetBool (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CCmdParser::GetBool (const wchar name[]) const {
|
||||
bool CCmdParser::GetBool (const wchar_t name[]) const {
|
||||
return fParser->FindArgByName(name)->val.boolVal;
|
||||
}
|
||||
|
||||
@ -558,7 +558,7 @@ float CCmdParser::GetFloat (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
float CCmdParser::GetFloat (const wchar name[]) const {
|
||||
float CCmdParser::GetFloat (const wchar_t name[]) const {
|
||||
return fParser->FindArgByName(name)->val.floatVal;
|
||||
}
|
||||
|
||||
@ -568,17 +568,17 @@ int CCmdParser::GetInt (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
int CCmdParser::GetInt (const wchar name[]) const {
|
||||
int CCmdParser::GetInt (const wchar_t name[]) const {
|
||||
return fParser->FindArgByName(name)->val.intVal;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * CCmdParser::GetString (unsigned id) const {
|
||||
const wchar_t * CCmdParser::GetString (unsigned id) const {
|
||||
return fParser->FindArgById(id)->val.strVal;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * CCmdParser::GetString (const wchar name[]) const {
|
||||
const wchar_t * CCmdParser::GetString (const wchar_t name[]) const {
|
||||
return fParser->FindArgByName(name)->val.strVal;
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ unsigned CCmdParser::GetUnsigned (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned CCmdParser::GetUnsigned (const wchar name[]) const {
|
||||
unsigned CCmdParser::GetUnsigned (const wchar_t name[]) const {
|
||||
return fParser->FindArgByName(name)->val.unsignedVal;
|
||||
}
|
||||
|
||||
@ -605,23 +605,23 @@ bool CCmdParser::IsSpecified (unsigned id) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CCmdParser::IsSpecified (const wchar name[]) const {
|
||||
bool CCmdParser::IsSpecified (const wchar_t name[]) const {
|
||||
if (const CmdArgData * data = fParser->FindArgByName(name))
|
||||
return data->isSpecified;
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CCmdParser::OnError (const wchar str[], ECmdError errorCode, const wchar arg[], const wchar value[]) {
|
||||
void CCmdParser::OnError (const wchar_t str[], ECmdError errorCode, const wchar_t arg[], const wchar_t value[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CCmdParser::OnExtra (const wchar str[]) {
|
||||
bool CCmdParser::OnExtra (const wchar_t str[]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CCmdParser::Parse (const wchar cmdLine[]) {
|
||||
bool CCmdParser::Parse (const wchar_t cmdLine[]) {
|
||||
// If no command line was passed, use the application's command line,
|
||||
// skipping past the program name
|
||||
if (!cmdLine) {
|
||||
@ -657,12 +657,12 @@ bool CCmdParser::Parse (const wchar cmdLine[]) {
|
||||
CCmdParserSimple::CCmdParserSimple (
|
||||
unsigned requiredStringCount,
|
||||
unsigned optionalStringCount,
|
||||
const wchar flaggedBoolNames[] // double null terminated if used
|
||||
const wchar_t flaggedBoolNames[] // double null terminated if used
|
||||
) {
|
||||
|
||||
// Count the number of flagged arguments
|
||||
unsigned flaggedBoolCount = 0;
|
||||
const wchar * curr;
|
||||
const wchar_t * curr;
|
||||
if (flaggedBoolNames)
|
||||
for (curr = flaggedBoolNames; *curr; curr += StrLen(curr) + 1)
|
||||
++flaggedBoolCount;
|
||||
|
@ -96,15 +96,15 @@ enum ECmdError {
|
||||
|
||||
struct CmdArgDef {
|
||||
unsigned flags;
|
||||
const wchar * name; // must be compile-time constant
|
||||
const wchar_t * name; // must be compile-time constant
|
||||
unsigned id;
|
||||
};
|
||||
|
||||
class CCmdParser {
|
||||
class CICmdParser * fParser;
|
||||
|
||||
static void DispatchError (const wchar str[], ECmdError errorCode, const wchar arg[], const wchar value[], void * param);
|
||||
static bool DispatchExtra (const wchar str[], void * param);
|
||||
static void DispatchError (const wchar_t str[], ECmdError errorCode, const wchar_t arg[], const wchar_t value[], void * param);
|
||||
static bool DispatchExtra (const wchar_t str[], void * param);
|
||||
|
||||
protected:
|
||||
CCmdParser ();
|
||||
@ -115,22 +115,22 @@ public:
|
||||
virtual ~CCmdParser ();
|
||||
|
||||
bool GetBool (unsigned id) const;
|
||||
bool GetBool (const wchar name[]) const;
|
||||
bool GetBool (const wchar_t name[]) const;
|
||||
float GetFloat (unsigned id) const;
|
||||
float GetFloat (const wchar name[]) const;
|
||||
float GetFloat (const wchar_t name[]) const;
|
||||
int GetInt (unsigned id) const;
|
||||
int GetInt (const wchar name[]) const;
|
||||
const wchar * GetString (unsigned id) const;
|
||||
const wchar * GetString (const wchar name[]) const;
|
||||
int GetInt (const wchar_t name[]) const;
|
||||
const wchar_t * GetString (unsigned id) const;
|
||||
const wchar_t * GetString (const wchar_t name[]) const;
|
||||
unsigned GetUnsigned (unsigned id) const;
|
||||
unsigned GetUnsigned (const wchar name[]) const;
|
||||
unsigned GetUnsigned (const wchar_t name[]) const;
|
||||
bool IsSpecified (unsigned id) const;
|
||||
bool IsSpecified (const wchar name[]) const;
|
||||
bool IsSpecified (const wchar_t name[]) const;
|
||||
|
||||
virtual void OnError (const wchar str[], ECmdError errorCode, const wchar arg[], const wchar value[]);
|
||||
virtual bool OnExtra (const wchar str[]);
|
||||
virtual void OnError (const wchar_t str[], ECmdError errorCode, const wchar_t arg[], const wchar_t value[]);
|
||||
virtual bool OnExtra (const wchar_t str[]);
|
||||
|
||||
bool Parse (const wchar cmdLine[] = nil);
|
||||
bool Parse (const wchar_t cmdLine[] = nil);
|
||||
};
|
||||
|
||||
class CCmdParserSimple : public CCmdParser {
|
||||
@ -138,7 +138,7 @@ public:
|
||||
CCmdParserSimple (
|
||||
unsigned requiredStringCount,
|
||||
unsigned optionalStringCount,
|
||||
const wchar flaggedBoolNames[] // double null terminated if used
|
||||
const wchar_t flaggedBoolNames[] // double null terminated if used
|
||||
);
|
||||
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ void Sha1Process (
|
||||
static void Rc4Codec (
|
||||
CryptKey * key,
|
||||
bool encrypt,
|
||||
ARRAY(byte) * dest,
|
||||
ARRAY(uint8_t) * dest,
|
||||
unsigned sourceBytes,
|
||||
const void * sourceData
|
||||
) {
|
||||
@ -166,7 +166,7 @@ static void Rc4Codec (
|
||||
void * data
|
||||
) {
|
||||
// RC4 uses the same algorithm to both encrypt and decrypt
|
||||
byte * temp = ALLOCA(byte, bytes);
|
||||
uint8_t * temp = ALLOCA(uint8_t, bytes);
|
||||
RC4((RC4_KEY *)key->handle, bytes, (const unsigned char *)data, temp);
|
||||
MemCopy(data, temp, bytes);
|
||||
}
|
||||
@ -278,7 +278,7 @@ unsigned CryptKeyGetBlockSize (
|
||||
//============================================================================
|
||||
void CryptCreateRandomSeed (
|
||||
unsigned bytes,
|
||||
byte * data
|
||||
uint8_t * data
|
||||
) {
|
||||
COMPILER_ASSERT(SHA_DIGEST_LENGTH == 20);
|
||||
|
||||
@ -289,16 +289,16 @@ void CryptCreateRandomSeed (
|
||||
unsigned cur = 0;
|
||||
unsigned end = max(bytes, sizeof(s_shaSeed));
|
||||
for (; cur < end; ++cur) {
|
||||
((byte *) &s_shaSeed)[seedIndex] ^= data[dataIndex];
|
||||
((uint8_t *) &s_shaSeed)[seedIndex] ^= data[dataIndex];
|
||||
if (++seedIndex >= sizeof(s_shaSeed))
|
||||
seedIndex = 0;
|
||||
if (++dataIndex >= bytes)
|
||||
dataIndex = 0;
|
||||
}
|
||||
|
||||
s_shaSeed.data[2] ^= (dword) &bytes;
|
||||
s_shaSeed.data[3] ^= (dword) bytes;
|
||||
s_shaSeed.data[4] ^= (dword) data;
|
||||
s_shaSeed.data[2] ^= (uint32_t) &bytes;
|
||||
s_shaSeed.data[3] ^= (uint32_t) bytes;
|
||||
s_shaSeed.data[4] ^= (uint32_t) data;
|
||||
}
|
||||
|
||||
// Hash seed
|
||||
@ -312,7 +312,7 @@ void CryptCreateRandomSeed (
|
||||
unsigned cur = 0;
|
||||
unsigned end = max(bytes, sizeof(digest));
|
||||
for (; cur < end; ++cur) {
|
||||
data[dst] ^= ((const byte *) &digest)[src];
|
||||
data[dst] ^= ((const uint8_t *) &digest)[src];
|
||||
if (++src >= sizeof(digest))
|
||||
src = 0;
|
||||
if (++dst >= bytes)
|
||||
@ -330,14 +330,14 @@ void CryptCreateRandomSeed (
|
||||
|
||||
//============================================================================
|
||||
void CryptHashPassword (
|
||||
const wchar username[],
|
||||
const wchar password[],
|
||||
const wchar_t username[],
|
||||
const wchar_t password[],
|
||||
ShaDigest * namePassHash
|
||||
) {
|
||||
unsigned passlen = StrLen(password);
|
||||
unsigned userlen = StrLen(username);
|
||||
|
||||
wchar * buffer = ALLOCA(wchar, passlen + userlen);
|
||||
wchar_t * buffer = ALLOCA(wchar_t, passlen + userlen);
|
||||
StrCopy(buffer, password, passlen);
|
||||
StrCopy(buffer + passlen, username, userlen);
|
||||
StrLower(buffer + passlen); // lowercase the username
|
||||
@ -359,8 +359,8 @@ void CryptHashPasswordChallenge (
|
||||
) {
|
||||
#include <pshpack1.h>
|
||||
struct {
|
||||
dword clientChallenge;
|
||||
dword serverChallenge;
|
||||
uint32_t clientChallenge;
|
||||
uint32_t serverChallenge;
|
||||
ShaDigest namePassHash;
|
||||
} buffer;
|
||||
#include <poppack.h>
|
||||
@ -393,7 +393,7 @@ void CryptCreateFastWeakChallenge (
|
||||
//============================================================================
|
||||
void CryptEncrypt (
|
||||
CryptKey * key,
|
||||
ARRAY(byte) * dest,
|
||||
ARRAY(uint8_t) * dest,
|
||||
unsigned sourceBytes,
|
||||
const void * sourceData
|
||||
) {
|
||||
@ -436,7 +436,7 @@ void CryptEncrypt (
|
||||
//============================================================================
|
||||
void CryptDecrypt (
|
||||
CryptKey * key,
|
||||
ARRAY(byte) * dest,
|
||||
ARRAY(uint8_t) * dest,
|
||||
unsigned sourceBytes,
|
||||
const void * sourceData
|
||||
) {
|
||||
|
@ -69,7 +69,7 @@ enum ECryptAlgorithm {
|
||||
};
|
||||
|
||||
struct ShaDigest {
|
||||
dword data[5];
|
||||
uint32_t data[5];
|
||||
};
|
||||
|
||||
|
||||
@ -116,8 +116,8 @@ void CryptKeyGenerate (
|
||||
unsigned keyBits, // used for algorithms with variable key strength
|
||||
unsigned randomBytes,
|
||||
const void * randomData,
|
||||
ARRAY(byte) * privateData,
|
||||
ARRAY(byte) * publicData // only for public key cryptography
|
||||
ARRAY(uint8_t) * privateData,
|
||||
ARRAY(uint8_t) * publicData // only for public key cryptography
|
||||
);
|
||||
|
||||
unsigned CryptKeyGetBlockSize (
|
||||
@ -126,12 +126,12 @@ unsigned CryptKeyGetBlockSize (
|
||||
|
||||
void CryptCreateRandomSeed (
|
||||
unsigned bytes,
|
||||
byte * data
|
||||
uint8_t * data
|
||||
);
|
||||
|
||||
void CryptHashPassword (
|
||||
const wchar username[],
|
||||
const wchar password[],
|
||||
const wchar_t username[],
|
||||
const wchar_t password[],
|
||||
ShaDigest * namePassHash
|
||||
);
|
||||
|
||||
@ -157,7 +157,7 @@ void CryptCreateFastWeakChallenge (
|
||||
|
||||
void CryptEncrypt (
|
||||
CryptKey * key,
|
||||
ARRAY(byte) * dest,
|
||||
ARRAY(uint8_t) * dest,
|
||||
unsigned sourceBytes,
|
||||
const void * sourceData
|
||||
);
|
||||
@ -170,7 +170,7 @@ void CryptEncrypt (
|
||||
|
||||
void CryptDecrypt (
|
||||
CryptKey * key,
|
||||
ARRAY(byte) * dest, // padded out to the algorithm's block size
|
||||
ARRAY(uint8_t) * dest, // padded out to the algorithm's block size
|
||||
unsigned sourceBytes,
|
||||
const void * sourceData
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
// These random values were generated by the radioactive decay based
|
||||
// random number generator at www.fourmilab.ch
|
||||
const dword CHashValue::s_hashTable[] = {
|
||||
const uint32_t CHashValue::s_hashTable[] = {
|
||||
0xe8fd2035, 0xaf1add63, 0x049fb872, 0xcf9bb8eb, 0xc30d2a72, 0x15efaec1, 0xd250c7d9, 0xaf3c60a8,
|
||||
0x17ae32ff, 0x4089cd9e, 0x91dd6936, 0x093f880d, 0x9608ae8f, 0x452c0e11, 0xb6840ffd, 0x3e36c913,
|
||||
0x393114fd, 0xa72556b2, 0x7c338fb7, 0x4e445027, 0x2864eace, 0x9b0a17d6, 0x108da74b, 0xf2c479c1,
|
||||
|
@ -107,14 +107,14 @@ class TBaseHashTable;
|
||||
|
||||
class CHashValue {
|
||||
private:
|
||||
static const dword s_hashTable[];
|
||||
static const uint32_t s_hashTable[];
|
||||
|
||||
dword m_result;
|
||||
uint32_t m_result;
|
||||
|
||||
inline void Construct () { m_result = 0x325d1eae; }
|
||||
|
||||
public:
|
||||
static dword LookupHashBits (unsigned value) { ASSERT(value < 0x100); return s_hashTable[value]; }
|
||||
static uint32_t LookupHashBits (unsigned value) { ASSERT(value < 0x100); return s_hashTable[value]; }
|
||||
|
||||
inline CHashValue () { Construct() ; }
|
||||
inline CHashValue (const CHashValue & source) { m_result = source.m_result; }
|
||||
@ -122,7 +122,7 @@ public:
|
||||
inline CHashValue & operator= (const CHashValue & source) { m_result = source.m_result; return *this; }
|
||||
inline bool operator== (const CHashValue & source) const { return (m_result == source.m_result); }
|
||||
|
||||
inline dword GetHash () const { return m_result; }
|
||||
inline uint32_t GetHash () const { return m_result; }
|
||||
|
||||
forceinline void Hash (const void * data, unsigned bytes);
|
||||
forceinline void Hash8 (unsigned data);
|
||||
@ -133,7 +133,7 @@ public:
|
||||
|
||||
//===========================================================================
|
||||
void CHashValue::Hash (const void * data, unsigned bytes) {
|
||||
for (const byte * curr = (const byte *)data, * term = curr + bytes; curr != term; ++curr)
|
||||
for (const uint8_t * curr = (const uint8_t *)data, * term = curr + bytes; curr != term; ++curr)
|
||||
Hash8(*curr);
|
||||
}
|
||||
|
||||
@ -359,13 +359,13 @@ unsigned & TBaseHashTable<T>::GetHash (T * object) {
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
const THashLink<T> & TBaseHashTable<T>::GetLink (const T * object) const {
|
||||
return *(const THashLink<T> *)((const byte *)object + m_linkOffset);
|
||||
return *(const THashLink<T> *)((const uint8_t *)object + m_linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
THashLink<T> & TBaseHashTable<T>::GetLink (T * object) {
|
||||
return *(THashLink<T> *)((byte *)object + m_linkOffset);
|
||||
return *(THashLink<T> *)((uint8_t *)object + m_linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -706,8 +706,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
typedef THashKeyStrPtr< wchar, THashKeyStrCmp<wchar> > CHashKeyStrPtr;
|
||||
typedef THashKeyStrPtr< wchar, THashKeyStrCmpI<wchar> > CHashKeyStrPtrI;
|
||||
typedef THashKeyStrPtr< wchar_t, THashKeyStrCmp<wchar_t> > CHashKeyStrPtr;
|
||||
typedef THashKeyStrPtr< wchar_t, THashKeyStrCmpI<wchar_t> > CHashKeyStrPtrI;
|
||||
typedef THashKeyStrPtr< char, THashKeyStrCmp<char> > CHashKeyStrPtrChar;
|
||||
typedef THashKeyStrPtr< char, THashKeyStrCmpI<char> > CHashKeyStrPtrCharI;
|
||||
|
||||
@ -738,7 +738,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
typedef THashKeyStr< wchar, THashKeyStrCmp<wchar> > CHashKeyStr;
|
||||
typedef THashKeyStr< wchar, THashKeyStrCmpI<wchar> > CHashKeyStrI;
|
||||
typedef THashKeyStr< wchar_t, THashKeyStrCmp<wchar_t> > CHashKeyStr;
|
||||
typedef THashKeyStr< wchar_t, THashKeyStrCmpI<wchar_t> > CHashKeyStrI;
|
||||
typedef THashKeyStr< char, THashKeyStrCmp<char> > CHashKeyStrChar;
|
||||
typedef THashKeyStr< char, THashKeyStrCmpI<char> > CHashKeyStrCharI;
|
||||
|
@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
***/
|
||||
|
||||
//===========================================================================
|
||||
void CBaseList::Link (CBaseList * list, byte * afterNode, byte * beforeNode, ELinkType linkType, byte * existingNode) {
|
||||
void CBaseList::Link (CBaseList * list, uint8_t * afterNode, uint8_t * beforeNode, ELinkType linkType, uint8_t * existingNode) {
|
||||
|
||||
// Verify that the two lists share a common link offset
|
||||
ASSERT(m_linkOffset != LINK_OFFSET_UNINIT);
|
||||
@ -76,8 +76,8 @@ void CBaseList::Link (CBaseList * list, byte * afterNode, byte * beforeNode, ELi
|
||||
ASSERT(firstLink != beforeLink);
|
||||
|
||||
// Store nodes for later use in linking
|
||||
byte * firstNode = afterLink->m_next;
|
||||
byte * lastNextNode = lastLink->m_next;
|
||||
uint8_t * firstNode = afterLink->m_next;
|
||||
uint8_t * lastNextNode = lastLink->m_next;
|
||||
ASSERT(firstNode);
|
||||
ASSERT(lastNextNode);
|
||||
|
||||
|
@ -100,25 +100,25 @@ class TList;
|
||||
class CBaseLink {
|
||||
friend class CBaseList;
|
||||
|
||||
inline static bool TermCheck (byte * ptr);
|
||||
inline static byte * TermMark (byte * ptr);
|
||||
inline static byte * TermUnmarkAlways (byte * ptr);
|
||||
inline static bool TermCheck (uint8_t * ptr);
|
||||
inline static uint8_t * TermMark (uint8_t * ptr);
|
||||
inline static uint8_t * TermUnmarkAlways (uint8_t * ptr);
|
||||
|
||||
protected:
|
||||
CBaseLink * volatile m_prevLink;
|
||||
byte * volatile m_next;
|
||||
uint8_t * volatile m_next;
|
||||
|
||||
inline int CalcLinkOffset () const;
|
||||
inline void InitializeLinks ();
|
||||
inline void InitializeLinksWithOffset (int linkOffset);
|
||||
inline void InsertAfter (byte * node, CBaseLink * prevLink, int linkOffset);
|
||||
inline void InsertBefore (byte * node, CBaseLink * nextLink);
|
||||
inline byte * Next () const;
|
||||
inline byte * NextIgnoreTerm () const;
|
||||
inline byte * NextUnchecked () const;
|
||||
inline void InsertAfter (uint8_t * node, CBaseLink * prevLink, int linkOffset);
|
||||
inline void InsertBefore (uint8_t * node, CBaseLink * nextLink);
|
||||
inline uint8_t * Next () const;
|
||||
inline uint8_t * NextIgnoreTerm () const;
|
||||
inline uint8_t * NextUnchecked () const;
|
||||
inline CBaseLink * NextLink () const;
|
||||
inline CBaseLink * NextLink (int linkOffset) const;
|
||||
inline byte * Prev () const;
|
||||
inline uint8_t * Prev () const;
|
||||
inline void UnlinkFromNeighbors ();
|
||||
|
||||
public:
|
||||
@ -160,24 +160,24 @@ CBaseLink & CBaseLink::operator= (const CBaseLink & source) {
|
||||
|
||||
//===========================================================================
|
||||
int CBaseLink::CalcLinkOffset () const {
|
||||
return (int)((byte *)this - m_prevLink->NextIgnoreTerm());
|
||||
return (int)((uint8_t *)this - m_prevLink->NextIgnoreTerm());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseLink::InitializeLinks () {
|
||||
ASSERT(!((unsigned_ptr)this & 3));
|
||||
ASSERT(!((uintptr_t)this & 3));
|
||||
m_prevLink = this;
|
||||
m_next = TermMark((byte *)this);
|
||||
m_next = TermMark((uint8_t *)this);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseLink::InitializeLinksWithOffset (int linkOffset) {
|
||||
m_prevLink = this;
|
||||
m_next = TermMark((byte *)this - linkOffset);
|
||||
m_next = TermMark((uint8_t *)this - linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseLink::InsertAfter (byte * node, CBaseLink * prevLink, int linkOffset) {
|
||||
void CBaseLink::InsertAfter (uint8_t * node, CBaseLink * prevLink, int linkOffset) {
|
||||
UnlinkFromNeighbors();
|
||||
m_prevLink = prevLink;
|
||||
m_next = prevLink->m_next;
|
||||
@ -186,7 +186,7 @@ void CBaseLink::InsertAfter (byte * node, CBaseLink * prevLink, int linkOffset)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseLink::InsertBefore (byte * node, CBaseLink * nextLink) {
|
||||
void CBaseLink::InsertBefore (uint8_t * node, CBaseLink * nextLink) {
|
||||
UnlinkFromNeighbors();
|
||||
m_prevLink = nextLink->m_prevLink;
|
||||
m_next = m_prevLink->m_next;
|
||||
@ -200,17 +200,17 @@ bool CBaseLink::IsLinked () const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::Next () const {
|
||||
uint8_t * CBaseLink::Next () const {
|
||||
return TermCheck(m_next) ? nil : m_next;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::NextIgnoreTerm () const {
|
||||
uint8_t * CBaseLink::NextIgnoreTerm () const {
|
||||
return TermUnmarkAlways(m_next);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::NextUnchecked () const {
|
||||
uint8_t * CBaseLink::NextUnchecked () const {
|
||||
return m_next;
|
||||
}
|
||||
|
||||
@ -226,27 +226,27 @@ CBaseLink * CBaseLink::NextLink (int linkOffset) const {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::Prev () const {
|
||||
uint8_t * CBaseLink::Prev () const {
|
||||
return m_prevLink->m_prevLink->Next();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CBaseLink::TermCheck (byte * ptr) {
|
||||
return (unsigned_ptr)ptr & 1;
|
||||
bool CBaseLink::TermCheck (uint8_t * ptr) {
|
||||
return (uintptr_t)ptr & 1;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::TermMark (byte * ptr) {
|
||||
uint8_t * CBaseLink::TermMark (uint8_t * ptr) {
|
||||
// Converts an unmarked pointer to a marked pointer
|
||||
ASSERT(!TermCheck(ptr));
|
||||
return (byte *)((unsigned_ptr)ptr + 1);
|
||||
return (uint8_t *)((uintptr_t)ptr + 1);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseLink::TermUnmarkAlways (byte * ptr) {
|
||||
uint8_t * CBaseLink::TermUnmarkAlways (uint8_t * ptr) {
|
||||
// Returns an unmarked pointer regardless of whether the source pointer
|
||||
// was marked on unmarked
|
||||
return (byte *)((unsigned_ptr)ptr & ~1);
|
||||
return (uint8_t *)((uintptr_t)ptr & ~1);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -333,16 +333,16 @@ private:
|
||||
CBaseLink m_terminator;
|
||||
|
||||
protected:
|
||||
inline CBaseLink * GetLink (const byte * node) const;
|
||||
inline byte * Head () const;
|
||||
inline bool IsLinked (const byte * node) const;
|
||||
inline void Link (byte * node, ELinkType linkType, byte * existingNode);
|
||||
void Link (CBaseList * list, byte * afterNode, byte * beforeNode, ELinkType linkType, byte * existingNode);
|
||||
inline byte * Next (const byte * node) const;
|
||||
inline byte * NextUnchecked (const byte * node) const;
|
||||
inline byte * Prev (byte * node) const;
|
||||
inline byte * Tail () const;
|
||||
inline void Unlink (byte * node);
|
||||
inline CBaseLink * GetLink (const uint8_t * node) const;
|
||||
inline uint8_t * Head () const;
|
||||
inline bool IsLinked (const uint8_t * node) const;
|
||||
inline void Link (uint8_t * node, ELinkType linkType, uint8_t * existingNode);
|
||||
void Link (CBaseList * list, uint8_t * afterNode, uint8_t * beforeNode, ELinkType linkType, uint8_t * existingNode);
|
||||
inline uint8_t * Next (const uint8_t * node) const;
|
||||
inline uint8_t * NextUnchecked (const uint8_t * node) const;
|
||||
inline uint8_t * Prev (uint8_t * node) const;
|
||||
inline uint8_t * Tail () const;
|
||||
inline void Unlink (uint8_t * node);
|
||||
|
||||
public:
|
||||
inline CBaseList ();
|
||||
@ -376,23 +376,23 @@ CBaseList & CBaseList::operator= (const CBaseList & source) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
CBaseLink * CBaseList::GetLink (const byte * node) const {
|
||||
CBaseLink * CBaseList::GetLink (const uint8_t * node) const {
|
||||
return (CBaseLink *)(node + m_linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseList::Head () const {
|
||||
uint8_t * CBaseList::Head () const {
|
||||
return m_terminator.Next();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool CBaseList::IsLinked (const byte * node) const {
|
||||
bool CBaseList::IsLinked (const uint8_t * node) const {
|
||||
ASSERT(node);
|
||||
return GetLink(node)->IsLinked();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseList::Link (byte * node, ELinkType linkType, byte * existingNode) {
|
||||
void CBaseList::Link (uint8_t * node, ELinkType linkType, uint8_t * existingNode) {
|
||||
ASSERT(node != existingNode);
|
||||
ASSERT(m_linkOffset != LINK_OFFSET_UNINIT);
|
||||
ASSERT((linkType == kListLinkAfter) || (linkType == kListLinkBefore));
|
||||
@ -403,19 +403,19 @@ void CBaseList::Link (byte * node, ELinkType linkType, byte * existingNode) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseList::Next (const byte * node) const {
|
||||
uint8_t * CBaseList::Next (const uint8_t * node) const {
|
||||
ASSERT(node);
|
||||
return GetLink(node)->Next();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseList::NextUnchecked (const byte * node) const {
|
||||
uint8_t * CBaseList::NextUnchecked (const uint8_t * node) const {
|
||||
ASSERT(node);
|
||||
return GetLink(node)->NextUnchecked();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseList::Prev (byte * node) const {
|
||||
uint8_t * CBaseList::Prev (uint8_t * node) const {
|
||||
ASSERT(node);
|
||||
return GetLink(node)->Prev();
|
||||
}
|
||||
@ -429,12 +429,12 @@ void CBaseList::SetLinkOffset (int linkOffset) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
byte * CBaseList::Tail () const {
|
||||
uint8_t * CBaseList::Tail () const {
|
||||
return m_terminator.Prev();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CBaseList::Unlink (byte * node) {
|
||||
void CBaseList::Unlink (uint8_t * node) {
|
||||
ASSERT(node);
|
||||
GetLink(node)->Unlink();
|
||||
}
|
||||
@ -503,49 +503,49 @@ const T * TList<T>::Head () const {
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
bool TList<T>::IsLinked (const T * node) const {
|
||||
return CBaseList::IsLinked((const byte *)node);
|
||||
return CBaseList::IsLinked((const uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void TList<T>::Link (T * node, ELinkType linkType, T * existingNode) {
|
||||
CBaseList::Link((byte *)node, linkType, (byte *)existingNode);
|
||||
CBaseList::Link((uint8_t *)node, linkType, (uint8_t *)existingNode);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void TList<T>::Link (TList<T> * list, ELinkType linkType, T * existingNode) {
|
||||
CBaseList::Link(list, nil, nil, linkType, (byte *)existingNode);
|
||||
CBaseList::Link(list, nil, nil, linkType, (uint8_t *)existingNode);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void TList<T>::Link (TList<T> * list, T * afterNode, T * beforeNode, ELinkType linkType, T * existingNode) {
|
||||
CBaseList::Link(list, (byte *)afterNode, (byte *)beforeNode, linkType, (byte *)existingNode);
|
||||
CBaseList::Link(list, (uint8_t *)afterNode, (uint8_t *)beforeNode, linkType, (uint8_t *)existingNode);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T * TList<T>::Next (const T * node) {
|
||||
return (T *)CBaseList::Next((byte *)node);
|
||||
return (T *)CBaseList::Next((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline const T * TList<T>::Next (const T * node) const {
|
||||
return (const T *)CBaseList::Next((byte *)node);
|
||||
return (const T *)CBaseList::Next((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T * TList<T>::NextUnchecked (const T * node) {
|
||||
return (T *)CBaseList::NextUnchecked((byte *)node);
|
||||
return (T *)CBaseList::NextUnchecked((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline const T * TList<T>::NextUnchecked (const T * node) const {
|
||||
return (const T *)CBaseList::NextUnchecked((byte *)node);
|
||||
return (const T *)CBaseList::NextUnchecked((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -576,13 +576,13 @@ inline T * TList<T>::NewZero (ELinkType linkType, T * existingNode, const char f
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T * TList<T>::Prev (const T * node) {
|
||||
return (T *)CBaseList::Prev((byte *)node);
|
||||
return (T *)CBaseList::Prev((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline const T * TList<T>::Prev (const T * node) const {
|
||||
return (const T *)CBaseList::Prev((byte *)node);
|
||||
return (const T *)CBaseList::Prev((uint8_t *)node);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -600,7 +600,7 @@ inline const T * TList<T>::Tail () const {
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline void TList<T>::Unlink (T * node) {
|
||||
CBaseList::Unlink((byte *)node);
|
||||
CBaseList::Unlink((uint8_t *)node);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,15 +58,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
//===========================================================================
|
||||
#ifndef _M_IX86
|
||||
|
||||
unsigned MathHighBitPos (dword val) {
|
||||
unsigned MathHighBitPos (uint32_t val) {
|
||||
ASSERT(val);
|
||||
double f = (double)val;
|
||||
return (*((dword *)&f + 1) >> 20) - 1023;
|
||||
return (*((uint32_t *)&f + 1) >> 20) - 1023;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
__declspec(naked) unsigned __fastcall MathHighBitPos (dword) {
|
||||
__declspec(naked) unsigned __fastcall MathHighBitPos (uint32_t) {
|
||||
__asm {
|
||||
bsr eax, ecx
|
||||
ret 0
|
||||
@ -78,16 +78,16 @@ __declspec(naked) unsigned __fastcall MathHighBitPos (dword) {
|
||||
//===========================================================================
|
||||
#ifndef _M_IX86
|
||||
|
||||
unsigned MathLowBitPos (dword val) {
|
||||
unsigned MathLowBitPos (uint32_t val) {
|
||||
val &= ~(val - 1); // clear all but the low bit
|
||||
ASSERT(val);
|
||||
double f = (double)val;
|
||||
return (*((dword *)&f + 1) >> 20) - 1023;
|
||||
return (*((uint32_t *)&f + 1) >> 20) - 1023;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
__declspec(naked) unsigned __fastcall MathLowBitPos (dword) {
|
||||
__declspec(naked) unsigned __fastcall MathLowBitPos (uint32_t) {
|
||||
__asm {
|
||||
bsf eax, ecx
|
||||
ret 0
|
||||
|
@ -70,11 +70,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*
|
||||
***/
|
||||
|
||||
unsigned MATHCALL MathLowBitPos (dword val);
|
||||
unsigned MATHCALL MathHighBitPos (dword val);
|
||||
unsigned MATHCALL MathLowBitPos (uint32_t val);
|
||||
unsigned MATHCALL MathHighBitPos (uint32_t val);
|
||||
|
||||
//===========================================================================
|
||||
inline unsigned MathBitCount (dword val) {
|
||||
inline unsigned MathBitCount (uint32_t val) {
|
||||
val = val - ((val >> 1) & 033333333333) - ((val >> 2) & 011111111111);
|
||||
val = ((val + (val >> 3)) & 030707070707);
|
||||
val = val + (val >> 6);
|
||||
@ -89,7 +89,7 @@ inline unsigned MathBitMaskCreate (unsigned count) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline dword MathHighBitValue (dword val) {
|
||||
inline uint32_t MathHighBitValue (uint32_t val) {
|
||||
return val ? 1 << MathHighBitPos(val) : 0;
|
||||
}
|
||||
|
||||
@ -111,6 +111,6 @@ inline unsigned MathNextMultiplePow2 (unsigned val, unsigned multiple) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline dword MathNextPow2 (dword val) {
|
||||
inline uint32_t MathNextPow2 (uint32_t val) {
|
||||
return MathIsPow2(val) ? val : 1 << (MathHighBitPos(val) + 1);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*
|
||||
***/
|
||||
|
||||
const wchar UNICODE_BOM = 0xfeff; // Unicode byte-order mark
|
||||
const wchar_t UNICODE_BOM = 0xfeff; // Unicode byte-order mark
|
||||
const char UTF8_BOM[] = "\xef\xbb\xbf";
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ void * ModuleGetInstance ();
|
||||
*
|
||||
***/
|
||||
|
||||
const wchar * AppGetCommandLine ();
|
||||
const wchar_t * AppGetCommandLine ();
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -85,7 +85,7 @@ const wchar * AppGetCommandLine ();
|
||||
* System info functions
|
||||
*
|
||||
***/
|
||||
void MachineGetName (wchar * computerName, unsigned length = 32);
|
||||
void MachineGetName (wchar_t * computerName, unsigned length = 32);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -97,7 +97,7 @@ void MachineGetName (wchar * computerName, unsigned length = 32);
|
||||
// used to dump the internal state of a module
|
||||
typedef void (CDECL * FStateDump)(
|
||||
void * param,
|
||||
const wchar fmt[],
|
||||
const wchar_t fmt[],
|
||||
...
|
||||
);
|
||||
|
||||
@ -133,7 +133,7 @@ struct MemoryStatus {
|
||||
void MemoryGetStatus (MemoryStatus * status);
|
||||
|
||||
struct DiskStatus {
|
||||
wchar name[16];
|
||||
wchar_t name[16];
|
||||
unsigned totalSpaceMB;
|
||||
unsigned freeSpaceMB;
|
||||
};
|
||||
@ -142,9 +142,9 @@ void DiskGetStatus (ARRAY(DiskStatus) * disks);
|
||||
|
||||
|
||||
void CpuGetInfo (
|
||||
word * cpuCaps,
|
||||
dword * cpuVendor,
|
||||
word * cpuSignature
|
||||
uint16_t * cpuCaps,
|
||||
uint32_t * cpuVendor,
|
||||
uint16_t * cpuSignature
|
||||
);
|
||||
|
||||
// CPU capability flags
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//===========================================================================
|
||||
void PathGetProgramDirectory (
|
||||
wchar *dst,
|
||||
wchar_t *dst,
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -69,15 +69,15 @@ void PathGetProgramDirectory (
|
||||
|
||||
//===========================================================================
|
||||
void PathAddFilename (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
const wchar fname[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t fname[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar temp[MAX_PATH];
|
||||
wchar_t temp[MAX_PATH];
|
||||
if (dst == src) {
|
||||
StrCopy(temp, src, arrsize(temp));
|
||||
src = temp;
|
||||
@ -92,42 +92,42 @@ void PathAddFilename (
|
||||
|
||||
//===========================================================================
|
||||
void PathRemoveFilename (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(src);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar drive[MAX_DRIVE];
|
||||
wchar dir[MAX_DIR];
|
||||
wchar_t drive[MAX_DRIVE];
|
||||
wchar_t dir[MAX_DIR];
|
||||
PathSplitPath(src, drive, dir, 0, 0);
|
||||
PathMakePath(dst, dstChars, drive, dir, 0, 0);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathRemoveExtension (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(src);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar drive[MAX_DRIVE];
|
||||
wchar dir[MAX_DIR];
|
||||
wchar fname[MAX_FNAME];
|
||||
wchar_t drive[MAX_DRIVE];
|
||||
wchar_t dir[MAX_DIR];
|
||||
wchar_t fname[MAX_FNAME];
|
||||
PathSplitPath(src, drive, dir, fname, 0);
|
||||
PathMakePath(dst, dstChars, drive, dir, fname, 0);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathSetExtension (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
const wchar ext[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t ext[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -135,18 +135,18 @@ void PathSetExtension (
|
||||
ASSERT(dst != ext);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar drive[MAX_DRIVE];
|
||||
wchar dir[MAX_DIR];
|
||||
wchar fname[MAX_FNAME];
|
||||
wchar_t drive[MAX_DRIVE];
|
||||
wchar_t dir[MAX_DIR];
|
||||
wchar_t fname[MAX_FNAME];
|
||||
PathSplitPath(src, drive, dir, fname, 0);
|
||||
PathMakePath(dst, dstChars, drive, dir, fname, ext);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void PathAddExtension (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
const wchar ext[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t ext[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
@ -154,10 +154,10 @@ void PathAddExtension (
|
||||
ASSERT(dst != ext);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar drive[MAX_DRIVE];
|
||||
wchar dir[MAX_DIR];
|
||||
wchar fname[MAX_FNAME];
|
||||
wchar oldext[MAX_EXT];
|
||||
wchar_t drive[MAX_DRIVE];
|
||||
wchar_t dir[MAX_DIR];
|
||||
wchar_t fname[MAX_FNAME];
|
||||
wchar_t oldext[MAX_EXT];
|
||||
PathSplitPath(src, drive, dir, fname, oldext);
|
||||
PathMakePath(
|
||||
dst,
|
||||
@ -171,16 +171,16 @@ void PathAddExtension (
|
||||
|
||||
//===========================================================================
|
||||
void PathRemoveDirectory (
|
||||
wchar *dst,
|
||||
const wchar src[],
|
||||
wchar_t *dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
) {
|
||||
ASSERT(dst);
|
||||
ASSERT(src);
|
||||
ASSERT(dstChars);
|
||||
|
||||
wchar fname[MAX_FNAME];
|
||||
wchar ext[MAX_EXT];
|
||||
wchar_t fname[MAX_FNAME];
|
||||
wchar_t ext[MAX_EXT];
|
||||
PathSplitPath(src, 0, 0, fname, ext);
|
||||
PathMakePath(dst, dstChars, 0, 0, fname, ext);
|
||||
}
|
||||
@ -194,14 +194,14 @@ void PathRemoveDirectory (
|
||||
|
||||
//============================================================================
|
||||
void PathSplitEmail (
|
||||
const wchar emailAddr[],
|
||||
wchar * user,
|
||||
const wchar_t emailAddr[],
|
||||
wchar_t * user,
|
||||
unsigned userChars,
|
||||
wchar * domain,
|
||||
wchar_t * domain,
|
||||
unsigned domainChars,
|
||||
wchar * tld,
|
||||
wchar_t * tld,
|
||||
unsigned tldChars,
|
||||
wchar * subDomains,
|
||||
wchar_t * subDomains,
|
||||
unsigned subDomainChars,
|
||||
unsigned subDomainCount
|
||||
) {
|
||||
@ -234,12 +234,12 @@ void PathSplitEmail (
|
||||
return;
|
||||
|
||||
// copy email address so we can tokenize it
|
||||
wchar * tmp = ALLOCA(wchar, len + 1);
|
||||
wchar_t * tmp = ALLOCA(wchar_t, len + 1);
|
||||
StrCopy(tmp, emailAddr, len + 1);
|
||||
const wchar * work = tmp;
|
||||
const wchar_t * work = tmp;
|
||||
|
||||
// parse user
|
||||
wchar token[MAX_PATH];
|
||||
wchar_t token[MAX_PATH];
|
||||
if (!StrTokenize(&work, token, arrsize(token), L"@"))
|
||||
return;
|
||||
|
||||
@ -252,10 +252,10 @@ void PathSplitEmail (
|
||||
return;
|
||||
|
||||
// parse all domains
|
||||
ARRAY(wchar *) arr;
|
||||
ARRAY(wchar_t *) arr;
|
||||
while (StrTokenize(&work, token, arrsize(token), L".")) {
|
||||
unsigned toklen = StrLen(token);
|
||||
wchar * str = ALLOCA(wchar, toklen + 1);
|
||||
wchar_t * str = ALLOCA(wchar_t, toklen + 1);
|
||||
StrCopy(str, token, toklen + 1);
|
||||
arr.Add(str);
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ const unsigned kPathFlagRecurse = 1<<4; // also set if "**" used in filesp
|
||||
|
||||
struct PathFind {
|
||||
unsigned flags;
|
||||
qword fileLength;
|
||||
qword lastWriteTime;
|
||||
wchar name[MAX_PATH];
|
||||
uint64_t fileLength;
|
||||
uint64_t lastWriteTime;
|
||||
wchar_t name[MAX_PATH];
|
||||
};
|
||||
|
||||
|
||||
@ -90,49 +90,49 @@ struct PathFind {
|
||||
|
||||
void PathFindFiles (
|
||||
ARRAY(PathFind) * paths,
|
||||
const wchar fileSpec[],
|
||||
const wchar_t fileSpec[],
|
||||
unsigned pathFlags
|
||||
);
|
||||
void PathGetProgramName (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetModuleName (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
// this function will use the current directory if <src> is a relative path
|
||||
// (see PathSetCurrentDirectory/PathGetCurrentDirectory)
|
||||
bool PathFromString (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
);
|
||||
bool PathFromString (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars,
|
||||
const wchar baseDir[]
|
||||
const wchar_t baseDir[]
|
||||
);
|
||||
|
||||
bool PathDoesFileExist (
|
||||
const wchar fileName[]
|
||||
const wchar_t fileName[]
|
||||
);
|
||||
bool PathDoesDirectoryExist (
|
||||
const wchar directory[]
|
||||
const wchar_t directory[]
|
||||
);
|
||||
|
||||
bool PathDeleteFile (
|
||||
const wchar file[]
|
||||
const wchar_t file[]
|
||||
);
|
||||
bool PathMoveFile (
|
||||
const wchar src[],
|
||||
const wchar dst[]
|
||||
const wchar_t src[],
|
||||
const wchar_t dst[]
|
||||
);
|
||||
bool PathCopyFile (
|
||||
const wchar src[],
|
||||
const wchar dst[]
|
||||
const wchar_t src[],
|
||||
const wchar_t dst[]
|
||||
);
|
||||
|
||||
|
||||
@ -143,41 +143,41 @@ bool PathCopyFile (
|
||||
***/
|
||||
|
||||
void PathSplitPath (
|
||||
const wchar path[],
|
||||
wchar * drive,
|
||||
wchar * dir,
|
||||
wchar * fname,
|
||||
wchar * ext
|
||||
const wchar_t path[],
|
||||
wchar_t * drive,
|
||||
wchar_t * dir,
|
||||
wchar_t * fname,
|
||||
wchar_t * ext
|
||||
);
|
||||
|
||||
void PathMakePath (
|
||||
wchar * path,
|
||||
wchar_t * path,
|
||||
unsigned chars,
|
||||
const wchar drive[],
|
||||
const wchar dir[],
|
||||
const wchar fname[],
|
||||
const wchar ext[]
|
||||
const wchar_t drive[],
|
||||
const wchar_t dir[],
|
||||
const wchar_t fname[],
|
||||
const wchar_t ext[]
|
||||
);
|
||||
|
||||
// c:\dir1 + dir2\file.txt => c:\dir1\dir2\file.txt
|
||||
void PathAddFilename (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
const wchar fname[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t fname[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
// c:\dir1\dir2\file.txt => c:\dir1\dir2\ * note trailing backslash
|
||||
void PathRemoveFilename (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
// c:\file.txt => c:\dir1\dir2\file
|
||||
void PathRemoveExtension (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
@ -185,9 +185,9 @@ void PathRemoveExtension (
|
||||
// c:\file. + .out => c:\file.out
|
||||
// c:\file.txt + .out => c:\file.out
|
||||
void PathSetExtension (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
const wchar ext[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t ext[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
@ -195,41 +195,41 @@ void PathSetExtension (
|
||||
// c:\file. + .out => c:\file.
|
||||
// c:\file.txt + .out => c:\file.txt
|
||||
void PathAddExtension (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
const wchar ext[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
const wchar_t ext[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
// c:\dir1\dir2\file.txt => file.txt
|
||||
void PathRemoveDirectory (
|
||||
wchar * dst,
|
||||
const wchar src[],
|
||||
wchar_t * dst,
|
||||
const wchar_t src[],
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
// c:\dir1\dir2\file.txt - c:\dir1 => .\dir2\file.txt
|
||||
// c:\dir1\dir2\file1.txt - c:\dir1\dir4\file2.txt => ..\dir4\file2.txt
|
||||
bool PathMakeRelative (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned fromFlags,
|
||||
const wchar from[],
|
||||
const wchar_t from[],
|
||||
unsigned toFlags,
|
||||
const wchar to[],
|
||||
const wchar_t to[],
|
||||
unsigned dstChars
|
||||
);
|
||||
bool PathIsRelative (
|
||||
const wchar src[]
|
||||
const wchar_t src[]
|
||||
);
|
||||
|
||||
const wchar * PathFindFilename (const wchar path[]);
|
||||
inline wchar * PathFindFilename (wchar * path) {
|
||||
return const_cast<wchar *>(PathFindFilename(const_cast<const wchar *>(path)));
|
||||
const wchar_t * PathFindFilename (const wchar_t path[]);
|
||||
inline wchar_t * PathFindFilename (wchar_t * path) {
|
||||
return const_cast<wchar_t *>(PathFindFilename(const_cast<const wchar_t *>(path)));
|
||||
}
|
||||
|
||||
const wchar * PathFindExtension (const wchar path[]);
|
||||
inline wchar * PathFindExtension (wchar * path) {
|
||||
return const_cast<wchar *>(PathFindExtension(const_cast<const wchar *>(path)));
|
||||
const wchar_t * PathFindExtension (const wchar_t path[]);
|
||||
inline wchar_t * PathFindExtension (wchar_t * path) {
|
||||
return const_cast<wchar_t *>(PathFindExtension(const_cast<const wchar_t *>(path)));
|
||||
}
|
||||
|
||||
|
||||
@ -260,46 +260,46 @@ const unsigned kPathCreateDirFlagCreateNew = 1<<1;
|
||||
|
||||
|
||||
EPathCreateDirError PathCreateDirectory (
|
||||
const wchar path[],
|
||||
const wchar_t path[],
|
||||
unsigned flags
|
||||
);
|
||||
void PathDeleteDirectory (
|
||||
const wchar path[],
|
||||
const wchar_t path[],
|
||||
unsigned flags
|
||||
);
|
||||
|
||||
|
||||
// Set directory
|
||||
bool PathSetCurrentDirectory (const wchar path[]);
|
||||
bool PathSetCurrentDirectory (const wchar_t path[]);
|
||||
void PathSetProgramDirectory ();
|
||||
|
||||
|
||||
// Get directory
|
||||
void PathGetProgramDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetCurrentDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetTempDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
|
||||
// Product and user-specific common directory locations
|
||||
void PathGetUserDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetLogDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
void PathGetInitDirectory (
|
||||
wchar * dst,
|
||||
wchar_t * dst,
|
||||
unsigned dstChars
|
||||
);
|
||||
|
||||
@ -312,14 +312,14 @@ void PathGetInitDirectory (
|
||||
|
||||
// you may send nil for any fields you don't care about
|
||||
void PathSplitEmail (
|
||||
const wchar emailAddr[],
|
||||
wchar * user,
|
||||
const wchar_t emailAddr[],
|
||||
wchar_t * user,
|
||||
unsigned userChars,
|
||||
wchar * domain,
|
||||
wchar_t * domain,
|
||||
unsigned domainChars,
|
||||
wchar * tld,
|
||||
wchar_t * tld,
|
||||
unsigned tldChars,
|
||||
wchar * subDomains, // (wchar *)&subs --> wchar subs[16][256];
|
||||
wchar_t * subDomains, // (wchar_t *)&subs --> wchar_t subs[16][256];
|
||||
unsigned subDomainChars, // arrsize(subs[0]) --> 256
|
||||
unsigned subDomainCount // arrsize(subs) --> 16
|
||||
);
|
||||
|
@ -234,14 +234,14 @@ inline void TPriorityQueue<C,P>::Link (unsigned index) {
|
||||
template<class C, class P>
|
||||
inline P * TPriorityQueue<C,P>::Priority (C * object) {
|
||||
ASSERT(m_linkOffset != LINK_OFFSET_UNINIT);
|
||||
return (P *)((byte *)object + m_linkOffset);
|
||||
return (P *)((uint8_t *)object + m_linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class C, class P>
|
||||
inline P const * TPriorityQueue<C,P>::Priority (C const * object) const {
|
||||
ASSERT(m_linkOffset != LINK_OFFSET_UNINIT);
|
||||
return (P const *)((byte const *)object + m_linkOffset);
|
||||
return (P const *)((uint8_t const *)object + m_linkOffset);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -56,8 +56,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
***/
|
||||
|
||||
class RandomContext {
|
||||
dword m_seed;
|
||||
dword m_value;
|
||||
uint32_t m_seed;
|
||||
uint32_t m_value;
|
||||
|
||||
void UpdateValue ();
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
*
|
||||
***/
|
||||
|
||||
static const dword kDefaultRandomSeed = 0x075bd924;
|
||||
static const uint32_t kDefaultRandomSeed = 0x075bd924;
|
||||
|
||||
static RandomContext s_random;
|
||||
|
||||
@ -99,11 +99,11 @@ RandomContext::RandomContext ()
|
||||
|
||||
//============================================================================
|
||||
void RandomContext::UpdateValue () {
|
||||
const dword A = 0xbc8f;
|
||||
const dword Q = 0xadc8;
|
||||
const dword R = 0x0d47;
|
||||
const uint32_t A = 0xbc8f;
|
||||
const uint32_t Q = 0xadc8;
|
||||
const uint32_t R = 0x0d47;
|
||||
|
||||
dword div = m_value / Q;
|
||||
uint32_t div = m_value / Q;
|
||||
m_value = A * (m_value - Q * div) - R * div;
|
||||
if (m_value > kRandomMax)
|
||||
m_value -= kRandomMax + 1;
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
*
|
||||
***/
|
||||
|
||||
const dword kRandomMax = 0x7fffffff;
|
||||
const uint32_t kRandomMax = 0x7fffffff;
|
||||
|
||||
void RandReset ();
|
||||
void RandSetSeed (unsigned seed);
|
||||
|
@ -374,7 +374,7 @@ T * TSkipList<T,K,keyOffset,Cmp>::Tail (SkipListTag * tag) const {
|
||||
template<class T, class K, unsigned keyOffset, class Cmp>
|
||||
void TSkipList<T,K,keyOffset,Cmp>::Link (T * object) {
|
||||
|
||||
const K * key = (const K *)((const byte *)object + keyOffset);
|
||||
const K * key = (const K *)((const uint8_t *)object + keyOffset);
|
||||
|
||||
// Find the node's insertion point
|
||||
m_stop->key = key;
|
||||
@ -418,7 +418,7 @@ void TSkipList<T,K,keyOffset,Cmp>::Link (T * object) {
|
||||
template<class T, class K, unsigned keyOffset, class Cmp>
|
||||
void TSkipList<T,K,keyOffset,Cmp>::Unlink (T * object) {
|
||||
|
||||
const K * key = (const K *)((const byte *)object + keyOffset);
|
||||
const K * key = (const K *)((const uint8_t *)object + keyOffset);
|
||||
|
||||
Node * node = m_head;
|
||||
Node * update[kMaxLevels];
|
||||
|
@ -81,7 +81,7 @@ void * CBaseSpareList::Alloc (unsigned objectSize, const char typeName[]) {
|
||||
|
||||
// initialize memory to a freaky value in debug mode
|
||||
#ifdef HS_DEBUGGING
|
||||
MemSet(object, (byte) ((unsigned) object >> 4), objectSize);
|
||||
MemSet(object, (uint8_t) ((unsigned) object >> 4), objectSize);
|
||||
#endif
|
||||
|
||||
return object;
|
||||
@ -91,7 +91,7 @@ void * CBaseSpareList::Alloc (unsigned objectSize, const char typeName[]) {
|
||||
void CBaseSpareList::Free (void * object, unsigned objectSize) {
|
||||
// initialize memory to a freaky value in debug mode
|
||||
#ifdef HS_DEBUGGING
|
||||
MemSet(object, (byte) ((unsigned) object >> 4), objectSize);
|
||||
MemSet(object, (uint8_t) ((unsigned) object >> 4), objectSize);
|
||||
#endif
|
||||
|
||||
// link memory block onto head of spare list
|
||||
@ -129,11 +129,11 @@ void CBaseSpareList::GrowSpareList (unsigned objectSize, const char typeName[])
|
||||
|
||||
// chain newly created raw memory units together onto the spare list
|
||||
SpareNode * spareCurr = (SpareNode *) (allocNode + 1);
|
||||
SpareNode * spareEnd = (SpareNode *) ((byte *) spareCurr + objectSize * m_chunkSize);
|
||||
SpareNode * spareEnd = (SpareNode *) ((uint8_t *) spareCurr + objectSize * m_chunkSize);
|
||||
do {
|
||||
spareCurr->spareNext = m_spareHead;
|
||||
m_spareHead = spareCurr;
|
||||
spareCurr = (SpareNode *) ((byte *) spareCurr + objectSize);
|
||||
spareCurr = (SpareNode *) ((uint8_t *) spareCurr + objectSize);
|
||||
} while (spareCurr < spareEnd);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ protected:
|
||||
private:
|
||||
union AllocNode {
|
||||
AllocNode * allocNext;
|
||||
qword align;
|
||||
uint64_t align;
|
||||
};
|
||||
AllocNode * m_allocHead;
|
||||
unsigned m_chunkSize;
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
// These random values were generated by the radioactive decay based
|
||||
// random number generator at www.fourmilab.ch
|
||||
static dword s_hashValue[] = {
|
||||
static uint32_t s_hashValue[] = {
|
||||
0xc30d2a72, 0x15efaec1, 0xd250c7d9, 0xaf3c60a8,
|
||||
0x9608ae8f, 0x452c0e11, 0xb6840ffd, 0x3e36c913,
|
||||
0x2864eace, 0x9b0a17d6, 0x108da74b, 0xf2c479c1,
|
||||
@ -115,7 +115,7 @@ static chartype * IStrChrR (chartype * str, findchartype ch) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar * source[], unsigned destChars) {
|
||||
static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar_t * source[], unsigned destChars) {
|
||||
unsigned ch = *(*source)++;
|
||||
bool result = false;
|
||||
if (ch < 0x80) {
|
||||
@ -143,7 +143,7 @@ static inline bool ICharUnicodeToUtf8 (char ** dest, const wchar * source[], uns
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
static inline void ICharUtf8ToUnicode (wchar ** dest, const char * source[]) {
|
||||
static inline void ICharUtf8ToUnicode (wchar_t ** dest, const char * source[]) {
|
||||
unsigned result, remaining;
|
||||
if ((**source & 0xf0) == 0xe0) {
|
||||
result = *(*source)++ & 0x0f;
|
||||
@ -165,7 +165,7 @@ static inline void ICharUtf8ToUnicode (wchar ** dest, const char * source[]) {
|
||||
for (; remaining-- && *source; ++*source)
|
||||
if ((**source & 0xc0) == 0x80)
|
||||
result = (result << 6) | (**source & 0x3f);
|
||||
*(*dest)++ = (wchar)result;
|
||||
*(*dest)++ = (wchar_t)result;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -317,10 +317,10 @@ static void IStrLower (chartype * dest, const chartype source[], unsigned chars)
|
||||
|
||||
//===========================================================================
|
||||
template<class chartype>
|
||||
static dword IStrHash (const chartype str[], unsigned chars) {
|
||||
dword temp0 = 0xE2C15C9D;
|
||||
dword temp1 = 0x2170A28A;
|
||||
dword result = 0x325D1EAE;
|
||||
static uint32_t IStrHash (const chartype str[], unsigned chars) {
|
||||
uint32_t temp0 = 0xE2C15C9D;
|
||||
uint32_t temp1 = 0x2170A28A;
|
||||
uint32_t result = 0x325D1EAE;
|
||||
for (unsigned ch; chars-- && ((ch = (unsigned)*str) != 0); ++str) {
|
||||
temp0 = (temp0 << 3) ^ ch;
|
||||
temp1 += s_hashValue[temp0 & 0x0F];
|
||||
@ -331,10 +331,10 @@ static dword IStrHash (const chartype str[], unsigned chars) {
|
||||
|
||||
//===========================================================================
|
||||
template<class chartype>
|
||||
static dword IStrHashI (const chartype str[], unsigned chars) {
|
||||
dword temp0 = 0xE2C15C9D;
|
||||
dword temp1 = 0x2170A28A;
|
||||
dword result = 0x325D1EAE;
|
||||
static uint32_t IStrHashI (const chartype str[], unsigned chars) {
|
||||
uint32_t temp0 = 0xE2C15C9D;
|
||||
uint32_t temp1 = 0x2170A28A;
|
||||
uint32_t result = 0x325D1EAE;
|
||||
for (unsigned ch; chars-- && ((ch = (unsigned)*str) != 0); ++str) {
|
||||
if ((ch >= 'a') && (ch <= 'z'))
|
||||
ch = ch + 'A' - 'a';
|
||||
@ -438,7 +438,7 @@ char * StrDup (const char str[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrDup (const wchar str[]) {
|
||||
wchar_t * StrDup (const wchar_t str[]) {
|
||||
return IStrDup(str);
|
||||
}
|
||||
|
||||
@ -448,21 +448,21 @@ char * StrDupLen (const char str[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrDupLen (const wchar str[], unsigned chars) {
|
||||
wchar_t * StrDupLen (const wchar_t str[], unsigned chars) {
|
||||
return IStrDupLen(str, chars);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
wchar * StrDupToUnicode (const char str[]) {
|
||||
unsigned bytes = StrBytes(str) * sizeof(wchar);
|
||||
wchar * dst = (wchar*)ALLOC(bytes);
|
||||
StrToUnicode(dst, str, bytes / sizeof(wchar));
|
||||
wchar_t * StrDupToUnicode (const char str[]) {
|
||||
unsigned bytes = StrBytes(str) * sizeof(wchar_t);
|
||||
wchar_t * dst = (wchar_t*)ALLOC(bytes);
|
||||
StrToUnicode(dst, str, bytes / sizeof(wchar_t));
|
||||
return dst;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
char * StrDupToAnsi (const wchar str[]) {
|
||||
unsigned bytes = StrBytes(str) / sizeof(wchar);
|
||||
char * StrDupToAnsi (const wchar_t str[]) {
|
||||
unsigned bytes = StrBytes(str) / sizeof(wchar_t);
|
||||
char * dst = (char*)ALLOC(bytes);
|
||||
StrToAnsi(dst, str, bytes);
|
||||
return dst;
|
||||
@ -474,7 +474,7 @@ unsigned StrBytes (const char str[]) { // includes space for terminator
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrBytes (const wchar str[]) { // includes space for terminator
|
||||
unsigned StrBytes (const wchar_t str[]) { // includes space for terminator
|
||||
return (IStrLen(str) + 1) * sizeof(str[0]);
|
||||
}
|
||||
|
||||
@ -484,7 +484,7 @@ char * StrChr (char * str, char ch, unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrChr (wchar * str, wchar ch, unsigned chars) {
|
||||
wchar_t * StrChr (wchar_t * str, wchar_t ch, unsigned chars) {
|
||||
return IStrChr(str, ch, chars);
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ const char * StrChr (const char str[], char ch, unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * StrChr (const wchar str[], wchar ch, unsigned chars) {
|
||||
const wchar_t * StrChr (const wchar_t str[], wchar_t ch, unsigned chars) {
|
||||
return IStrChr(str, ch, chars);
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ char * StrChrR (char * str, char ch) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrChrR (wchar * str, wchar ch) {
|
||||
wchar_t * StrChrR (wchar_t * str, wchar_t ch) {
|
||||
return IStrChrR(str, ch);
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ const char * StrChrR (const char str[], char ch) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * StrChrR (const wchar str[], wchar ch) {
|
||||
const wchar_t * StrChrR (const wchar_t str[], wchar_t ch) {
|
||||
return IStrChrR(str, ch);
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ unsigned StrPrintf (char * dest, unsigned count, const char format[], ...) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrPrintf (wchar * dest, unsigned count, const wchar format[], ...) {
|
||||
unsigned StrPrintf (wchar_t * dest, unsigned count, const wchar_t format[], ...) {
|
||||
va_list argList;
|
||||
va_start(argList, format);
|
||||
int result = _vsnwprintf(dest, count, format, argList);
|
||||
@ -543,7 +543,7 @@ unsigned StrPrintfV (char * dest, unsigned count, const char format[], va_list a
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrPrintfV (wchar * dest, unsigned count, const wchar format[], va_list args) {
|
||||
unsigned StrPrintfV (wchar_t * dest, unsigned count, const wchar_t format[], va_list args) {
|
||||
int result = _vsnwprintf(dest, count, format, args);
|
||||
return IStrPrintfValidate(dest, count, result);
|
||||
}
|
||||
@ -554,7 +554,7 @@ int StrCmp (const char str1[], const char str2[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
int StrCmp (const wchar str1[], const wchar str2[], unsigned chars) {
|
||||
int StrCmp (const wchar_t str1[], const wchar_t str2[], unsigned chars) {
|
||||
return IStrCmp(str1, str2, chars);
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ int StrCmpI (const char str1[], const char str2[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
int StrCmpI (const wchar str1[], const wchar str2[], unsigned chars) {
|
||||
int StrCmpI (const wchar_t str1[], const wchar_t str2[], unsigned chars) {
|
||||
return IStrCmpI(str1, str2, chars);
|
||||
}
|
||||
|
||||
@ -574,7 +574,7 @@ void StrCopy (char * dest, const char source[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void StrCopy (wchar * dest, const wchar source[], unsigned chars) {
|
||||
void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars) {
|
||||
IStrCopy(dest, source, chars);
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ unsigned StrCopyLen (char * dest, const char source[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrCopyLen (wchar * dest, const wchar source[], unsigned chars) {
|
||||
unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars) {
|
||||
return IStrCopyLen(dest, source, chars);
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ void StrPack (char * dest, const char source[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void StrPack (wchar * dest, const wchar source[], unsigned chars) {
|
||||
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars) {
|
||||
IStrPack(dest, source, chars);
|
||||
}
|
||||
|
||||
@ -609,13 +609,13 @@ const char * StrStr (const char source[], const char match[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrStr (wchar * source, const wchar match[]) {
|
||||
wchar_t * StrStr (wchar_t * source, const wchar_t match[]) {
|
||||
return IStrStr(source, match);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * StrStr (const wchar source[], const wchar match[]) {
|
||||
return IStrStr<const wchar>(source, match);
|
||||
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]) {
|
||||
return IStrStr<const wchar_t>(source, match);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -629,13 +629,13 @@ const char * StrStrI (const char source[], const char match[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
wchar * StrStrI (wchar * source, const wchar match[]) {
|
||||
wchar_t * StrStrI (wchar_t * source, const wchar_t match[]) {
|
||||
return IStrStrI(source, match);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
const wchar * StrStrI (const wchar source[], const wchar match[]) {
|
||||
return IStrStrI<const wchar>(source, match);
|
||||
const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]) {
|
||||
return IStrStrI<const wchar_t>(source, match);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -644,12 +644,12 @@ unsigned StrLen (const char str[]) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrLen (const wchar str[]) {
|
||||
unsigned StrLen (const wchar_t str[]) {
|
||||
return IStrLen(str);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrUnicodeToUtf8 (char * dest, const wchar source[], unsigned destChars) {
|
||||
unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars) {
|
||||
char * destCurr = dest;
|
||||
char * destTerm = dest + destChars;
|
||||
while (*source && (destCurr + 1 < destTerm))
|
||||
@ -661,9 +661,9 @@ unsigned StrUnicodeToUtf8 (char * dest, const wchar source[], unsigned destChars
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrUtf8ToUnicode (wchar * dest, const char source[], unsigned destChars) {
|
||||
wchar * destCurr = dest;
|
||||
wchar * destTerm = dest + destChars;
|
||||
unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars) {
|
||||
wchar_t * destCurr = dest;
|
||||
wchar_t * destTerm = dest + destChars;
|
||||
while (*source && (destCurr + 1 < destTerm))
|
||||
ICharUtf8ToUnicode(&destCurr, &source);
|
||||
if (destCurr < destTerm)
|
||||
@ -677,8 +677,8 @@ float StrToFloat (const char source[], const char ** endptr) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
float StrToFloat (const wchar source[], const wchar ** endptr) {
|
||||
return (float) wcstod(source, const_cast<wchar **>(endptr));
|
||||
float StrToFloat (const wchar_t source[], const wchar_t ** endptr) {
|
||||
return (float) wcstod(source, const_cast<wchar_t **>(endptr));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -687,8 +687,8 @@ int StrToInt (const char source[], const char ** endptr) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
int StrToInt (const wchar source[], const wchar ** endptr) {
|
||||
return wcstol(source, const_cast<wchar **>(endptr), 0);
|
||||
int StrToInt (const wchar_t source[], const wchar_t ** endptr) {
|
||||
return wcstol(source, const_cast<wchar_t **>(endptr), 0);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -697,8 +697,8 @@ unsigned StrToUnsigned (char source[], char ** endptr, int radix) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToUnsigned (wchar source[], wchar ** endptr, int radix) {
|
||||
return wcstoul(source, const_cast<wchar **>(endptr), radix);
|
||||
unsigned StrToUnsigned (wchar_t source[], wchar_t ** endptr, int radix) {
|
||||
return wcstoul(source, const_cast<wchar_t **>(endptr), radix);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -707,8 +707,8 @@ unsigned StrToUnsigned (const char source[], const char ** endptr, int radix) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
unsigned StrToUnsigned (const wchar source[], const wchar ** endptr, int radix) {
|
||||
return wcstoul(source, const_cast<wchar **>(endptr), radix);
|
||||
unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int radix) {
|
||||
return wcstoul(source, const_cast<wchar_t **>(endptr), radix);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@ -717,7 +717,7 @@ void StrLower (char * dest, unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void StrLower (wchar * dest, unsigned chars) {
|
||||
void StrLower (wchar_t * dest, unsigned chars) {
|
||||
IStrLower(dest, chars);
|
||||
}
|
||||
|
||||
@ -727,27 +727,27 @@ void StrLower (char * dest, const char source[], unsigned chars) {
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void StrLower (wchar * dest, const wchar source[], unsigned chars) {
|
||||
void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars) {
|
||||
IStrLower(dest, source, chars);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
dword StrHash (const char str[], unsigned chars) {
|
||||
uint32_t StrHash (const char str[], unsigned chars) {
|
||||
return IStrHash(str, chars);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
dword StrHash (const wchar str[], unsigned chars) {
|
||||
uint32_t StrHash (const wchar_t str[], unsigned chars) {
|
||||
return IStrHash(str, chars);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
dword StrHashI (const char str[], unsigned chars) {
|
||||
uint32_t StrHashI (const char str[], unsigned chars) {
|
||||
return IStrHashI(str, chars);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
dword StrHashI (const wchar str[], unsigned chars) {
|
||||
uint32_t StrHashI (const wchar_t str[], unsigned chars) {
|
||||
return IStrHashI(str, chars);
|
||||
}
|
||||
|
||||
@ -757,7 +757,7 @@ bool StrTokenize (const char * source[], char * dest, unsigned chars, const char
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool StrTokenize (const wchar * source[], wchar * dest, unsigned chars, const wchar whitespace[], unsigned maxWhitespaceSkipCount) {
|
||||
bool StrTokenize (const wchar_t * source[], wchar_t * dest, unsigned chars, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount) {
|
||||
return IStrTokenize(source, dest, chars, whitespace, maxWhitespaceSkipCount);
|
||||
}
|
||||
|
||||
@ -767,6 +767,6 @@ bool StrTokenize (const char * source[], ARRAY(char) * destArray, const char whi
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
bool StrTokenize (const wchar * source[], ARRAY(wchar) * destArray, const wchar whitespace[], unsigned maxWhitespaceSkipCount) {
|
||||
bool StrTokenize (const wchar_t * source[], ARRAY(wchar_t) * destArray, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount) {
|
||||
return IStrTokenize(source, destArray, whitespace, maxWhitespaceSkipCount);
|
||||
}
|
||||
|
@ -58,99 +58,99 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
***/
|
||||
|
||||
inline char CharLowerFast (char ch) { return ((ch >= 'A') && (ch <= 'Z')) ? (char )(ch + 'a' - 'A') : ch; }
|
||||
inline wchar CharLowerFast (wchar ch) { return ((ch >= L'A') && (ch <= L'Z')) ? (wchar)(ch + L'a' - L'A') : ch; }
|
||||
inline wchar_t CharLowerFast (wchar_t ch) { return ((ch >= L'A') && (ch <= L'Z')) ? (wchar_t)(ch + L'a' - L'A') : ch; }
|
||||
|
||||
inline char CharUpperFast (char ch) { return ((ch >= 'a') && (ch <= 'z')) ? (char )(ch + 'A' - 'a') : ch; }
|
||||
inline wchar CharUpperFast (wchar ch) { return ((ch >= L'a') && (ch <= L'z')) ? (wchar)(ch + L'A' - L'a') : ch; }
|
||||
inline wchar_t CharUpperFast (wchar_t ch) { return ((ch >= L'a') && (ch <= L'z')) ? (wchar_t)(ch + L'A' - L'a') : ch; }
|
||||
|
||||
unsigned StrBytes (const char str[]); // includes space for terminator
|
||||
unsigned StrBytes (const wchar str[]); // includes space for terminator
|
||||
unsigned StrBytes (const wchar_t str[]); // includes space for terminator
|
||||
|
||||
char * StrChr (char * str, char ch, unsigned chars = (unsigned)-1);
|
||||
wchar * StrChr (wchar * str, wchar ch, unsigned chars = (unsigned)-1);
|
||||
wchar_t * StrChr (wchar_t * str, wchar_t ch, unsigned chars = (unsigned)-1);
|
||||
const char * StrChr (const char str[], char ch, unsigned chars = (unsigned)-1);
|
||||
const wchar * StrChr (const wchar str[], wchar ch, unsigned chars = (unsigned)-1);
|
||||
const wchar_t * StrChr (const wchar_t str[], wchar_t ch, unsigned chars = (unsigned)-1);
|
||||
|
||||
unsigned StrPrintf (char * dest, unsigned count, const char format[], ...);
|
||||
unsigned StrPrintf (wchar * dest, unsigned count, const wchar format[], ...);
|
||||
unsigned StrPrintf (wchar_t * dest, unsigned count, const wchar_t format[], ...);
|
||||
|
||||
unsigned StrPrintfV (char * dest, unsigned count, const char format[], va_list args);
|
||||
unsigned StrPrintfV (wchar * dest, unsigned count, const wchar format[], va_list args);
|
||||
unsigned StrPrintfV (wchar_t * dest, unsigned count, const wchar_t format[], va_list args);
|
||||
|
||||
unsigned StrLen (const char str[]);
|
||||
unsigned StrLen (const wchar str[]);
|
||||
unsigned StrLen (const wchar_t str[]);
|
||||
|
||||
char * StrDup (const char str[]);
|
||||
wchar * StrDup (const wchar str[]);
|
||||
wchar_t * StrDup (const wchar_t str[]);
|
||||
|
||||
char * StrDupLen (const char str[], unsigned chars);
|
||||
wchar * StrDupLen (const wchar str[], unsigned chars);
|
||||
wchar_t * StrDupLen (const wchar_t str[], unsigned chars);
|
||||
|
||||
wchar * StrDupToUnicode (const char str[]);
|
||||
char * StrDupToAnsi (const wchar str[]);
|
||||
wchar_t * StrDupToUnicode (const char str[]);
|
||||
char * StrDupToAnsi (const wchar_t str[]);
|
||||
|
||||
int StrCmp (const char str1[], const char str2[], unsigned chars = (unsigned)-1);
|
||||
int StrCmp (const wchar str1[], const wchar str2[], unsigned chars = (unsigned)-1);
|
||||
int StrCmp (const wchar_t str1[], const wchar_t str2[], unsigned chars = (unsigned)-1);
|
||||
|
||||
int StrCmpI (const char str1[], const char str2[], unsigned chars = (unsigned)-1);
|
||||
int StrCmpI (const wchar str1[], const wchar str2[], unsigned chars = (unsigned)-1);
|
||||
int StrCmpI (const wchar_t str1[], const wchar_t str2[], unsigned chars = (unsigned)-1);
|
||||
|
||||
char * StrStr (char * source, const char match[]);
|
||||
const char * StrStr (const char source[], const char match[]);
|
||||
wchar * StrStr (wchar * source, const wchar match[]);
|
||||
const wchar * StrStr (const wchar source[], const wchar match[]);
|
||||
wchar_t * StrStr (wchar_t * source, const wchar_t match[]);
|
||||
const wchar_t * StrStr (const wchar_t source[], const wchar_t match[]);
|
||||
|
||||
char * StrStrI (char * source, const char match[]);
|
||||
const char * StrStrI (const char source[], const char match[]);
|
||||
wchar * StrStrI (wchar * source, const wchar match[]);
|
||||
const wchar * StrStrI (const wchar source[], const wchar match[]);
|
||||
wchar_t * StrStrI (wchar_t * source, const wchar_t match[]);
|
||||
const wchar_t * StrStrI (const wchar_t source[], const wchar_t match[]);
|
||||
|
||||
char * StrChrR (char * str, char ch);
|
||||
wchar * StrChrR (wchar * str, wchar ch);
|
||||
wchar_t * StrChrR (wchar_t * str, wchar_t ch);
|
||||
const char * StrChrR (const char str[], char ch);
|
||||
const wchar * StrChrR (const wchar str[], wchar ch);
|
||||
const wchar_t * StrChrR (const wchar_t str[], wchar_t ch);
|
||||
|
||||
void StrCopy (char * dest, const char source[], unsigned chars);
|
||||
void StrCopy (wchar * dest, const wchar source[], unsigned chars);
|
||||
void StrCopy (wchar_t * dest, const wchar_t source[], unsigned chars);
|
||||
|
||||
unsigned StrCopyLen (char * dest, const char source[], unsigned chars);
|
||||
unsigned StrCopyLen (wchar * dest, const wchar source[], unsigned chars);
|
||||
unsigned StrCopyLen (wchar_t * dest, const wchar_t source[], unsigned chars);
|
||||
|
||||
void StrPack (char * dest, const char source[], unsigned chars);
|
||||
void StrPack (wchar * dest, const wchar source[], unsigned chars);
|
||||
void StrPack (wchar_t * dest, const wchar_t source[], unsigned chars);
|
||||
|
||||
unsigned StrToAnsi (char * dest, const wchar source[], unsigned destChars);
|
||||
unsigned StrToAnsi (char * dest, const wchar source[], unsigned destChars, unsigned codePage);
|
||||
unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars);
|
||||
unsigned StrToAnsi (char * dest, const wchar_t source[], unsigned destChars, unsigned codePage);
|
||||
|
||||
unsigned StrToUnicode (wchar * dest, const char source[], unsigned destChars);
|
||||
unsigned StrToUnicode (wchar * dest, const char source[], unsigned destChars, unsigned codePage);
|
||||
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars);
|
||||
unsigned StrToUnicode (wchar_t * dest, const char source[], unsigned destChars, unsigned codePage);
|
||||
|
||||
unsigned StrUnicodeToUtf8 (char * dest, const wchar source[], unsigned destChars);
|
||||
unsigned StrUtf8ToUnicode (wchar * dest, const char source[], unsigned destChars);
|
||||
unsigned StrUnicodeToUtf8 (char * dest, const wchar_t source[], unsigned destChars);
|
||||
unsigned StrUtf8ToUnicode (wchar_t * dest, const char source[], unsigned destChars);
|
||||
|
||||
float StrToFloat (const char source[], const char ** endptr);
|
||||
float StrToFloat (const wchar source[], const wchar ** endptr);
|
||||
float StrToFloat (const wchar_t source[], const wchar_t ** endptr);
|
||||
|
||||
int StrToInt (const char source[], const char ** endptr);
|
||||
int StrToInt (const wchar source[], const wchar ** endptr);
|
||||
int StrToInt (const wchar_t source[], const wchar_t ** endptr);
|
||||
|
||||
unsigned StrToUnsigned (char source[], char ** endptr, int radix);
|
||||
unsigned StrToUnsigned (wchar source[], wchar ** endptr, int radix);
|
||||
unsigned StrToUnsigned (wchar_t source[], wchar_t ** endptr, int radix);
|
||||
unsigned StrToUnsigned (const char source[], const char ** endptr, int radix);
|
||||
unsigned StrToUnsigned (const wchar source[], const wchar ** endptr, int radix);
|
||||
unsigned StrToUnsigned (const wchar_t source[], const wchar_t ** endptr, int radix);
|
||||
|
||||
void StrLower (char * dest, unsigned chars = (unsigned) -1);
|
||||
void StrLower (wchar * dest, unsigned chars = (unsigned) -1);
|
||||
void StrLower (wchar_t * dest, unsigned chars = (unsigned) -1);
|
||||
void StrLower (char * dest, const char source[], unsigned chars);
|
||||
void StrLower (wchar * dest, const wchar source[], unsigned chars);
|
||||
void StrLower (wchar_t * dest, const wchar_t source[], unsigned chars);
|
||||
|
||||
dword StrHash (const char str[], unsigned chars = (unsigned)-1);
|
||||
dword StrHash (const wchar str[], unsigned chars = (unsigned)-1);
|
||||
uint32_t StrHash (const char str[], unsigned chars = (unsigned)-1);
|
||||
uint32_t StrHash (const wchar_t str[], unsigned chars = (unsigned)-1);
|
||||
|
||||
dword StrHashI (const char str[], unsigned chars = (unsigned)-1);
|
||||
dword StrHashI (const wchar str[], unsigned chars = (unsigned)-1);
|
||||
uint32_t StrHashI (const char str[], unsigned chars = (unsigned)-1);
|
||||
uint32_t StrHashI (const wchar_t str[], unsigned chars = (unsigned)-1);
|
||||
|
||||
bool StrTokenize (const char * source[], char * dest, unsigned chars, const char whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
bool StrTokenize (const wchar * source[], wchar * dest, unsigned chars, const wchar whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
bool StrTokenize (const wchar_t * source[], wchar_t * dest, unsigned chars, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
bool StrTokenize (const char * source[], ARRAY(char) * destArray, const char whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
bool StrTokenize (const wchar * source[], ARRAY(wchar) * destArray, const wchar whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
bool StrTokenize (const wchar_t * source[], ARRAY(wchar_t) * destArray, const wchar_t whitespace[], unsigned maxWhitespaceSkipCount = (unsigned)-1);
|
||||
|
@ -243,8 +243,8 @@ bool IVarSubstPreParsed (
|
||||
|
||||
//============================================================================
|
||||
bool ParseForSubst (
|
||||
SubstParsedData<wchar> * dest,
|
||||
const wchar src[]
|
||||
SubstParsedData<wchar_t> * dest,
|
||||
const wchar_t src[]
|
||||
) {
|
||||
return IParseForSubst(dest, src);
|
||||
}
|
||||
@ -259,11 +259,11 @@ bool ParseForSubst (
|
||||
|
||||
//============================================================================
|
||||
bool VarSubstitute (
|
||||
ARRAY(wchar) * dst,
|
||||
const wchar src[],
|
||||
ARRAY(wchar_t) * dst,
|
||||
const wchar_t src[],
|
||||
unsigned varCount,
|
||||
const wchar * varNames[], // [varCount]
|
||||
const wchar * varValues[] // [varCount]
|
||||
const wchar_t * varNames[], // [varCount]
|
||||
const wchar_t * varValues[] // [varCount]
|
||||
) {
|
||||
return IVarSubstitute(dst, src, varCount, varNames, varValues);
|
||||
}
|
||||
@ -281,11 +281,11 @@ bool VarSubstitute (
|
||||
|
||||
//============================================================================
|
||||
bool VarSubstitute (
|
||||
ARRAY(wchar) * dst,
|
||||
const SubstParsedData<wchar> * src,
|
||||
ARRAY(wchar_t) * dst,
|
||||
const SubstParsedData<wchar_t> * src,
|
||||
unsigned varCount,
|
||||
const wchar * varNames[], // [varCount]
|
||||
const wchar * varValues[] // [varCount]
|
||||
const wchar_t * varNames[], // [varCount]
|
||||
const wchar_t * varValues[] // [varCount]
|
||||
) {
|
||||
return IVarSubstPreParsed(dst, src, varCount, varNames, varValues);
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ struct SubstParsedData {
|
||||
};
|
||||
|
||||
bool ParseForSubst (
|
||||
SubstParsedData<wchar> * dest,
|
||||
const wchar src[]
|
||||
SubstParsedData<wchar_t> * dest,
|
||||
const wchar_t src[]
|
||||
);
|
||||
bool ParseForSubst (
|
||||
SubstParsedData<char> * dest,
|
||||
@ -90,11 +90,11 @@ bool ParseForSubst (
|
||||
|
||||
// Return value is for validation purposes only; it may be ignored
|
||||
bool VarSubstitute (
|
||||
ARRAY(wchar) * dst,
|
||||
const wchar src[],
|
||||
ARRAY(wchar_t) * dst,
|
||||
const wchar_t src[],
|
||||
unsigned varCount,
|
||||
const wchar * varNames[], // [varCount]
|
||||
const wchar * varValues[] // [varCount]
|
||||
const wchar_t * varNames[], // [varCount]
|
||||
const wchar_t * varValues[] // [varCount]
|
||||
);
|
||||
bool VarSubstitute (
|
||||
ARRAY(char) * dst,
|
||||
@ -104,11 +104,11 @@ bool VarSubstitute (
|
||||
const char * varValues[] // [varCount]
|
||||
);
|
||||
bool VarSubstitute (
|
||||
ARRAY(wchar) * dst,
|
||||
const SubstParsedData<wchar> * src,
|
||||
ARRAY(wchar_t) * dst,
|
||||
const SubstParsedData<wchar_t> * src,
|
||||
unsigned varCount,
|
||||
const wchar * varNames[], // [varCount]
|
||||
const wchar * varValues[] // [varCount]
|
||||
const wchar_t * varNames[], // [varCount]
|
||||
const wchar_t * varValues[] // [varCount]
|
||||
);
|
||||
bool VarSubstitute (
|
||||
ARRAY(char) * dst,
|
||||
|
@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
//===========================================================================
|
||||
void TimeGetElapsedDesc (
|
||||
dword minutesElapsed,
|
||||
uint32_t minutesElapsed,
|
||||
TimeElapsedDesc * desc
|
||||
) {
|
||||
|
||||
@ -67,7 +67,7 @@ void TimeGetElapsedDesc (
|
||||
const unsigned kMinutesPerMonth = 43830;
|
||||
const unsigned kMinutesPerYear = 525960;
|
||||
|
||||
dword & elapsed = minutesElapsed;
|
||||
uint32_t & elapsed = minutesElapsed;
|
||||
desc->years = (elapsed / kMinutesPerYear); elapsed -= desc->years * kMinutesPerYear;
|
||||
desc->months = (elapsed / kMinutesPerMonth); elapsed -= desc->months * kMinutesPerMonth;
|
||||
desc->weeks = (elapsed / kMinutesPerWeek); elapsed -= desc->weeks * kMinutesPerWeek;
|
||||
@ -78,15 +78,15 @@ void TimeGetElapsedDesc (
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
dword TimeGetSecondsSince2001Utc () {
|
||||
qword time = TimeGetTime();
|
||||
dword seconds = (dword)((time - kTime1601To2001) / kTimeIntervalsPerSecond);
|
||||
uint32_t TimeGetSecondsSince2001Utc () {
|
||||
uint64_t time = TimeGetTime();
|
||||
uint32_t seconds = (uint32_t)((time - kTime1601To2001) / kTimeIntervalsPerSecond);
|
||||
return seconds;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
dword TimeGetSecondsSince1970Utc () {
|
||||
qword time = TimeGetTime();
|
||||
dword seconds = (dword)((time - kTime1601To1970) / kTimeIntervalsPerSecond);
|
||||
uint32_t TimeGetSecondsSince1970Utc () {
|
||||
uint64_t time = TimeGetTime();
|
||||
uint32_t seconds = (uint32_t)((time - kTime1601To1970) / kTimeIntervalsPerSecond);
|
||||
return seconds;
|
||||
}
|
||||
|
@ -77,19 +77,19 @@ struct TimeElapsedDesc {
|
||||
};
|
||||
|
||||
void TimeGetDesc (
|
||||
qword time,
|
||||
uint64_t time,
|
||||
TimeDesc * desc
|
||||
);
|
||||
|
||||
void TimeGetElapsedDesc (
|
||||
dword minutesElapsed,
|
||||
uint32_t minutesElapsed,
|
||||
TimeElapsedDesc * desc
|
||||
);
|
||||
|
||||
void TimePrettyPrint (
|
||||
qword time,
|
||||
uint64_t time,
|
||||
unsigned chars,
|
||||
wchar * buffer
|
||||
wchar_t * buffer
|
||||
);
|
||||
|
||||
|
||||
@ -99,31 +99,31 @@ void TimePrettyPrint (
|
||||
*
|
||||
***/
|
||||
|
||||
const qword kTimeIntervalsPerMs = 10000;
|
||||
const qword kTimeIntervalsPerSecond = 1000 * kTimeIntervalsPerMs;
|
||||
const qword kTimeIntervalsPerMinute = 60 * kTimeIntervalsPerSecond;
|
||||
const qword kTimeIntervalsPerHour = 60 * kTimeIntervalsPerMinute;
|
||||
const qword kTimeIntervalsPerDay = 24 * kTimeIntervalsPerHour;
|
||||
const uint64_t kTimeIntervalsPerMs = 10000;
|
||||
const uint64_t kTimeIntervalsPerSecond = 1000 * kTimeIntervalsPerMs;
|
||||
const uint64_t kTimeIntervalsPerMinute = 60 * kTimeIntervalsPerSecond;
|
||||
const uint64_t kTimeIntervalsPerHour = 60 * kTimeIntervalsPerMinute;
|
||||
const uint64_t kTimeIntervalsPerDay = 24 * kTimeIntervalsPerHour;
|
||||
|
||||
// millisecond timer; wraps ~49 days
|
||||
dword TimeGetMs ();
|
||||
uint32_t TimeGetMs ();
|
||||
|
||||
// 100 nanosecond intervals; won't wrap in our lifetimes
|
||||
qword TimeGetTime ();
|
||||
qword TimeGetLocalTime ();
|
||||
uint64_t TimeGetTime ();
|
||||
uint64_t TimeGetLocalTime ();
|
||||
|
||||
// Minutes elapsed since 2001 UTC
|
||||
dword TimeGetMinutes ();
|
||||
uint32_t TimeGetMinutes ();
|
||||
|
||||
// Seconds elapsed since 00:00:00 January 1, 2001 UTC
|
||||
dword TimeGetSecondsSince2001Utc ();
|
||||
uint32_t TimeGetSecondsSince2001Utc ();
|
||||
|
||||
// Seconds elapsed since 00:00:00 January 1, 1970 UTC (the Unix Epoch)
|
||||
dword TimeGetSecondsSince1970Utc ();
|
||||
uint32_t TimeGetSecondsSince1970Utc ();
|
||||
|
||||
|
||||
// These magic numbers taken from Microsoft's "Shared Source CLI implementation" source code.
|
||||
// http://msdn.microsoft.com/library/en-us/Dndotnet/html/mssharsourcecli.asp
|
||||
|
||||
static const qword kTime1601To1970 = 11644473600 * kTimeIntervalsPerSecond;
|
||||
static const qword kTime1601To2001 = 12622780800 * kTimeIntervalsPerSecond;
|
||||
static const uint64_t kTime1601To1970 = 11644473600 * kTimeIntervalsPerSecond;
|
||||
static const uint64_t kTime1601To2001 = 12622780800 * kTimeIntervalsPerSecond;
|
||||
|
@ -59,13 +59,13 @@ const Uuid kNilGuid;
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
Uuid::Uuid (const wchar str[]) {
|
||||
Uuid::Uuid (const wchar_t str[]) {
|
||||
|
||||
GuidFromString(str, this);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
Uuid::Uuid (const byte buf[], unsigned length) {
|
||||
Uuid::Uuid (const uint8_t buf[], unsigned length) {
|
||||
|
||||
GuidFromHex(buf, length, this);
|
||||
}
|
||||
@ -78,11 +78,11 @@ unsigned GuidHash (const Uuid & uuid) {
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
static const wchar s_hexChars[] = L"0123456789ABCDEF";
|
||||
const wchar * GuidToHex (const Uuid & uuid, wchar * dst, unsigned chars) {
|
||||
static const wchar_t s_hexChars[] = L"0123456789ABCDEF";
|
||||
const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars) {
|
||||
|
||||
wchar * str = ALLOCA(wchar, sizeof(uuid.data) * 2 + 1);
|
||||
wchar * cur = str;
|
||||
wchar_t * str = ALLOCA(wchar_t, sizeof(uuid.data) * 2 + 1);
|
||||
wchar_t * cur = str;
|
||||
|
||||
for (unsigned i = 0; i < sizeof(uuid.data); ++i) {
|
||||
*cur++ = s_hexChars[(uuid.data[i] >> 4) & 0x0f];
|
||||
@ -95,7 +95,7 @@ const wchar * GuidToHex (const Uuid & uuid, wchar * dst, unsigned chars) {
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool GuidFromHex (const byte buf[], unsigned length, Uuid * uuid) {
|
||||
bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid) {
|
||||
|
||||
ASSERT(length == msizeof(Uuid, data));
|
||||
MemCopy(uuid->data, buf, msizeof(Uuid, data));
|
||||
|
@ -78,16 +78,16 @@ extern const Uuid kNilGuid;
|
||||
|
||||
Uuid GuidGenerate ();
|
||||
void GuidClear (Uuid * uuid);
|
||||
bool GuidFromString (const wchar str[], Uuid * uuid);
|
||||
bool GuidFromString (const wchar_t str[], Uuid * uuid);
|
||||
bool GuidFromString (const char str[], Uuid * uuid);
|
||||
int GuidCompare (const Uuid & a, const Uuid & b);
|
||||
inline bool GuidsAreEqual (const Uuid & a, const Uuid & b) { return 0 == GuidCompare(a, b); }
|
||||
bool GuidIsNil (const Uuid & uuid);
|
||||
unsigned GuidHash (const Uuid & uuid);
|
||||
const wchar * GuidToString (const Uuid & uuid, wchar * dst, unsigned chars); // returns dst
|
||||
const wchar_t * GuidToString (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst
|
||||
const char * GuidToString (const Uuid & uuid, char * dst, unsigned chars); // returns dst
|
||||
const wchar * GuidToHex (const Uuid & uuid, wchar * dst, unsigned chars); // returns dst
|
||||
bool GuidFromHex (const byte buf[], unsigned length, Uuid * uuid);
|
||||
const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst
|
||||
bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@ -99,13 +99,13 @@ bool GuidFromHex (const byte buf[], unsigned length, Uuid * uuid);
|
||||
#include <pshpack1.h>
|
||||
struct Uuid {
|
||||
union {
|
||||
dword dwords[4];
|
||||
byte data[16];
|
||||
uint32_t uint32_ts[4];
|
||||
uint8_t data[16];
|
||||
};
|
||||
|
||||
Uuid () {}
|
||||
Uuid (const wchar str[]);
|
||||
Uuid (const byte buf[], unsigned length);
|
||||
Uuid (const wchar_t str[]);
|
||||
Uuid (const uint8_t buf[], unsigned length);
|
||||
operator bool () const { return !GuidIsNil(*this); }
|
||||
inline bool operator ! () const { return GuidIsNil(*this); }
|
||||
inline bool operator < (const Uuid & rhs) const { return GuidCompare(*this, rhs) < 0; }
|
||||
|
Reference in New Issue
Block a user