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


C++ KviCString::len方法代码示例

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


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

示例1: printSSLCertificate

	KVIRC_API void printSSLCertificate(KviWindow * wnd, const char * description, KviSSLCertificate * c)
	{
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: %c%s"), KviControlCodes::Bold, description);
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:  Version: %c%d"), KviControlCodes::Bold, c->version());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:  Serial number: %c%d"), KviControlCodes::Bold, c->serialNumber());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:  Subject:"));
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Common name: %c%s"), KviControlCodes::Bold, c->subjectCommonName());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Organization: %c%s"), KviControlCodes::Bold, c->subjectOrganization());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Organizational unit: %c%s"), KviControlCodes::Bold, c->subjectOrganizationalUnit());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Country: %c%s"), KviControlCodes::Bold, c->subjectCountry());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     State or province: %c%s"), KviControlCodes::Bold, c->subjectStateOrProvince());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Locality: %c%s"), KviControlCodes::Bold, c->subjectLocality());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:   Issuer:"));
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Common name: %c%s"), KviControlCodes::Bold, c->issuerCommonName());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Organization: %c%s"), KviControlCodes::Bold, c->issuerOrganization());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Organizational unit: %c%s"), KviControlCodes::Bold, c->issuerOrganizationalUnit());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Country: %c%s"), KviControlCodes::Bold, c->issuerCountry());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     State or province: %c%s"), KviControlCodes::Bold, c->issuerStateOrProvince());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:     Locality: %c%s"), KviControlCodes::Bold, c->issuerLocality());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:   Public key: %c%s (%d bits)"), KviControlCodes::Bold, c->publicKeyType(), c->publicKeyBits());
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:   Signature type: %c%s"), KviControlCodes::Bold, c->signatureType());
		KviCString tmp = c->signatureContents();
		if(tmp.len() > 40)
		{
			tmp.cutRight(tmp.len() - 40);
			tmp.append("...");
		}
		wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]:   Signature contents: %c%s"), KviControlCodes::Bold, tmp.ptr());
	}
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:29,代码来源:KviSSLMaster.cpp

示例2: QWidget

	KviIpcSentinel::KviIpcSentinel()
	: QWidget(0)
	{
		setObjectName("kvirc4_ipc_sentinel");
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
		setWindowTitle("kvirc4_ipc_sentinel");
		setWindowFlags(Qt::FramelessWindowHint);
#else
	#if defined(COMPILE_X11_SUPPORT) && defined(COMPILE_QX11INFO_SUPPORT)
		kvi_ipcLoadAtoms();

		XChangeProperty(kvi_ipc_get_xdisplay(),winId(),kvi_atom_ipc_sentinel_window,XA_STRING,8,
			PropModeReplace,(const unsigned char *)kvi_sentinel_id.ptr(),kvi_sentinel_id.len());

		kvi_ipcSetRemoteCommand(winId(),"");
	#endif //!COMPILE_NO_X
#endif

		move(-50,-50);
		resize(1,1);
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
		// we need to show the window once otherwise it will never get "realized"
		// and we will not be able to find it via FindWindow()
		show();
#endif
		hide();

	}
开发者ID:Heufneutje,项目名称:KVIrc,代码行数:28,代码来源:KviIpcSentinel.cpp

示例3: encrypt

KviCryptEngine::EncryptResult KviMircryptionEngine::encrypt(const char * plainText, KviCString & outBuffer)
{
	KviCString szPlain = plainText;
	outBuffer = "";
	if(m_bEncryptCBC)
	{
		if(!doEncryptCBC(szPlain, outBuffer))
			return KviCryptEngine::EncryptError;
	}
	else
	{
		if(!doEncryptECB(szPlain, outBuffer))
			return KviCryptEngine::EncryptError;
	}
	outBuffer.prepend("+OK ");

	if(outBuffer.len() > maxEncryptLen())
	{
		if(maxEncryptLen() > 0)
		{
			setLastError(__tr2qs("Data buffer too long"));
			return KviCryptEngine::EncryptError;
		}
	}

	//outBuffer = MCPS2_STARTTAG;
	//outBuffer += MCPS2_ENDTAG;
	return KviCryptEngine::Encrypted;
}
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:29,代码来源:libkvirijndael.cpp

