示例#1
0
bool rfc2047::encode_update(const char* in, int n, acl::string* out,
	const char* charset /* = "gb2312" */, char coding /* = 'B' */)
{
	if (charset == NULL || *charset == 0)
		return false;
	char ch = toupper(coding);
	if (ch != 'B' && ch != 'Q')
		return false;

	acl_assert(in);
	acl_assert(n > 0);
	acl_assert(out);

	if (m_pCurrentEntry == NULL
		|| !EQ(m_pCurrentEntry->pCharset->c_str(), charset)
		|| m_pCurrentEntry->coding != ch)
	{
		if (m_coder)
		{
			acl_assert(m_pCurrentEntry);
			m_coder->encode_finish(out);
			*out << "?=";
			delete m_coder;
			m_coder = NULL;
		}

		m_pCurrentEntry = NEW rfc2047_entry;
		m_pCurrentEntry->pData = NEW acl::string(n * 4/3);
		m_pCurrentEntry->pCharset = NEW acl::string(charset);
		m_pCurrentEntry->pCharset->upper();
		m_pCurrentEntry->coding = ch;

		m_List.push_back(m_pCurrentEntry);

		if (ch == 'B')
		{
			m_coder = NEW mime_base64(m_addCrlf, false);
			*out << "=?" << m_pCurrentEntry->pCharset->c_str()
				<< "?B?";
		}
		else if (ch == 'Q')
		{
			m_coder = NEW mime_quoted_printable(m_addCrlf, false);
			*out << "=?" << m_pCurrentEntry->pCharset->c_str()
				<< "?Q?";
		}
	}

	acl_assert(m_pCurrentEntry);
	acl_assert(m_coder);

	m_coder->encode_update(in, n, out);
	return true;
}
示例#2
0
文件: mail_body.cpp 项目: wzugang/acl
mail_body::mail_body(const char* charset /* = "utf-8" */,
	const char* encoding /* = "base64" */)
	: charset_(charset)
	, transfer_encoding_(encoding)
{
	if (transfer_encoding_.compare("base64", false) == 0)
		coder_ = NEW mime_base64(true, true);
	else if (transfer_encoding_.compare("qp", false) == 0)
		coder_ = NEW mime_quoted_printable(true, true);
	else if (transfer_encoding_.compare("uucode", false) == 0)
		coder_ = NEW mime_uucode(true, true);
	else if (transfer_encoding_.compare("xxcode", false) == 0)
		coder_ = NEW mime_xxcode(true, true);
	else
		coder_ = NULL;

	html_ = NULL;
	hlen_ = 0;
	text_ = NULL;
	tlen_ = 0;
	attachments_ = NULL;
	mime_stype_ = MIME_STYPE_OTHER;
}