rfc822.c | rfc822.c | |||
---|---|---|---|---|
/* ======================================================================== | /* ======================================================================== | |||
* Copyright 1988-2007 University of Washington | * Copyright 1988-2008 University of Washington | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* | * | |||
* ======================================================================== | * ======================================================================== | |||
*/ | */ | |||
/* | /* | |||
* Program: RFC 2822 and MIME routines | * Program: RFC 2822 and MIME routines | |||
* | * | |||
* Author: Mark Crispin | * Author: Mark Crispin | |||
* Networks and Distributed Computing | * UW Technology | |||
* Computing & Communications | ||||
* University of Washington | * University of Washington | |||
* Administration Building, AG-44 | ||||
* Seattle, WA 98195 | * Seattle, WA 98195 | |||
* Internet: MRC@CAC.Washington.EDU | * Internet: MRC@Washington.EDU | |||
* | * | |||
* Date: 27 July 1988 | * Date: 27 July 1988 | |||
* Last Edited: 11 September 2007 | * Last Edited: 14 May 2008 | |||
* | * | |||
* This original version of this file is | * This original version of this file is | |||
* Copyright 1988 Stanford University | * Copyright 1988 Stanford University | |||
* and was developed in the Symbolic Systems Resources Group of the Knowled ge | * and was developed in the Symbolic Systems Resources Group of the Knowled ge | |||
* Systems Laboratory at Stanford University in 1987-88, and was funded by the | * Systems Laboratory at Stanford University in 1987-88, and was funded by the | |||
* Biomedical Research Technology Program of the NationalInstitutes of Heal th | * Biomedical Research Technology Program of the NationalInstitutes of Heal th | |||
* under grant number RR-00785. | * under grant number RR-00785. | |||
*/ | */ | |||
#include <ctype.h> | #include <ctype.h> | |||
skipping to change at line 295 | skipping to change at line 293 | |||
/* charset still unknown? */ | /* charset still unknown? */ | |||
if (!body->parameter->value) { | if (!body->parameter->value) { | |||
if ((c == I2C_ESC) && (i && i--) && ((c = SNX (bs)) == I2C_MULTI) && | if ((c == I2C_ESC) && (i && i--) && ((c = SNX (bs)) == I2C_MULTI) && | |||
(i && i--) && (((c = SNX (bs)) == I2CS_94x94_JIS_NEW) || | (i && i--) && (((c = SNX (bs)) == I2CS_94x94_JIS_NEW) || | |||
(c == I2CS_94x94_JIS_OLD))) | (c == I2CS_94x94_JIS_OLD))) | |||
body->parameter->value = cpystr ("ISO-2022-JP"); | body->parameter->value = cpystr ("ISO-2022-JP"); | |||
else if (c & 0x80) body->parameter->value = cpystr ("X-UNKNOWN"); | else if (c & 0x80) body->parameter->value = cpystr ("X-UNKNOWN"); | |||
} | } | |||
if (c == '\n') body->size.lines++; | if (c == '\n') body->size.lines++; | |||
} | } | |||
/* otherwise assume US-ASCII */ | /* 7-bit content */ | |||
if (!body->parameter->value) body->parameter->value = cpystr("US-ASCI | if (!body->parameter->value) switch (body->encoding) { | |||
I"); | case ENC7BIT: /* unadorned 7-bit */ | |||
case ENC8BIT: /* unadorned 8-bit (but 7-bit content) */ | ||||
case ENCBINARY: /* binary (but 7-bit content( */ | ||||
body->parameter->value = cpystr ("US-ASCII"); | ||||
break; | ||||
default: /* QUOTED-PRINTABLE, BASE64, etc. */ | ||||
body->parameter->value = cpystr ("X-UNKNOWN"); | ||||
break; | ||||
} | ||||
} | } | |||
/* just count lines */ | /* just count lines */ | |||
else while (i--) if ((SNX (bs)) == '\n') body->size.lines++; | else while (i--) if ((SNX (bs)) == '\n') body->size.lines++; | |||
break; | break; | |||
case TYPEMESSAGE: /* encapsulated message */ | case TYPEMESSAGE: /* encapsulated message */ | |||
/* encapsulated RFC-822 message? */ | /* encapsulated RFC-822 message? */ | |||
if (!strcmp (body->subtype,"RFC822")) { | if (!strcmp (body->subtype,"RFC822")) { | |||
body->nested.msg = mail_newmsg (); | body->nested.msg = mail_newmsg (); | |||
switch (body->encoding) { /* make sure valid encoding */ | switch (body->encoding) { /* make sure valid encoding */ | |||
case ENC7BIT: /* these are valid nested encodings */ | case ENC7BIT: /* these are valid nested encodings */ | |||
skipping to change at line 490 | skipping to change at line 497 | |||
} | } | |||
else { /* zero-length part, use default subtype */ | else { /* zero-length part, use default subtype */ | |||
part->body.subtype = cpystr (rfc822_default_subtype (part->body.type )); | part->body.subtype = cpystr (rfc822_default_subtype (part->body.type )); | |||
/* see if anything else special to do */ | /* see if anything else special to do */ | |||
switch (part->body.type) { | switch (part->body.type) { | |||
case TYPETEXT: /* text content */ | case TYPETEXT: /* text content */ | |||
/* default parameters */ | /* default parameters */ | |||
if (!part->body.parameter) { | if (!part->body.parameter) { | |||
part->body.parameter = mail_newbody_parameter (); | part->body.parameter = mail_newbody_parameter (); | |||
part->body.parameter->attribute = cpystr ("CHARSET"); | part->body.parameter->attribute = cpystr ("CHARSET"); | |||
part->body.parameter->value = cpystr ("US-ASCII"); | /* only assume US-ASCII if 7BIT */ | |||
part->body.parameter->value = | ||||
cpystr ((part->body.encoding == ENC7BIT) ? | ||||
"US-ASCII" : "X-UNKNOWN"); | ||||
} | } | |||
break; | break; | |||
case TYPEMESSAGE: /* encapsulated message in digest */ | case TYPEMESSAGE: /* encapsulated message in digest */ | |||
part->body.nested.msg = mail_newmsg (); | part->body.nested.msg = mail_newmsg (); | |||
break; | break; | |||
default: | default: | |||
break; | break; | |||
} | } | |||
} | } | |||
} | } | |||
skipping to change at line 1508 | skipping to change at line 1518 | |||
/* yes, write group */ | /* yes, write group */ | |||
if (!(rfc822_output_cat (buf,adr->mailbox,rspecials) && | if (!(rfc822_output_cat (buf,adr->mailbox,rspecials) && | |||
rfc822_output_string (buf,": "))) return NIL; | rfc822_output_string (buf,": "))) return NIL; | |||
++n; /* in a group now */ | ++n; /* in a group now */ | |||
} | } | |||
else if (n) { /* must be end of group (but be paranoid) */ | else if (n) { /* must be end of group (but be paranoid) */ | |||
if (!rfc822_output_char (buf,';') || | if (!rfc822_output_char (buf,';') || | |||
((!--n && adr->next && adr->next->mailbox) && | ((!--n && adr->next && adr->next->mailbox) && | |||
!rfc822_output_string (buf,", "))) return NIL; | !rfc822_output_string (buf,", "))) return NIL; | |||
} | } | |||
if (pretty && /* pretty printing? */ | if (pretty && adr->next && /* pretty printing? */ | |||
((pretty += ((buf->cur > base) ? buf->cur - base : | ((pretty += ((buf->cur > base) ? buf->cur - base : | |||
(buf->end - base) + (buf->cur - buf->beg))) >= 78)) { | (buf->end - base) + (buf->cur - buf->beg))) >= 78)) { | |||
if (!(rfc822_output_string (buf,"\015\012") && | if (!(rfc822_output_string (buf,"\015\012") && | |||
rfc822_output_string (buf,RFC822CONT))) return NIL; | rfc822_output_string (buf,RFC822CONT))) return NIL; | |||
base = buf->cur; /* update base for pretty printing */ | base = buf->cur; /* update base for pretty printing */ | |||
pretty = sizeof (RFC822CONT) - 1; | pretty = sizeof (RFC822CONT) - 1; | |||
} | } | |||
} | } | |||
return LONGT; | return LONGT; | |||
} | } | |||
End of changes. 8 change blocks. | ||||
11 lines changed or deleted | 20 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |