1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*************************************************************************
*
* HTCd - Copyright (C) 1998-2006 Henrik Rydberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mime/mailbox.h>
#include <mime/mime.h>
#include <mime/enc.h>
#include <sys/stat.h>
static fp_stream mout(stdout),merr(stderr);
static void Show(mstream& out,const Message& msg)
{
if(msg.cont_type.empty()||
eqn(msg.cont_type,mime_textplain)||
eqn(msg.cont_type,mime_texthtml)) {
if(eqn(msg.cont_trans_enc,trans_quote)) {
//decodeQP(out,msg.body);
mswrite tmp;
decodeQP(tmp,msg.body);
encodeQP(out,tmp.str());
}
else {
//out<<msg.body<<"\n";
encodeQP(out,msg.body);
}
}
else out<<"(not shown)\n";
}
main(int argc,char* argv[])
{
if(argc<2) {
merr<<"Usage: "<<argv[0]<<" <source> [index]\n";
return 1;
}
Mailbox box;
GetMessages(box,argv[1]);
merr<<"Found "<<box.size()<<" messages\n";
if(argc>2) {
Message msg(box[atoi(argv[2])]);
//msg.Pick(mime_textplain);
mswrite tmp;
encodeHeader(tmp,mime_default,msg.subject);
msg.subject=tmp.str();
msg.putHead(mout);
mout<<"-----------------------------------------\n";
rpile part;
if(msg.Multipart(part)) {
for(int i=0;i<part.size();i++) {
Message pm(part[i]);
pm.putHead(mout);
mout<<"-------------------------------\n";
Show(mout,pm);
mout<<"-------------------------------\n";
}
}
else {
Show(mout,msg);
}
mout<<"**********\n";
mout<<msg.head;
mout<<"**********\n";
mout<<msg.body;
mout<<"**********\n";
}
return 0;
}
/*
main(int argc,char* argv[])
{
if(argc<2) {
merr<<"Usage: "<<argv[0]<<" <source>\n";
return 1;
}
mstring buffer; buffer.load(argv[1]);
merr<<buffer.size()<<"\n";
mswrite enc;
encode64(enc,buffer);
merr<<enc.str().size()<<"\n";
mswrite nbuf;
decode64(nbuf,enc.str());
merr<<nbuf.str().size()<<"\n";
if(nbuf.str()==buffer) merr<<"Match.\n";
mout<<enc.str();
}
*/
|