當前位置: 首頁>>代碼示例>>C++>>正文


C++ CMWEXCEPTION函數代碼示例

本文整理匯總了C++中CMWEXCEPTION函數的典型用法代碼示例。如果您正苦於以下問題:C++ CMWEXCEPTION函數的具體用法?C++ CMWEXCEPTION怎麽用?C++ CMWEXCEPTION使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CMWEXCEPTION函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CMWEXCEPTION

APL_Certif *APL_Certifs::getCert(unsigned long ulIndex, bool bOnlyVisible)
{
	APL_Certif *cert=NULL;
	unsigned long ulCount=0;

	std::vector<unsigned long>::const_iterator itrOrder;
	std::map<unsigned long, APL_Certif *>::const_iterator itrCert;

	for(itrOrder=m_certifsOrder.begin();itrOrder!=m_certifsOrder.end();itrOrder++)
	{
		itrCert = m_certifs.find(*itrOrder);
		if(itrCert==m_certifs.end())
		{
			//The certif is not in the map
			//Should not happend
			throw CMWEXCEPTION(EIDMW_ERR_PARAM_RANGE); 
		}

		cert=itrCert->second;

		if(!bOnlyVisible || !cert->isHidden())
		{
			if(ulCount==ulIndex)
				return cert;
			else
				ulCount++;
		}
	}

	throw CMWEXCEPTION(EIDMW_ERR_PARAM_RANGE);
}
開發者ID:Andhr3y,項目名稱:dcfd-mw-applet,代碼行數:31,代碼來源:APLCertif.cpp

示例2: CMWEXCEPTION

void CReader::WriteFile(const std::string &csPath, unsigned long ulOffset,
    const CByteArray & oData)
{
    if (m_poCard == NULL)
        throw CMWEXCEPTION(EIDMW_ERR_NO_CARD);

	try
	{
		return m_poCard->WriteFile(csPath, ulOffset, oData);
	}
	catch (const CNotAuthenticatedException & e)
	{
		// A PIN is needed to write -> ask the correct PIN and do a verification
		unsigned long ulRemaining;
		tPin pin = m_oPKCS15.GetPinByRef(e.GetPinRef());
		if (pin.bValid)
		{
			if (m_poCard->PinCmd(PIN_OP_VERIFY, pin, "", "", ulRemaining, NULL))
			{
				return m_poCard->WriteFile(csPath, ulOffset, oData);
			}
			else
				throw CMWEXCEPTION(ulRemaining == 0 ?
					EIDMW_ERR_PIN_BLOCKED : EIDMW_ERR_PIN_BAD);
		}
		else
			throw CMWEXCEPTION(EIDMW_ERR_CMD_NOT_ALLOWED);
	}
}
開發者ID:12019,項目名稱:svn.gov.pt,代碼行數:29,代碼來源:Reader.cpp

示例3: CMWEXCEPTION

void CByteArray::SetByte(unsigned char ucByte, unsigned long ulIndex)
{
    if (m_bMallocError)
        throw CMWEXCEPTION(EIDMW_ERR_MEMORY);

    if (ulIndex >= m_ulSize)
        throw CMWEXCEPTION(EIDMW_ERR_PARAM_RANGE); 

    m_pucData[ulIndex] = ucByte;
}
開發者ID:Andhr3y,項目名稱:dcfd-mw-applet,代碼行數:10,代碼來源:bytearray.cpp

示例4: SetString

