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


C++ CByteArray类代码示例

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


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

示例1: oCmd

CCard *BeidCardGetInstance(unsigned long ulVersion, const char *csReader,
	SCARDHANDLE hCard, CContext *poContext, CPinpad *poPinpad)
{
	CCard *poCard = NULL;

	if ((ulVersion % 100) == (PLUGIN_VERSION % 100))
	{
		unsigned long ulLockCount = 1;
		try {
			bool bNeedToSelectApplet = false;
			CByteArray oData;
			CByteArray oCmd(40);
			unsigned char tucSelectApp[] = {0x00, 0xA4, 0x04, 0x0C};
			oCmd.Append(tucSelectApp, sizeof(tucSelectApp));
			oCmd.Append((unsigned char) sizeof(BELPIC_AID));
			oCmd.Append(BELPIC_AID, sizeof(BELPIC_AID));
			long lRetVal;
			// Don't remove these brackets, CAutoLock dtor must be called!
			//{
			//don't use autolock when card might be reset
				//CAutoLock oAutLock(&poContext->m_oPCSC, hCard);
				
				poContext->m_oPCSC.BeginTransaction(hCard);
				oData = poContext->m_oPCSC.Transmit(hCard, oCmd, &lRetVal);
				if (lRetVal == SCARD_E_COMM_DATA_LOST || lRetVal == SCARD_E_NOT_TRANSACTED)
				{
					poContext->m_oPCSC.Recover(hCard, &ulLockCount);
					
					bNeedToSelectApplet = BeidCardSelectApplet(poContext, hCard);
					if (bNeedToSelectApplet)// try again to select the belpic app
						oData = poContext->m_oPCSC.Transmit(hCard, oCmd,&lRetVal);
				}
				if (oData.Size() == 2 && oData.GetByte(0) == 0x6A &&
					(oData.GetByte(1) == 0x82 || oData.GetByte(1) == 0x86))
				{
					// Perhaps the applet is no longer selected; so try to select it
					// first; and if successfull then try to select the Belpic AID again
					bNeedToSelectApplet = BeidCardSelectApplet(poContext, hCard);
					if (bNeedToSelectApplet)
						oData = poContext->m_oPCSC.Transmit(hCard, oCmd,&lRetVal);
				}

				bool bIsBeidCard = oData.Size() == 2 && oData.GetByte(0) == 0x90 && oData.GetByte(1) == 0x00;

				if (bIsBeidCard)
					poCard = new CBeidCard(hCard, poContext, poPinpad, oData,
					bNeedToSelectApplet ? ALW_SELECT_APPLET : TRY_SELECT_APPLET);
#ifdef __APPLE__
				else {
					// On Mac, if an unknown asynchronous card is inserted,
					// we don't return NULL but a CUnknownCard instance.
					// Reason: if we return NULL then the SISCardPlugin who
					// will be consulted next in card of a ACR38U reader
					// causes the reader/driver to get in a strange state
					// (if no SIS card is present) and if then a CUnknownCard
					// is instantiated, it will throw an exception if e.g.
					// SCardStatus() is called.
					// Remark: this trick won't work if synchronous card
					// (other then the SIS card is inserted).
					if(ulLockCount)
					{
						poContext->m_oPCSC.EndTransaction(hCard);
					}
					return new CUnknownCard(hCard, poContext, poPinpad, CByteArray());
				}
#endif
			//}
			if(ulLockCount)
			{
				poContext->m_oPCSC.EndTransaction(hCard);
			}
		}
		catch(...)
		{
			if(ulLockCount)
			{
				poContext->m_oPCSC.EndTransaction(hCard);
			}
			//printf("Exception in cardPluginBeid.CardGetInstance()\n");
		}
	}

	return poCard;
}
开发者ID:taktik,项目名称:eid-mw,代码行数:84,代码来源:beidcard.cpp

示例2: productGUID

