Subject: Problem on size and content for base64 encoding

From: "Niels Jakob Buch" <[email-masked]>
Date: Mon, 10 Feb 1997 15:59:40 +0000

Below is some code. I want to read a MULTIPART/MIME mail-message 
sent from PINE, the parts are either text or application. The strange 
thing is, that it finds the parts, but the size of the parts are 
either wrong or zero after decoding (I assume that means decoding 
goes wrong!), and the content is sometimes nearly right, but never 
OK, that means it is sometimes even readable, but something is 
missing in the end, or in the beginning. 

(I'm running NT, if that matters!?)

I hope one of you can help :)

mail_fetchstructure (stream,1,&body);

for (part=body->nested.part, sec=1 ; NULL != part ; 
                            part=part->next, sec++)    {
        switch(part->body.type) {
        case TYPETEXT:
            sprintf(tmp, "%d", sec);
            text = mail_fetchbody(stream, 1, tmp, &ltext);

            data = rfc822_base64(text, ltext, &ldata);
            printf("Textlen:%i\n",lvdata);
            printf("%s\n",vdata);

            break;

        case TYPEAPPLICATION:
            sprintf(tmp, "%d", sec);
            text = mail_fetchbody(stream, 1, tmp, &ltext);

            data = rfc822_base64(text, ltext, &ldata);

            printf("Applicationdatalen:%i\n",ldata);

            break;

        default:
            printf("section == %d, body type == %s\n", sec,
            body_types[part->body.type]); break;

      }
     }

---

From: Mark Crispin <[email-masked]>
Date: Mon, 10 Feb 1997 19:13:19 -0800 (PST)

On Mon, 10 Feb 1997 15:59:40 +0000, Niels Jakob Buch wrote:
> The strange

In observing your code, I see nothing that checks the encoding prior to
calling rfc822_base64().  It is unlikely that a body part of type TEXT would
be BASE64 encoded.