X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fmhoutsbr.c;h=87e7943c26b5b186d02a2209ab48bc16d6959e20;hb=refs%2Fheads%2Fmaster;hp=25495eb2af5a2952aac60c84a4c941058cc5fb1f;hpb=3363e2624dce0eb8164cf8b3f1ab385c8ff72e88;p=mmh diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index 25495eb..2915afe 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -9,9 +9,7 @@ #include #include -#include #include -#include #include #include #include @@ -25,7 +23,6 @@ static char nib2b64[0x40+1] = */ int output_message(CT, char *); int output_message_fp(CT, FILE *, char *); -int writeBase64aux(FILE *, FILE *); /* ** static prototypes @@ -35,6 +32,7 @@ static void output_headers(CT, FILE *); static int write8Bit(CT, FILE *); static int writeQuoted(CT, FILE *); static int writeBase64(CT, FILE *); +static int writeBase64aux(FILE *, FILE *); /* @@ -163,12 +161,15 @@ static void output_headers(CT ct, FILE *out) { HF hp; + charstring_t body = charstring_create(0); hp = ct->c_first_hf; while (hp) { - fprintf(out, "%s:%s", hp->name, hp->value); + fold(body, strlen(hp->name), hp->value); + fprintf(out, "%s:%s", hp->name, charstring_buffer(body)); hp = hp->next; } + charstring_free(body); } @@ -230,7 +231,7 @@ writeQuoted(CT ct, FILE *out) n = 0; } for (; *cp; cp++) { - if (n > CPERLIN - 3) { + if (n + 1 >= CPERLIN) { fputs("=\n", out); n = 0; } @@ -243,8 +244,16 @@ writeQuoted(CT ct, FILE *out) break; default: - if (*cp < '!' || *cp > '~') + if (*cp < '!' || *cp > '~') { goto three_print; + } + if (n == 0 && *cp == '.') { + /* + ** encode dot at start of line, + ** because it could be alone ... + */ + goto three_print; + } putc(*cp, out); n++; break; @@ -293,7 +302,7 @@ writeBase64(CT ct, FILE *out) } -int +static int writeBase64aux(FILE *in, FILE *out) { unsigned int cc, n;