Download Sun Java System Messaging Server 6 2005Q1 MTA Developer`s
Transcript
A Simple Virus Scanner Example
Code Example 5-2
Decoding MIME Messages Complex Example (Continued)
MTA_DECODE_CSUBTYPE, "plain", 5,
MTA_DECODE_CCHARSET, "us-ascii", 8,
MTA_DECODE_CDISP, "inline", 6,
MTA_DECODE_CLANG, "en", 2, 0));
}
else
/*
* Keep the part
* See explanatory comment 12
*/
return(mtaDecodeMessagePartCopy(dctx, 0));
}
/*
* is_bad_mime_type() -- See if the part’s media type is in our
*
bad MIME content types, for example:
*
application/vbscript
* See explanatory comment 13
*/
static int is_bad_mime_type(our_options_t *options,
mta_decode_t *dctx, char *buf,
size_t maxbuflen)
{
const char *csubtype, *ctype;
size_t i, len1, len2;
char *ptr;
/*
* Sanity checks
*/
if (!options || !options->bmt_len ||
!options->bad_mime_types[0] ||
!dctx)
return(0);
/*
* Get the MIME content type
*/
ctype = mtaDecodeMessageInfoString(dctx, MTA_DECODE_CTYPE,
NULL, &len1);
csubtype = mtaDecodeMessageInfoString(dctx,
MTA_DECODE_CSUBTYPE,
NULL, &len2);
/*
* Build the string: <0x01>type/subtype<0x01><0x00>
*/
ptr = buf;
*ptr++ = (char)0x01;
for (i = 0; i < len1; i++)
*ptr++ = tolower(*ctype++);
*ptr++ = ’/’;
for (i = 0; i < len2; i++)
*ptr++ = tolower(*csubtype++);
*ptr++ = (char)0x01;
*ptr = ’\0’;
Chapter 5
Decoding Messages
101