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