diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-19 00:19:29 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-19 00:19:29 +0000 |
commit | f8247040e6231c4b3b5099ea3a526348b7941566 (patch) | |
tree | 0cc92ad6ebf6ae49a62f6e7ef8ec819121d63630 /trunk/main/minimime/tests | |
parent | d88e56c61ce2042544c1a8a71c93b69ab2e6ffba (diff) |
Creating tag for the release of asterisk-1.6.0-beta1v1.6.0-beta1
git-svn-id: http://svn.digium.com/svn/asterisk/tags/1.6.0-beta1@99163 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'trunk/main/minimime/tests')
-rw-r--r-- | trunk/main/minimime/tests/Makefile | 18 | ||||
-rw-r--r-- | trunk/main/minimime/tests/create.c | 105 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test1.txt | 50 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test2.txt | 50 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test3.txt | 12 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test4.txt | 168 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test5.txt | 44 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test6.txt | 12 | ||||
-rw-r--r-- | trunk/main/minimime/tests/messages/test7.txt | 64 | ||||
-rw-r--r-- | trunk/main/minimime/tests/parse.c | 230 |
10 files changed, 753 insertions, 0 deletions
diff --git a/trunk/main/minimime/tests/Makefile b/trunk/main/minimime/tests/Makefile new file mode 100644 index 000000000..ae460c6b2 --- /dev/null +++ b/trunk/main/minimime/tests/Makefile @@ -0,0 +1,18 @@ +BINARIES=parse create +CFLAGS=-Wall -ggdb -g3 -I.. +LDFLAGS=-L.. +LIBS=-lmmime +CC=gcc + +all: parse create + +parse: parse.o + $(CC) -o parse parse.o $(LDFLAGS) $(LIBS) + +create: create.o + $(CC) -o create create.o $(LDFLAGS) $(LIBS) + +clean: + rm -f $(BINARIES) + rm -f *.o + rm -f *.core diff --git a/trunk/main/minimime/tests/create.c b/trunk/main/minimime/tests/create.c new file mode 100644 index 000000000..c881f17f7 --- /dev/null +++ b/trunk/main/minimime/tests/create.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2004 Jann Fischer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * MiniMIME test program - create.c + * + * Creates a MIME message of the given MIME parts + */ +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <getopt.h> + +#include "mm.h" + +const char *progname; + +void +usage(void) +{ + fprintf(stderr, + "MiniMIME test suite\n" + "USAGE: %s <part> [<part_2>[<part_N>[...]]]\n", + progname + ); +} + +void +print_error(void) +{ + fprintf(stderr, "ERROR: %s\n", mm_error_string()); +} + +int +main(int argc, char **argv) +{ + MM_CTX *ctx; + struct mm_mimepart *part; + char *data; + size_t length; + int i; + + progname = argv[0]; + + if (argc < 2) { + usage(); + exit(1); + } + + mm_library_init(); + + ctx = mm_context_new(); + + part = mm_mimepart_new(); + mm_context_attachpart(ctx, part); + mm_envelope_setheader(ctx, "From", "foo@bar.com"); + + for (i=1; i < argc; i++) { + part = mm_mimepart_fromfile(argv[i]); + if (part == NULL) { + print_error(); + exit(1); + } + mm_context_attachpart(ctx, part); + } + + if (mm_context_flatten(ctx, &data, &length, 0) == -1) { + print_error(); + exit(1); + } + + printf("%s", data); + + exit(0); +} diff --git a/trunk/main/minimime/tests/messages/test1.txt b/trunk/main/minimime/tests/messages/test1.txt new file mode 100644 index 000000000..2c24b1972 --- /dev/null +++ b/trunk/main/minimime/tests/messages/test1.txt @@ -0,0 +1,50 @@ +Return-Path: <rezine@hannover.ccc.de> +X-Original-To: test@mistrust.net +Delivered-To: rezine@hannover.ccc.de +Received: from thinktank.niedersachsen.de (thinktank.niedersachsen.de [195.37.192.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by gost.hannover.ccc.de (Postfix) with ESMTP id 90EDEBBF2 + for <test@mistrust.net>; Sun, 24 Aug 2003 16:05:29 +0200 (CEST) +Date: Sun, 24 Aug 2003 15:49:15 +0200 +From: Jann Fischer <rezine@hannover.ccc.de> +To: test@mistrust.net +Subject: Test +Message-Id: <20030824154915.12cb3f85.rezine@hannover.ccc.de> +Organization: Chaos Computer Club Hannover +X-Mailer: Who-Cares 5.23 +Mime-Version: 1.0 +Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; + boundary="=.2S1ZDSX8ir3lbt" + +--=.2S1ZDSX8ir3lbt +Content-Type: application/pgp-encrypted + +Version: 1 + +--=.2S1ZDSX8ir3lbt +Content-Type: application/octet-stream + +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1.2.2 (OpenBSD) + +hQEOA3TvLJ6KBZLBEAP/cl4DiRH5+8S7/kP2BIVdDavHJ9cwHh8awGoyddhMKPJ3 +2558r8MKT0Etjpo649O5WUvT5Z2Jcp12+dTPlAC1kvoIjNNk8+Oe3JCREz/pXYnm +5ANSCThVYSS34jppgT3NsqiV8sQK3e+Nq/NY7SoKVAV37L0fU4HHozcDZfXqOLsE +AJgfxjRjjEazPHmgTTu8Pnt5gmlxyP35Yy0pl+gJmboG3Cn5WBcD/rrQf8oiwrB6 +Vak2Hk9TNU7hDO2IRolz4wUfkId47SK31PdhDLBnNPWn6LNWHd+G4hI97e+xeqLW +dpG7Li5CdP0gfuHx2ux9Y5buWVVtqPhdDUlRaIBfM7Fu0sENAeREANAtdPHn0yTf +V4T5NvImY3gXgLST5wNm3Ft+4nIDZrcnSy04x4faTLFBOcY95W0O1omILHyN5Ste +Le5NhXhQRKyl6ebXtIvEOsJOK4NT6JaUF20l4yvgf0AnetG9Pbzc37mRqmE6Fb8O +h/De3iqw7dexaQc+LaD3XTmvPyyDK2aI4cXOdc9WOzrWR7+9iEiY32SFsQWMRMZJ +GdKkGk22K2p7MPFaU3MHQ3Af+WCN4mRW8SurFxH1379Y5e1IPfTeL6OBkj8hHilX +Y+Y7523ADiStJsONIZPBXJVhZ/VAJ+jL+T1/Xht10VsJcWAY8A9tP+jNgyg8dh+J +JgWVchQOZipdftYwR7w5GkhL2Nc5NYBJBg4DFd9g2nnwuzaAKYO5kMTzEmm9KOYq +0DC5ukok4SGDwWPUIogNHmaSnFr723hYuJC7DwSxHXVG3VxxF78u1gzEnImOWRsf +1RzGb7b8Lf7Rj98H5cNiZ55BXAmidjm7WghCLsT2GvxviqQoRIJ2h/WHM0Bl2v3F +Dpa3N01p2NIIgQLRoXXyBCZTwGOH4y9nBj5PU7vzzSrMweHHt1BwHXcqItCyWFXX +2tj4//Dyw3Lw/L5xGxYRP1Q= +=fSLd +-----END PGP MESSAGE----- + +--=.2S1ZDSX8ir3lbt-- diff --git a/trunk/main/minimime/tests/messages/test2.txt b/trunk/main/minimime/tests/messages/test2.txt new file mode 100644 index 000000000..2c24b1972 --- /dev/null +++ b/trunk/main/minimime/tests/messages/test2.txt @@ -0,0 +1,50 @@ +Return-Path: <rezine@hannover.ccc.de> +X-Original-To: test@mistrust.net +Delivered-To: rezine@hannover.ccc.de +Received: from thinktank.niedersachsen.de (thinktank.niedersachsen.de [195.37.192.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by gost.hannover.ccc.de (Postfix) with ESMTP id 90EDEBBF2 + for <test@mistrust.net>; Sun, 24 Aug 2003 16:05:29 +0200 (CEST) +Date: Sun, 24 Aug 2003 15:49:15 +0200 +From: Jann Fischer <rezine@hannover.ccc.de> +To: test@mistrust.net +Subject: Test +Message-Id: <20030824154915.12cb3f85.rezine@hannover.ccc.de> +Organization: Chaos Computer Club Hannover +X-Mailer: Who-Cares 5.23 +Mime-Version: 1.0 +Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; + boundary="=.2S1ZDSX8ir3lbt" + +--=.2S1ZDSX8ir3lbt +Content-Type: application/pgp-encrypted + +Version: 1 + +--=.2S1ZDSX8ir3lbt +Content-Type: application/octet-stream + +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1.2.2 (OpenBSD) + +hQEOA3TvLJ6KBZLBEAP/cl4DiRH5+8S7/kP2BIVdDavHJ9cwHh8awGoyddhMKPJ3 +2558r8MKT0Etjpo649O5WUvT5Z2Jcp12+dTPlAC1kvoIjNNk8+Oe3JCREz/pXYnm +5ANSCThVYSS34jppgT3NsqiV8sQK3e+Nq/NY7SoKVAV37L0fU4HHozcDZfXqOLsE +AJgfxjRjjEazPHmgTTu8Pnt5gmlxyP35Yy0pl+gJmboG3Cn5WBcD/rrQf8oiwrB6 +Vak2Hk9TNU7hDO2IRolz4wUfkId47SK31PdhDLBnNPWn6LNWHd+G4hI97e+xeqLW +dpG7Li5CdP0gfuHx2ux9Y5buWVVtqPhdDUlRaIBfM7Fu0sENAeREANAtdPHn0yTf +V4T5NvImY3gXgLST5wNm3Ft+4nIDZrcnSy04x4faTLFBOcY95W0O1omILHyN5Ste +Le5NhXhQRKyl6ebXtIvEOsJOK4NT6JaUF20l4yvgf0AnetG9Pbzc37mRqmE6Fb8O +h/De3iqw7dexaQc+LaD3XTmvPyyDK2aI4cXOdc9WOzrWR7+9iEiY32SFsQWMRMZJ +GdKkGk22K2p7MPFaU3MHQ3Af+WCN4mRW8SurFxH1379Y5e1IPfTeL6OBkj8hHilX +Y+Y7523ADiStJsONIZPBXJVhZ/VAJ+jL+T1/Xht10VsJcWAY8A9tP+jNgyg8dh+J +JgWVchQOZipdftYwR7w5GkhL2Nc5NYBJBg4DFd9g2nnwuzaAKYO5kMTzEmm9KOYq +0DC5ukok4SGDwWPUIogNHmaSnFr723hYuJC7DwSxHXVG3VxxF78u1gzEnImOWRsf +1RzGb7b8Lf7Rj98H5cNiZ55BXAmidjm7WghCLsT2GvxviqQoRIJ2h/WHM0Bl2v3F +Dpa3N01p2NIIgQLRoXXyBCZTwGOH4y9nBj5PU7vzzSrMweHHt1BwHXcqItCyWFXX +2tj4//Dyw3Lw/L5xGxYRP1Q= +=fSLd +-----END PGP MESSAGE----- + +--=.2S1ZDSX8ir3lbt-- diff --git a/trunk/main/minimime/tests/messages/test3.txt b/trunk/main/minimime/tests/messages/test3.txt new file mode 100644 index 000000000..082b6fb61 --- /dev/null +++ b/trunk/main/minimime/tests/messages/test3.txt @@ -0,0 +1,12 @@ +From: Jann Fischer <rezine@criminology.de> +To: cipherlist <cipherlist@mistrust.net> +Subject: Foobar +Date: blahblah +MIME-Version: 1.0 (MiniMIME) +Content-Type: multipart/mixed; boundary="abcd" + +--abcd +Content-Type: plain/text; + +This is a test :-> +--abcd-- diff --git a/trunk/main/minimime/tests/messages/test4.txt b/trunk/main/minimime/tests/messages/test4.txt new file mode 100644 index 000000000..a08246939 --- /dev/null +++ b/trunk/main/minimime/tests/messages/test4.txt @@ -0,0 +1,168 @@ +X-Envelope-From: <511-bounces@hannover.ccc.de> +X-Envelope-To: <rezine@criminology.de> +X-Delivery-Time: 1070263752 +Received: from gost.hannover.ccc.de (hannover.ccc.de [62.48.71.164]) + by mailin.webmailer.de (8.12.10/8.12.10) with ESMTP id hB17TAUR020052 + for <rezine@criminology.de>; Mon, 1 Dec 2003 08:29:10 +0100 (MET) +Received: from localhost.hannover.ccc.de (unknown [127.0.0.1]) + by gost.hannover.ccc.de (Postfix) with ESMTP + id 092C8BC81; Mon, 1 Dec 2003 08:29:23 +0100 (CET) +X-Original-To: 511@hannover.ccc.de +Delivered-To: 511@hannover.ccc.de +Received: from sbapp3 (unknown [211.157.36.9]) + by gost.hannover.ccc.de (Postfix) with ESMTP id 3F93ABC7C + for <511@hannover.ccc.de>; Mon, 1 Dec 2003 08:29:12 +0100 (CET) +From: "Vanessa Lintner" <reply@seekercenter.net> +To: 511@hannover.ccc.de +Date: Mon, 1 Dec 2003 15:30:57 +0800 +X-Priority: 3 +X-Library: Indy 8.0.25 +Message-Id: <20031201072912.3F93ABC7C@gost.hannover.ccc.de> +Subject: [CCC511] http://lists.hannover.ccc.de +X-BeenThere: 511@hannover.ccc.de +X-Mailman-Version: 2.1.2 +Precedence: list +Reply-To: Vanessa Lintner <vanessa@seekercenter.net>, + Oeffentliche Mailingliste des C3H <511@hannover.ccc.de> +List-Id: Oeffentliche Mailingliste des C3H <511.hannover.ccc.de> +List-Unsubscribe: <http://hannover.ccc.de/mailman/listinfo/511>, + <mailto:511-request@hannover.ccc.de?subject=unsubscribe> +List-Post: <mailto:511@hannover.ccc.de> +List-Help: <mailto:511-request@hannover.ccc.de?subject=help> +List-Subscribe: <http://hannover.ccc.de/mailman/listinfo/511>, + <mailto:511-request@hannover.ccc.de?subject=subscribe> +Content-Type: multipart/mixed; boundary="===============14807035762661644==" +Sender: 511-bounces@hannover.ccc.de +Errors-To: 511-bounces@hannover.ccc.de + +--===============14807035762661644== +Content-Type: text/html; + +<html> +<head> +<title></title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<style type="text/css"> +.stbtm { + BACKGROUND-COLOR:#cecbde; BORDER-BOTTOM: #665b8e 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #665b8e 1px solid; BORDER-TOP: #ffffff 1px solid; COLOR: #000000; FONT-SIZE: 12pt; HEIGHT: 26px; WIDTH: 120px; clip: rect( )} +.stedit { + background-color:#484C68; white-space: nowrap; border: #000000; BORDER-BOTTOM: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 10pt; color: #CCCCCC; font-weight: bold} + +</style> +</head> +<BODY leftMargin=0 onload="" topMargin=0 marginheight="0" marginwidth="0" bgcolor="#FFFFFF"> + <table border="0" cellspacing="0" cellpadding="0" width="580"> + <tr> + <td width="20" rowspan="2"> </td> + <td colspan="3"> + <table border="0" cellspacing="0" cellpadding="0" align="left" width="560"> + <tr> + <td width="330" height="307"> + <table width="330" border="0" cellspacing="0" cellpadding="0" background="http://www.imagespool.com/skbmp/letter_01.gif" height="307"> + <tr> + <td> + <p> <font face=Arial size=2> </font> <font face=Arial size=2><font face="Verdana, Arial, Helvetica, sans-serif" color="#000000">Hello,<br> + <br> + I have visited <a href='http://lists.hannover.ccc.de'>lists.hannover.ccc.de</a> + and noticed that your website is not listed on some search + engines. I am sure that through our service the number of + people who visit your website will definitely increase. + <a target=_blank href="http://www.seekercenter.net/index.php">SeekerCenter</a> + is a unique technology that instantly submits your website + to over 500,000 search engines and directories -- a really + low-cost and effective way to advertise your site. For more + details please go to <a target=_blank href="http://www.seekercenter.net/index.php">SeekerCenter.net</a>.<br> + <br> + Give your website maximum exposure today!<br> + Looking forward to hearing from you.<br> + <br> + </font></font> + <table border=0 width=100%> + <tr> + <td width=50%> <font face="Arial" color="#000000" size="2">Best + Regards,<br> + Vanessa Lintner<br> + Sales & Marketing <br> + <a target=_blank href="http://www.seekercenter.net/index.php">www.SeekerCenter.net</a></font> + <TD><td width=50%> + <div align="center" valign=middle> + <form target=_blank action=http://www.seekercenter.net method=POST> + <input type="submit" name="Submit" value="Signup Now!!!" class="stbtm"> + </form> + </div> + </TD> + </tr> + </table> + </td> + </tr> + </table> + </td> + <td width="250" height="64" valign="middle"> + <table width="230" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td colspan="3" height="2"></td> + </tr> + <tr> + <td colspan="3"><img src="http://report.imagespool.com/report_email.php?s=1&e=511@hannover.ccc.de" border=0 width=0 height=0> + <p><img src="http://www.imagespool.com/skbmp/letter_04.gif" height="12"></p> + </td> + </tr> + <tr> + <td colspan="3"><img src="http://www.imagespool.com/skbmp/letter_05.gif" height="127"><img src="http://ww2.imagespool.com/1/9/b/0r066.jpg" width="177" height="127"><img src="http://www.imagespool.com/skbmp/letter_07.gif" width="33" height="127"></td> + </tr> + <tr> + <td colspan="3" height="92" background="http://www.imagespool.com/skbmp/letter_08.gif" valign="bottom"> + <table width="230" border="0" cellspacing="0" cellpadding="0" height="92"> + <tr> + <td width="36" height="43"> </td> + <td width="157" height="43"> </td> + <td width="134" height="43"> </td> + </tr> + <tr> + <td width="36" height="2"> </td> + <td width="157" height="2"> </td> + <td width="134" height="2"> </td> + </tr> + </table> + </td> + </tr> + <tr> </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + <tr> + <td colspan="3"> + <table width="560" border="0" cellspacing="0" cellpadding="1" bordercolor="0"> + <tr> + <td> </td> + </tr> + <tr> + <td bgcolor="#EFEFEF"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">You + are receiving this email because you opted-in to receive special + offers through a partner website. If you feel that you received + this email in error or do not wish to receive additional special + offers, please enter your email address here and click the button + of "Remove Me": <a href="http://www.seekercenter.net/remove.php?email=511@hannover.ccc.de"> + <img src="http://www.imagespool.com/skbmp/removeme.gif" width="73" height="17" border="0"></a> + </font></td> + </tr> + </table> + </td> + </tr> + </table> +</body> +</html> + +--===============14807035762661644== +Content-Type: text/plain; charset="iso-8859-1" +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +_______________________________________________ +511 mailing list +511@hannover.ccc.de +--===============14807035762661644==-- diff --git a/trunk/main/minimime/tests/messages/test5.txt b/trunk/main/minimime/tests/messages/test5.txt new file mode 100644 index 000000000..5e4cdb17d --- /dev/null +++ b/trunk/main/minimime/tests/messages/test5.txt @@ -0,0 +1,44 @@ +Return-Path: <rezine@criminology.de> +X-Original-To: rezine@mistrust.net +Delivered-To: rezine@hannover.ccc.de +Received: from thinktank.niedersachsen.de (thinktank.niedersachsen.de [195.37.192.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by gost.hannover.ccc.de (Postfix) with ESMTP id 79E9BBC7C + for <rezine@mistrust.net>; Wed, 24 Dec 2003 13:35:36 +0100 (CET) +Received: from thinktank.niedersachsen.de (localhost [127.0.0.1]) + by thinktank.niedersachsen.de (8.12.9/8.12.2) with SMTP id hBOCZBFU029588 + for <rezine@mistrust.net>; Wed, 24 Dec 2003 13:35:11 +0100 (CET) +Date: Wed, 24 Dec 2003 13:35:11 +0100 +From: Jann Fischer <rezine@criminology.de> +To: rezine@mistrust.net +Subject: Test +Message-Id: <20031224133511.5f4b6d9b.rezine@criminology.de> +X-Mailer: Who Cares 5.23 +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="Multipart_Wed__24_Dec_2003_13:35:11_+0100_00148800" + +This is a multi-part message in MIME format. + +--Multipart_Wed__24_Dec_2003_13:35:11_+0100_00148800 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +Test + +-- +Be careful who you follow. +0x6D839821 | FA8C 3663 9906 D8C3 AC16 F7C4 66E0 F351 6D83 9821 + +--Multipart_Wed__24_Dec_2003_13:35:11_+0100_00148800 +Content-Type: application/octet-stream; + name="bar.c" +Content-Disposition: attachment; + filename="bar.c" +Content-Transfer-Encoding: base64 + +I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkCm1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KQp7CgkJ +cHJpbnRmKCIlc1xuIiwgYXJndlswXSk7Cn0K + +--Multipart_Wed__24_Dec_2003_13:35:11_+0100_00148800-- diff --git a/trunk/main/minimime/tests/messages/test6.txt b/trunk/main/minimime/tests/messages/test6.txt new file mode 100644 index 000000000..fb4e7a14c --- /dev/null +++ b/trunk/main/minimime/tests/messages/test6.txt @@ -0,0 +1,12 @@ +From: Me +Date: Foobar +To: There +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="abcde" + +--abcde +Content-Type: text/plain + +Blah blah +Blah +--abcde-- diff --git a/trunk/main/minimime/tests/messages/test7.txt b/trunk/main/minimime/tests/messages/test7.txt new file mode 100644 index 000000000..1cda11e3f --- /dev/null +++ b/trunk/main/minimime/tests/messages/test7.txt @@ -0,0 +1,64 @@ +Return-Path: MAILER-DAEMON +Received: from chaos.verfassungsschutz.de (localhost [IPv6:::1]) + by chaos.verfassungsschutz.de (8.12.7/8.12.2) with ESMTP id h2EKV1oM031761 + for <jfi@chaos.verfassungsschutz.de>; Fri, 14 Mar 2003 21:31:18 +0100 (CET) +Received: from localhost (localhost) + by chaos.verfassungsschutz.de (8.12.7/8.12.2/Submit) id h2BNU1vr029177; + Wed, 12 Mar 2003 00:35:01 +0100 (CET) +Date: Wed, 12 Mar 2003 00:35:01 +0100 (CET) +From: Mail Delivery Subsystem <MAILER-DAEMON@chaos.verfassungsschutz.de> +Message-Id: <200303112335.h2BNU1vr029177@chaos.verfassungsschutz.de> +To: jfi@chaos.verfassungsschutz.de +MIME-Version: 1.0 +Content-Type: multipart/report; report-type=delivery-status; + boundary="h2BNU1vr029177.1047425701/chaos.verfassungsschutz.de" +Subject: Warning: could not send message for past 4 hours +Auto-Submitted: auto-generated (warning-timeout) + +This is a MIME-encapsulated message + +--h2BNU1vr029177.1047425701/chaos.verfassungsschutz.de + + ********************************************** + ** THIS IS A WARNING MESSAGE ONLY ** + ** YOU DO NOT NEED TO RESEND YOUR MESSAGE ** + ********************************************** + +The original message was received at Tue, 11 Mar 2003 20:18:36 +0100 (CET) +from jfi@localhost + + ----- Transcript of session follows ----- +451 4.4.1 reply: read error from localhost +rezine@kommunism.us... Deferred: Connection timed out with localhost +Warning: message still undelivered after 4 hours +Will keep trying until message is 5 days old + +--h2BNU1vr029177.1047425701/chaos.verfassungsschutz.de +Content-Type: message/delivery-status + +Reporting-MTA: dns; chaos.verfassungsschutz.de +Arrival-Date: Tue, 11 Mar 2003 20:18:36 +0100 (CET) + +Final-Recipient: RFC822; rezine@kommunism.us +Action: delayed +Status: 4.4.2 +Last-Attempt-Date: Wed, 12 Mar 2003 00:35:01 +0100 (CET) +Will-Retry-Until: Sun, 16 Mar 2003 20:18:36 +0100 (CET) + +--h2BNU1vr029177.1047425701/chaos.verfassungsschutz.de +Content-Type: message/rfc822 + +Return-Path: <jfi> +Received: (from jfi@localhost) + by chaos.verfassungsschutz.de (8.12.7/8.12.2/Submit) id h2BJIawm025679 + for rezine@kommunism.us; Tue, 11 Mar 2003 20:18:36 +0100 (CET) +Date: Tue, 11 Mar 2003 20:18:36 +0100 (CET) +From: Jann Fischer <jfi> +Message-Id: <200303111918.h2BJIawm025679@chaos.verfassungsschutz.de> +To: rezine@kommunism.us +Subject: Test + +Test + +--h2BNU1vr029177.1047425701/chaos.verfassungsschutz.de-- + diff --git a/trunk/main/minimime/tests/parse.c b/trunk/main/minimime/tests/parse.c new file mode 100644 index 000000000..3d3bdf028 --- /dev/null +++ b/trunk/main/minimime/tests/parse.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2004 Jann Fischer. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * MiniMIME test program - parse.c + * + * Parses any given messages + */ +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <getopt.h> + +#include "mm.h" + +const char *progname; + +void +usage(void) +{ + fprintf(stderr, + "MiniMIME test suite\n" + "Usage: %s [-m] <filename>\n\n" + " -m : use memory based scanning\n\n", + progname + ); + exit(1); +} + +int +main(int argc, char **argv) +{ + MM_CTX *ctx; + struct mm_mimeheader *header, *lastheader = NULL; + struct mm_mimepart *part; + struct mm_content *ct; + int parts, i; + struct stat st; + int fd; + char *buf; + int scan_mode = 0; + + progname = strdup(argv[0]); + + while ((i = getopt(argc, argv, "m")) != -1) { + switch(i) { + case 'm': + scan_mode = 1; + break; + default: + usage(); + } + } + + argc -= optind; + argv += optind; + + if (argc < 1) { + usage(); + } + +#ifdef __HAVE_LEAK_DETECTION + /* Initialize memory leak detection if compiled in */ + MM_leakd_init(); +#endif + + /* Initialize MiniMIME library */ + mm_library_init(); + + /* Register all default codecs (base64/qp) */ + mm_codec_registerdefaultcodecs(); + + do { + /* Create a new context */ + ctx = mm_context_new(); + + /* Parse a file into our context */ + if (scan_mode == 0) { + i = mm_parse_file(ctx, argv[0], MM_PARSE_LOOSE, 0); + } else { + if (stat(argv[0], &st) == -1) { + err(1, "stat"); + } + + if ((fd = open(argv[0], O_RDONLY)) == -1) { + err(1, "open"); + } + + buf = (char *)malloc(st.st_size); + if (buf == NULL) { + err(1, "malloc"); + } + + if (read(fd, buf, st.st_size) != st.st_size) { + err(1, "read"); + } + + close(fd); + buf[st.st_size] = '\0'; + + i = mm_parse_mem(ctx, buf, MM_PARSE_LOOSE, 0); + } + + if (i == -1 || mm_errno != MM_ERROR_NONE) { + printf("ERROR: %s at line %d\n", mm_error_string(), mm_error_lineno()); + exit(1); + } + + /* Get the number of MIME parts */ + parts = mm_context_countparts(ctx); + if (parts == 0) { + printf("ERROR: got zero MIME parts, huh\n"); + exit(1); + } else { + if (mm_context_iscomposite(ctx)) { + printf("Got %d MIME parts\n", parts - 1); + } else { + printf("Flat message (not multipart)\n"); + } + } + + /* Get the main MIME part */ + part = mm_context_getpart(ctx, 0); + if (part == NULL) { + fprintf(stderr, "Could not get envelope part\n"); + exit(1); + } + + printf("Printing envelope headers:\n"); + /* Print all headers */ + lastheader = NULL; + while ((header = mm_mimepart_headers_next(part, &lastheader)) != NULL) + printf("%s: %s\n", header->name, header->value); + + printf("%s\n", mm_content_tostring(part->type)); + printf("\n"); + + ct = part->type; + assert(ct != NULL); + + if (mm_context_iscomposite(ctx) == 0) { + printf("Printing body part for FLAT message:\n"); + part = mm_context_getpart(ctx, 0); + printf("%s", part->body); + } + + /* Loop through all MIME parts beginning with 1 */ + for (i = 1; i < mm_context_countparts(ctx); i++) { + char *decoded; + + printf("Printing headers for MIME part %d\n", i); + + /* Get the current MIME entity */ + part = mm_context_getpart(ctx, i); + if (part == NULL) { + fprintf(stderr, "Should have %d parts but " + "couldn't retrieve part %d", + mm_context_countparts(ctx), i); + exit(1); + } + + /* Print all headers */ + lastheader = NULL; + while ((header = mm_mimepart_headers_next(part, &lastheader)) != NULL) + printf("%s: %s\n", header->name, header->value); + + printf("%s\n", mm_content_tostring(part->type)); + + /* Print MIME part body */ + printf("\nPRINTING MESSAGE BODY (%d):\n%s\n", i, part->opaque_body); + decoded = mm_mimepart_decode(part); + if (decoded != NULL) { + printf("DECODED:\n%s\n", decoded); + free(decoded); + } + } + + printf("RECONSTRUCTED MESSAGE:\n"); + + do { + char *env; + size_t env_len; + + mm_context_flatten(ctx, &env, &env_len, 0); + printf("%s", env); + free(env); + + } while (0); + + mm_context_free(ctx); + ctx = NULL; + +#ifdef __HAVE_LEAK_DETECTION + MM_leakd_printallocated(); +#endif + + } while (0); + + return 0; +} |