示例4: decode

	void decode(KviCString & szText, unsigned char ** buf, int *len)
	{
		// make sure its length is multiple of 12 (eventually pad with zeroes)
		if(szText.len() % 12)
		{
			int oldL = szText.len();
			szText.setLen(szText.len() + (12 - (szText.len() % 12)));
			char * padB = szText.ptr() + oldL;
			char * padE = szText.ptr() + szText.len();
			while(padB < padE)*padB++ = 0;
		}

		*len = (int)(szText.len() * 2) / 3;

		*buf = (unsigned char *)KviMemory::allocate(*len);
		unsigned char * p = (unsigned char *)szText.ptr();
		unsigned char * e = p + szText.len();
		int i;
		unsigned char * bufp = *buf;
		while(p < e)
		{
			quint32 * dw1 = (quint32 *)bufp;
			bufp += 4;
			quint32 * dw2 = (quint32 *)bufp;
			bufp += 4;
			*dw2 = 0;
			for(i=0;i < 6;i++)*dw2 |= (fake_base64dec(*p++)) << (i * 6);
			*dw1 = 0;
			for(i=0;i < 6;i++)*dw1 |= (fake_base64dec(*p++)) << (i * 6);
		}

		// FIXME: this is probably needed only on LittleEndian machines!
		byteswap_buffer(*buf,*len);
	}
开发者ID:kartagis,项目名称:KVIrc,代码行数:34,代码来源:UglyBase64.cpp

示例5: doEncryptCBC

bool KviMircryptionEngine::doEncryptCBC(KviCString & plain, KviCString & encoded)
{
	// make sure it is a multiple of 8 bytes (eventually pad with zeroes)
	if(plain.len() % 8)
	{
		int oldL = plain.len();
		plain.setLen(plain.len() + (8 - (plain.len() % 8)));
		char * padB = plain.ptr() + oldL;
		char * padE = plain.ptr() + plain.len();
		while(padB < padE)
			*padB++ = 0;
	}

	int ll = plain.len() + 8;
	unsigned char * in = (unsigned char *)KviMemory::allocate(ll);

	InitVectorEngine::fillRandomIV(in, 8);

	KviMemory::copy(in + 8, plain.ptr(), plain.len());

	// encrypt
	unsigned char * out = (unsigned char *)KviMemory::allocate(ll);
	BlowFish bf((unsigned char *)m_szEncryptKey.ptr(), m_szEncryptKey.len());
	bf.ResetChain();
	bf.Encrypt(in, out, ll, BlowFish::CBC);
	KviMemory::free(in);

	encoded.bufferToBase64((const char *)out, ll);
	KviMemory::free(out);

	encoded.prepend('*'); // prepend the signature

	return true;
}
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:34,代码来源:libkvirijndael.cpp

示例6:

static Window kvi_x11_findIpcSentinel(Window win)
{
	Atom type;
	int format;
	unsigned long nItems, after;
	unsigned char * data = nullptr;
	if(XGetWindowProperty(kvi_ipc_get_xdisplay(), win, kvi_atom_ipc_sentinel_window,
		   0, 32, false, XA_STRING, &type, &format, &nItems, &after, &data) == Success)
	{
		if((type == XA_STRING) && (format == 8))
		{
			if((nItems == ((unsigned long)(kvi_sentinel_id.len()))) && data)
			{
				if(kvi_strEqualCSN((const char *)data, kvi_sentinel_id.ptr(), kvi_sentinel_id.len()))
				{
					XFree((char *)data);
					return win;
				}
			}
		}
	}

	Window root, parent;
	Window * children;
	unsigned int nChildren;

	if(!XQueryTree(kvi_ipc_get_xdisplay(), win, &root, &parent, &children, &nChildren))
	{
		if(children)
			XFree((char *)children);
		return 0;
	}

	Window found = 0;

	for(size_t i = 0; !found && i < nChildren; ++i)
		found = kvi_x11_findIpcSentinel(children[i]);

	if(children)
		XFree((char *)children);

	return found;
}
开发者ID:Dessa,项目名称:KVIrc,代码行数:43,代码来源:KviIpcSentinel.cpp

示例7: playMrl