//
//    ScanExceptions
//    ==============
//
//    Scan for applications which have been proven to not be picked up by any 'standard' methods
//
//	  Currently this includes:
//		Sophos SweepNT
//		Novell Client
//
void CApplicationInstanceList::ScanExceptions ()
{
	CString applicationName;
	CString publisher;
	CString productID;
	CString productGUID("");
	CString version("");

	HKEY hKey;
	
	CString strExceptionKey = "SOFTWARE\\Sophos\\SweepNT";

	// See if we have the SOPHOS Sweep NT primary registry key
	if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, strExceptionKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) 
	{
		// OK so it's probably installed - get any display version
		CString strDisplayVersion = CReg::GetItemString(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "Version");	
		RegCloseKey (hKey);

		applicationName = "Sophos SweepNT";
		publisher = "Sophos Inc.";
		productID = "|" + strDisplayVersion + "|" + publisher;

		// Valid application so add to our list
		AddApplicationInstance(applicationName, publisher, productGUID, productID, version);
	}

	// Novell Client
	strExceptionKey = "Software\\Novell\\NetWareWorkstation\\CurrentVersion";
	if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_LOCAL_MACHINE, strExceptionKey, 0, KEY_READ, &hKey)) 
	{
		// OK so it's probably installed - get the Display Name
		applicationName = CReg::GetItemString(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "Title");	
		RegCloseKey (hKey);
		publisher = "Novell Inc.";
		productID = "";

		// ...and then the version
		int nMajorVersion = CReg::GetItemInt(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "MajorVersion");	
		int nMinorVersion = CReg::GetItemInt(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "MinorVersion");	
		CString strBuildNumber = CReg::GetItemString(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "");	

		// format the version
		version.Format("%d.%d %s" ,nMajorVersion ,nMinorVersion ,strBuildNumber);

		// Valid application so add to our list
		AddApplicationInstance(applicationName, publisher, productGUID, productID, version);
	}

	// IE (Bug #525)
	strExceptionKey = "SOFTWARE\\Microsoft\\Internet Explorer";
	if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_LOCAL_MACHINE, strExceptionKey, 0, KEY_READ, &hKey)) 
	{
		// OK so it's probably installed - get the Display Name
		applicationName = "Internet Explorer";	
		RegCloseKey (hKey);

		publisher = "Microsoft Corporation, Inc.";
		version = CReg::GetItemString(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "svcVersion");
		if (version == "")
			version = CReg::GetItemString(HKEY_LOCAL_MACHINE, strExceptionKey.GetBuffer(0), "Version");
		productID = CReg::GetItemString(HKEY_LOCAL_MACHINE ,"SOFTWARE\\Microsoft\\Internet Explorer\\Registration" ,PRODUCTID);

		CByteArray arrayDigitalProductID;
		
		// Using the passed in 
		if (CReg::GetItemBinary (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Registration", DIGITALPRODUCTID ,arrayDigitalProductID))
		{
			// if we have an empty DigitalPRoductID we will hit an exception
			// so check here that the byte array larger size is > 1
			if (arrayDigitalProductID.GetSize() > 1)
				productGUID = DecodeDigitalProductKey(arrayDigitalProductID);
		}		

		// Valid application so add to our list
		CApplicationInstance newApplication;
		CApplicationSerial newSerial;

		newApplication.Name(applicationName);
		newApplication.Publisher(publisher);
		newApplication.Version(version);
		newApplication.Guid(productGUID);
		newApplication.Source("Windows Installer Key");

		newSerial.ApplicationName(applicationName);
		newSerial.ProductId(productID);
		newSerial.CdKey(productGUID);
		newApplication.Serial(newSerial);		

		// ...add to our list
//.........这里部分代码省略.........
开发者ID:sambasivarao,项目名称:AW-master,代码行数:101,代码来源:ApplicationInstance.cpp

示例3: UpdateGUI

int CPartFileConvert::performConvertToeMule(CString folder)
{
	BOOL bWorking;
	CString filepartindex,newfilename;
	CString buffer;
	UINT fileindex;
	CFileFind finder;
	
	CString partfile=folder;
	folder.Delete(folder.ReverseFind('\\'),folder.GetLength());
	partfile=partfile.Mid(partfile.ReverseFind('\\')+1,partfile.GetLength());


	UpdateGUI(0,GetResString(IDS_IMP_STEPREADPF),true);

	filepartindex=partfile.Left(partfile.Find('.'));
	//int pos=filepartindex.ReverseFind('\\');
	//if (pos>-1) filepartindex=filepartindex.Mid(pos+1,filepartindex.GetLength()-pos);

	UpdateGUI(4,GetResString(IDS_IMP_STEPBASICINF));

	CPartFile* file=new CPartFile();
	pfconverting->partmettype=file->LoadPartFile(folder,partfile,true);

	switch (pfconverting->partmettype) {
		case PMT_UNKNOWN:
		case PMT_BADFORMAT:
			delete file;
			return CONV_BADFORMAT;
			break;
	}

	CString oldfile=folder+_T("\\")+partfile.Left(partfile.GetLength()- ((pfconverting->partmettype==PMT_SHAREAZA)?3:4) );

	pfconverting->size=file->GetFileSize();
	pfconverting->filename=file->GetFileName();
	pfconverting->filehash= EncodeBase16( file->GetFileHash() ,16);
	UpdateGUI(pfconverting);

	if (theApp.downloadqueue->GetFileByID(file->GetFileHash())!=0) {
		delete file;
		return CONV_ALREADYEXISTS;
	}
	
	if (pfconverting->partmettype==PMT_SPLITTED ) {
		try {
			CByteArray ba;
			ba.SetSize(PARTSIZE);

			CFile inputfile;
			int pos1,pos2;
			CString filename;

			// just count
			UINT maxindex=0;
			UINT partfilecount=0;
			bWorking = finder.FindFile(folder+_T("\\")+filepartindex+_T(".*.part"));
			while (bWorking)
			{
				bWorking = finder.FindNextFile();
				++partfilecount;
				buffer=finder.GetFileName();
				pos1=buffer.Find('.');
				pos2=buffer.Find('.',pos1+1);
				fileindex=_tstoi(buffer.Mid(pos1+1,pos2-pos1) );
				if (fileindex==0) continue;
				if (fileindex>maxindex) maxindex=fileindex;
			}
			float stepperpart;
			if (partfilecount>0) {
				stepperpart=(80.0f / partfilecount );
				if (maxindex*PARTSIZE<=pfconverting->size) pfconverting->spaceneeded=maxindex*PARTSIZE;
					else pfconverting->spaceneeded=((pfconverting->size / PARTSIZE) * PARTSIZE)+(pfconverting->size % PARTSIZE);
			} else {
				stepperpart=80.0f;
				pfconverting->spaceneeded=0;
			}
			
			UpdateGUI(pfconverting);

			if (GetFreeDiskSpaceX(thePrefs.GetTempDir()) < (maxindex*PARTSIZE) ) {
				delete file;
				return CONV_OUTOFDISKSPACE;
			}

			// create new partmetfile, and remember the new name
			file->CreatePartFile();
			newfilename=file->GetFullName();

			UpdateGUI(8,GetResString(IDS_IMP_STEPCRDESTFILE));
			file->m_hpartfile.SetLength( pfconverting->spaceneeded );

			uint16 curindex=0;
			bWorking = finder.FindFile(folder+_T("\\")+filepartindex+_T(".*.part"));
			while (bWorking)
			{
				bWorking = finder.FindNextFile();
				
				//stats
				++curindex;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:nextemf,代码行数:101,代码来源:PartFileConvert.cpp

示例4: oAutoLock

CByteArray CBeidCard::Ctrl(long ctrl, const CByteArray & oCmdData)
{
	CAutoLock oAutoLock(this);

	switch(ctrl)
    {
    case CTRL_BEID_GETCARDDATA:
        return m_oCardData;
    case CTRL_BEID_GETSIGNEDCARDDATA:
		if (m_ucAppletVersion < 0x17)
			throw CMWEXCEPTION(EIDMW_ERR_NOT_SUPPORTED);
		else
		{
			if (m_selectAppletMode == ALW_SELECT_APPLET)
				SelectApplet();
			m_ucCLA = 0x80;
			CByteArray oRet = SendAPDU(0xE4, 0x02, 0x00, 0x9C);
			m_ucCLA = 0;
			getSW12(oRet, 0x9000);
			oRet.Chop(2);
			return oRet;
		}
    case CTRL_BEID_GETSIGNEDPINSTATUS:
		// oCmdData must contain:
		// - the pin reference (1 byte)
		if (m_ucAppletVersion < 0x17)
			throw CMWEXCEPTION(EIDMW_ERR_NOT_SUPPORTED);
		else
		{
			if (m_selectAppletMode == ALW_SELECT_APPLET)
				SelectApplet();
			unsigned char ucPinRef = oCmdData.GetByte(0);
			m_ucCLA = 0x80;
			CByteArray oRet = SendAPDU(0xEA, 0x02, ucPinRef, 0x81);
			m_ucCLA = 0;
			if (ShouldSelectApplet(0xEA, getSW12(oRet)))
			{
				if (SelectApplet())
				{
					m_selectAppletMode = ALW_SELECT_APPLET;
					m_ucCLA = 0x80;
					CByteArray oRet = SendAPDU(0xEA, 0x02, ucPinRef, 0x81);
					m_ucCLA = 0;
				}
			}
			getSW12(oRet, 0x9000);
			oRet.Chop(2);
			return oRet;
		}
	case CTRL_BEID_INTERNAL_AUTH:
		// oCmdData must contain:
		// - the key reference (1 byte)
		// - the challenge to be signed (20 bytes)
		if (oCmdData.Size() != 21)
			throw CMWEXCEPTION(EIDMW_ERR_PARAM_BAD);
		else
		{
			if (m_selectAppletMode == ALW_SELECT_APPLET)
				SelectApplet();
			unsigned char ucKeyRef = oCmdData.GetByte(0);
			CByteArray oData(22);
			oData.Append(0x94);
			oData.Append(0x14);
			oData.Append(oCmdData.GetBytes() + 1, 20);
			CByteArray oRet = SendAPDU(0x88, 0x02, ucKeyRef, oData);
			if (ShouldSelectApplet(0x88, getSW12(oRet)))
			{
				if (SelectApplet())
				{
					m_selectAppletMode = ALW_SELECT_APPLET;
					CByteArray oRet = SendAPDU(0x88, 0x02, ucKeyRef, oData);
				}
			}
			getSW12(oRet, 0x9000);
			oRet.Chop(2);
			return oRet;
		}
    default:
        MWLOG(LEV_WARN, MOD_CAL, L"Ctrl(): Unknown CRTL code %d (0x%0x) specified", ctrl, ctrl);
		throw CMWEXCEPTION(EIDMW_ERR_PARAM_BAD);
    }
}
开发者ID:taktik,项目名称:eid-mw,代码行数:82,代码来源:beidcard.cpp

示例5: AddMap

CTobCompiler::EToken CTobCompiler::CompilePass1()
{
    EToken r, LastToken;
    CString str, buf, sizebuf;
    CByteArray* bin;
    SValueType* val;
    SExpression* exp;

    for(;;)
    {
        BOOL bSkipGetToken = FALSE;
        if ((r = GetToken(str)) <= 0) return r;
_SkipGetToken:
        if (r == SYM_DEF)
        {
/*
            if (m_bin.GetSize() > 0)
            {
                m_err = "const token can not defined after data";
                return ERR_NORMAL;
            }
*/
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '@'";
                return ERR_NORMAL;
            }

            if (str == "_IGNORECASE")
            {
                m_Option.bIgnoreCase = TRUE;
                continue;
            }

            if ((r = GetToken(buf)) < 0) return r;
            if (r == SYM_BIN)
            {
                bin = new CByteArray;
                if ((r = GetBinary(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_STR)
            {
                bin = new CByteArray;
                if ((r = GetString(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_INT)
            {
                ULONG Length;
                BOOL bHex = (buf[0] == '0' && buf[1] == 'x');

                r = GetToken(sizebuf);
                LastToken = r;
                if (r == SYM_TYPE)
                {
                    r = GetToken(sizebuf);
                    if (r != SYM_TOKEN)
                    {
                        m_err = "not found type after ':'";
                        return ERR_NORMAL;
                    }

                    Length = GetSizeFromType(sizebuf[0]);
                    if (Length == -1)
                    {
                        m_err.Format("unknown type '%c' after ':'", sizebuf[0]);
                        return ERR_NORMAL;
                    }
                }
                else
                {
                    Length = -1;
                }
                val = new SValueType((int)strtoul(buf, NULL, bHex ? 16 : 10), Length);
                AddMap(m_valmap, str, val);

                if (Length == -1)
                    bSkipGetToken = TRUE;

                r = SYM_INT;
            }
            else if (r == SYM_FLOAT)
            {
                AddMap(m_valmap, str, new SValueType(atof(buf)));
            }
            else
            {
                m_err.Format("not found '[' or ''' or '\"' or number after '@%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }

            if (m_Option.bIgnoreCase)
                str.MakeUpper();

            if (str == "_DEFI")
            {
                if (r != SYM_INT || val->ival < 1 || val->ival > 4)
                {
//.........这里部分代码省略.........
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:101,代码来源:tobc.cpp

示例6: LogOff

bool CPkiCard::PinCmd(tPinOperation operation, const tPin & Pin,
        const std::string & csPin1, const std::string & csPin2,
        unsigned long & ulRemaining, const tPrivKey *pKey)
{
	// No standard for Logoff, so each card has to implement
	// it's own command here.
	if (operation == PIN_OP_LOGOFF )
		return LogOff(Pin);

	bool bRet = false;
	std::string csReadPin1, csReadPin2;
	const std::string *pcsPin1 = &csPin1;
	const std::string *pcsPin2 = &csPin2;
	bool bAskPIN = csPin1.empty();
	bool bUsePinpad = bAskPIN ? m_poPinpad->UsePinpad(operation) : false;

bad_pin:
     //If no Pin(s) provided and it's no Pinpad reader -> ask Pins
    if (bAskPIN && !bUsePinpad)
	{
        showPinDialog(operation, Pin, csReadPin1, csReadPin2, pKey);
		pcsPin1 = &csReadPin1;
		pcsPin2 = &csReadPin2;
	}

    CByteArray oPinBuf = MakePinBuf(Pin, *pcsPin1, bUsePinpad);
    if (operation != PIN_OP_VERIFY)
        oPinBuf.Append(MakePinBuf(Pin, *pcsPin2, bUsePinpad));

    CByteArray oAPDU = MakePinCmd(operation, Pin); // add CLA, INS, P1, P2
    oAPDU.Append((unsigned char) oPinBuf.Size());  // add P3
    oAPDU.Append(oPinBuf);

	CByteArray oResp;
	bool bSelected = false;

	// Don't remove these brackets!!
	{
		CAutoLock autolock(this);

		// Select the path where the Pin is, if necessary
		if (!Pin.csPath.empty() && !bSelected && Pin.csPath != "3F00")
		{
			SelectFile(Pin.csPath);
			bSelected = true;
		}

		// Send the command
		if (csPin1.empty() && bUsePinpad)
			oResp = m_poPinpad->PinCmd(operation, Pin,
			PinUsage2Pinpad(Pin, pKey), oAPDU, ulRemaining);
		else
			oResp = SendAPDU(oAPDU);
	}

    unsigned long ulSW12 = getSW12(oResp);
    if (ulSW12 == 0x9000)
        bRet = true;
    else if (ulSW12 == 0x6983)
        ulRemaining = 0;
    else if (ulSW12 / 16 == 0x63C)
        ulRemaining = ulSW12 % 16;
	else
		throw CMWEXCEPTION(m_poContext->m_oPCSC.SW12ToErr(ulSW12));

#ifndef NO_DIALOGS
	// Bad PIN: show a dialog to ask the user to try again
	// PIN blocked: show a dialog to tell the user
	if (bAskPIN && !bRet)
	{
		DlgPinUsage usage = PinUsage2Dlg(Pin, pKey);
		DlgRet dlgret = DlgBadPin(usage, utilStringWiden(Pin.csLabel).c_str(), ulRemaining);
		if (0 != ulRemaining && DLG_RETRY == dlgret)
			goto bad_pin;
	}
#endif

	// If PIN command OK and no SSO, then state that we have now
	// verified this PIN, this info is needed in the Sign() method
	if (bRet && !m_poContext->m_bSSO)
	{
		bool bFound = false;
		for (size_t i = 0; i < m_verifiedPINs.size() && !bFound; i++)
			bFound = (m_verifiedPINs[i] == Pin.ulID);
		if (!bFound)
			m_verifiedPINs.push_back(Pin.ulID);
	}

	return bRet;
}
开发者ID:Blandinium,项目名称:eid-mw,代码行数:90,代码来源:pkicard.cpp

示例7: bGetMsgInfoFromMsgStr

BOOL bGetMsgInfoFromMsgStr( CONST CString& omSendMsgLine,
                            PSTCANDATA psCANData,
                            BOOL bHexON)
{
    CString omStrTemp       ="";
    CString omStrMsgID      ="";
    CString omStrDLC        ="";
    CString omStrData       ="";
    CString omStrMsgIDType  ="";
    CHAR* pcStopString      = nullptr;
    BOOL nReturn            = FALSE;

    CByteArray omByteArrayDataTx;
    // Get the string before first white space charactor
    omStrTemp = omSendMsgLine.SpanExcluding("\t ");
    if(omStrTemp.IsEmpty()==0)
    {
        INT nIndex = omStrTemp.GetLength();
        if(nIndex>0)
        {
            // Remove the time stamp string
            omStrTemp = omSendMsgLine.Right(omSendMsgLine.GetLength() -
                                            nIndex -1);
            if(omStrTemp.IsEmpty() ==0)
            {
                omStrTemp.TrimLeft();
                omStrTemp.TrimRight();
                // Get the message ID after removing Tx/Rx string
                omStrMsgID = omStrTemp.SpanExcluding("\t ");
                if( omStrMsgID.Compare("Tx") == 0 )
                {
                    psCANData->m_ucDataType = TX_FLAG;
                }
                else
                {
                    psCANData->m_ucDataType = RX_FLAG;
                }
                nIndex     = omStrMsgID.GetLength();
                omStrTemp  = omStrTemp.Right(omStrTemp.GetLength() - nIndex - 1);
                omStrTemp.TrimLeft();
                // Channel ID
                omStrMsgID = omStrTemp.SpanExcluding("\t ");
                UCHAR ucChannel    =
                    (UCHAR) strtol( (LPCTSTR )omStrMsgID,&pcStopString ,10);
                nIndex     = omStrMsgID.GetLength();
                omStrTemp  = omStrTemp.Right(omStrTemp.GetLength() - nIndex -1);

                omStrTemp.TrimLeft();
                // Get the message with name
                omStrMsgID = omStrTemp.SpanExcluding("\t ");
                // Get the rest of the string.
                nIndex     = omStrMsgID.GetLength();
                omStrTemp  = omStrTemp.Right(omStrTemp.GetLength() - nIndex -1);
                omStrTemp.TrimLeft();

                // Get message ID string after removing any message name.
                omStrMsgID = omStrMsgID.SpanExcluding(defMSGID_NAME_DELIMITER);
                UINT unMsgID = 0;
                if( bHexON == TRUE)
                {
                    unMsgID    =
                        (UINT) strtol( (LPCTSTR )omStrMsgID,&pcStopString ,16);
                }
                else
                {
                    unMsgID    =
                        (UINT) strtol( (LPCTSTR )omStrMsgID,&pcStopString ,10);
                }

                // Get the message ID Type
                omStrMsgIDType = omStrTemp.SpanExcluding("\t ");
                // Message Id type is EXTENDED
                if(omStrMsgIDType.Find(defMSGID_EXTENDED) != -1)
                {
                    psCANData->m_uDataInfo.m_sCANMsg.m_ucEXTENDED = 1;
                }// Message Id type is STD
                else if(omStrMsgIDType.Find(defMSGID_STD)!= -1)
                {
                    psCANData->m_uDataInfo.m_sCANMsg.m_ucEXTENDED = 0;
                }
                // Message Id type is RTR
                if(omStrMsgIDType.Find(defMSGID_RTR)!= -1)
                {
                    psCANData->m_uDataInfo.m_sCANMsg.m_ucRTR = 1;
                }
                else
                {
                    psCANData->m_uDataInfo.m_sCANMsg.m_ucRTR = 0;
                }
                nIndex     = omStrMsgIDType.GetLength();
                omStrTemp  = omStrTemp.Right(omStrTemp.GetLength() - nIndex -1);
                omStrTemp.TrimLeft();

                // Get the DLC
                omStrDLC   = omStrTemp.SpanExcluding("\t ");
                nIndex     = omStrDLC.GetLength();
                UINT unDLC = (UINT) strtol((LPCTSTR)omStrDLC,&pcStopString ,16);
                omStrTemp  = omStrTemp.Right(omStrTemp.GetLength() - nIndex -1);

                omStrTemp.TrimLeft();
//.........这里部分代码省略.........
开发者ID:ETAS-Eder,项目名称:busmaster,代码行数:101,代码来源:Utility_Replay.cpp

示例8: Reset

BOOL CTobCompiler::CompileFile(LPWSTR fsrcname, LPWSTR fdstname, F_ErrorHandler ErrorHandler)
{
    WChar szOutput[MAX_PATH];
    CString err;
    BOOL haserr = FALSE;

    Reset();

    m_line = 1;

    m_fsrc = _wfopen(fsrcname, L"rb");
    if (!m_fsrc)
    {
        m_err.Format("can't open src file '%S'", fsrcname);
        (this->*ErrorHandler)(GetErrorString(err));
        return FALSE;
    }

    for(;;)
    {
        EToken r = CompilePass1();
        if (r == ERR_EOF)
            break;

        if (r < 0)
        {
            haserr = TRUE;
            if (!(this->*ErrorHandler)(GetErrorString(err)))
                return FALSE;
        }

        if (r == ERR_SEVERE)
            return FALSE;
    }

    fclose(m_fsrc);
    m_fsrc = 0;

    if (!CompilePass2(ErrorHandler) || haserr)
        return FALSE;

    if (fdstname == NULL)
    {
        CByteArray* bin;
        if (m_binmap.Lookup("_FILE", bin) && bin->GetSize() > 0)
        {
            MultiByteToWideChar(
                CP_GB2312,
                0,
                (LPSTR)bin->GetData(),
                bin->GetSize(),
                szOutput,
                countof(szOutput));
            fdstname = szOutput;
        }
        else
        {
            LPWSTR pszExtension;

            lstrcpyW(szOutput, fsrcname);
            pszExtension = findextw(szOutput);
            !lstrcmpiW(pszExtension, L".bin") ? lstrcatW(pszExtension, L".bin") : lstrcpyW(pszExtension, L".bin");
            fdstname = szOutput;
        }
    }

    m_fdst = _wfopen(fdstname, L"wb");
    if (m_fdst == NULL)
    {
        m_err.Format("can't create dst file '%S'", fdstname);
        (this->*ErrorHandler)(GetErrorString(err));
        return FALSE;
    }

    if (m_bin.GetSize() > 0 && fwrite(m_bin.GetData(), m_bin.GetSize(), 1, m_fdst) != 1)
    {
        fclose(m_fdst); m_fdst = 0;
        m_err.Format("can't write dst file '%S'", fdstname);
        (this->*ErrorHandler)(GetErrorString(err));
        return FALSE;
    }

    fclose(m_fdst);
    m_fdst = NULL;

    return TRUE;
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:87,代码来源:tobc.cpp

示例9: wreg

// Write Operation
void CFanmotorDlg::wreg(int reg_addr, int datr)
{
	success=1;

	VARIANT r;
	CByteArray baData;
	CStringArray dataStr;

	//separate input 2 bytes datr into 1byte + 1byte
	int datrH=datr/256;
	int datrL=datr%256;

	CString regstring;
	regstring.Format(_T("%02x "),reg_addr);
	CString strinputH;
    strinputH.Format(_T("%02x "),datrH);
	CString strinputL;
    strinputL.Format(_T("%02x"),datrL);

	CString str = regstring+strinputH+strinputL;

	
	int timeout_counter=0;

	if(this->virtual_board)
	{
		WriteVirtualBoardReg(reg_addr, datr, fOTP);
		return;
	}


	int parseResult = ParseString(dataStr,str);
	if (parseResult != -1){
		AfxMessageBox(L"Incorrect Data (\""+dataStr[parseResult]+L"\") is Typed. Please correct it",
						MB_ICONERROR | MB_OK,0);
		return;
	}
	else{
		if (dataStr.GetSize() == 0) {
			AfxMessageBox(L"Type some HEX data to send!",MB_ICONERROR | MB_OK,0);
			return;
		}
	}
	for (int i=0; i<dataStr.GetSize(); i++) {
		WCHAR *ch,*buf;
		buf = dataStr[i].GetBuffer(dataStr[i].GetLength());
		BYTE dataByte = (BYTE)wcstol(buf,&ch,16);
		dataStr[i].ReleaseBuffer();
		baData.Add(dataByte);
	}

	COleVariant data(baData); // Create array of Data
	// Send Data To Bridge

	r = Bridge->SendIICdata(L"0000011", 0x49, data);//spi comm, no acknowledge signal return to r.cannot check connection success.

	//do{
	//	timeout_counter++;
	//	if (timeout_counter == TIMEOUT){
	//		DisplayInforMessageBox((LPCWSTR)L"Error", (LPCWSTR)L"Device is not available.\nPlease check your hardware connection and power supply!");
	//		success = 0;
	//	}
	//	r = Bridge->SendIICdata(L"0000011", 0x49, data); 
	//}while ((r.bVal != 34) && (timeout_counter != TIMEOUT));

    Sleep(20);
end:;
}
开发者ID:ChenChengCC,项目名称:test2,代码行数:69,代码来源:FanmotorDlg.cpp

示例10: ConvertStringToSendData

BOOL ConvertStringToSendData(const CString & s, CByteArray & msg)
    {
#ifdef _UNICODE
     int n = ::WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL);
     if(n == 0)
        { /* failed */
         //DWORD err = ::GetLastError();
         msg.SetSize(0);
         return FALSE;
        } /* failed */
     else
        { /* success */
         msg.SetSize(n);
         n = ::WideCharToMultiByte(CP_UTF8, 0, s, -1, (LPSTR)msg.GetData(), n, NULL, NULL);
         if(n == 0)
            { /* conversion failed */
             DWORD err = ::GetLastError();
             msg.SetSize(0);
             return FALSE;
            } /* conversion failed */
         else
            { /* use multibyte string */
             msg.SetSize(n - 1);
             return TRUE;
            } /* use multibyte string */
        } /* success */
#else // ANSI
     CArray<WCHAR, WCHAR> wc;

     int n = ::MultiByteToWideChar(CP_ACP, 0, s, -1, NULL, 0);
     if(n == 0)
        { /* failed */
         DWORD err = ::GetLastError();
         msg.SetSize(0);
         return FALSE;
        } /* failed */
     else
        { /* success */
         wc.SetSize(n);
         n = ::MultiByteToWideChar(CP_ACP, 0, s, -1, wc.GetData(), n);
        } /* success */     

     n = ::WideCharToMultiByte(CP_UTF8, 0, wc.GetData(), -1, NULL, 0, NULL, NULL);
     if(n == 0)
        { /* failed */
         DWORD err = ::GetLastError();
         msg.SetSize(0);
         return FALSE;
        } /* failed */
     else
        { /* success */
         msg.SetSize(n);
         n = ::WideCharToMultiByte(CP_UTF8, 0, wc.GetData(), -1, (LPSTR)msg.GetData(), n, NULL, NULL);
         if(n == 0)
            { /* conversion failed */
             DWORD err = ::GetLastError();
             msg.SetSize(0);
             return FALSE;
            } /* conversion failed */
         else
            { /* use multibyte string */
             msg.SetSize(n - 1);
             return TRUE;
            } /* use multibyte string */
        } /* success */
#endif
    } // ConvertStringToSendData
开发者ID:Cholga,项目名称:tlcopy,代码行数:67,代码来源:Convert.cpp

示例11: AnalysisCard

/**
* @brief 从7张牌中分析出5张最大牌型
* @param bHandCards[]     要分析的手牌
* @param nCount           手牌张数
* @param bPublicCards[]   要分析公共牌
* @param nPublicCount     公共牌张数
* @param bResultCard[]    返回分析得到的数据牌
* @return 牌型
*/
int CUpGradeGameLogic::AnalysisCard(BYTE bHandCards[], int nHandCount, BYTE bPublicCards[], int nPublicCount, BYTE bResultCard[])
{
    if ((nHandCount + nPublicCount) != 7)
    {
        return 0;
    }
    
    int i, j;
    CByteArray arrCards;

    for (i = 0; i < nHandCount; i++)
    {
        arrCards.Add(bHandCards[i]);
    }
    
    for (i = 0; i < nPublicCount; i++)
    {
        arrCards.Add(bPublicCards[i]);
    }

    BYTE bCard[5] = {0};
    int nCardKind[21] = {0};

    //// 21种组成方法
    //BYTE bIndex[21][5] = {0, 1, 2, 3, 4, \
    //                      0, 1, 2, 3, 5, \
    //                      0, 1, 2, 3, 6, \
    //                      0, 1, 2, 4, 5, \
    //                      0, 1, 2, 4, 6, \
    //                      0, 1, 2, 5, 6, \
    //                      0, 1, 3, 4, 5, \
    //                      0, 1, 3, 4, 6, \
    //                      0, 1, 3, 5, 6, \
    //                      0, 1, 4, 5, 6, \
    //                      0, 2, 3, 4, 5, \
    //                      0, 2, 3, 4, 6, \
    //                      0, 2, 3, 5, 6, \
    //                      0, 2, 4, 5, 6, \
    //                      0, 3, 4, 5, 6, \
    //                      1, 2, 3, 4, 5, \
    //                      1, 2, 3, 4, 6, \
    //                      1, 2, 3, 5, 6, \
    //                      1, 2, 4, 5, 6, \
    //                      1, 3, 4, 5, 6, \
    //                      2, 3, 4, 5, 6, \
    //                     };

	// 21种组成方法
	BYTE bIndex[21][7] = {0, 1, 2, 3, 4, 5, 6,
		                  0, 1, 2, 3, 5, 4, 6,
		                  0, 1, 2, 3, 6, 4, 5,
		                  0, 1, 2, 4, 5, 3, 6,
		                  0, 1, 2, 4, 6, 3, 5,
		                  0, 1, 2, 5, 6, 3, 4,
		                  0, 1, 3, 4, 5, 2, 6,
		                  0, 1, 3, 4, 6, 2, 5,
		                  0, 1, 3, 5, 6, 2, 4, 
		                  0, 1, 4, 5, 6, 2, 3, 
		                  0, 2, 3, 4, 5, 1, 6, 
		                  0, 2, 3, 4, 6, 1, 5, 
		                  0, 2, 3, 5, 6, 1, 4, 
		                  0, 2, 4, 5, 6, 1, 3, 
		                  0, 3, 4, 5, 6, 1, 2, 
		                  1, 2, 3, 4, 5, 0, 6, 
		                  1, 2, 3, 4, 6, 0, 5, 
		                  1, 2, 3, 5, 6, 0, 4, 
		                  1, 2, 4, 5, 6, 0, 3, 
		                  1, 3, 4, 5, 6, 0, 2, 
		                  2, 3, 4, 5, 6, 0, 1
						 };

    for (i = 0; i < 21; i++)
    {	
        for (j = 0; j < 5; j++)
        {
            // 按牌下标取出5张牌
            bCard[j] = arrCards.GetAt(bIndex[i][j]);
        }
      
        // 获取牌型
        nCardKind[i] = GetCardShape(bCard, 5);

		//CString str;
		//str.Format("dxh: 第%d种方法, 牌型: %d",  i, nCardKind[i]);
		//OutputDebugString(str);
    }

    // 取最大牌型位置
    int nMax = 0;
    for (i = 1; i < 21; i++)
    {
//.........这里部分代码省略.........
开发者ID:liuwanbing,项目名称:liuwanbing,代码行数:101,代码来源:UpGradeLogic.cpp

示例12: Hash

CByteArray CHash::Hash(tHashAlgo algo, const CByteArray & data)
{
	return Hash(algo, data, 0, data.Size());
}
开发者ID:Fedict,项目名称:eid-mw,代码行数:4,代码来源:hash.cpp

示例13: Update

void CHash::Update(const CByteArray & data)
{
	Update(data, 0, data.Size());
}
开发者ID:Fedict,项目名称:eid-mw,代码行数:4,代码来源:hash.cpp

示例14: CByteArray

CByteArray CPinpadLibOldBeid::PinCmd(SCARDHANDLE hCard, unsigned long ulControl,
	CByteArray oCmd, unsigned char ucPintype, unsigned char ucOperation)
{
	if (ulControl == CCID_IOCTL_GET_FEATURE_REQUEST)
	{
		unsigned char tucFeatures[] = {0x06, 0x04, 0x00, 0x31, 0x32, 0x33, 0x07, 0x04, 0x00 ,0x31, 0x32, 0x33};
		return CByteArray(tucFeatures, sizeof(tucFeatures));
	}

	SCR_Card xCard = {
		hCard,
		tcsLangs[m_iLangIdx],
		{NULL, 0},
		NULL
	};
	unsigned char tucStatus[2];
	long lRet = SCARD_F_INTERNAL_ERROR;

	if (ucOperation == EIDMW_PP_OP_VERIFY)
	{
		SCR_PinUsage xPinUsage = {
			ucPintype == EIDMW_PP_TYPE_SIGN ? SCR_USAGE_SIGN: SCR_USAGE_AUTH,
			ucPintype == EIDMW_PP_TYPE_SIGN ? "SIG" : "AUT",
			ucPintype == EIDMW_PP_TYPE_SIGN ? tcsUsageSig[m_iLangIdx] : tcsUsageAuth[m_iLangIdx]
		};

		lRet = m_pVerifyPin(&xCard, oCmd.GetByte(22), &xPinUsage, &xApp, tucStatus);
	}
	else if (ucOperation == EIDMW_PP_OP_CHANGE)
	{
		lRet = m_pChangePin(&xCard, oCmd.GetByte(27), &xApp, tucStatus);	
	}
	else
		throw CMWEXCEPTION(EIDMW_ERR_PIN_OPERATION);

	CByteArray oResp(2);
	switch(lRet)
	{
	case SCARD_S_SUCCESS:
		if (tucStatus[0] == 0xEC && tucStatus[1] == 0xD2)
			oResp.Append(tucErrTimeout, sizeof(tucErrTimeout));
		else if (tucStatus[0] == 0xEC && tucStatus[1] == 0xD6)
			oResp.Append(tucErrCancel, sizeof(tucErrCancel));
		else
			oResp.Append(tucStatus, 2);
		break;
	case SCARD_E_CANCELLED:
		oResp.Append(tucErrCancel, sizeof(tucErrCancel));
		break;
	case SCARD_W_REMOVED_CARD:
		throw CMWEXCEPTION(EIDMW_ERR_NO_CARD);
		break;
	case SCR_I_PIN_CHECK_FAILED:
		oResp.Append(tucErrPinsDiffer, sizeof(tucErrPinsDiffer));
		break;
	default:
		oResp.Append(tucErrGeneral, sizeof(tucErrGeneral));
	}

	return oResp;
}
开发者ID:Blandinium,项目名称:eid-mw,代码行数:61,代码来源:PinpadLibOldBeid.cpp

示例15: Append

void CByteArray::Append(const CByteArray & oByteArray)
{
    Append(oByteArray.GetBytes(), oByteArray.Size());
}
开发者ID:Andhr3y,项目名称:dcfd-mw-applet,代码行数:4,代码来源:bytearray.cpp


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