本文整理汇总了C++中AnsiString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::GetLength方法的具体用法?C++ AnsiString::GetLength怎么用?C++ AnsiString::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiString
的用法示例。
在下文中一共展示了AnsiString::GetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAutoLogoutTimer
void
TCPConnection::AsyncRead(const AnsiString &delimitor)
{
UpdateAutoLogoutTimer();
std::function<void (const boost::system::error_code&, size_t)> AsyncReadCompletedFunction =
std::bind(&TCPConnection::AsyncReadCompleted, shared_from_this(),
std::placeholders::_1,
std::placeholders::_2);
if (is_ssl_)
{
if (delimitor.GetLength() == 0)
boost::asio::async_read(ssl_socket_, receive_buffer_, boost::asio::transfer_at_least(1), AsyncReadCompletedFunction);
else
boost::asio::async_read_until(ssl_socket_, receive_buffer_, delimitor, AsyncReadCompletedFunction);
}
else
{
if (delimitor.GetLength() == 0)
{
boost::asio::async_read(socket_, receive_buffer_, boost::asio::transfer_at_least(1), AsyncReadCompletedFunction);
}
else
{
boost::asio::async_read_until(socket_, receive_buffer_, delimitor, AsyncReadCompletedFunction);
}
}
}
示例2:
void
StringParser::Base64Decode(const String &sInput, String &sOutput)
{
if (sInput.GetLength() == 0)
{
sOutput.Empty();
return;
}
AnsiString sInputStr = sInput;
MimeCodeBase64 DeCoder;
DeCoder.AddLineBreak(false);
DeCoder.SetInput(sInputStr, sInputStr.GetLength(), false);
AnsiString output;
DeCoder.GetOutput(output);
int length = output.GetLength();
// Since we're going to store the result in
// a normal StdString, we can't return null
// characters.
for (int i = 0; i < length; i++)
{
if (output[i] == 0)
output[i] = '\t';
}
sOutput = output;
}
示例3:
String
MessageUtilities::GetSendersIP(boost::shared_ptr<Message> pMessage)
{
const String fileName = PersistentMessage::GetFileName(pMessage);
AnsiString sHeader = PersistentMessage::LoadHeader(fileName);
MimeHeader oHeader;
oHeader.Load(sHeader, sHeader.GetLength(), true);
// Locate the first Received header
MimeField *pReceivedHeader = oHeader.GetField("Received");
if (pReceivedHeader == 0)
return "127.0.0.1";
// Now we should try to find the IP in the received header.
String sReceivedValue = pReceivedHeader->GetValue();
int iAddressStart = sReceivedValue.Find(_T("[")) +1;
int iAddressEnd = sReceivedValue.Find(_T("]"), iAddressStart);
int iAddressLen = iAddressEnd - iAddressStart;
if (iAddressLen <= 0)
return "127.0.0.1";
String sIPAddress = sReceivedValue.Mid(iAddressStart, iAddressLen);
if (!StringParser::IsValidIPAddress(sIPAddress))
return "127.0.0.1";
return sIPAddress;
}
示例4:
AnsiString
Canonicalization::GetDKIMWithoutSignature_(AnsiString value)
{
// locate the b= tag
int pos = value.Find("b=");
if (pos < 0)
return "";
// Locate end of b-tag. We need to use the ;-separator
// here. The signature may contain spaces and newlines
// if it's folded (and canon-mode is set to simple).
int end = value.Find(";", pos);
int actualEnd = 0;
if (end > pos)
actualEnd = end;
else
actualEnd = value.GetLength();
int len = actualEnd - pos;
AnsiString before = value.Mid(0, pos+2);
AnsiString after = value.Mid(actualEnd);
AnsiString result = before + after;
return result;
}
示例5: Write
bool
File::Write(const AnsiString &sWrite)
{
AnsiString sTmp = sWrite;
DWORD dwWritten = 0;
return Write((const unsigned char*) sTmp.GetBuffer(), sTmp.GetLength(), dwWritten);
}
示例6:
String
MimeHeader::GetUnicodeFieldValue(const AnsiString &pszFieldName, const AnsiString &sRawFieldValue)
{
AnsiString sWideStr;
sWideStr = "";
if (sRawFieldValue.IsEmpty())
{
if (IniFileSettings::Instance()->GetLogLevel() > 99) LOG_DEBUG("MimeHeader::GetUnicodeFieldValue - sRawFieldValue.IsEmpty");
return sWideStr;
}
// De-code the value to plain text.
AnsiString sRetVal;
FieldCodeBase* pCoder = MimeEnvironment::CreateFieldCoder(pszFieldName);
pCoder->SetInput(sRawFieldValue, sRawFieldValue.GetLength(), false);
pCoder->GetOutput(sRetVal);
AnsiString sCharset = pCoder->GetCharset();
delete pCoder;
sWideStr = Charset::ToWideChar(sRetVal, sCharset);
if (IniFileSettings::Instance()->GetLogLevel() > 99) LOG_DEBUG("MimeHeader::GetUnicodeFieldValue - sWideStr: " + sWideStr);
return sWideStr;
}
示例7: server
void
SMTPClientConnection::ParseData(const AnsiString &Request)
//---------------------------------------------------------------------------()
// DESCRIPTION:
// Parses a server SMTP cmmand.
//---------------------------------------------------------------------------()
{
multi_line_response_buffer_ += Request;
if (multi_line_response_buffer_.GetLength() > 10000)
{
UpdateAllRecipientsWithError_(500, "Unexpected response from server (too long).", false);
return;
}
if (Request.GetLength() > 3 && (Request.GetAt(3) == '-'))
{
// Multi-line response. Wait for full buffer.
multi_line_response_buffer_ += "\r\n";
EnqueueRead();
return;
}
bool postReceive = InternalParseData(multi_line_response_buffer_);
multi_line_response_buffer_.Empty();
if (postReceive)
EnqueueRead();
}
示例8: GetSignatureFields
/*
Returns one of the following
Neutral - Undecided
Pass - Signature verified properly.
TempFail - Failed to verify signature, potentially a local problem.
PermFail - Failed to verify signature.
*/
DKIM::Result
DKIM::Verify(const String &fileName)
{
if (FileUtilities::FileSize(fileName) > MaxFileSize)
return Neutral;
AnsiString messageHeader = PersistentMessage::LoadHeader(fileName);
MimeHeader mimeHeader;
mimeHeader.Load(messageHeader.GetBuffer(), messageHeader.GetLength(), false);
vector<pair<AnsiString, AnsiString> > signatureFields = GetSignatureFields(mimeHeader);
if (signatureFields.size() == 0)
{
// No signatures in message.
return Neutral;
}
Result result = Neutral;
typedef pair<AnsiString, AnsiString> HeaderField;
boost_foreach (HeaderField signatureField, signatureFields)
{
result = _VerifySignature(fileName, messageHeader, signatureField);
if (result == Pass)
return Pass;
};
示例9:
// helper.
EVP_PKEY*
_GetPublicKey(const AnsiString &keyData)
{
// base64 decode the public key.
AnsiString publicKeyData = Base64::Decode(keyData, keyData.GetLength());
const unsigned char * publicKeyDataPointer = (const unsigned char*) publicKeyData.GetBuffer();
EVP_PKEY *publicKey = d2i_PUBKEY(NULL, &publicKeyDataPointer, publicKeyData.GetLength());
return publicKey;
}
示例10: while
AnsiString
SimpleCanonicalization::CanonicalizeBody(AnsiString value)
{
// remove all empty lines.
while (value.EndsWith("\r\n"))
value = value.Mid(0, value.GetLength()-2);
value += "\r\n";
return value;
}
示例11: protocols
void
Base64Tester::Test()
{
String s;
AnsiString input = "Test";
s = Base64::Encode(input.GetBuffer(), input.GetLength());
if (s.Compare(_T("VGVzdA==")) != 0)
throw;
input = "Test test test test test test test!!!!";
s = Base64::Encode(input, input.GetLength());
if (s.Compare(_T("VGVzdCB0ZXN0IHRlc3QgdGVzdCB0ZXN0IHRlc3QgdGVzdCEhISE=")) != 0)
throw;
input = "hMailServer is a free e-mail server for Microsoft Windows. It's used by Internet service providers, companies, governments, schools and enthusiasts in all parts of the world. It supports the common e-mail protocols (IMAP, SMTP and POP3) and can easily be integrated with many existing web mail systems. It has flexible score-based spam protection and can attach to your virus scanner to scan all incoming and outgoing email.";
s = Base64::Encode(input, input.GetLength());
if (s.Compare(_T("aE1haWxTZXJ2ZXIgaXMgYSBmcmVlIGUtbWFpbCBzZXJ2ZXIgZm9yIE1pY3Jvc29mdCBXaW5kb3dzLiBJdCdzIHVzZWQgYnkgSW50ZXJuZXQgc2VydmljZSBwcm92aWRlcnMsIGNvbXBhbmllcywgZ292ZXJubWVudHMsIHNjaG9vbHMgYW5kIGVudGh1c2lhc3RzIGluIGFsbCBwYXJ0cyBvZiB0aGUgd29ybGQuIEl0IHN1cHBvcnRzIHRoZSBjb21tb24gZS1tYWlsIHByb3RvY29scyAoSU1BUCwgU01UUCBhbmQgUE9QMykgYW5kIGNhbiBlYXNpbHkgYmUgaW50ZWdyYXRlZCB3aXRoIG1hbnkgZXhpc3Rpbmcgd2ViIG1haWwgc3lzdGVtcy4gSXQgaGFzIGZsZXhpYmxlIHNjb3JlLWJhc2VkIHNwYW0gcHJvdGVjdGlvbiBhbmQgY2FuIGF0dGFjaCB0byB5b3VyIHZpcnVzIHNjYW5uZXIgdG8gc2NhbiBhbGwgaW5jb21pbmcgYW5kIG91dGdvaW5nIGVtYWlsLg==")) != 0)
throw;
input = "VGVzdA==";
s = Base64::Decode(input, input.GetLength());
if (s.Compare(_T("Test")) != 0)
throw;
input = "VGVzdCB0ZXN0IHRlc3QgdGVzdCB0ZXN0IHRlc3QgdGVzdCEhISE=";
s = Base64::Decode(input, input.GetLength());
if (s.Compare(_T("Test test test test test test test!!!!")) != 0)
throw;
input = "aE1haWxTZXJ2ZXIgaXMgYSBmcmVlIGUtbWFpbCBzZXJ2ZXIgZm9yIE1pY3Jvc29mdCBXaW5kb3dzLiBJdCdzIHVzZWQgYnkgSW50ZXJuZXQgc2VydmljZSBwcm92aWRlcnMsIGNvbXBhbmllcywgZ292ZXJubWVudHMsIHNjaG9vbHMgYW5kIGVudGh1c2lhc3RzIGluIGFsbCBwYXJ0cyBvZiB0aGUgd29ybGQuIEl0IHN1cHBvcnRzIHRoZSBjb21tb24gZS1tYWlsIHByb3RvY29scyAoSU1BUCwgU01UUCBhbmQgUE9QMykgYW5kIGNhbiBlYXNpbHkgYmUgaW50ZWdyYXRlZCB3aXRoIG1hbnkgZXhpc3Rpbmcgd2ViIG1haWwgc3lzdGVtcy4gSXQgaGFzIGZsZXhpYmxlIHNjb3JlLWJhc2VkIHNwYW0gcHJvdGVjdGlvbiBhbmQgY2FuIGF0dGFjaCB0byB5b3VyIHZpcnVzIHNjYW5uZXIgdG8gc2NhbiBhbGwgaW5jb21pbmcgYW5kIG91dGdvaW5nIGVtYWlsLg==";
s = Base64::Decode(input, input.GetLength());
if (s.Compare(_T("hMailServer is a free e-mail server for Microsoft Windows. It's used by Internet service providers, companies, governments, schools and enthusiasts in all parts of the world. It supports the common e-mail protocols (IMAP, SMTP and POP3) and can easily be integrated with many existing web mail systems. It has flexible score-based spam protection and can attach to your virus scanner to scan all incoming and outgoing email.")) != 0)
throw;
}
示例12: GenerateHash
AnsiString HashCreator::GenerateHash(const AnsiString &inputString, const AnsiString &salt)
{
AnsiString saltString = salt;
if (saltString.GetLength() == 0 && _hashType == SHA256)
{
AnsiString randomString = PasswordGenerator::Generate();
saltString = _GetHash(randomString, hex);
saltString = saltString.Mid(0, SALT_LENGTH);
}
AnsiString value = saltString + _GetHash(saltString + inputString, hex);
return value;
}
示例13: MimeHeader
boost::shared_ptr<MimeHeader>
MessageUtilities::_GetMessageHeader(boost::shared_ptr<Message> pMessage)
{
String fileName = PersistentMessage::GetFileName(pMessage);
AnsiString sHeader = PersistentMessage::LoadHeader(fileName);
boost::shared_ptr<MimeHeader> pHeader = boost::shared_ptr<MimeHeader>(new MimeHeader());
boost::shared_ptr<MimeHeader> pMimeHeader = boost::shared_ptr<MimeHeader>(new MimeHeader);
pHeader->Load(sHeader, sHeader.GetLength(), true);
return pHeader;
}
示例14:
void
POP3ClientConnection::PrependHeaders_()
//---------------------------------------------------------------------------()
// DESCRIPTION:
// Adds headers to the beginning of the message.
//---------------------------------------------------------------------------()
{
// Add a header with the name of the external account, so that
// we can check where we downloaded it from later on.
String sHeader;
sHeader.Format(_T("X-hMailServer-ExternalAccount: %s\r\n"), account_->GetName().c_str());
AnsiString sAnsiHeader = sHeader;
transmission_buffer_->Append((BYTE*) sAnsiHeader.GetBuffer(), sAnsiHeader.GetLength());
}
示例15: Store
// store the body part to un-encoded string buffer
void MimeBody::Store(AnsiString &output, bool bIncludeHeader) const
{
// store header fields
int nSize = 0;
if (bIncludeHeader)
MimeHeader::Store(output);
// Copy the data to the output buffer.
output.append(m_pbText);
if (m_listBodies.empty())
return;
// store child body parts
string strBoundary = GetBoundary();
if (strBoundary.empty())
return; // boundary not be set
int nBoundSize = (int)strBoundary.size() + 6;
// Bill48105 - These iOutputSize are temp fix for [ ambiguous error
int iOutputSizeLess2 = output.size() - 2;
int iOutputSizeLess1 = output.size() - 1;
for (BodyList::const_iterator it=m_listBodies.begin(); it!=m_listBodies.end(); it++)
{
// If the initial body ends with \r\n, remove them. We add new ones below.
if (m_listBodies.begin() == it && output.size() >= 2 &&
output[iOutputSizeLess2] == '\r' && output[iOutputSizeLess1] == '\n')
{
output = output.Mid(0, output.GetLength() - 2);
}
AnsiString boundaryLine = Formatter::Format(_T("\r\n--{0}\r\n"), String(strBoundary));
output.append(boundaryLine);
shared_ptr<MimeBody> pBP = *it;
ASSERT(pBP != NULL);
pBP->Store(output);
}
AnsiString endBoundaryLine = Formatter::Format(_T("\r\n--{0}--\r\n"), String(strBoundary));
output.append(endBoundaryLine);
}