/** Retrieve from the configuration a parameter of the type STRING in the user settings

\return std::wstring            requested parameter
\retval EIMDW_NOT_OK            exception; when section   is not found
\retval EIDMW_ERR_PARAM_BAD     exception; when parameter is not found

\sa SetString(), DelString,   SetLong(), GetLong(), DelLong()  
*************************************************************************************/
std::wstring CConfig::GetStringInt(
	CConfig::tLocation location, 
	const std::wstring & csName,                /**< In:     parameter name */
	const std::wstring & czSection,             /**< In:     the configuration-section where you can find above specified parameter */
    bool                 bExpand                /**< In:     expand $home macro's to the value for this user/PC */
    ) 
{
    wchar_t     wcsKeyRegName[MAX_PATH];
    BYTE        abValueDat[512];

    DWORD       dwValDatLen = 0;
    DWORD       dwType;
    LONG        lRes;
    HKEY        hRegKey;
    HKEY		hRegKeyRoot;

    if(location == CConfig::SYSTEM)
        hRegKeyRoot = HKEY_LOCAL_MACHINE;
    else
        hRegKeyRoot = HKEY_CURRENT_USER ;

    //--- Open the KeyInfo entry
    swprintf_s(wcsKeyRegName, sizeof(wcsKeyRegName)/sizeof(wchar_t), L"%s\\%s", SC_CONF_REG, czSection.c_str());

    lRes = RegOpenKeyEx(hRegKeyRoot, wcsKeyRegName, 0L, KEY_READ , &hRegKey);
    if (lRes != ERROR_SUCCESS){
        throw CMWEXCEPTION(EIDMW_CONF);
    }

    //--- get the value
    dwValDatLen = sizeof(abValueDat); 
    dwType      = REG_SZ;
    lRes        = RegQueryValueEx(hRegKey, csName.c_str(), 0L, &dwType, abValueDat, &dwValDatLen);
    if ((lRes != ERROR_SUCCESS)){     
        //try current user if no value found and not yet in current user
        RegCloseKey(hRegKey);
        throw CMWEXCEPTION(EIDMW_ERR_PARAM_BAD);
    }
 
    if (dwValDatLen > 2)            //remove ending "00"
        dwValDatLen -= 2;

    RegCloseKey(hRegKey);
    const std::wstring wsResult((const wchar_t*)abValueDat, (size_t) (dwValDatLen/2));  //convert byte to double byte
    if(bExpand)
        return( ExpandSection(wsResult) );
    else
        return( wsResult );
}
開發者ID:Blandinium,項目名稱:eid-mw,代碼行數:57,代碼來源:configreg.cpp

示例5: CMWEXCEPTION

tFileInfo CPkiCard::SelectFile(const std::string & csPath, bool bReturnFileInfo)
{
	CByteArray oResp;
    tFileInfo xFileInfo = {0};

    unsigned long ulPathLen = (unsigned long) csPath.size();
    if (ulPathLen % 4 != 0 || ulPathLen == 0)
        throw CMWEXCEPTION(EIDMW_ERR_BAD_PATH);
    ulPathLen /= 2;

    unsigned char ucP2 = bReturnFileInfo ? 0x00 : 0x0C;

    CAutoLock autolock(this);

	if (m_selectAppletMode == ALW_SELECT_APPLET)
	{
		SelectApplet();
        oResp = SelectByPath(csPath, bReturnFileInfo);
	}
	else
	{
		// First try to select the file by ID, assuming we're in the correct DF

		CByteArray oPath(ulPathLen);
		oPath.Append(Hex2Byte(csPath, ulPathLen - 2));
		oPath.Append(Hex2Byte(csPath, ulPathLen - 1));

		// Select File
		oResp = SendAPDU(0xA4, 0x02, ucP2, oPath);
		unsigned long ulSW12 = getSW12(oResp);
		if (ulSW12 == 0x6A82 || ulSW12 == 0x6A86)
		{
			if (ulPathLen == 2)
				throw CMWEXCEPTION(m_poContext->m_oPCSC.SW12ToErr(ulSW12));

			// The file wasn't found in this DF, so let's select by full path
			oResp = SelectByPath(csPath, bReturnFileInfo);
		}
		else
		{
			getSW12(oResp, 0x9000);
		}
	}

    if (bReturnFileInfo)
        xFileInfo = ParseFileInfo(oResp);

    return xFileInfo;
}
開發者ID:giapdangle,項目名稱:eid-mw,代碼行數:49,代碼來源:pkicard.cpp

示例6: CMWEXCEPTION

 tCert CPKCS15::GetCert(unsigned long ulIndex)
 {
   if( ! m_xCDF.isRead) ReadLevel3(CDF);
   if(ulIndex >= m_oCertificates.size())
     throw CMWEXCEPTION(EIDMW_ERR_PARAM_RANGE);
   return m_oCertificates.at(ulIndex);
 }
開發者ID:12019,項目名稱:svn.gov.pt,代碼行數:7,代碼來源:PKCS15.cpp

示例7: throw

CSocket *CSocketServer::Accept(struct sockaddr *outSockAddr, int *ioSockAddrLen) throw(CMWException)
{

  socklen_t tSockAddrLen = *ioSockAddrLen;
  SOCKET new_socket = accept(m_socket, outSockAddr, &tSockAddrLen);
	if (new_socket == INVALID_SOCKET)
	{
#ifdef WIN32
	  bool error = (WSAGetLastError() == WSAEWOULDBLOCK) ;
#else
	  bool error = (errno == EWOULDBLOCK);
#endif
		if (error)
		{
			return 0;
		}
		else
		{
			throw CMWEXCEPTION(EIDMW_ERR_SOCKET_ACCEPT);
		}
	}

	CSocket *result = new CSocket(new_socket);
	return result;
}
開發者ID:Andhr3y,項目名稱:dcfd-mw-applet,代碼行數:25,代碼來源:socketserver.cpp

