資源簡介
實現(xiàn)foxmail的郵件收取與發(fā)送,源代碼。

代碼片段和文件信息
//?base64.cpp:?implementation?of?the?Cbase64?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“base64.h“
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
Cbase64::Cbase64()?:
m_pszEncodeList(?“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=“?)?
{
//?初始化解碼表
unsigned?int?i??uiIndex?=?0?;?
for(?i?=?‘A‘?;?i?<=?‘Z‘?;?++i?)
m_szDecodeList[?i?]?=?uiIndex++?;?
for(?i?=?‘a(chǎn)‘?;?i?<=?‘z‘?;?++i?)
m_szDecodeList[?i?]?=?uiIndex++?;?
for(?i?=?‘0‘?;?i?<=?‘9‘?;?++i?)
m_szDecodeList[?i?]?=?uiIndex++?;?
m_szDecodeList[?‘+‘?]?=?uiIndex++?;
m_szDecodeList[?‘/‘?]?=?uiIndex++?;
//?m_szDecodeList[?‘=‘?]?=?uiIndex++?;
}
Cbase64::~Cbase64()
{
}
/*
功能: base64編碼
參數(shù): pSource 要編碼的字節(jié)
uiSize 要編碼的字節(jié)大小
pDestination 編碼輸出
pdwWritten 編碼輸入的字節(jié)數(shù),這個數(shù)一定是4的整數(shù)倍。
?? 備注: 計算base64編碼需要的字節(jié)數(shù)(不包括NULL):uiSize?/?3?*?4?+?uiSize?%?3???4?:?0?;
*/
void?Cbase64::Encode(const?void?*const?pSource?const?unsigned?int?uiSize?
?void?*pDestination??unsigned?long?*?const?pdwWritten?)
{
//?必須使用unsigned?char否者位移有符號字節(jié)會得到奇怪結(jié)果。比如:213右移2位后得:245
const?unsigned?char?*pSrc?=?(const?unsigned?char*?)pSource?;
unsigned?char?*pDst?=?(unsigned?char?*)pDestination?;?
const?unsigned?char?*?const?pEnd?=?pSrc?+?uiSize?-?uiSize?%?3?;?//?末尾
for(?;?pSrc? {
pDst[0]?=?m_pszEncodeList[?pSrc[0]?>>?2?]?;
pDst[1]?=?m_pszEncodeList[?(?(?pSrc[0]?&?3?)<<4?)?|?(?(?pSrc[1]?/*&?240*/?)?>>4?)?]?;?
pDst[2]?=?m_pszEncodeList[?(?(?pSrc[1]?&?15?)?<<2?)?|?(?(?pSrc[2]?/*&?192*/?)?>>6?)?];
pDst[3]?=?m_pszEncodeList[?pSrc[2]?&?63?]?;
}
//?處理末尾不足3位的字節(jié)
if(?uiSize?%?3?==?1?)?//?如果剩余了1位,那么應該補2個=
{
pDst[0]?=?m_pszEncodeList[?pSrc[0]?>>?2?]?;
pDst[1]?=?m_pszEncodeList[?(?(?pSrc[0]?&?3?)<<4?)?|?(?(?pSrc[1]?&?240?)?>>4?)?]?;?
pDst[2]?=?‘=‘?;
pDst[3]?=?‘=‘?;
}
else?if?(?uiSize?%?3?==?2?)
{
pDst[0]?=?m_pszEncodeList[?pSrc[0]?>>?2?]?;
pDst[1]?=?m_pszEncodeList[?(?(?pSrc[0]?&?3?)<<4?)?|?(?(?pSrc[1]?&?240?)?>>4?)?]?;?
pDst[2]?=?m_pszEncodeList[?(?(?pSrc[1]?&?15?)?<<2?)?|?(?(?pSrc[2]?&?192?)?>>6?)?]?;
pDst[3]?=??‘=‘?;
}
*pdwWritten?=?uiSize?/?3?*?4??;
if(?uiSize?%?3?)
*pdwWritten?+=?4?;
}
/*
功能: base64解碼
參數(shù): pSource 編碼后的數(shù)據(jù)buffer
uiSize 編碼的大小,需要是4的整數(shù)倍
pDestination 輸出buffer
pWritten?輸出實際寫入的字節(jié)數(shù)
返回: true?解碼成功,false 失敗。
備注: 輸出最多需要的字節(jié)數(shù)是(不包括NULL):uiSize?/?4?*?3?
最多會浪費2個字節(jié)空間,當末尾有2個=號時。
并不做解碼的數(shù)據(jù)合法性檢查。如果做的話,需要檢測每個字節(jié)高2是否是0,
這樣做不太有效率。
*/
bool?Cbase64::Decode(const?void?*const?pSource?const?unsigned?int?uiSize?
?void?*pDestination??unsigned?long?*?const?pdwWritten?)
{
//?如果要解碼的字符數(shù)不是4的倍數(shù),那么解碼的數(shù)據(jù)肯定不合法了。
//?因為base64編碼只會生成4的倍數(shù)的編碼數(shù)據(jù)。
if(?uiSize?%?4?)
return?false?;
const?unsigned?char?*pSrc?=?(const?unsigned?char*?)pSource?;
u
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5079??2010-07-26?18:11??foxmail?2010.08.10\ba
?????文件????????867??2010-07-26?18:06??foxmail?2010.08.10\ba
?????文件??????19340??2010-08-10?23:38??foxmail?2010.08.10\DlgFoxmail.cpp
?????文件???????2356??2010-08-10?22:04??foxmail?2010.08.10\DlgFoxmail.h
?????文件???????7503??2010-08-07?22:10??foxmail?2010.08.10\DlgNewMail.cpp
?????文件???????1811??2010-08-07?03:02??foxmail?2010.08.10\DlgNewMail.h
?????文件???????2762??2010-08-05?23:31??foxmail?2010.08.10\DlgOption.cpp
?????文件???????1380??2010-08-04?14:37??foxmail?2010.08.10\DlgOption.h
?????文件?????175472??2010-08-10?20:33??foxmail?2010.08.10\Foxmail.aps
?????文件???????3207??2010-08-16?16:50??foxmail?2010.08.10\Foxmail.clw
?????文件???????2077??2010-08-03?20:34??foxmail?2010.08.10\Foxmail.cpp
?????文件???????5701??2010-08-11?00:42??foxmail?2010.08.10\Foxmail.dsp
?????文件????????539??2010-08-03?20:34??foxmail?2010.08.10\Foxmail.dsw
?????文件???????1335??2010-08-03?20:34??foxmail?2010.08.10\Foxmail.h
?????文件??????61952??2010-08-16?17:10??foxmail?2010.08.10\Foxmail.opt
?????文件???????2956??2010-08-16?16:50??foxmail?2010.08.10\Foxmail.plg
?????文件??????10009??2010-08-08?00:00??foxmail?2010.08.10\Foxmail.rc
?????文件???????4597??2010-08-10?23:16??foxmail?2010.08.10\MailIO.cpp
?????文件???????1184??2010-08-10?23:16??foxmail?2010.08.10\MailIO.h
?????文件????????157??2010-08-06?16:57??foxmail?2010.08.10\Options.ini
?????文件???????4252??2010-08-10?20:50??foxmail?2010.08.10\Pop3\Pop3.cpp
?????文件???????1289??2010-08-10?20:57??foxmail?2010.08.10\Pop3\Pop3.h
?????文件???????3597??2010-08-03?20:34??foxmail?2010.08.10\ReadMe.txt
?????文件??????????0??2010-08-04?13:33??foxmail?2010.08.10\res\default1.bin
?????文件???????5390??2010-08-05?16:56??foxmail?2010.08.10\res\Deleted.ico
?????文件???????5854??2010-08-05?16:56??foxmail?2010.08.10\res\Draftbox.ico
?????文件??????97566??2010-08-04?14:28??foxmail?2010.08.10\res\Foxmail.ico
?????文件????????399??2010-08-03?20:34??foxmail?2010.08.10\res\Foxmail.rc2
?????文件???????1406??2010-08-05?16:24??foxmail?2010.08.10\res\Inbox.ico
?????文件???????1406??2010-08-04?13:54??foxmail?2010.08.10\res\New?Mail?2.ico
............此處省略20個文件信息
評論
共有 條評論