本文整理汇总了C++中COUNTOF函数的典型用法代码示例。如果您正苦于以下问题:C++ COUNTOF函数的具体用法?C++ COUNTOF怎么用?C++ COUNTOF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了COUNTOF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LogSpewAlwaysValist
VOID LogSpewAlwaysValist(const char *fmt, va_list args)
{
SCAN_IGNORE_FAULT; // calls to new (nothrow) in logging code are OK
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
DEBUG_ONLY_FUNCTION;
// We can't do heap allocations at all. The current thread may have
// suspended another thread, and the suspended thread may be inside of the
// heap lock.
//
// (Some historical comments:)
//
// We must operate with a very small stack (in case we're logging durring
// a stack overflow)
//
// We're going to bypass our debug memory allocator and just allocate memory from
// the process heap. Why? Because our debug memory allocator will log out of memory
// conditions. If we're low on memory, and we try to log an out of memory condition, and we try
// and allocate memory again using the debug allocator, we could (and probably will) hit
// another low memory condition, try to log it, and we spin indefinately until we hit a stack overflow.
const int BUFFERSIZE = 1000;
static char rgchBuffer[BUFFERSIZE];
EnterLogLock();
char * pBuffer = &rgchBuffer[0];
DWORD buflen = 0;
DWORD written;
static bool needsPrefix = true;
if (needsPrefix)
buflen = sprintf_s(pBuffer, COUNTOF(rgchBuffer), "TID %04x: ", GetCurrentThreadId());
needsPrefix = (fmt[strlen(fmt)-1] == '\n');
int cCountWritten = _vsnprintf(&pBuffer[buflen], BUFFERSIZE-buflen, fmt, args );
pBuffer[BUFFERSIZE-1] = 0;
if (cCountWritten < 0) {
buflen = BUFFERSIZE - 1;
} else {
buflen += cCountWritten;
}
// Its a little late for this, but at least you wont continue
// trashing your program...
_ASSERTE((buflen < (DWORD) BUFFERSIZE) && "Log text is too long!") ;
#if !PLATFORM_UNIX
//convert NL's to CR NL to fixup notepad
const int BUFFERSIZE2 = BUFFERSIZE + 500;
char rgchBuffer2[BUFFERSIZE2];
char * pBuffer2 = &rgchBuffer2[0];
char *d = pBuffer2;
for (char *p = pBuffer; *p != '\0'; p++)
{
if (*p == '\n') {
_ASSERTE(d < pBuffer2 + BUFFERSIZE2);
*(d++) = '\r';
}
_ASSERTE(d < pBuffer2 + BUFFERSIZE2);
*(d++) = *p;
}
*d = 0;
buflen = (DWORD)(d - pBuffer2);
pBuffer = pBuffer2;
#endif // PLATFORM_UNIX
if (LogFlags & LOG_ENABLE_FILE_LOGGING && LogFileHandle != INVALID_HANDLE_VALUE)
{
WriteFile(LogFileHandle, pBuffer, buflen, &written, NULL);
if (LogFlags & LOG_ENABLE_FLUSH_FILE) {
FlushFileBuffers( LogFileHandle );
}
}
if (LogFlags & LOG_ENABLE_CONSOLE_LOGGING)
{
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, buflen, &written, 0);
//<TODO>@TODO ...Unnecessary to flush console?</TODO>
if (LogFlags & LOG_ENABLE_FLUSH_FILE)
FlushFileBuffers( GetStdHandle(STD_OUTPUT_HANDLE) );
}
if (LogFlags & LOG_ENABLE_DEBUGGER_LOGGING)
{
OutputDebugStringA(pBuffer);
}
LeaveLogLock();
}
示例2: ASSERT
void CItemStone::SetCharter( unsigned int iLine, LPCTSTR pCharter )
{
ASSERT(iLine<COUNTOF(m_sCharter));
m_sCharter[iLine] = pCharter;
}
示例3: ADDTOCALLSTACK
//.........这里部分代码省略.........
i++;
}
return true;
}
else if ( !strnicmp("guildfromuid.", pszKey, 13) )
{
LPCTSTR pszCmd = pszKey + 13;
sVal.FormatVal(0);
if ( !pszCmd[0] )
return true;
CGrayUID pGuildUid = static_cast<DWORD>(Exp_GetVal(pszCmd));
SKIP_SEPARATORS(pszCmd);
CItem * pMemberGuild = pGuildUid.ItemFind();
if ( pMemberGuild )
{
CStoneMember * pGuild = GetMember( pMemberGuild );
if ( pGuild )
{
return pGuild->r_WriteVal(pszCmd, sVal, pSrc);
}
}
return true;
}
else if ( !strnicmp(sm_szLoadKeys[STC_CHARTER], pszKey, 7) )
{
LPCTSTR pszCmd = pszKey + 7;
unsigned int i = ATOI(pszCmd);
if ( i >= COUNTOF(m_sCharter))
sVal = "";
else
sVal = m_sCharter[i];
return( true );
}
STC_TYPE iIndex = (STC_TYPE) FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 );
switch ( iIndex )
{
case STC_ABBREV: // "ABBREV"
sVal = m_sAbbrev;
return true;
case STC_ALIGN:
sVal.FormatVal( GetAlignType());
return true;
case STC_WEBPAGE: // "WEBPAGE"
sVal = GetWebPageURL();
return true;
case STC_AbbreviationToggle:
{
CStoneMember * pMember = GetMember(pCharSrc);
CVarDefCont * pResult = NULL;
if ( pMember == NULL )
{
pResult = g_Exp.m_VarDefs.GetKey("STONECONFIG_VARIOUSNAME_NONMEMBER");
}
else
{
示例4: defined
{
#if defined(TARGET_GP2X) || defined(TARGET_DINGUX)
{ 320, 240, no_scale, nn_16, nn_32, "None" },
#else
{ 1 * vga_width, 1 * vga_height, no_scale, nn_16, nn_32, "None" },
{ 2 * vga_width, 2 * vga_height, NULL, nn_16, nn_32, "2x" },
{ 2 * vga_width, 2 * vga_height, NULL, scale2x_16, scale2x_32, "Scale2x" },
{ 2 * vga_width, 2 * vga_height, NULL, NULL, hq2x_32, "hq2x" },
{ 3 * vga_width, 3 * vga_height, NULL, nn_16, nn_32, "3x" },
{ 3 * vga_width, 3 * vga_height, NULL, scale3x_16, scale3x_32, "Scale3x" },
{ 3 * vga_width, 3 * vga_height, NULL, NULL, hq3x_32, "hq3x" },
{ 4 * vga_width, 4 * vga_height, NULL, nn_16, nn_32, "4x" },
{ 4 * vga_width, 4 * vga_height, NULL, NULL, hq4x_32, "hq4x" },
#endif
};
const uint scalers_count = COUNTOF(scalers);
void set_scaler_by_name( const char *name )
{
for (uint i = 0; i < scalers_count; ++i)
{
if (strcmp(name, scalers[i].name) == 0)
{
scaler = i;
break;
}
}
}
#if defined(TARGET_GP2X) || defined(TARGET_DINGUX)
#define VGA_CENTERED
示例5: JE_saveConfiguration
//.........这里部分代码省略.........
tempSaveFile.level = SDL_SwapLE16(tempSaveFile.level);
memcpy(p, &tempSaveFile.level, sizeof(JE_word)); p += 2;
memcpy(p, &tempSaveFile.items, sizeof(JE_PItemsType)); p += sizeof(JE_PItemsType);
tempSaveFile.score = SDL_SwapLE32(tempSaveFile.score);
memcpy(p, &tempSaveFile.score, sizeof(JE_longint)); p += 4;
tempSaveFile.score2 = SDL_SwapLE32(tempSaveFile.score2);
memcpy(p, &tempSaveFile.score2, sizeof(JE_longint)); p += 4;
/* SYN: Pascal strings are prefixed by a byte holding the length! */
memset(p, 0, sizeof(tempSaveFile.levelName));
*p = strlen(tempSaveFile.levelName);
memcpy(&p[1], &tempSaveFile.levelName, *p);
p += 10;
/* This was a BYTE array, not a STRING, in the original. Go fig. */
memcpy(p, &tempSaveFile.name, 14);
p += 14;
memcpy(p, &tempSaveFile.cubes, sizeof(JE_byte)); p++;
memcpy(p, &tempSaveFile.power, sizeof(JE_byte) * 2); p += 2;
memcpy(p, &tempSaveFile.episode, sizeof(JE_byte)); p++;
memcpy(p, &tempSaveFile.lastItems, sizeof(JE_PItemsType)); p += sizeof(JE_PItemsType);
memcpy(p, &tempSaveFile.difficulty, sizeof(JE_byte)); p++;
memcpy(p, &tempSaveFile.secretHint, sizeof(JE_byte)); p++;
memcpy(p, &tempSaveFile.input1, sizeof(JE_byte)); p++;
memcpy(p, &tempSaveFile.input2, sizeof(JE_byte)); p++;
/* booleans were 1 byte in pascal -- working around it */
Uint8 temp = tempSaveFile.gameHasRepeated != false;
memcpy(p, &temp, 1); p++;
memcpy(p, &tempSaveFile.initialDifficulty, sizeof(JE_byte)); p++;
tempSaveFile.highScore1 = SDL_SwapLE32(tempSaveFile.highScore1);
memcpy(p, &tempSaveFile.highScore1, sizeof(JE_longint)); p += 4;
tempSaveFile.highScore2 = SDL_SwapLE32(tempSaveFile.highScore2);
memcpy(p, &tempSaveFile.highScore2, sizeof(JE_longint)); p += 4;
memset(p, 0, sizeof(tempSaveFile.highScoreName));
*p = strlen(tempSaveFile.highScoreName);
memcpy(&p[1], &tempSaveFile.highScoreName, *p);
p += 30;
memcpy(p, &tempSaveFile.highScoreDiff, sizeof(JE_byte)); p++;
}
saveTemp[SIZEOF_SAVEGAMETEMP - 6] = editorLevel >> 8;
saveTemp[SIZEOF_SAVEGAMETEMP - 5] = editorLevel;
JE_encryptSaveTemp();
f = dir_fopen_warn(get_user_directory(), "tyrian.sav", "wb");
if (f)
{
efwrite(saveTemp, 1, sizeof(saveTemp), f);
fclose(f);
#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500)
sync();
#endif
}
JE_decryptSaveTemp();
f = dir_fopen_warn(get_user_directory(), "tyrian.cfg", "wb");
if (f)
{
efwrite(&background2, 1, 1, f);
efwrite(&gameSpeed, 1, 1, f);
efwrite(&inputDevice_, 1, 1, f);
efwrite(&jConfigure, 1, 1, f);
efwrite(&versionNum, 1, 1, f);
efwrite(&processorType, 1, 1, f);
efwrite(&midiPort, 1, 1, f);
efwrite(&soundEffects, 1, 1, f);
efwrite(&gammaCorrection, 1, 1, f);
efwrite(&difficultyLevel, 1, 1, f);
efwrite(joyButtonAssign, 1, 4, f);
efwrite(&tyrMusicVolume, 2, 1, f);
efwrite(&fxVolume, 2, 1, f);
efwrite(inputDevice, 1, 2, f);
efwrite(keySettings, sizeof(*keySettings), COUNTOF(keySettings), f);
fclose(f);
}
save_opentyrian_config();
#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500)
sync();
#endif
}
示例6: make_program_env
/*
* The way windows takes environment variables is different than what C does;
* Windows wants a contiguous block of null-terminated strings, terminated
* with an additional null.
*
* Windows has a few "essential" environment variables. winsock will fail
* to initialize if SYSTEMROOT is not defined; some APIs make reference to
* TEMP. SYSTEMDRIVE is probably also important. We therefore ensure that
* these get defined if the input environment block does not contain any
* values for them.
*/
wchar_t* make_program_env(char** env_block) {
wchar_t* dst;
wchar_t* ptr;
char** env;
int env_len = 1 * sizeof(wchar_t); /* room for closing null */
int len;
int i;
DWORD var_size;
env_var_t required_vars[] = {
E_V("SYSTEMROOT"),
E_V("SYSTEMDRIVE"),
E_V("TEMP"),
};
for (env = env_block; *env; env++) {
check_required_vars_contains_var(required_vars,
COUNTOF(required_vars),
*env);
env_len += (uv_utf8_to_utf16(*env, NULL, 0) * sizeof(wchar_t));
}
for (i = 0; i < COUNTOF(required_vars); ++i) {
if (!required_vars[i].supplied) {
env_len += required_vars[i].len * sizeof(wchar_t);
var_size = GetEnvironmentVariableW(required_vars[i].wide, NULL, 0);
if (var_size == 0) {
uv_fatal_error(GetLastError(), "GetEnvironmentVariableW");
}
required_vars[i].value_len = (int)var_size;
env_len += (int)var_size * sizeof(wchar_t);
}
}
dst = malloc(env_len);
if (!dst) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
ptr = dst;
for (env = env_block; *env; env++, ptr += len) {
len = uv_utf8_to_utf16(*env, ptr, (size_t)(env_len - (ptr - dst)));
if (!len) {
free(dst);
return NULL;
}
}
for (i = 0; i < COUNTOF(required_vars); ++i) {
if (!required_vars[i].supplied) {
wcscpy(ptr, required_vars[i].wide);
ptr += required_vars[i].len - 1;
*ptr++ = L'=';
var_size = GetEnvironmentVariableW(required_vars[i].wide,
ptr,
required_vars[i].value_len);
if (var_size == 0) {
uv_fatal_error(GetLastError(), "GetEnvironmentVariableW");
}
ptr += required_vars[i].value_len;
}
}
*ptr = L'\0';
return dst;
}
示例7: uv_spawn
//.........这里部分代码省略.........
if (options.stderr_stream) {
err = uv_create_stdio_pipe_pair(
loop,
options.stderr_stream,
&child_stdio[2],
PIPE_ACCESS_INBOUND,
GENERIC_WRITE);
} else {
err = duplicate_std_handle(loop, STD_ERROR_HANDLE, &child_stdio[2]);
}
if (err) {
goto done;
}
startup.cb = sizeof(startup);
startup.lpReserved = NULL;
startup.lpDesktop = NULL;
startup.lpTitle = NULL;
startup.dwFlags = STARTF_USESTDHANDLES;
startup.cbReserved2 = 0;
startup.lpReserved2 = NULL;
startup.hStdInput = child_stdio[0];
startup.hStdOutput = child_stdio[1];
startup.hStdError = child_stdio[2];
if (CreateProcessW(application_path,
arguments,
NULL,
NULL,
1,
CREATE_UNICODE_ENVIRONMENT,
env,
cwd,
&startup,
&info)) {
/* Spawn succeeded */
process->process_handle = info.hProcess;
process->pid = info.dwProcessId;
/* Setup notifications for when the child process exits. */
result = RegisterWaitForSingleObject(&process->wait_handle,
process->process_handle, exit_wait_callback, (void*)process, INFINITE,
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE);
if (!result) {
uv_fatal_error(GetLastError(), "RegisterWaitForSingleObject");
}
CloseHandle(info.hThread);
} else {
/* CreateProcessW failed, but this failure should be delivered */
/* asynchronously to retain unix compatibility. So pretent spawn */
/* succeeded, and start a thread instead that prints an error */
/* to the child's intended stderr. */
process->spawn_errno = GetLastError();
keep_child_stdio_open = 1;
if (!QueueUserWorkItem(spawn_failure, process, WT_EXECUTEDEFAULT)) {
uv_fatal_error(GetLastError(), "QueueUserWorkItem");
}
}
done:
free(application);
if (application_path != application) {
free(application_path);
}
free(arguments);
free(cwd);
free(env);
free(path);
/* Under normal circumstances we should close the stdio handles now - */
/* the child now has its own duplicates, or something went horribly wrong. */
/* The only exception is when CreateProcess has failed, then we actually */
/* need to keep the stdio handles to report the error asynchronously. */
if (!keep_child_stdio_open) {
close_child_stdio(process);
} else {
/* We're keeping the handles open, the thread pool is going to have */
/* it's way with them. But at least make them noninheritable. */
int i;
for (i = 0; i < COUNTOF(process->child_stdio); i++) {
SetHandleInformation(child_stdio[i], HANDLE_FLAG_INHERIT, 0);
}
}
if (err) {
if (process->wait_handle != INVALID_HANDLE_VALUE) {
UnregisterWait(process->wait_handle);
process->wait_handle = INVALID_HANDLE_VALUE;
}
if (process->process_handle != INVALID_HANDLE_VALUE) {
CloseHandle(process->process_handle);
process->process_handle = INVALID_HANDLE_VALUE;
}
}
return err;
}
示例8: SaveVersionHeader
void CResourceVersionInfo::ExportToStream(GrowBuf &strm, int Index)
{
DWORD v;
WORD wSize;
int p, p1;
strm.resize(0);
SaveVersionHeader(strm, 0, sizeof (VS_FIXEDFILEINFO), 0, L"VS_VERSION_INFO", &m_FixedInfo);
DefineList *pChildStrings = m_ChildStringLists.get_strings(Index);
if ( pChildStrings->getnum() > 0 )
{
GrowBuf stringInfoStream;
int codepage = m_ChildStringLists.get_codepage(Index);
LANGID langid = m_ChildStringLists.get_lang(Index);
wchar_t Buff[16];
_snwprintf(Buff, COUNTOF(Buff), L"%04x%04x", langid, codepage);
SaveVersionHeader(stringInfoStream, 0, 0, 0, Buff, &ZEROS);
for ( int i = 0; i < pChildStrings->getnum(); i++ )
{
PadStream (stringInfoStream);
WCToUTF16LEHlpr cnvName, cnvValue;
if (!cnvName.Create(pChildStrings->getname(i), codepage)) throw std::runtime_error("Unicode conversion failed");
if (!cnvValue.Create(pChildStrings->getvalue(i), codepage)) throw std::runtime_error("Unicode conversion failed");
p = stringInfoStream.getlen();
SaveVersionHeaderUTF16LE(stringInfoStream, 0, WORD(StrLenUTF16(cnvValue.Get()) + 1), 1, cnvName.Get(), (void*)cnvValue.Get());
cnvName.Destroy(), cnvValue.Destroy();
wSize = WORD(stringInfoStream.getlen() - p);
*(WORD*)((PBYTE)stringInfoStream.get()+p)=wSize;
}
wSize = WORD(stringInfoStream.getlen());
*(WORD*)((PBYTE)stringInfoStream.get())=wSize;
PadStream (strm);
p = strm.getlen();
SaveVersionHeader(strm, 0, 0, 0, L"StringFileInfo", &ZEROS);
strm.add (stringInfoStream.get(), stringInfoStream.getlen());
wSize = WORD(strm.getlen() - p);
*(WORD*)((PBYTE)strm.get()+p)=wSize;
}
// Show all languages avaiable using Var-Translations
if ( m_ChildStringLists.getnum() > 0 )
{
PadStream (strm);
p = strm.getlen();
SaveVersionHeader(strm, 0, 0, 0, L"VarFileInfo", &ZEROS);
PadStream (strm);
p1 = strm.getlen();
SaveVersionHeader(strm, 0, 0, 0, L"Translation", &ZEROS);
// First add selected code language translation
v = MAKELONG(m_ChildStringLists.get_lang(Index), m_ChildStringLists.get_codepage(Index));
strm.add (&v, sizeof (v));
for ( int k =0; k < m_ChildStringLists.getnum(); k++ )
{
if ( k != Index )
{
v = MAKELONG(m_ChildStringLists.get_lang(k), m_ChildStringLists.get_codepage(k));
strm.add (&v, sizeof (v));
}
}
wSize = WORD(strm.getlen() - p1);
*(WORD*)((PBYTE)strm.get()+p1)=wSize;
wSize = WORD(sizeof (int) * m_ChildStringLists.getnum());
p1+=sizeof(WORD);
*(WORD*)((PBYTE)strm.get()+p1)=wSize;
wSize = WORD(strm.getlen() - p);
*(WORD*)((PBYTE)strm.get()+p)=wSize;
}
wSize = WORD(strm.getlen());
*(WORD*)((PBYTE)strm.get())=wSize;
}
示例9: DECL
DECL(DRIVING_EMPTYGRANDSTAND),
DECL(DRIVING_TUNNEL),
DECL(CITY_STREETS),
DECL(CITY_SUBWAY),
DECL(CITY_MUSEUM),
DECL(CITY_LIBRARY),
DECL(CITY_UNDERPASS),
DECL(CITY_ABANDONED),
DECL(DUSTYROOM),
DECL(CHAPEL),
DECL(SMALLWATERROOM),
};
#undef DECL
static const ALsizei reverblistsize = COUNTOF(reverblist);
ALvoid LoadReverbPreset(const char *name, ALeffect *effect)
{
int i;
if(strcasecmp(name, "NONE") == 0)
{
InitEffectParams(effect, AL_EFFECT_NULL);
TRACE("Loading reverb '%s'\n", "NONE");
return;
}
if(!DisabledEffects[EAXREVERB])
InitEffectParams(effect, AL_EFFECT_EAXREVERB);
else if(!DisabledEffects[REVERB])
示例10: ValidateHKDF
bool ValidateHKDF()
{
bool pass = true;
{
// SHA-1 from RFC 5869, Appendix A, https://tools.ietf.org/html/rfc5869
static const HKDF_TestTuple testSet[] =
{
// Test Case #4
{"0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "085a01ea1b10f36933068b56efa5ad81 a4f14b822f5b091568a9cdd4f155fda2 c22e422478d305f3f896", 42},
// Test Case #5
{"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "0bd770a74d1160f7c9f12cd5912a06eb ff6adcae899d92191fe4305673ba2ffe 8fa3f1a4e5ad79f3f334b3b202b2173c 486ea37ce3d397ed034c7f9dfeb15c5e 927336d0441f4c4300e2cff0d0900b52 d3b4", 82},
// Test Case #6
{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", NULL, NULL, "0ac1af7002b3d761d1e55298da9d0506 b9ae52057220a306e07b6b87e8df21d0 ea00033de03984d34918", 42}
};
HKDF<SHA1> hkdf;
cout << "\nRFC 5869 HKDF(SHA-1) validation suite running...\n\n";
pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass;
}
{
// SHA-256 from RFC 5869, Appendix A, https://tools.ietf.org/html/rfc5869
static const HKDF_TestTuple testSet[] =
{
// Test Case #1
{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "3cb25f25faacd57a90434f64d0362f2a 2d2d0a90cf1a5a4c5db02d56ecc4c5bf 34007208d5b887185865", 42},
// Test Case #2
{"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "b11e398dc80327a1c8e7f78c596a4934 4f012eda2d4efad8a050cc4c19afa97c 59045a99cac7827271cb41c65e590e09 da3275600c2f09b8367793a9aca3db71 cc30c58179ec3e87c14c01d5c1f3434f 1d87", 82},
// Test Case #3
{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", NULL, NULL, "8da4e775a563c18f715f802a063c5a31 b8a11f5c5ee1879ec3454e5f3c738d2d 9d201395faa4b61a96c8", 42}
};
HKDF<SHA256> hkdf;
cout << "\nRFC 5869 HKDF(SHA-256) validation suite running...\n\n";
pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass;
}
{
// SHA-512 based on RFC 5869, https://tools.ietf.org/html/rfc5869
static const HKDF_TestTuple testSet[] =
{
// Test Case #0
{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "000102030405060708090a0b0c", "f0f1f2f3f4f5f6f7f8f9", "832390086CDA71FB47625BB5CEB168E4 C8E26A1A16ED34D9FC7FE92C14815793 38DA362CB8D9F925D7CB", 42},
// Test Case #0
{"000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f", "606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f 808182838485868788898a8b8c8d8e8f 909192939495969798999a9b9c9d9e9f a0a1a2a3a4a5a6a7a8a9aaabacadaeaf", "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf c0c1c2c3c4c5c6c7c8c9cacbcccdcecf d0d1d2d3d4d5d6d7d8d9dadbdcdddedf e0e1e2e3e4e5e6e7e8e9eaebecedeeef f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "CE6C97192805B346E6161E821ED16567 3B84F400A2B514B2FE23D84CD189DDF1 B695B48CBD1C8388441137B3CE28F16A A64BA33BA466B24DF6CFCB021ECFF235 F6A2056CE3AF1DE44D572097A8505D9E 7A93", 82},
// Test Case #0
{"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", NULL, NULL, "F5FA02B18298A72A8C23898A8703472C 6EB179DC204C03425C970E3B164BF90F FF22D04836D0E2343BAC", 42}
};
HKDF<SHA512> hkdf;
cout << "\nRFC 5869 HKDF(SHA-512) validation suite running...\n\n";
pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass;
}
return pass;
}
示例11: ValidateRIPEMD
bool ValidateRIPEMD()
{
static const HashTestTuple testSet128[] =
{
HashTestTuple("", "\xcd\xf2\x62\x13\xa1\x50\xdc\x3e\xcb\x61\x0f\x18\xf6\xb3\x8b\x46"),
HashTestTuple("a", "\x86\xbe\x7a\xfa\x33\x9d\x0f\xc7\xcf\xc7\x85\xe7\x2f\x57\x8d\x33"),
HashTestTuple("abc", "\xc1\x4a\x12\x19\x9c\x66\xe4\xba\x84\x63\x6b\x0f\x69\x14\x4c\x77"),
HashTestTuple("message digest", "\x9e\x32\x7b\x3d\x6e\x52\x30\x62\xaf\xc1\x13\x2d\x7d\xf9\xd1\xb8"),
HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xfd\x2a\xa6\x07\xf7\x1d\xc8\xf5\x10\x71\x49\x22\xb3\x71\x83\x4e"),
HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\xa1\xaa\x06\x89\xd0\xfa\xfa\x2d\xdc\x22\xe8\x8b\x49\x13\x3a\x06"),
HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xd1\xe9\x59\xeb\x17\x9c\x91\x1f\xae\xa4\x62\x4c\x60\xc5\xc7\x02"),
HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x3f\x45\xef\x19\x47\x32\xc2\xdb\xb2\xc4\xa2\xc7\x69\x79\x5f\xa3"),
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x4a\x7f\x57\x23\xf9\x54\xeb\xa1\x21\x6c\x9d\x8f\x63\x20\x43\x1f", 15625)
};
static const HashTestTuple testSet160[] =
{
HashTestTuple("", "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31"),
HashTestTuple("a", "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe"),
HashTestTuple("abc", "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc"),
HashTestTuple("message digest", "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36"),
HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc"),
HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc\xf4\x9a\xda\x62\xeb\x2b"),
HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89"),
HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb"),
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\x52\x78\x32\x43\xc1\x69\x7b\xdb\xe1\x6d\x37\xf9\x7f\x68\xf0\x83\x25\xdc\x15\x28", 15625)
};
static const HashTestTuple testSet256[] =
{
HashTestTuple("", "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18\x77\xfc\x52\xd6\x4d\x30\xe3\x7a\x2d\x97\x74\xfb\x1e\x5d\x02\x63\x80\xae\x01\x68\xe3\xc5\x52\x2d"),
HashTestTuple("a", "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9\x0a\x91\xba\xb7\x0a\x1e\xba\x0c\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf\xcd\x88\x3a\x91\x34\x69\x29\x25"),
HashTestTuple("abc", "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb\xce\xf5\xca\x2d\x03\xe6\xdb\xa1\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e\x1e\x42\xd2\xe9\x75\x45\x9b\x65"),
HashTestTuple("message digest", "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a\x51\x4d\x5c\x91\x4c\x39\x2c\x90\x18\xc7\xc4\x6b\xc1\x44\x65\x55\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e"),
HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\x64\x9d\x30\x34\x75\x1e\xa2\x16\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc\x78\x96\x11\x8a\x51\x97\x96\x87\x82\xdd\x1f\xd9\x7d\x8d\x51\x33"),
HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\x38\x43\x04\x55\x83\xaa\xc6\xc8\xc8\xd9\x12\x85\x73\xe7\xa9\x80\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f"),
HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\x57\x40\xa4\x08\xac\x16\xb7\x20\xb8\x44\x24\xae\x93\x1c\xbb\x1f\xe3\x63\xd1\xd0\xbf\x40\x17\xf1\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8"),
HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x06\xfd\xcc\x7a\x40\x95\x48\xaa\xf9\x13\x68\xc0\x6a\x62\x75\xb5\x53\xe3\xf0\x99\xbf\x0e\xa4\xed\xfd\x67\x78\xdf\x89\xa8\x90\xdd"),
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\xac\x95\x37\x44\xe1\x0e\x31\x51\x4c\x15\x0d\x4d\x8d\x7b\x67\x73\x42\xe3\x33\x99\x78\x82\x96\xe4\x3a\xe4\x85\x0c\xe4\xf9\x79\x78", 15625)
};
static const HashTestTuple testSet320[] =
{
HashTestTuple("", "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8"),
HashTestTuple("a", "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d"),
HashTestTuple("abc", "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d"),
HashTestTuple("message digest", "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97"),
HashTestTuple("abcdefghijklmnopqrstuvwxyz", "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09"),
HashTestTuple("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac"),
HashTestTuple("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4"),
HashTestTuple("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42"),
HashTestTuple("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "\xbd\xee\x37\xf4\x37\x1e\x20\x64\x6b\x8b\x0d\x86\x2d\xda\x16\x29\x2a\xe3\x6f\x40\x96\x5e\x8c\x85\x09\xe6\x3d\x1d\xbd\xde\xcc\x50\x3e\x2b\x63\xeb\x92\x45\xbb\x66", 15625)
};
bool pass = true;
cout << "\nRIPEMD-128 validation suite running...\n\n";
RIPEMD128 md128;
pass = HashModuleTest(md128, testSet128, COUNTOF(testSet128)) && pass;
cout << "\nRIPEMD-160 validation suite running...\n\n";
RIPEMD160 md160;
pass = HashModuleTest(md160, testSet160, COUNTOF(testSet160)) && pass;
cout << "\nRIPEMD-256 validation suite running...\n\n";
RIPEMD256 md256;
pass = HashModuleTest(md256, testSet256, COUNTOF(testSet256)) && pass;
cout << "\nRIPEMD-320 validation suite running...\n\n";
RIPEMD320 md320;
pass = HashModuleTest(md320, testSet320, COUNTOF(testSet320)) && pass;
return pass;
}
示例12: InitLogging
VOID InitLogging()
{
STATIC_CONTRACT_NOTHROW;
// <TODO>FIX bit of a workaround for now, check for the log file in the
// registry and if there, turn on file logging VPM</TODO>
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogEnable, LOG_ENABLE);
LogFacilityMask = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogFacility, LogFacilityMask) | LF_ALWAYS;
LogVMLevel = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::EXTERNAL_LogLevel, LogVMLevel);
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogFileAppend, LOG_ENABLE_APPEND_FILE);
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogFlushFile, LOG_ENABLE_FLUSH_FILE);
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToDebugger, LOG_ENABLE_DEBUGGER_LOGGING);
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToFile, LOG_ENABLE_FILE_LOGGING);
LogFlags |= REGUTIL::GetConfigFlag_DontUse_(CLRConfig::INTERNAL_LogToConsole, LOG_ENABLE_CONSOLE_LOGGING);
LogFacilityMask2 = REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogFacility2, LogFacilityMask2) | LF_ALWAYS;
LPWSTR fileName = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_LogFile);
if (fileName != 0)
{
int ret;
ret = WszWideCharToMultiByte(CP_ACP, 0, fileName, -1, szLogFileName, sizeof(szLogFileName)-1, NULL, NULL);
_ASSERTE(ret != 0);
delete fileName;
}
if (REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_LogWithPid, FALSE))
{
char szPid[20];
sprintf_s(szPid, COUNTOF(szPid), ".%d", GetCurrentProcessId());
strcat_s(szLogFileName, _countof(szLogFileName), szPid);
}
if ((LogFlags & LOG_ENABLE) &&
(LogFlags & LOG_ENABLE_FILE_LOGGING) &&
(LogFileHandle == INVALID_HANDLE_VALUE))
{
DWORD fdwCreate = (LogFlags & LOG_ENABLE_APPEND_FILE) ? OPEN_ALWAYS : CREATE_ALWAYS;
LogFileHandle = CreateFileA(
szLogFileName,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
fdwCreate,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | ((LogFlags & LOG_ENABLE_FLUSH_FILE) ? FILE_FLAG_WRITE_THROUGH : 0),
NULL);
if(0 == LogFileMutex)
{
LogFileMutex = ClrCreateMutex(
NULL,
FALSE,
NULL);
_ASSERTE(LogFileMutex != 0);
}
// Some other logging may be going on, try again with another file name
if (LogFileHandle == INVALID_HANDLE_VALUE)
{
char* ptr = szLogFileName + strlen(szLogFileName) + 1;
ptr[-1] = '.';
ptr[0] = '0';
ptr[1] = 0;
for(int i = 0; i < 10; i++)
{
LogFileHandle = CreateFileA(
szLogFileName,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
fdwCreate,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | ((LogFlags & LOG_ENABLE_FLUSH_FILE) ? FILE_FLAG_WRITE_THROUGH : 0),
NULL);
if (LogFileHandle != INVALID_HANDLE_VALUE)
break;
*ptr = *ptr + 1;
}
if (LogFileHandle == INVALID_HANDLE_VALUE) {
DWORD written;
char buff[MAX_PATH+60];
strcpy(buff, "Could not open log file, logging to ");
strcat_s(buff, _countof(buff), szLogFileName);
// ARULM--Changed WriteConsoleA to WriteFile to be CE compat
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buff, (DWORD)strlen(buff), &written, 0);
}
}
if (LogFileHandle == INVALID_HANDLE_VALUE)
UtilMessageBoxNonLocalized(NULL, W("Could not open log file"), W("CLR logging"), MB_OK | MB_ICONINFORMATION, FALSE, TRUE);
if (LogFileHandle != INVALID_HANDLE_VALUE)
{
if (LogFlags & LOG_ENABLE_APPEND_FILE)
SetFilePointer(LogFileHandle, 0, NULL, FILE_END);
LogSpew( LF_ALWAYS, FATALERROR, "************************ New Output *****************\n" );
}
}
}
示例13: Str_MakeFilePath
bool CTaksiConfig::WriteIniFile()
{
// RETURN: true = success
// false = cant save!
//
char* pFileOld = NULL;
DWORD nSizeOld = 0;
TCHAR szIniFileName[_MAX_PATH];
Str_MakeFilePath( szIniFileName, COUNTOF(szIniFileName),
sg_Shared.m_szIniDir, _T(TAKSI_INI_FILE) );
// first read all lines
CNTHandle FileOld( ::CreateFile( szIniFileName,
GENERIC_READ, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ));
if ( FileOld.IsValidHandle())
{
nSizeOld = ::GetFileSize(FileOld, NULL);
pFileOld = (char*) ::HeapAlloc( g_Proc.m_hHeap, HEAP_ZERO_MEMORY, nSizeOld);
if (pFileOld == NULL)
return false;
DWORD dwBytesRead = 0;
::ReadFile(FileOld, pFileOld, nSizeOld, &dwBytesRead, NULL);
if (dwBytesRead != nSizeOld)
{
::HeapFree( g_Proc.m_hHeap, 0, pFileOld );
return false;
}
FileOld.CloseHandle();
}
// create new file
FILE* pFile = fopen( TAKSI_INI_FILE, "wt");
if ( pFile == NULL )
return false;
// loop over every line from the old file, and overwrite it in the new file
// if necessary. Otherwise - copy the old line.
CIniObject* pObj = NULL;
char* pszLine = pFileOld;
if (pFileOld)
while (true)
{
if ( pszLine >= pFileOld + nSizeOld )
break;
if ( *pszLine == '[' )
{
if ( pObj ) // finish previous section.
{
pObj->PropsWrite(pFile);
}
if ( ! strnicmp( pszLine, "[" TAKSI_SECTION "]", sizeof(TAKSI_SECTION)+1 ))
{
pObj = this;
}
else if ( ! strnicmp( pszLine, "[" TAKSI_CUSTOM_SECTION " ", sizeof(TAKSI_CUSTOM_SECTION)+1 ))
{
TCHAR szSection[ _MAX_PATH ];
#ifdef _UNICODE
ASSERT(0);
#else
strncpy( szSection, pszLine+14, sizeof(szSection));
#endif
TCHAR* pszEnd = _tcschr(szSection, ']');
if (pszEnd)
*pszEnd = '\0';
pObj = CustomConfig_FindAppId(szSection);
}
else
{
pObj = NULL;
}
}
char* pszEndLine = strchr(pszLine, '\n' ); // INI_CR
if (pszEndLine)
{
// covers \n or \r\n
char* pszTmp = pszEndLine;
for ( ; pszTmp >= pszLine && Str_IsSpace(*pszTmp); pszTmp-- )
pszTmp[0] = '\0';
pszEndLine++;
}
// it's a custom setting.
bool bReplaced;
if (pObj)
{
bReplaced = pObj->PropWriteName( pFile, pszLine );
}
else
{
bReplaced = false;
}
if (!bReplaced)
//.........这里部分代码省略.........
示例14: switch
INT_PTR
CALLBACK
CProgressDlg::DialogProc(
HWND hDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
// Retrieve and store the "this" pointer
CProgressDlg *that = (CProgressDlg *) lParam;
SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR) that);
that->m_hDlg = hDlg;
// Initialize progress bar to the range 0 to 100
SendDlgItemMessage(hDlg, IDC_PROGRESS_BAR, PBM_SETRANGE32, (WPARAM) 0, (LPARAM) 100);
// Signal the main thread that we are ready
SetEvent(that->m_hInitDlg);
return TRUE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDCANCEL:
{
// If the user presses the cancel button, set the m_bCancelled flag.
CProgressDlg *that = (CProgressDlg *) GetWindowLongPtr(hDlg, DWLP_USER);
InterlockedIncrement(&that->m_bCancelled);
// The cancel operation will probably take some time, so
// change the cancel button text to "wait...", so that
// the user will see the cancel command is received and
// is being processed
TCHAR szWait[DEFAULT_STRING_SIZE] = _T("...");
LoadString(g_hInstance, IDS_WAIT, szWait, COUNTOF(szWait));
SetDlgItemText(hDlg, IDCANCEL, szWait);
return TRUE;
}
}
break;
}
}
return FALSE;
}
示例15: ADDTOCALLSTACK
//.........这里部分代码省略.........
{
sVal.FormatHex( idTile );
return true;
}
else if ( strnicmp( pszKey, "MULTI", 5 ) == 0 )
{
pszKey += 5;
if (*pszKey != '\0')
{
SKIP_SEPARATORS(pszKey);
return pItem->r_WriteVal( pszKey, sVal, &g_Serv );
}
sVal.FormatHex( pItem->GetUID() );
return true;
}
else if ( strnicmp( pszKey, "Z", 1 ) == 0 )
{
sVal.FormatVal( pItem->GetTopZ() + pMultiItem->m_dz );
return true;
}
// Check the script def for the item.
CItemBase * pItemDef = CItemBase::FindItemBase( idTile );
if ( pItemDef == NULL )
{
DEBUG_ERR(("Must have ITEMDEF section for item ID 0%x\n", idTile ));
return false;
}
return pItemDef->r_WriteVal( pszKey, sVal, &g_Serv );
}
int index = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1 );
if ( index < 0 )
return false;
switch ( index )
{
case PT_M:
case PT_MAP:
sVal.FormatVal(m_map);
break;
case PT_X:
sVal.FormatVal(m_x);
break;
case PT_Y:
sVal.FormatVal(m_y);
break;
case PT_Z:
sVal.FormatVal(m_z);
break;
case PT_ISNEARTYPE:
{
pszKey += 10;
SKIP_SEPARATORS( pszKey );
SKIP_ARGSEP( pszKey );
int iType = g_Cfg.ResourceGetIndexType( RES_TYPEDEF, pszKey );
int iDistance = 0;
bool bCheckMulti = false;
SKIP_IDENTIFIERSTRING( pszKey );
SKIP_SEPARATORS( pszKey );
SKIP_ARGSEP( pszKey );