LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
unset LC_CTYPE
unset LC_NUMERIC
unset LC_TIME
unset LC_COLLATE
unset LC_MONETARY
unset LC_MESSAGES
unset LC_PAPER
unset LC_NAME
unset LC_ADDRESS
unset LC_TELEPHONE
unset LC_MEASUREMENT
unset LC_IDENTIFICATION
unset LC_ALL
unset CHARSET
unset MM_CHARSET
export LANG
export LC_ALL
export MM_CHARSET=utf-8

echo "foo" >confmdtest

./makemime -c application/octet-stream -C utf-8 -N footest confmdtest
./makemime -c auto -C utf-8 -N text7bit confmdtest
echo "foox" | tr 'x' '\000' >confmdtest
./makemime -c auto -C utf-8 -N binarybase64 confmdtest

cat >confmdtest <<EOF
   -c
   auto

   -C
   utf-8

   -N
   text8bit

   &3

   -
Tést
EOF
./makemime "@&3" 3<confmdtest
echo "Test Test Test Test Tést" >confmdtest
./makemime -c auto -C utf-8 -N text8bit confmdtest

echo 'Plain text' >mmcontents1
echo 'HTML' >mmcontents2

./makemime -j \( -m multipart/mixed -a 'Mime-Version: 1.0' \( -c text/plain -C iso-8859-1 -a 'Content-Description: something' mmcontents1 \) \) -o mmtest1 \( -c text/html -C utf-8 -N name -e base64 mmcontents2 \)

sed 's/boundary=.*//;/^--/d' <mmtest1

rm -f mmcontents[12] mmtest1

x="1234567890"
x="$x$x$x$x$x$x$x$x$x$x"
x="$x$x$x$x$x$x$x$x$x$x"

echo $x >confmdtest
./makemime -c auto -C utf-8 -N textqp confmdtest

x="ééééé"
x="$x$x$x$x$x$x$x$x$x$x"
x="$x$x$x$x$x$x$x$x$x$x"
echo $x >confmdtest
./makemime -c auto -C utf-8 -N textbase64 confmdtest

echo "test" >confmdtest
x="1::::::::0"
x="$x$x$x"
x="$x$x"
./makemime -c auto -C utf-8 -N "longname:$x" confmdtest
./makemime -c auto -C iso-8859-1 -N "shortname" confmdtest
./makemime -c auto -C iso-8859-1 -N "user@domain" confmdtest
./makemime -c auto -C iso-8859-1 -N "shortname:encoded" confmdtest

rm -f confmdtest

./reformime -o 'дададададададададада'
./reformime -h '=?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?='

./reformime -o 'дададададададададада дададададададададада'
./reformime -h '=?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsCDQtNCw0LQ=?= =?UTF-8?B?0LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?='

./reformime -o 'дададададададададада foo дададададададададада'
./reformime -h '=?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?= foo =?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?='

./reformime -o 'дададададададададада foo bar дададададададададада'
./reformime -h '=?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?= foo bar =?UTF-8?B?0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsNC00LDQtNCw0LTQsA==?='

cat >testsuite.msg <<EOF
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary=xx

--xx
Content-Type: text/plain

section 1

--xx
Content-Type text/plain

section 2

--xx--
EOF
echo ""
./reformime -X -s1.1 `which cat` <testsuite.msg
./reformime -X -s1.2 `which cat` <testsuite.msg
./reformime -X `which cat` <testsuite.msg
rm -f testsuite.msg