示例8: getNAttached

	void SharedMem::Delete(int iSegmentID)
	{

		// delete the shared memory area
		// once all processes have detached from this segment

		int iAttachedProcs = getNAttached(iSegmentID);

		if (iAttachedProcs > -1)
		{

			MWLOG(LEV_DEBUG, MOD_DLG,
			      L"  SharedMem::Delete : request to delete memory segment with ID %d. N proc = %d",
			      iSegmentID, iAttachedProcs);

			// check that no process is attached to this segment
			if (iAttachedProcs == 0)
			{
				if (shmctl(iSegmentID, IPC_RMID, NULL) == 1)
				{
					MWLOG(LEV_ERROR, MOD_DLG,
					      L"  SharedMem::Delete shmctl: %s",
					      strerror(errno));
					throw CMWEXCEPTION(EIDMW_ERR_MEMORY);
				}
				MWLOG(LEV_DEBUG, MOD_DLG,
				      L"  SharedMem::Delete : deleted memory segment with ID %d",
				      iSegmentID);
			}
		}
	}
開發者ID:Fedict,項目名稱:eid-mw,代碼行數:31,代碼來源:sharedmem.cpp

示例9: autolock

void CPkiCard::WriteUncachedFile(const std::string & csPath,
    unsigned long ulOffset, const CByteArray & oData)
{
    CAutoLock autolock(this);

    tFileInfo fileInfo = SelectFile(csPath, true);

    const unsigned char *pucData = oData.GetBytes();
    unsigned long ulDataLen = oData.Size();
    for (unsigned long i = 0; i < ulDataLen; i += MAX_APDU_WRITE_LEN)
    {
        unsigned long ulLen = ulDataLen - i;
		if (ulLen > MAX_APDU_WRITE_LEN)
            ulLen = MAX_APDU_WRITE_LEN;

        CByteArray oResp = UpdateBinary(ulOffset + i, CByteArray(pucData + i, ulLen));
		unsigned long ulSW12 = getSW12(oResp);
		if (ulSW12 == 0x6982)
			throw CNotAuthenticatedException(
				EIDMW_ERR_NOT_AUTHENTICATED, fileInfo.lWritePINRef);
		else if (ulSW12 != 0x9000)
			throw CMWEXCEPTION(m_poContext->m_oPCSC.SW12ToErr(ulSW12));
    }

	MWLOG(LEV_INFO, MOD_CAL, L"Written file %ls to card", utilStringWiden(csPath).c_str());

}
開發者ID:giapdangle,項目名稱:eid-mw,代碼行數:27,代碼來源:pkicard.cpp

示例10: GetDefaultReader

	CReader& CCardLayer::getReader(const std::string & csReaderName)
	{
		// Do an SCardEstablishContext() if not done yet
		m_oPCSC.EstablishContext();

		CReader *pRet = NULL;

		// If csReaderName == "", take the default (= first found) reader name
		const std::string * pcsReaderName = (csReaderName.size() == 0) ? GetDefaultReader() : &csReaderName;
		if (pcsReaderName->size() == 0)
		{
			throw CMWEXCEPTION(EIDMW_ERR_NO_READER);
		}
		// First check if the reader doesn't exist already
		for (unsigned long i = 0; i < MAX_READERS; i++)
		{
			if (m_tpReaders[i] != NULL)
			{
				if (m_tpReaders[i]->GetReaderName() == *pcsReaderName)
				{
					pRet = m_tpReaders[i];
					break;
				}
			}
		}

		// No CReader object for this readername -> make one
		if (pRet == NULL)
		{
			for (unsigned long i = 0; i < MAX_READERS; i++)
			{
				if (m_tpReaders[i] == NULL)
				{
					pRet = new CReader(*pcsReaderName, &m_oPCSC);
					m_tpReaders[i] = pRet;
					break;
				}
			}
		}
		// No room in m_tpReaders -> throw an exception
		if (pRet == NULL)
		{
			throw CMWEXCEPTION(EIDMW_ERR_LIMIT);
		}

		return *pRet;
	}
開發者ID:Fedict,項目名稱:eid-mw,代碼行數:47,代碼來源:cardlayer.cpp


注:本文中的CMWEXCEPTION函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。