求pop3邮件带附件的解码程序代码,高分相送! RT 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单得很,base64编码。#define cBASE64PAD '='char* CBase64::szBase64Table= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/";int CBase64::Encode(char* orig, int len, char* base64, int size){ if(size < EncodeSize(len)) return -1; char* current=orig; int i=0; while(len > 2) { base64[i++] = szBase64Table[current[0] >> 2]; base64[i++] = szBase64Table[((current[0] & 0x03) << 4) + (current[1] >> 4)]; base64[i++] = szBase64Table[((current[1] & 0x0f) << 2) + (current[2] >> 6)]; base64[i++] = szBase64Table[current[2] & 0x3f]; current += 3; len -= 3; } if(len != 0) { base64[i++] = szBase64Table[current[0] >> 2]; if (len > 1) { base64[i++] = szBase64Table[((current[0] & 0x03) << 4) + (current[1] >> 4)]; base64[i++] = szBase64Table[(current[1] & 0x0f) << 2]; base64[i++] = cBASE64PAD; } else { base64[i++] = szBase64Table[(current[0] & 0x03) << 4]; base64[i++] = cBASE64PAD; base64[i++] = cBASE64PAD; } } return i;}int CBase64::Decode(char* base64, int len, char* orig, int size){ if(size < DecodeSize(len)) return -1; int c; int i; //index of base64 int j=0; //index of orig for(i=0; i<len; i++) { c=base64[i]; if(c==cBASE64PAD) break; c=(int)strchr(szBase64Table, c); if(c==0) return -1; c-=(int)szBase64Table; switch(i & 0x03) //i%4 { case 0: orig[j] = c << 2; break; case 1: orig[j++] |= c >> 4; orig[j] = (c & 0x0f) << 4; break; case 2: orig[j++] |= c >> 2; orig[j] = (c & 0x03) << 6; break; case 3: orig[j++] |= c; break; } } if(c == cBASE64PAD) { switch(i & 0x03) //i % 4 { case 0: case 1: return -1; case 2: j++; case 3:// j++; break; } } return j;} 忘了,两个inline的东西static int EncodeSize(int nOrigSize){ return ((nOrigSize + 2) / 3) << 2;}static int DecodeSize(int nBase64Size){ return nBase64Size / 4 * 3;} 谢谢 ndy_w(carpe diem)不过你说的也太简单了吧,我指的是如果将一个邮件的原始信息存成一个.msg文件,能将邮件的信息以及附件等从中解析出来的整个代码; mime++ 1.0是公开的源码的,网上可以搜到 to kingbird(core dump):没有找到源代码啊,那个网站没提供源代码,你有吗? upqp编码解码的部分的MIME++里面好像也有; mime++ 1.0好像很难用啊,有谁用过吗 iocp中GetQueuedCompletionStatus的问题? 对话框基类的选择 为什么用socket I/O模型得不对客户端的IP和端口号 .NET中如何调试vc编写的动态链接库 怎样在程序中设置Label控件的宽度和高度呀 寻找VC下的波形控件 帮帮新手 帮帮忙把int型转成string型或者char型的函数,谢谢??? 我得到拥有窗口和没有窗口的进程ID,怎么得到它的HWND?? 如何簡繁體轉換,如何簡繁體顯示 请问哪位同仁有用vc编的抽奖程序?高分收购! 如何disable掉propertsheet的下一步按钮?
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";int CBase64::Encode(char* orig, int len, char* base64, int size)
{
if(size < EncodeSize(len))
return -1;
char* current=orig;
int i=0;
while(len > 2)
{
base64[i++] = szBase64Table[current[0] >> 2];
base64[i++] = szBase64Table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
base64[i++] = szBase64Table[((current[1] & 0x0f) << 2) + (current[2] >> 6)];
base64[i++] = szBase64Table[current[2] & 0x3f];
current += 3;
len -= 3;
}
if(len != 0)
{
base64[i++] = szBase64Table[current[0] >> 2];
if (len > 1)
{
base64[i++] = szBase64Table[((current[0] & 0x03) << 4) + (current[1] >> 4)];
base64[i++] = szBase64Table[(current[1] & 0x0f) << 2];
base64[i++] = cBASE64PAD;
}
else
{
base64[i++] = szBase64Table[(current[0] & 0x03) << 4];
base64[i++] = cBASE64PAD;
base64[i++] = cBASE64PAD;
}
}
return i;
}int CBase64::Decode(char* base64, int len, char* orig, int size)
{
if(size < DecodeSize(len))
return -1;
int c;
int i; //index of base64
int j=0; //index of orig
for(i=0; i<len; i++)
{
c=base64[i];
if(c==cBASE64PAD)
break;
c=(int)strchr(szBase64Table, c);
if(c==0)
return -1;
c-=(int)szBase64Table;
switch(i & 0x03) //i%4
{
case 0:
orig[j] = c << 2;
break;
case 1:
orig[j++] |= c >> 4;
orig[j] = (c & 0x0f) << 4;
break;
case 2:
orig[j++] |= c >> 2;
orig[j] = (c & 0x03) << 6;
break;
case 3:
orig[j++] |= c;
break;
}
}
if(c == cBASE64PAD)
{
switch(i & 0x03) //i % 4
{
case 0:
case 1:
return -1;
case 2:
j++;
case 3:
// j++;
break;
}
}
return j;
}
{
return ((nOrigSize + 2) / 3) << 2;
}
static int DecodeSize(int nBase64Size)
{
return nBase64Size / 4 * 3;
}
没有找到源代码啊,那个网站没提供源代码,你有吗?