当前位置: 首页>>代码示例>>C++>>正文


C++ CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent方法代码示例

本文整理汇总了C++中CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent方法的具体用法?C++ CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent怎么用?C++ CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CK_FUNCTION_LIST_PTR的用法示例。


在下文中一共展示了CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EstEID_tokensChanged

int EstEID_tokensChanged() {
  LOG_LOCATION;
	CK_SLOT_ID slotID;
	int changed = FALSE;
	while (fl->C_WaitForSlotEvent(CKF_DONT_BLOCK, &slotID, NULL_PTR) == CKR_OK) {
    EstEID_log("C_WaitForSlotEvent() pass cycle 1");
		changed = TRUE;
	}
	if (!changed) {
		while (fl->C_WaitForSlotEvent(CKF_DONT_BLOCK, &slotID, NULL_PTR) == CKR_OK) {
      EstEID_log("C_WaitForSlotEvent() pass cycle 2");
			changed = TRUE;
		}
	}  
  EstEID_log("tokens change %sdetected", changed ? "" : "not ");
	return changed;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:17,代码来源:esteid_certinfo.c

示例2: WaitForCardEvent

CK_RV WaitForCardEvent(HWND hTextEdit, CK_FUNCTION_LIST_PTR functions, DWORD *pAutoFlags)
{
	CK_RV retVal = CKR_OK; 
	CK_FLAGS flags = 0;
	CK_SLOT_ID slotID;
	CK_SLOT_INFO slotInfo;
	CK_TOKEN_INFO tokenInfo;
	CK_ULONG ulPreviousCount = 0;
	CK_ULONG ulCount = 0;
	CK_ULONG ulCounter = 0;
	CK_SLOT_ID_PTR pSlotList;
	CK_ULONG_PTR pCardPresentList;
	//CK_BYTE_PTR pserialNumberList;
	//CK_ULONG_PTR pserialNumberLenList;
								//CK_ULONG certContextLen = 5;
	PCCERT_CONTEXT**	pCertContextArray;

	retVal = functions->C_GetSlotList(FALSE, NULL_PTR, &ulCount);
	ulPreviousCount = ulCount;
	pSlotList = (CK_SLOT_ID_PTR) malloc(ulCount*sizeof(CK_SLOT_ID));
	pCardPresentList = (CK_ULONG_PTR)malloc(ulCount*sizeof(CK_SLOT_ID));
	//pserialNumberList = (CK_BYTE*)malloc(ulCount*sizeof(CK_BYTE));
	//memset(pserialNumberList,0,ulCount*sizeof(CK_BYTE));
	//pserialNumberLenList = (CK_ULONG*)malloc(ulCount*sizeof(CK_ULONG));
	//allocate space for the array of certificate pointers per slot
	pCertContextArray = malloc(ulCount*sizeof(PCCERT_CONTEXT*));
	//initialize with zero's
	memset(pCertContextArray,0,ulCount*sizeof(PCCERT_CONTEXT*));

	if((pSlotList != NULL) &&(pCardPresentList != NULL) &&(pCertContextArray != NULL))
	{
		//retVal = functions->C_GetSlotList(FALSE, NULL_PTR, &ulCount);
		//if(retVal != CKR_OK){}
		if ((retVal == CKR_OK) && (ulCount > 0)) {
			SendMessage(hTextEdit, EM_REPLACESEL, 0, (LPARAM)"Readers found: \r\n");
			retVal = functions->C_GetSlotList(FALSE, pSlotList, &ulCount);
			if(retVal != CKR_OK){}

			//ulCount readers found, now fill in the certificate context array,
			//and register all certificates found
			while(ulCounter < ulCount)
			{
				/* Get slot information*/
				retVal = functions->C_GetSlotInfo(pSlotList[ulCounter], &slotInfo);
				if(retVal != CKR_OK){}
				else
				{
					slotInfo.slotDescription[63] = 0;
					//do not display the PnP slot
					if(strncmp(slotInfo.slotDescription,"\\\\?PnP?\\Notification",20) != 0)
					{
						SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"- ");
						SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)slotInfo.slotDescription);
						//SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"\r\n");

						/* Get token information*/
						retVal = functions->C_GetTokenInfo(pSlotList[ulCounter], &tokenInfo);
						if (retVal == CKR_TOKEN_NOT_PRESENT) {
							pCardPresentList[ulCounter] = 0;
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"  No Card Found \r\n");
						}
						else if (retVal==CKR_OK)
						{
							pCardPresentList[ulCounter] = 1;
							tokenInfo.label[31]=0;
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"  Card Found: ");
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)tokenInfo.label);
							SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"\r\n");
							//allocate space for 5 certificate context pointers
							pCertContextArray[ulCounter] = malloc (5*sizeof(PCCERT_CONTEXT));
							memset(pCertContextArray[ulCounter],0,5*sizeof(PCCERT_CONTEXT));
							if(pCertContextArray[ulCounter] != NULL)
							{
								memset(pCertContextArray[ulCounter],0,5*sizeof(PCCERT_CONTEXT));
								if(*pAutoFlags & AUTO_REGISTER)
									retVal = HandleNewCardFound(hTextEdit, functions, ulCounter, pSlotList,pCertContextArray[ulCounter], 5);						
							}
							else
							{
								SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"ERROR:  Out of memory\r\n");
							}
						}
					}
				}
				ulCounter++;
			}//end of while
		}

		//as long as the readercount didn't change; keep the current slotlist
		//TODO: match the entire slotList, not just checking its size
		while(ulCount == ulPreviousCount)
		{
			/* Block and wait for a slot event */
			retVal = functions->C_WaitForSlotEvent(flags, &slotID, NULL_PTR);
			if(retVal != CKR_OK)
			{
				SendMessage(hTextEdit, EM_REPLACESEL,0,  (LPARAM)"WARNING: C_WaitForSlotEvent returned an error \r\n");
				return retVal;

				//	printError()
//.........这里部分代码省略.........
开发者ID:Andhr3y,项目名称:dcfd-mw-applet,代码行数:101,代码来源:carddata.c

示例3: EstEID_waitForSlotEvent

void EstEID_waitForSlotEvent() {
	CK_SLOT_ID slotID = 0;
	CK_RV result = fl->C_WaitForSlotEvent(0, &slotID, NULL_PTR);
	printf("result: %s, slotID: %lu\n", pkcs11_error_message(result), slotID);
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:5,代码来源:esteid_certinfo.c


注:本文中的CK_FUNCTION_LIST_PTR::C_WaitForSlotEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。