bool KviWinampInterface::playMrl(const QString & mrl)
{
	HWND hWinamp = find_winamp(this);
	if(hWinamp)
	{
		QTextCodec * c = mediaplayer_get_codec();
		KviCString szMrl = c ? c->fromUnicode(mrl) : mrl.toUtf8();
		COPYDATASTRUCT cds;
		cds.dwData = IPC_PLAYFILE;
		cds.lpData = (void *)szMrl.ptr();
		cds.cbData = szMrl.len() + 1; // include space for null char
		SendMessage(hWinamp, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
		return true;
	}
	return false;
}
开发者ID:Dessa,项目名称:KVIrc,代码行数:16,代码来源:MpWinampInterface.cpp

示例8: doEncryptECB

bool KviMircryptionEngine::doEncryptECB(KviCString & plain, KviCString & encoded)
{
	// make sure it is a multiple of 8 bytes (eventually pad with zeroes)
	if(plain.len() % 8)
	{
		int oldL = plain.len();
		plain.setLen(plain.len() + (8 - (plain.len() % 8)));
		char * padB = plain.ptr() + oldL;
		char * padE = plain.ptr() + plain.len();
		while(padB < padE)
			*padB++ = 0;
	}

	unsigned char * out = (unsigned char *)KviMemory::allocate(plain.len()); // we use this to avoid endiannes problems

	BlowFish bf((unsigned char *)m_szEncryptKey.ptr(), m_szEncryptKey.len());
	bf.ResetChain();
	bf.Encrypt((unsigned char *)plain.ptr(), out, plain.len(), BlowFish::ECB);

	UglyBase64::encode(out, plain.len(), encoded);
	KviMemory::free(out);
	return true;
}
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:23,代码来源:libkvirijndael.cpp

示例9: initializeEngine

	bool KviCryptController::initializeEngine(KviCryptEngine * pEngine)
	{
		KviCString szEncryptKey;
		KviCString szDecryptKey;
		KviCString szEncKey = "";
		KviCString szDecKey = "";

		if(m_pEnableEncrypt->isChecked())
		{
			bool bEcb=false, bOld=false;
			szEncryptKey = m_pEncryptKeyEdit->text();
			if(kvi_strEqualCIN("ecb:",szEncryptKey.ptr(),4) && (szEncryptKey.len() > 4))
			{
				szEncryptKey.cutLeft(4);
				bEcb=true;
			} else if(kvi_strEqualCIN("old:",szEncryptKey.ptr(),4) && (szEncryptKey.len() > 4)) {
				szEncryptKey.cutLeft(4);
				bOld=true;
			} else if(kvi_strEqualCIN("cbc:",szEncryptKey.ptr(),4)) {
				szEncryptKey.cutLeft(4);
			}

			if(m_pEncryptHexKeyCheck->isChecked())
			{
				char * pcTmpKey;
				if(szEncryptKey.hexToBuffer(&pcTmpKey,false))
				{
					szEncKey = pcTmpKey;
					KviCString::freeBuffer(pcTmpKey);
				}
			} else {
				szEncKey = szEncryptKey;
			}
			if(bEcb)
				szEncKey.prepend("ecb:");
			else if(bOld)
				szEncKey.prepend("old:");
		}

		if(m_pEnableDecrypt->isChecked())
		{
			bool bEcb=false, bOld=false;
			szDecryptKey = m_pDecryptKeyEdit->text();
			if(kvi_strEqualCIN("ecb:",szDecryptKey.ptr(),4) && (szDecryptKey.len() > 4))
			{
				szDecryptKey.cutLeft(4);
				bEcb=true;
			} else if(kvi_strEqualCIN("old:",szDecryptKey.ptr(),4) && (szDecryptKey.len() > 4)) {
				szDecryptKey.cutLeft(4);
				bOld=true;
			} else if(kvi_strEqualCIN("cbc:",szDecryptKey.ptr(),4)) {
				szDecryptKey.cutLeft(4);
			}

			if(m_pDecryptHexKeyCheck->isChecked())
			{
				char * pcTmpKey;
				if(szDecryptKey.hexToBuffer(&pcTmpKey,false))
				{
					szDecKey = pcTmpKey;
					KviCString::freeBuffer(pcTmpKey);
				}
			} else {
				szDecKey = szDecryptKey;
			}
			if(bEcb)
				szDecKey.prepend("ecb:");
			else if(bOld)
				szDecKey.prepend("old:");
		}

		bool bRet = pEngine->init(szEncKey.ptr(),szEncKey.len(),szDecKey.ptr(),szDecKey.len());

		return bRet;
	}
开发者ID:kartagis,项目名称:KVIrc,代码行数:75,代码来源:KviCryptController.cpp

示例10: init

bool KviRijndaelEngine::init(const char * encKey, int encKeyLen, const char * decKey, int decKeyLen)
{
	if(m_pEncryptCipher)
	{
		delete m_pEncryptCipher;
		m_pEncryptCipher = nullptr;
	}
	if(m_pDecryptCipher)
	{
		delete m_pDecryptCipher;
		m_pDecryptCipher = nullptr;
	}

	if(encKey && (encKeyLen > 0))
	{
		if(!(decKey && (decKeyLen > 0)))
		{
			decKey = encKey;
			decKeyLen = encKeyLen;
		} // else all
	}
	else
	{
		// no encrypt key specified...
		if(decKey && decKeyLen)
		{
			encKey = decKey;
			encKeyLen = decKeyLen;
		}
		else
		{
			// both keys missing
			setLastError(__tr2qs("Missing both encryption and decryption key: at least one is needed"));
			return false;
		}
	}

	KviCString szTmpEncryptKey = KviCString(encKey, encKeyLen);
	KviCString szTmpDecryptKey = KviCString(decKey, decKeyLen);

	m_bEncryptMode = CBC; // default mode
	m_bDecryptMode = CBC; // default mode

	if(kvi_strEqualCIN("ecb:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
		m_bEncryptMode = ECB;
	}
	else if(kvi_strEqualCIN("old:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
		m_bEncryptMode = OldCBC;
	}
	else if(kvi_strEqualCIN("cbc:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
	{
		szTmpEncryptKey.cutLeft(4);
	}

	if(kvi_strEqualCIN("ecb:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
		m_bDecryptMode = ECB;
	}
	else if(kvi_strEqualCIN("old:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
		m_bDecryptMode = OldCBC;
	}
	else if(kvi_strEqualCIN("cbc:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
	{
		szTmpDecryptKey.cutLeft(4);
	}

	int defLen = getKeyLen();

	szTmpEncryptKey.padRight(defLen);
	szTmpDecryptKey.padRight(defLen);

	m_pEncryptCipher = new Rijndael();

	int retVal = m_pEncryptCipher->init(
	    (m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
	    Rijndael::Encrypt,
	    (unsigned char *)szTmpEncryptKey.ptr(),
	    getKeyLenId());
	if(retVal != RIJNDAEL_SUCCESS)
	{
		delete m_pEncryptCipher;
		m_pEncryptCipher = nullptr;
		setLastErrorFromRijndaelErrorCode(retVal);
		return false;
	}

	m_pDecryptCipher = new Rijndael();
	retVal = m_pDecryptCipher->init(
	    (m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
	    Rijndael::Decrypt,
	    (unsigned char *)szTmpDecryptKey.ptr(),
	    getKeyLenId());
	if(retVal != RIJNDAEL_SUCCESS)
//.........这里部分代码省略.........
开发者ID:CardinalSins,项目名称:KVIrc,代码行数:101,代码来源:libkvirijndael.cpp

示例11: load


//.........这里部分代码省略.........
			switch(*begin)
			{
				case 0:
					// empty line
				break;
				case '#':
					// comment: just skip it
				break;
				case '[':
					// group ?
					begin++;
					if(*begin && (*begin != ']'))
					{
						char * z = begin;
#define COMPAT_WITH_OLD_CONFIGS
#ifdef COMPAT_WITH_OLD_CONFIGS
						// run to the end of the string
						while(*z)z++;
						// run back to the trailing ']'
						while((z > begin) && (*z != ']'))z--;
						// if it is not ther just run back to the end of the string
						if(*z != ']')while(*z)z++;
#else
						// new configs have it always encoded properly
						while(*z && (*z != ']'))z++;
#endif
						*z = 0;
						tmp.hexDecode(begin);
						tmp.stripRightWhiteSpace(); // no external spaces in group names

						if(!tmp.isEmpty())
						{
							QString szGroup = m_bLocal8Bit ?
								QString::fromLocal8Bit(tmp.ptr(),tmp.len()) :
								QString::fromUtf8(tmp.ptr(),tmp.len());
							p_group = m_pDict->find(szGroup);
							if(!p_group)
							{
								p_group = new KviConfigurationFileGroup(17,false);
								p_group->setAutoDelete(true);
								m_pDict->insert(szGroup,p_group);
							}
						}
					}
				break;
				default:
				{
					// real data ?
					char * z = begin;
					while(*z && (*z != '='))z++;
					if(*z && (z != begin))
					{
						*z = 0;
						tmp.hexDecode(begin);
						tmp.stripRightWhiteSpace(); // No external spaces at all in keys
						if(!tmp.isEmpty())
						{
							QString szKey =  m_bLocal8Bit ?
									QString::fromLocal8Bit(tmp.ptr(),tmp.len()) :
									QString::fromUtf8(tmp.ptr(),tmp.len());
							z++;
							while(*z && ((*z == ' ') || (*z == '\t')))z++;
							if(*z)
							{
								tmp.hexDecode(z);
								QString * pVal = new QString( m_bLocal8Bit ?
开发者ID:tronsha,项目名称:KVIrc,代码行数:67,代码来源:KviConfigurationFile.cpp

示例12: save

bool KviFile::save(const KviCString & szData)
{
	if(!save((kvi_u32_t)(szData.len())))
		return false;
	return (write(szData.ptr(), szData.len()) == (unsigned int)szData.len());
}
开发者ID:AndrioCelos,项目名称:KVIrc,代码行数:6,代码来源:KviFile.cpp


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