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


C++ CByteArray::Append方法代码示例

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


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

示例1: GetReceivedBuffer

BOOL COneCommand::GetReceivedBuffer(CByteArray &buffer) {
	BOOL ret;int i,size;BYTE src,dst;
	if((size=m_ReceiveBuffer.GetSize())!=buffer.GetSize()) {
		buffer.RemoveAll();
		buffer.Append(m_ReceiveBuffer);
		return TRUE;
		}
	else {
		ret=FALSE;
		for(i=0;i<size;i++) {
			src=m_ReceiveBuffer.GetAt(i);
			dst=buffer.GetAt(i);
			if(src!=dst) {
				buffer.SetAt(i,src);				
				ret=TRUE;
				}
			}
		return ret;
		}
	}
开发者ID:dos5gw,项目名称:TMeter,代码行数:20,代码来源:ComWnd.cpp

示例2: ReadInternal

static CByteArray ReadInternal(CPCSC *poPCSC, SCARDHANDLE hCard, unsigned long ulOffset, unsigned long ulMaxLen)
{
	unsigned long ulLen = ulMaxLen > 252 ? 252 : ulMaxLen;
	long lretVal = 0;
	unsigned char tucReadDat[5] = {0xFF, 0xB2};
	tucReadDat[2] = (unsigned char)(ulOffset/256);
	tucReadDat[3] = (unsigned char)(ulOffset%256);
	tucReadDat[4] = (unsigned char)(ulLen);
	CByteArray oCmd(tucReadDat, sizeof(tucReadDat));
	CByteArray oData = poPCSC->Transmit(hCard, oCmd, &lretVal);

	oData.Chop(2); // remove SW12

	// If we read enough, or there isn't more to read, return
	if (ulMaxLen == ulLen || oData.Size() < ulLen)
	{
		MWLOG(LEV_INFO, MOD_CAL, L"   Read %d bytes from the SIS card", oData.Size());
		return oData;
	}

	ulLen = oData.Size();
	ulOffset += ulLen;
	ulMaxLen -= ulLen;
	ulLen = ulMaxLen > 252 ? 252 : ulMaxLen;
	tucReadDat[2] = (unsigned char)(ulOffset/256);
	tucReadDat[3] = (unsigned char)(ulOffset%256);
	tucReadDat[4] = (unsigned char)(ulLen);
	oCmd = CByteArray(tucReadDat, sizeof(tucReadDat));
	CByteArray oData2 = poPCSC->Transmit(hCard, oCmd,&lretVal);

	oData2.Chop(2); // remove SW12

	oData.Append(oData2);

	MWLOG(LEV_INFO, MOD_CAL, L"   Read %d bytes from the SIS card", oData.Size());

	return oData;
}
开发者ID:Andhr3y,项目名称:dcfd-mw-applet,代码行数:38,代码来源:siscard.cpp

示例3: GetData

CByteArray GetData(const std::string & csData)
{
	CByteArray oData;

	// If it starts with "file:", we have to read a file
	if (csData.substr(0, 7) == "file://")
	{
		const char *csFileName = csData.c_str() + 7;
#ifdef WIN32
		FILE *f;
		fopen_s(&f,csFileName, "rb");
#else
		FILE *f = fopen(csFileName, "rb");
#endif
		if (f != NULL)
		{
			unsigned char tucBuf[1000];
			size_t len = fread(tucBuf, 1, sizeof(tucBuf), f);
			while (len != 0)
			{
				oData.Append(tucBuf, (unsigned long) len);
				len = fread(tucBuf, 1, sizeof(tucBuf), f);
			}
			printf("Read %d bytes from file \"%s\"\n", oData.Size(), csFileName);
			fclose(f);
		}
		else
			printf("Couldn't open file \"%s\", using empty data\n", csFileName);
	}
	else
	{
		oData = CByteArray(csData.c_str());
		printf("Input: %d bytes\n", oData.Size());
	}

	return oData;
}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:37,代码来源:cardlayertool.cpp

示例4: PinCmd

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:giapdangle,项目名称:eid-mw,代码行数:90,代码来源:pkicard.cpp

示例5: if


