- /*
- ** Check Content-Type field
- */
- if (!mh_strcasecmp(name, TYPE_FIELD)) {
- int passno = 1;
- char c;
-
- cp = getcpy(buf);
- while (state == FLDPLUS) {
- state = m_getfld(state, name, buf,
- sizeof(buf), fp);
- cp = add(buf, cp);
- }
- bp = cp;
-
-again:
- for (; isspace(*bp); bp++)
- continue;
- if (*bp == '(') {
- int i;
-
- for (bp++, i = 0;;) {
- switch (*bp++) {
- case '\0':
-invalid:
- result = 0;
- goto out;
- case '\\':
- if (*bp++ == '\0')
- goto invalid;
- continue;
- case '(':
- i++;
- /* and fall... */
- default:
- continue;
- case ')':
- if (--i < 0)
- break;
- continue;
- }
- break;
- }
- }
- if (passno == 2) {
- if (*bp != '/')
- goto invalid;
- bp++;
- passno = 3;
- goto again;
- }
- for (dp = bp; istoken(*dp); dp++)
- continue;
- c = *dp;
- *dp = '\0';
- if (!*bp)
- goto invalid;
- if (passno == 1) {
- if (!(result = (mh_strcasecmp(bp, "text") != 0))) {
- *dp = c;
- bp = dp;
- passno = 2;
- goto again;
- }
- } else {
- if ((result = (mh_strcasecmp(bp,
- "plain") != 0)))
- goto out;
- *dp = c;
- for (dp++; isspace(*dp); dp++)
- continue;
- if (*dp) {
- if ((result = !uprf(dp,
- "charset")))
- goto out;
- dp += sizeof("charset") - 1;
- while (isspace(*dp))
- dp++;
- if (*dp++ != '=')
- goto invalid;
- while (isspace(*dp))
- dp++;
- if (*dp == '"') {
- if ((bp = strchr(++dp, '"')))
- *bp = '\0';
- } else {
- for (bp = dp; *bp; bp++)
- if (!istoken(*bp)) {
- *bp = '\0';
- break;
- }
- }
- } else {
- /* Default character set */
- dp = "US-ASCII";
- }
- /* Check the character set */
- result = !check_charset(dp, strlen(dp));
- }
-out:
- free(cp);
- if (result) {
- fclose(fp);
- return result;
- }
- break;
+ /* Does it have a Mime-Version header? */
+ if (mh_strcasecmp(name, VRSN_FIELD)==0) {
+ fclose(fp);
+ return 1;