本文整理汇总了C++中Trace函数的典型用法代码示例。如果您正苦于以下问题:C++ Trace函数的具体用法?C++ Trace怎么用?C++ Trace使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Trace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if( StartTestsEvHandle == NULL )
{
Fail("Error:%d: Unexpected failure "
"to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT );
}
hMutexHandle = CreateMutex(
NULL,
FALSE, /* bInitialOwner, owns initially */
ObjName
);
if( (hMutexHandle == NULL)|| (GetLastError() != ERROR_ALREADY_EXISTS))
{
Fail("Unable to create Mutex handle for process id [%d], returned error [%d], expected ERROR_ALREADY_EXISTS\n", i, GetLastError());
}
/* We already assume that the mutex was created previously*/
for( i = 0; i < THREAD_COUNT; i++ )
{
dwParam = (int) i;
//Create thread
hThread[i] = CreateThread(
NULL, /* no security attributes */
0, /* use default stack size */
(LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */
(LPVOID)dwParam, /* argument to thread function */
0, /* use default creation flags */
&threadId[i] /* returns the thread identifier*/
);
if(hThread[i] == NULL)
{
Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError());
}
}
if (!SetEvent(StartTestsEvHandle))
{
Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError());
}
/* Test running */
returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE);
if( WAIT_OBJECT_0 != returnCode )
{
Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError());
testStatus = FAIL;
}
processStats.operationTime = GetTimeDiff(dwStartTime);
/* Write to a file*/
if(pFile!= NULL)
{
for( i = 0; i < THREAD_COUNT; i++ )
{
buffer = (struct statistics *)resultBuffer->getResultBuffer(i);
returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId );
// Trace("Iteration %d over\n", i);
}
}
fclose(pFile);
fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId );
fclose(pProcessFile);
/* Logging for the test case over, clean up the handles */
// Trace("Process Count %d over\n",USE_PROCESS_COUNT);
for( i = 0; i < THREAD_COUNT; i++ )
{
if(!CloseHandle(hThread[i]) )
{
Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i);
testStatus = FAIL;
}
}
if(!CloseHandle(StartTestsEvHandle))
{
Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT);
testStatus = FAIL;
}
if(!CloseHandle(hMutexHandle))
{
Trace("Error:%d: CloseHandle failed for Process [%d] hMutexHandle\n", GetLastError(), USE_PROCESS_COUNT);
testStatus = FAIL;
}
PAL_Terminate();
return testStatus;
}
示例2: At
void At(char * text)
{
#ifdef TRACE
Trace("At", text);
#endif
}
示例3: Exit
void Exit(char * text)
{
#ifdef TRACE_ENTER
Trace("Exit", text);
#endif
}
示例4: startThread
void* startThread(void* arg)
{
/*
SELECT W.PageID,PageType,URL,ResetCookies,AuthUser,AuthPass,DownloadThreshold,HackingString,ResetCache,ServiceType,SecurityID,WPS.CurrentErrorRef,WPS.AlertCount,AlertLevel2Count,AlertLevel3Count,WPS.ErrorStatus,W.Status,W.IgnoreRudeWords,W.CustomerNo,W.HTTPMethod,W.IgnoreContentErrors,W.DownloadSpeed,W.Referer,W.StoreResultDetail,W.MinSize,W.MaxSize,C.AlertCount,W.CertID,W.StepName,W.AgentString,W.sm_processScript,WPS.OverallAlertCount,W.StoreRequest,W.StoreHeaders,W.StoreHTML,W.StoreDiag,W.ContentType,W.Header1,W.Header2,W.GzipEncoding from WebPage W, Customer C, WebPageStatus WPS where W.PageID=13714 and WPS.PageID=W.PageID and W.CustomerNo=C.CustomerNo and (W.Status=1 or W.Status=3)
select VariableName, VariableValue, Encode from FormVariables where PageID=13714 order by OrderNo asc
SELECT Phrase, ID from ContentError
SELECT Word, ID from ObsceneWord
SELECT Phrase, ErrorCode from WebPagePhrase where PageID=13714 order by PhraseOrder
select CookieValue, CookieDomain from Cookies where PageID=13714
select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=0
select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=1
select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=2
INSERT INTO ResultHeader040303 (ResultID,PageID,TestServer,StartDateTime,ResultCode,DNSTime,FirstByteTime,CompleteTime,TotalBytes,RunID,BatchID,FirstDataTime) VALUES (0,13714,10,'2004-03-03 14:39:20',1,8,9,5309,25291,0,0,15)
SELECT LAST_INSERT_ID() from ResultHeader040303 where ResultID=LAST_INSERT_ID()
INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:20',0,8,9,15,892,200,4338,'http://192.168.1.5',1)
INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1012,1,1,7,4188,200,6543,'http://192.168.1.5/g/p10.png',2)
INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1025,0,2,3,4185,200,12237,'http://192.168.1.5/g/MYSQLAuthCSP_small.png',3)
INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1008,1,2,6,4301,200,2173,'http://192.168.1.5/g/newlogo.png',4)
SELECT PageID from WebPageStatus where PageID=13714
UPDATE WebPageStatus set LastResultID=40,StartDateTime='2004-03-03 14:39:20',LastResultCode=1,CompleteTime=5309 where PageID=13714
SELECT WS.ErrorStatus,WS.CurrentErrorRef,WS.AlertCount,C.AlertLevel2Count,C.AlertLevel3Count,C.AlertCount,W.OverallAlertCount from Customer C, WebPage W, WebPageStatus WS WHERE C.CustomerNo=W.CustomerNo and W.PageID=WS.PageID and W.PageID=13714
UPDATE WebPageStatus SET ErrorStatus=0,CurrentErrorRef=0,AlertCount=0 WHERE PageID=13714
UPDATE WebPageStatus SET OverallAlertCount=0 WHERE PageID=13714
select ErrorRef from WebPageError where PageID=13714 and Status<>2
*/
mysql_thread_init();
Connection* connection;
Result* result;
char query[10240];
for (int repNo = 0; repNo < numRepsPerThreads; ++repNo)
{
try
{
Trace("Connecting to db", "", repNo);
connection = new Connection(CConfig::getDBServer(), CConfig::getDBDatabase(),
CConfig::getDBUser(), CConfig::getDBPass(), CConfig::getDBRetryTime());
// run all the queries here...
result = connection->Query("SELECT W.PageID,PageType,URL,ResetCookies,AuthUser,AuthPass,DownloadThreshold,HackingString,ResetCache,ServiceType,SecurityID,WPS.CurrentErrorRef,WPS.AlertCount,AlertLevel2Count,AlertLevel3Count,WPS.ErrorStatus,W.Status,W.IgnoreRudeWords,W.CustomerNo,W.HTTPMethod,W.IgnoreContentErrors,W.DownloadSpeed,W.Referer,W.StoreResultDetail,W.MinSize,W.MaxSize,C.AlertCount,W.CertID,W.StepName,W.AgentString,W.sm_processScript,WPS.OverallAlertCount,W.StoreRequest,W.StoreHeaders,W.StoreHTML,W.StoreDiag,W.ContentType,W.Header1,W.Header2,W.GzipEncoding from WebPage W, Customer C, WebPageStatus WPS where W.PageID=13714 and WPS.PageID=W.PageID and W.CustomerNo=C.CustomerNo and (W.Status=1 or W.Status=3)");
result = connection->Query("select VariableName, VariableValue, Encode from FormVariables where PageID=13714 order by OrderNo asc");
result = connection->Query("SELECT Phrase, ID from ContentError");
result = connection->Query("SELECT Word, ID from ObsceneWord");
result = connection->Query("SELECT Phrase, ErrorCode from WebPagePhrase where PageID=13714 order by PhraseOrder");
result = connection->Query("select CookieValue, CookieDomain from Cookies where PageID=13714");
result = connection->Query("select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=0");
result = connection->Query("select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=1");
result = connection->Query("select URL, RequiredText from WebPageExtraFiles where PageID=13714 and Type=2");
// close the db connection
connection->Close();
delete connection;
connection = NULL;
Trace("Disonnected from db", "", repNo);
Trace("Connecting to db", "", repNo);
connection = new Connection(CConfig::getDBServer(), CConfig::getDBDatabase(),
CConfig::getDBUser(), CConfig::getDBPass(), CConfig::getDBRetryTime());
result = connection->Query("INSERT INTO ResultHeader040303 (ResultID,PageID,TestServer,StartDateTime,ResultCode,DNSTime,FirstByteTime,CompleteTime,TotalBytes,RunID,BatchID,FirstDataTime) VALUES (0,13714,10,'2004-03-03 14:39:20',1,8,9,5309,25291,0,0,15)");
result = connection->Query("SELECT LAST_INSERT_ID() from ResultHeader040303 where ResultID=LAST_INSERT_ID()");
result = connection->Query("INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:20',0,8,9,15,892,200,4338,'http://192.168.1.5',1)");
result = connection->Query("INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1012,1,1,7,4188,200,6543,'http://192.168.1.5/g/p10.png',2)");
result = connection->Query("INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1025,0,2,3,4185,200,12237,'http://192.168.1.5/g/MYSQLAuthCSP_small.png',3)");
result = connection->Query("INSERT INTO ResultDetail040303 (ResultID,StartDateTime,StartOffset,DNSTime,FirstByteTime,FirstDataTime,CompleteTime,ResultCode,TotalBytes,FileName,ComponentNo) VALUES (40,'2004-03-03 14:39:21',1008,1,2,6,4301,200,2173,'http://192.168.1.5/g/newlogo.png',4)");
result = connection->Query("SELECT PageID from WebPageStatus where PageID=13714");
result = connection->Query("UPDATE WebPageStatus set LastResultID=40,StartDateTime='2004-03-03 14:39:20',LastResultCode=1,CompleteTime=5309 where PageID=13714");
result = connection->Query("SELECT WS.ErrorStatus,WS.CurrentErrorRef,WS.AlertCount,C.AlertLevel2Count,C.AlertLevel3Count,C.AlertCount,W.OverallAlertCount from Customer C, WebPage W, WebPageStatus WS WHERE C.CustomerNo=W.CustomerNo and W.PageID=WS.PageID and W.PageID=13714");
result = connection->Query("UPDATE WebPageStatus SET ErrorStatus=0,CurrentErrorRef=0,AlertCount=0 WHERE PageID=13714");
result = connection->Query("UPDATE WebPageStatus SET OverallAlertCount=0 WHERE PageID=13714");
result = connection->Query("select ErrorRef from WebPageError where PageID=13714 and Status<>2");
// close the db connection
connection->Close();
delete connection;
connection = NULL;
Trace("Disonnected from db", "", repNo);
}
catch (const std::exception &e)
{
printf("Exception caught: - %s\r\n", e.what());
// all done - exit the thread
// pthread_exit(NULL);
}
Trace("Sleeping", "", 100 * sleepTime);
usleep(100 * sleepTime);
}
mysql_thread_end();
// all done - exit the thread
pthread_exit(NULL);
Trace("After Thread end", "", 0);
}
示例5: Direct3DCreate9
bool nGraphics::InitGraphics()
{
// Create our base direct3d object
m_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION);
if(!m_pDirect3D)
{
nMainFrame::LastError("Failed to create direct3d 9, directx 9 not installed?");
return TraceRet(__FUNCTION__" Failed to create direct3d 9, directx 9 not installed?\n",false);
}
// Check if the device support's the caps we will use
if(!ValidateDevice())
return false;
// Get the desktop's display mode
D3DDISPLAYMODE displayMode;
if(FAILED(m_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode)))
{
nMainFrame::LastError("Failed to get current display adapter mode.");
return TraceRet(__FUNCTION__" Failed to get current display adapter mode.\n",false);
}
// The struct that describes our direct3d device
ZeroMemory(&m_PresentParameters,sizeof(m_PresentParameters));
m_Fullscreen = !nGetInstance()->GetCommandLineVar("-windowed",SETTINGS_WINDOWED).asBool();
m_PresentParameters.Windowed = !m_Fullscreen;
m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_PresentParameters.BackBufferFormat = D3DFMT_X8R8G8B8;
m_PresentParameters.EnableAutoDepthStencil = TRUE;
m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8;
// Check if we should use fsaa
if(nGetInstance()->GetCommandLineVar("-fsaa",SETTINGS_FSAA).asBool())
{
unsigned long samples = 0;
// Check if multisampling is supported and enable it if it is
if(SUCCEEDED(m_pDirect3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_PresentParameters.BackBufferFormat,!m_Fullscreen,D3DMULTISAMPLE_NONMASKABLE,&samples)))
{
m_PresentParameters.MultiSampleQuality = samples-1;
m_PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
Trace(__FUNCTION__" Using %dx multisampling.\n",samples-1);
}
}
// Check if we should display in fullscreen
if(m_Fullscreen)
{
m_PresentParameters.BackBufferWidth = displayMode.Width;
m_PresentParameters.BackBufferHeight = displayMode.Height;
}
else
{
nRect rect;
GetClientRect(nGetInstance()->GetWindowHandle(),(LPRECT)&rect);
m_PresentParameters.BackBufferWidth = rect.GetWidth();
m_PresentParameters.BackBufferHeight = rect.GetHeight();
}
// Check if we shouldn't use vsync
if(!nGetInstance()->GetCommandLineVar("-vsync",SETTINGS_VSYNC).asBool())
m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
Trace(__FUNCTION__" Display mode %dx%d.\n",m_PresentParameters.BackBufferWidth,m_PresentParameters.BackBufferHeight);
// Now create our direct3d device from the base direct3d object
HRESULT hr = m_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,nGetInstance()->GetWindowHandle(),D3DCREATE_SOFTWARE_VERTEXPROCESSING,&m_PresentParameters,&m_pDevice);
if(FAILED(hr))
return TraceRet(__FUNCTION__" Failed to create the device.\n",false);
// Turn on color dithering
hr = m_pDevice->SetRenderState(D3DRS_DITHERENABLE,TRUE);
if(FAILED(hr))
Trace(__FUNCTION__" Display adapter doesn't support color dithering, using default.\n");
// Turn off culling
m_pDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
// Enable anisotropic filtering if fsaa is enabled
//if(flags & RECFLAG_FSAA)
// EnableAnisotropic(m_p3DDevice);
// Create our line drawing object
hr = D3DXCreateLine(m_pDevice, &m_pLine);
if(FAILED(hr))
{
nMainFrame::LastError("Failed to create line drawing object.");
return TraceRet(__FUNCTION__" Failed to create line drawing object.\n",false);
}
// Don't use gl lines
m_pLine->SetGLLines(false);
// Init our font
hr = D3DXCreateFont(m_pDevice,SETTINGS_FONTHEIGHT,0,FW_BOLD,0,FALSE,DEFAULT_CHARSET,OUT_TT_PRECIS,6/*CLEARTYPE_QUALITY*/,DEFAULT_PITCH,SETTINGS_FONTNAME,&m_pFontBold);
if(FAILED(hr))
//.........这里部分代码省略.........
示例6: OnIccCheck
/*******************************************************************
�� ��: laijinhong
�� Ȩ: �����¹����ɷ�����˾
��������: IC�����
��ڲ���:
�� �� ֵ:
�� ע:
********************************************************************/
s32 OnIccCheck(ST_TRANSFLOW *pstTransFlow) {
u8 temp[256], IcStatus[8];
s32 ret = 0;
u16 len = 0;
#if 0
Trace("Lai","%%% IC card OnCheck\r\n");
sdkIccOpenIcDev();
SDK_ICC_PARAM stIccParam;
memset(&stIccParam,0,sizeof(stIccParam));
ret = sdkIccGetCardStatus(&stIccParam,5);
if(SDK_OK==ret)
{
Trace("Lai","11111111 IC1 in slot");
}
else
Trace("Lai","11111111 IC1 Not in slot %d\r\n",ret);
sdkIccCloseIcDev();
#endif
#if 1
memset(IcStatus, 0, sizeof(IcStatus));
memset(temp, 0, sizeof(temp));
sdkIccOpenIcDev();
ret = sdkIccIsIccCardIn(5, temp, &len);//IC��
if (SDK_OK == ret) {
TraceHex("Lai", "IC card in slot\r\n", temp, len);
IcStatus[0] = 0x01;
}
else if (SDK_TIME_OUT == ret) {
Trace("Lai", "$$$ IC card timeout\r\n");
}
#if 0 //del by sujianzhong 2015.01.13
SDK_ICC_PARAM stIccParam;
memset(temp, 0, sizeof(temp));
memset(&stIccParam, 0, sizeof(SDK_ICC_PARAM));
stIccParam.ucCardMode = SDK_ICC_ICC;
stIccParam.eCardType = SDK_ICC_PSAM;
stIccParam.ucCLType=0x01;
stIccParam.ucSlotNo = 1;//PSAM1
ret = sdkIccReset(&stIccParam, temp, &len);
if(SDK_OK==ret)
{
TraceHex("Lai","sdkIccReset psam1 ret ok \r\n",temp,len);
IcStatus[3] = 0x01;
}
else
{
Trace("Lai","sdkIccReset psam1 ret %d \r\n",ret);
}
memset(temp, 0, sizeof(temp));
stIccParam.ucSlotNo = 2;//PSAM2
ret = sdkIccReset(&stIccParam, temp, &len);
if(SDK_OK==ret)
{
TraceHex("Lai","psam2 ret ok \r\n",temp,len);
IcStatus[4] = 0x01;
}
else
{
Trace("Lai","psam2 not found ret %d \r\n",ret);
}
#endif
sdkIccOpenRfDev();//�ǽ�
u8 cardtype = SDK_ICC_RFCARD_A | SDK_ICC_RFCARD_B | SDK_ICC_RFCARD_FELICA | SDK_ICC_RFCARD_24G;
memset(temp, 0, sizeof(temp));
ret = sdkIccRFQuery(cardtype, temp, 10);
sdkIccCloseRfDev();
if (ret > 0) {
if (temp[0] == 0) {
Trace("Lai", "@@@ sdkIccRFQuery found RF ok, cardtype:%2x cardNum%d %d %d %d\r\n",
temp[2], temp[3], temp[4], temp[5], temp[6]);
IcStatus[6] = 0x01;
}
else if (temp[0] == 2) {
Trace("Lai", "@@@ sdkIccRFQuery no RF card \r\n");
}
}
else {
Trace("Lai", "@@@ sdkIccRFQuery ret %d \r\n", ret);
}
//.........这里部分代码省略.........
示例7: OnIccCommum
/*******************************************************************
�� ��: laijinhong
�� Ȩ: �����¹����ɷ�����˾
��������: IC��ͨѶ
��ڲ���:
�� �� ֵ:
�� ע:
********************************************************************/
s32 OnIccCommum(ST_TRANSFLOW *pstTransFlow) {
Trace("Lai", "OnCommum\r\n");
u8 cardType = pstTransFlow->heReceiveData[0];
u16 len;
u32 ret;
//u8 tmpBuf[100]={0};
//s32 outlen=0;
SDK_ICC_PARAM stIccParam;
u16 apdulen = 3;
sdkBcdToU16(&len, &pstTransFlow->heReceiveData[1], 2);
if (len + 3 != pstTransFlow->ReceiveDataLen) {
sdkBcdToU16(&len, &pstTransFlow->heReceiveData[2], 2);
apdulen = 4;
}
memset(&stIccParam, 0, sizeof(stIccParam));
stIccParam.ucCardMode = SDK_ICC_ICC;
stIccParam.ucCLType = 0x01;
bool isRfDev = false;
switch (cardType) {
case 0:
stIccParam.eCardType = SDK_ICC_CPU;// CPU���нӴ��ͷǽ�
stIccParam.ucSlotNo = 0;
break;
case 3:
stIccParam.eCardType = SDK_ICC_PSAM;
stIccParam.ucSlotNo = 1;
break;
case 4:
stIccParam.eCardType = SDK_ICC_PSAM;
stIccParam.ucSlotNo = 2;
break;
case 6:
isRfDev = true;
stIccParam.ucCardMode = SDK_ICC_RF;
stIccParam.eCardType = SDK_ICC_CPU;
break;
case 7:
isRfDev = true;
stIccParam.ucCardMode = SDK_ICC_RF;
stIccParam.eCardType = SDK_ICC_MIFARE;
break;
default:
return INS_PARAM_ERR;
}
#if 0
if(!isRfDev)
sdkIccOpenIcDev();
else
{
sdkIccOpenRfDev();
u8 cardtype = SDK_ICC_RFCARD_A | SDK_ICC_RFCARD_B | SDK_ICC_RFCARD_FELICA | SDK_ICC_RFCARD_24G;
memset(tmpBuf, 0, sizeof(tmpBuf));
ret = sdkIccRFQuery (cardtype, tmpBuf, 10 );
if(ret>0)
{
TraceHex("Lai","sdkIccRFQuery ret data:\r\n",tmpBuf,ret);
}
else
return INS_OTHER_ERR;
}
//��Ҫ��λ,������������������ж��ڵ�һ�βŸ�λ�?
//sdkIccResetIcc
ret = sdkIccResetIcc(&stIccParam, tmpBuf, &outlen);//sdkIccReset
if(ret!=SDK_OK)
{
Trace("Lai","$$$ sdkIccReset ret:%d\r\n",ret);
// if(!isRfDev)
// sdkIccCloseIcDev();
// else
// sdkIccCloseRfDev();
return INS_OTHER_ERR;
}
else
{
Trace("Lai","sdkIccReset ok..................\r\n");
}
#endif
u16 lenOut = 510;
u8 *pSend = &pstTransFlow->heReceiveData[0]; //0416Send==Recv
//.........这里部分代码省略.........
示例8: main
int __cdecl main(int argc, char *argv[])
{
HANDLE hFile = NULL;
DWORD dwBytesWritten;
const char* hugeStringTest =
"1234567890123456789012345678901234567890";
const char* szWritableFile = "writeable.txt";
int i =0;
if (0 != PAL_Initialize(argc,argv))
{
return FAIL;
}
/* create the test file */
hFile = CreateFile(szWritableFile,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
Fail("WriteFile: ERROR -> Unable to create file \"%s\".\n",
szWritableFile);
}
/* write 4000 000 chars to the file.*/
for (i=0; i<100000;i++)
{
if( WriteFile(hFile, /* HANDLE handle to file */
hugeStringTest, /* data buffer */
strlen(hugeStringTest), /* number of bytes to write */
&dwBytesWritten, /* number of bytes written */
NULL) /* overlapped buffer */
==0)
{
Trace("WriteFile: ERROR -> Unable to write to file error: %ld \n",
GetLastError());
CleanUp(hFile,szWritableFile);
Fail("");
}
}
if(!FlushFileBuffers(hFile))
{
Trace("WriteFile: ERROR -> Call to FlushFileBuffers failed"
"error %ld \n",GetLastError());
CleanUp(hFile,szWritableFile);
Fail("");
}
/* test if the size changed properly. */
if(GetFileSize(hFile,NULL) != 4000000)
{
Trace("WriteFile: ERROR -> file size did not change properly"
" after writing 4000 000 chars to it ( size= %u )\n",
GetFileSize(hFile,NULL));
CleanUp(hFile,szWritableFile);
Fail("");
}
if (!CleanUp(hFile,szWritableFile))
{
Fail("");
}
PAL_Terminate();
return PASS;
}
示例9: main
int __cdecl main(int argc, char *argv[])
{
WORD VersionRequested = MAKEWORD(2,2);
WSADATA WsaData;
SOCKET aSocket;
int err;
int socketID;
struct sockaddr_in mySockaddr;
struct sockaddr mySocketaddrConnect;
int nSocketaddrLength;
int nBacklogNumber = 1;
struct timeval waitTime;
fd_set readFds;
int socketFds;
/*Initialize the PAL environment*/
err = PAL_Initialize(argc, argv);
if(0 != err)
{
return FAIL;
}
/*initialize to use winsock2.dll*/
err = WSAStartup(VersionRequested,&WsaData);
if ( err != 0 )
{
Fail("\nFailed to find a usable WinSock DLL!\n");
}
/* Confirm that the WinSock DLL supports 2.2.*/
if ( LOBYTE( WsaData.wVersion ) != 2 ||
HIBYTE( WsaData.wVersion ) != 2 )
{
Trace("\nFailed to find a usable WinSock DLL!\n");
err = WSACleanup();
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call WSACleanup API!\n");
}
Fail("");
}
/*create a stream socket in AF_INET domain*/
socketID = socket(AF_INET,SOCK_STREAM,0);
if(INVALID_SOCKET == socketID)
{
Trace("\nFailed to call socket API to create a stream socket!\n");
err = WSACleanup();
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call WSACleanup API!\n");
}
Fail("");
}
// Wait for 5 seconds for the client to connect.
waitTime.tv_sec = 5L;
waitTime.tv_usec = 0L;
/*initialize the except socket set*/
FD_ZERO(&readFds);
/*prepare the sockaddr_in structure*/
mySockaddr.sin_family = AF_INET;
mySockaddr.sin_port = getRotorTestPort();
mySockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
memset( &(mySockaddr.sin_zero), 0, 8);
/*bind the local address to the created socket*/
err = bind(socketID, (struct sockaddr *)&mySockaddr,
sizeof(struct sockaddr));
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call bind API bind a socket with "
"local address!\n");
err = closesocket(socketID);
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call closesocket API!\n");
}
err = WSACleanup();
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call WSACleanup API!\n");
}
Fail("");
}
/*to setup the backlog number for a created socket*/
err = listen(socketID,nBacklogNumber);
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call listen API to set backlog number!\n");
err = closesocket(socketID);
if(SOCKET_ERROR == err)
{
Trace("\nFailed to call closesocket API!\n");
}
//.........这里部分代码省略.........
示例10: Trace
void NaClEventLoop::wait(const EventTrigger &trigger, EventCallback *callback)
{
Trace("NaClEventLoop.wait: callback=%p", callback);
trigger.completion.reset(&m_instance, callback);
}
示例11: main
/**
* main
*
* executable entry point
*/
INT __cdecl main(INT argc, CHAR **argv)
{
int i;
int err;
struct sockaddr_in mySockaddr;
WSADATA wsaData;
int byteCounter;
/* Sockets descriptor */
const int numSockets = 1; /* number of sockets used in this test */
SOCKET testSockets[1];
/* Variables for WSASend */
WSABUF wsaSendBuf;
DWORD dwNbrOfByteSent;
DWORD dwNbrOfBuf = 1;
DWORD dwSendFlags = 0;
unsigned char sendBuffer[255];
WSAOVERLAPPED wsaOverlapped;
/* Socket DLL version */
const WORD wVersionRequested = MAKEWORD(2,2);
HANDLE writeEvent;
DWORD waitResult;
/* Sockets initialization to INVALID_SOCKET */
for( i = 0; i < numSockets; i++ )
{
testSockets[i] = INVALID_SOCKET;
}
/* PAL initialization */
if( PAL_Initialize(argc, argv) != 0 )
{
return FAIL;
}
/* Initialize to use winsock2.dll */
err = WSAStartup( wVersionRequested,
&wsaData);
if(err != 0)
{
Fail( "ERROR: Unexpected failure: "
"WSAStartup(%i) "
"returned %d\n",
wVersionRequested,
GetLastError() );
}
/* Confirm that the WinSock DLL supports 2.2.
Note that if the DLL supports versions greater
than 2.2 in addition to 2.2, it will still return
2.2 in wVersion since that is the version we
requested.
*/
if ( wsaData.wVersion != wVersionRequested )
{
Trace("ERROR: Unexpected failure "
"to find a usable version of WinSock DLL\n");
/* Do some cleanup */
DoWSATestCleanup( 0, 0);
Fail("");
}
/* create an overlapped stream socket in AF_INET domain */
testSockets[0] = WSASocketA( AF_INET,
SOCK_STREAM,
IPPROTO_TCP,
NULL,
0,
WSA_FLAG_OVERLAPPED );
if( testSockets[0] == INVALID_SOCKET )
{
Trace("ERROR: Unexpected failure: "
"WSASocketA"
"(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,WSA_FLAG_OVERLAPPED)) "
" returned %d\n",
GetLastError());
//.........这里部分代码省略.........
示例12: main
int __cdecl main (int argc, char **argv)
{
HANDLE hThread = NULL;
int ret;
int i,j;
BOOL bResult = FAIL;
PAPCFUNC APCFuncs[] =
{
APCFuncA,
APCFuncB,
APCFuncC,
APCFuncD,
};
/* initialize the PAL */
if (0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
ResultPtr = ResultBuffer;
/* create a pair of synchronization events to coordinate our threads */
hSyncEvent1 = CreateEvent( NULL, FALSE, FALSE, NULL );
if( hSyncEvent1 == NULL )
{
Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() );
goto cleanup;
}
hSyncEvent2 = CreateEvent( NULL, FALSE, FALSE, NULL );
if( hSyncEvent2 == NULL )
{
Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() );
goto cleanup;
}
/* create a child thread which will call SleepEx */
hThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE)SleeperProc,
0,
0,
&ChildThread);
if( hThread == NULL )
{
Trace( "ERROR:%lu:CreateThread() call failed\n",
GetLastError());
goto cleanup;
}
/* wait on our synchronization event to ensure the thread is running */
ret = WaitForSingleObject( hSyncEvent1, 20000 );
if( ret != WAIT_OBJECT_0 )
{
Trace( "ERROR:WaitForSingleObject() returned %lu, "
"expected WAIT_OBJECT_0\n",
ret );
goto cleanup;
}
/* queue our user APC functions on the thread */
for (i=0; i<4; i++)
{
for (j=0; j<sizeof(APCFuncs)/sizeof(APCFuncs[0]); j++)
{
ret = QueueUserAPC(APCFuncs[j], hThread, '0' + i);
if (ret == 0)
{
Trace( "ERROR:%lu:QueueUserAPC() call failed\n",
GetLastError());
goto cleanup;
}
}
}
/* signal the child thread to continue */
if( ! SetEvent( hSyncEvent2 ) )
{
Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() );
goto cleanup;
}
/* wait on our synchronization event to ensure the other thread is done */
ret = WaitForSingleObject( hSyncEvent1, 20000 );
if( ret != WAIT_OBJECT_0 )
{
Trace( "ERROR:WaitForSingleObject() returned %lu, "
"expected WAIT_OBJECT_0\n",
ret );
goto cleanup;
}
/* check that the thread executed successfully */
//.........这里部分代码省略.........
示例13: Run_Thread
void PALAPI Run_Thread (LPVOID lpParam)
{
unsigned int i = 0;
DWORD dwWaitResult;
struct statistics stats;
DWORD dwStartTime;
stats.relationId = RELATION_ID;
stats.processId = USE_PROCESS_COUNT;
stats.operationsFailed = 0;
stats.operationsPassed = 0;
stats.operationsTotal = 0;
stats.operationTime = 0;
int Id=(int)lpParam;
dwWaitResult = WaitForSingleObject(
StartTestsEvHandle, // handle to mutex
TIMEOUT);
if(dwWaitResult != WAIT_OBJECT_0)
{
Trace("Error while waiting for StartTest [email protected] thread %d\n", Id);
testStatus = FAIL;
}
dwStartTime = GetTickCount();
for( i = 0; i < REPEAT_COUNT; i++ )
{
dwWaitResult = WaitForSingleObject(
hMutexHandle, // handle to mutex
TIMEOUT);
if(dwWaitResult != WAIT_OBJECT_0)
{
// Trace("Error while waiting for onject @ thread %d, # iter %d, Error Returned [%d]\n", Id, i, GetLastError());
stats.operationsFailed += 1;
stats.operationsTotal += 1;
testStatus = FAIL;
continue;
}
if (! ReleaseMutex(hMutexHandle))
{
// Deal with error.
// Trace("Error while releasing mutex @ thread %d # iter %d\n", Id, i);
stats.operationsFailed += 1;
stats.operationsTotal += 1;
// Probably need to have while true loop to attempt to release mutex...
testStatus = FAIL;
continue;
}
stats.operationsTotal += 1;
stats.operationsPassed += 1;
// Trace("Successs while releasing mutex @ iteration %d -> thread %d -> Process count %d\n", i, Id, USE_PROCESS_COUNT);
}
stats.operationTime = GetTimeDiff(dwStartTime);
if(resultBuffer->LogResult(Id, (char *)&stats))
{
Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT);
}
}
示例14: Trace
// Initialize our rendering device
int GLDriver::initialize(IWindow* pWindow)
{
HWND hwnd;
Trace("Initializing OpenGL graphics driver");
hwnd = static_cast< HWND > (pWindow->getWindowHandle());
// Create an OpenGL pixel format descriptor
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // Format Must Support OpenGL and double buffering
PFD_TYPE_RGBA, // Request An RGBA Format
pWindow->getBpp(), // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
// Initialise stuff, and check for errors
Trace("Acquiring device context");
if (!(hdc = GetDC(hwnd)))
CEngine::CriticalError("Unable to create GL device context!");
Trace("Finding pixel format");
if (!(pixelFormat = ChoosePixelFormat(hdc, &pfd)))
CEngine::CriticalError("Unable to find a pixel format!");
Trace("Setting pixel format");
if(!SetPixelFormat(hdc, pixelFormat, &pfd))
CEngine::CriticalError("Unable to set the pixel format!");
Trace("Acquiring rendering context");
if(!(hrc = wglCreateContext(hdc)))
CEngine::CriticalError("Unable to create GL rendering context!");
Trace("Setting current GL window");
if(!wglMakeCurrent(hdc, hrc))
CEngine::CriticalError("Unable to activate GL rendering context!");
resize(pWindow->getWidth(), pWindow->getHeight());
// Set up initial gl parameters
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0,0.0,0.0,0.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_TEXTURE_2D);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
// Grab GL vendor information
Trace("Getting OpenGL driver info ...");
char* str;
str = (char*)glGetString(GL_VENDOR);
vendor.assign(str);
Trace("OpenGL Vendor: %s", vendor.c_str());
str = (char*)glGetString(GL_RENDERER);
renderer.assign(str);
Trace("OpenGL Renderer: %s", renderer.c_str());
str = (char*)glGetString(GL_VERSION);
version.assign(str);
Trace("OpenGL Version: %s", version.c_str());
str = (char*)glGetString(GL_EXTENSIONS);
extensions.assign(str);
// Replace all spaces with newlines
for(int i = 0; i < extensions.length(); ++i)
{
if(extensions[i] == ' ')
extensions[i] = '\n';
}
// Acquire pointer to extension functions
// Multitexturing
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB");
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");
//.........这里部分代码省略.........
示例15: main
int __cdecl main(int argc, char *argv[])
{
LPVOID TestingPointer = NULL;
BOOL ResultValue = 0;
/*
* Initialize the PAL and return FAILURE if this fails
*/
if(0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
TestingPointer = malloc(MEMORY_AMOUNT);
if ( TestingPointer == NULL )
{
Fail("ERROR: Failed to allocate memory for TestingPointer pointer. "
"Can't properly exec test case without this.\n");
}
/* This should be readable, and return 0 */
ResultValue = IsBadReadPtr(TestingPointer,MEMORY_AMOUNT);
if(ResultValue != 0)
{
free(TestingPointer);
Fail("ERROR: The function returned %d instead of 0, when pointing "
"at readable memory.\n",ResultValue);
}
/* If we pass 0, the result should be 0 as well */
ResultValue = IsBadReadPtr(TestingPointer,0);
if(ResultValue != 0)
{
free(TestingPointer);
Fail("ERROR: The function returned %d instead of 0, when the "
"function was passed a range of 0 bytes.\n",ResultValue);
}
free(TestingPointer); /* we are done with this */
/* create a READABLE address */
TestingPointer = VirtualAlloc(
NULL, /* system selects address */
80, /* size of allocation*/
MEM_COMMIT, /* commit */
PAGE_READONLY); /* protection = read only */
if (TestingPointer == NULL )
{
Fail("ERROR: call to VirtualAlloc failed\n");
}
ResultValue = IsBadReadPtr(TestingPointer,16);
if(ResultValue != 0) /* if no access */
{
if(!VirtualFree(TestingPointer, 0, MEM_RELEASE))
{
Trace("ERROR: Call to VirtualFree failed with error"
" code[ %u ]\n",GetLastError());
}
Fail("ERROR: The function returned %d instead of 1 when checking "
"on unreadable memory.\n",ResultValue);
}
if(!VirtualFree(TestingPointer,0, MEM_RELEASE))
{
Fail("ERROR: Call to VirtualFree failed with error"
" code[ %u ]\n",GetLastError());
}
/* create an unreadable address */
TestingPointer = VirtualAlloc(
NULL, /* system selects address */
80, /* size of allocation */
MEM_COMMIT, /* commit */
PAGE_NOACCESS); /* protection = no access */
if (TestingPointer == NULL )
{
Fail("ERROR: call to VirtualAlloc failed\n");
}
ResultValue = IsBadReadPtr(TestingPointer,16);
if(ResultValue == 0) /* if access */
{
if(!VirtualFree(TestingPointer, 0, MEM_RELEASE))
{
Trace("ERROR: Call to VirtualFree failed with error"
" code[ %u ]\n",GetLastError());
}
Fail("ERROR: The function returned %d instead of 1 when checking "
"on unreadable memory.\n",ResultValue);
}
//.........这里部分代码省略.........