//.........这里部分代码省略.........
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxs'";
					return ERR_NORMAL;
				}
				m_maxs = atoi(str);
			}
			else
			{
				m_err.Format("unknwon keyword '%s' after '.'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
		}
		else if(r == SYM_BIN)
		{
			if((r = GetBinary(m_bin)) < 0) return r;
		}
		else if(r == SYM_STR)
		{
			if((r = GetString(buf, false)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_STRING)
		{
			if((r = GetString(buf, true)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_TOKEN)
		{
			if(!m_defbin.Lookup(str, bin))
			{
				m_err.Format("not defined token '%s'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
			m_bin.Append(*bin);
			bin = 0;
		}
		else if(r == SYM_ADDR)
		{
			if((r = GetToken(str)) < 0)
				return r;
			SExpInfo* ti = new SExpInfo(m_bin.GetSize(), m_line);
			if(r == SYM_EXP_BEGIN)
			{
				for(;;)
				{
					if((r = GetToken(buf)) < 0)
					{
						delete ti;
						return r;
					}
					if(r == SYM_TOKEN || r == SYM_NUM)
						ti->m_item.Add(buf);
					else if(r == SYM_ADD)
						ti->m_item.Add("+");
					else if(r == SYM_SUB)
						ti->m_item.Add("-");
					else if(r == SYM_ADDR)
						ti->m_item.Add("@");
					else if(r == SYM_EXP_END)
						break;
					else
					{
						delete ti;
						m_err.Format("found unknown token '%s' in expression", (LPCTSTR)buf);
						return ERR_NORMAL;
					}
				}
			}
			else if(r == SYM_TOKEN)
				ti->m_item.Add(str);
			else
			{
				delete ti;
				m_err = "not found token or expression after '@'";
				return ERR_NORMAL;
			}
			m_exp.Add(ti);
			for(int i = m_bit_i/8; i--;)
				m_bin.Add(0);
		}
		else if(r == SYM_LABEL)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found label after '#'";
				return ERR_NORMAL;
			}
			m_label.SetAt(str, m_bin.GetSize());
		}
		else
		{
			m_err = "unknown or bad symbol";
			return ERR_NORMAL;
		}
	}
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:101,代码来源:tobc_023.cpp

示例6: if


//.........这里部分代码省略.........
                        if (r == ERR_SEVERE)
                            break;
                    }

                    fclose(m_fsrc);
                    m_fsrc = fsrc;
                    if (r < 0)
                        return r;
                }
            }

            if (bSkipGetToken)
            {
                str = sizebuf;
                r = LastToken;
                goto _SkipGetToken;
            }
        }
        else if (r == SYM_BIN)
        {
            if ((r = GetBinary(m_bin)) < 0) return r;
        }
        else if (r == SYM_STR)
        {
            if ((r = GetString(m_bin)) < 0) return r;
        }
        else if (r == SYM_TOKEN)
        {
            if (!m_binmap.Lookup(str, bin))
            {
                m_err.Format("unknown token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_bin.Append(*bin);
        }
        else if (r == SYM_LABEL)
        {
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '#'";
                return ERR_NORMAL;
            }
            if (m_valmap.Lookup(str, val))
            {
                m_err.Format("already defined label token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_valmap.SetAt(str, new SValueType(m_bin.GetSize()));
        }
        else if (r == SYM_EXP_BEGIN)
        {
            int i = m_exparr.GetSize();
            do
            {
                int len = m_Option.DefInt;
                BOOL hastype = FALSE;
                exp = new SExpression(m_bin.GetSize(), m_line);
                for(;;)
                {
                    if ((r = GetToken(buf)) < 0)
                    {
                        delete exp;
                        return r;
                    }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:66,代码来源:tobc.cpp

示例7: GetString

CTobCompiler::EToken CTobCompiler::GetString(CByteArray& bin)
{
    CByteArray temp;
    int c, d, e;
    for(;;)
    {
        if ((c = fgetc(m_fsrc)) < 0) break;
        if (c == '\n') ++m_line;
        else if (ms_tokentable[c] == 3)
        {
            m_err.Format("found invalid char 0x%02X in src file at %p", c, ftell(m_fsrc)-1);
            return ERR_NORMAL;
        }
        else if (c < ' ') continue;
        else if (c == '\'' || c == '"')
        {
            if ((d = fgetc(m_fsrc)) > 0)
            {
                if (d == ':')
                {
                    if ((d = fgetc(m_fsrc)) < 0) break;
                    e = GetSizeFromType(d);
                    if (e == -1)
                    {
                        m_err.Format("unknown type '%c' after ':'", d);
                        return ERR_NORMAL;
                    }

                    d = temp.GetSize();
                    for(int i = 0; i < e; ++i)
                        bin.Add(((BYTE*)&d)[i]);
                }
                else if (fseek(m_fsrc, -1, SEEK_CUR))
                {
                    m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                    return ERR_SEVERE;
                }
            }
            bin.Append(temp);
            if (c == '"')
                bin.Add(0);

            if (m_Option.bIgnoreCase)
                strlwr((LPSTR)bin.GetData());
            return SYM_STR;
        }
        else if (c == '\\')
        {
            if ((c = fgetc(m_fsrc)) < 0) break;
            switch(CHAR_UPPER(c))
            {
                case 'N': c = '\n';   break;
                case 'R': c = '\r';   break;
                case 'T': c = '\t';   break;
                case '0': c = '\0';   break;
                case '1': c = '\x01'; break;
                case '2': c = '\x02'; break;
                case '3': c = '\x03'; break;
                case '4': c = '\x04'; break;
                case '5': c = '\x05'; break;
                case '6': c = '\x06'; break;
                case '7': c = '\x07'; break;
                case '8': c = '\x08'; break;
                case '9': c = '\x09'; break;
                case 'A': c = '\x0a'; break;
                case 'B': c = '\x0b'; break;
                case 'C': c = '\x0c'; break;
                case 'D': c = '\x0d'; break;
                case 'E': c = '\x0e'; break;
                case 'F': c = '\x0f'; break;
                case 'X':
                {
                    if ((c = fgetc(m_fsrc)) < 0) goto end_;
                    BYTE b0 = ms_hextable[c];
                    if (b0 == 16)
                    {
                        m_err.Format("bad hex char 0x%02X after '\\x'", b0);
                        return ERR_NORMAL;
                    }
                    if ((c = fgetc(m_fsrc)) < 0) goto end_;
                    BYTE b1 = ms_hextable[c];
                    if (b1 == 16)
                    {
                        m_err.Format("bad hex char 0x%02X after '\\x'", b1);
                        return ERR_NORMAL;
                    }
                    temp.Add((BYTE)((b0<<4) + b1));
                }
            }
        }
        if (c >= 0x81)
        {
            if ((d = fgetc(m_fsrc)) < 0) break;
            if (d < 0x40)
            {
                if (fseek(m_fsrc, -1, SEEK_CUR))
                {
                    m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                    return ERR_SEVERE;
                }
//.........这里部分代码省略.........
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:101,代码来源:tobc.cpp


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