1.21 TRN (Threaded News Reader) A metamail patch for TRN was contributed byJohn Schmitz as follows: *** ../trn2.2/common.h Fri Nov 20 11:10:25 1992 --- common.h Mon Nov 23 15:51:15 1992 *************** *** 521,526 **** --- 521,542 ---- # define UNSHAR "/bin/sh" #endif + #ifndef NOMETAMAIL + /* default MIME extraction program */ + # ifndef MIMESTORE + # define MIMESTORE "/usr/local/bin/mh/mhn -store -auto -file " + # endif + + /* default MIME show program */ + # ifndef MIMESHOW + # ifdef SERVER + # define MIMESHOW "metamail -e -p -m trn %P/rrn%a.%$" + # else + # define MIMESHOW "metamail -e -p -m trn %s %A" + # endif + # endif + #endif + /* path to default editor */ #ifndef DEFEDITOR # define DEFEDITOR "/usr/ucb/vi" *************** *** 679,684 **** --- 695,710 ---- # endif #endif + #ifndef NOMETAMAIL + # ifndef EXMIMESAVER + # ifdef SERVER + # define EXMIMESAVER "%e %P/rrn%a.%$" + # else + # define EXMIMESAVER "%e %A" + # endif + # endif + #endif + #ifndef NORMSAVER /* % and ~ */ # ifdef SERVER # define NORMSAVER "%X/norm.saver %P/rrn%a.%$ %P %c %a %B %C \"%b\"" *************** *** 940,945 **** --- 966,975 ---- EXT char nocd[] INIT("Can't chdir to directory %s\n"); #else EXT char nocd[] INIT("Can't find %s\n"); + #endif + + #ifndef NOMETAMAIL + EXT bool mime_article INIT(FALSE); #endif #ifdef NOLINEBUF *** ../trn2.2/head.h Mon Nov 25 09:49:12 1991 --- head.h Fri Nov 20 11:12:06 1992 *************** *** 34,39 **** --- 34,72 ---- #define ACAT_LINE 4 /* ACategory (ClariNet) */ #define ANPA_LINE 5 /* ANPA (ClariNet) */ #define CODES_LINE 6 /* Codes (ClariNet) */ + #ifndef NOMETAMAIL + #define CONTENT_LINE 7 /* MIME */ + #define DIST_LINE 8 /* distribution */ + #define DATE_LINE 9 /* date */ + #define RECEIVED_LINE 10 /* date-received */ + #define EXPIR_LINE 11 /* expires */ + #define FOLLOW_LINE 12 /* followup-to */ + #define FROM_LINE 13 /* from */ + #define FORM_LINE 14 /* Format (ClariNet) */ + #define KEYW_LINE 15 /* keywords */ + #define LINES_LINE 16 /* lines */ + #define MESSID_LINE 17 /* message-id */ + #define NFFR_LINE 18 /* nf-from */ + #define NFID_LINE 19 /* nf-id */ + #define NGS_LINE 20 /* newsgroups */ + #define NNTP_LINE 21 /* nntp-posting-host */ + #define NOTE_LINE 22 /* Note (ClariNet) */ + #define ORG_LINE 23 /* organization */ + #define PATH_LINE 24 /* path */ + #define POSTED_LINE 25 /* posted */ + #define PVER_LINE 26 /* posting-version */ + #define PRI_LINE 27 /* Priority (ClariNet) */ + #define REPLY_LINE 28 /* reply-to */ + #define REFS_LINE 29 /* references */ + #define RVER_LINE 30 /* relay-version */ + #define SENDER_LINE 31 /* sender */ + #define SUMRY_LINE 32 /* summary */ + #define SUBJ_LINE 33 /* subject */ + #define SLUG_LINE 34 /* Slugword (ClariNet) */ + #define XREF_LINE 35 /* xref */ + #define XSUP_LINE 36 /* X-Supersedes (ClariNet) */ + #define HEAD_LAST 37 /* one more than the last one above */ + #else /* NOMETAMAIL #define DIST_LINE 7 /* distribution */ #define DATE_LINE 8 /* date */ #define RECEIVED_LINE 9 /* date-received */ *************** *** 63,68 **** --- 96,102 ---- #define XREF_LINE 33 /* xref */ #define XSUP_LINE 34 /* X-Supersedes (ClariNet) */ #define HEAD_LAST 35 /* one more than the last one above */ + #endif NOMETAMAIL struct headtype { char *ht_name; /* header line identifier */ *************** *** 94,99 **** --- 128,136 ---- {"acategory", 0, 0, 9, HT_HIDE }, {"anpa", 0, 0, 4, HT_HIDE }, {"codes", 0, 0, 5, HT_HIDE }, + #ifndef NOMETAMAIL + {"content-type", 0, 0, 12, HT_MAGIC }, + #endif {"distribution", 0, 0, 12, 0 }, #ifdef USETHREADS {"date", 0, 0, 4, HT_MAGIC }, *************** *** 111,116 **** --- 148,156 ---- {"nf-from", 0, 0, 7, HT_HIDE }, {"nf-id", 0, 0, 5, HT_HIDE }, {"newsgroups", 0, 0, 10, HT_MAGIC|HT_HIDE}, + #ifndef NOMETAMAIL + {"nntp-posting-host", 0, 0, 17, HT_HIDE}, + #endif {"note", 0, 0, 4, 0, }, {"organization", 0, 0, 12, 0 }, {"path", 0, 0, 4, HT_HIDE }, *** ../trn2.2/respond.c Fri Nov 20 11:10:31 1992 --- respond.c Mon Nov 23 15:55:50 1992 *************** *** 66,72 **** --- 66,76 ---- #ifdef ASYNC_PARSE parse_maybe(art); #endif + #ifndef NOMETAMAIL + savefrom = (!mime_article && (cmd == 'w' || cmd == 'e') ? htype[PAST_HEADER].ht_minpos : 0); + #else savefrom = (cmd == 'w' || cmd == 'e' ? htype[PAST_HEADER].ht_minpos : 0); + #endif if (artopen(art) == Nullfp) { #ifdef VERBOSE IF(verbose) *************** *** 173,178 **** --- 177,202 ---- while(fgets(art_buf,LBUFLEN,artfp) != Nullch) { if (*art_buf <= ' ') continue; /* Ignore empty or initially-whitespace lines */ + #ifndef NOMETAMAIL + if (mime_article) { + if (!custom_extract) { + printf("Extracting MIME article into %s:\n", s) FLUSH; + extractprog = savestr(filexp(getval("MIMESTORE",MIMESTORE))); + } + else + printf("Extracting MIME article into %s using %s\n", + s, extractprog) FLUSH; + cnt = 0; + interp(cmd_buf,(sizeof cmd_buf),getval("EXMIMESAVER",EXMIMESAVER)); + termlib_reset(); + resetty(); /* restore tty state */ + doshell(SH,cmd_buf); + noecho(); /* revert to cbreaking */ + crmode(); + termlib_init(); + break; + } + #endif if (found_cut && custom_extract) { printf("Extracting data into %s using %s:\n", s, extractprog) FLUSH; *** ../trn2.2/art.c Fri Nov 20 11:10:23 1992 --- art.c Mon Nov 23 14:24:27 1992 *************** *** 78,84 **** --- 78,106 ---- ; } + #ifndef NOMETAMAIL + #define VERY_LONG_STRING 200 int + display_mime() + { + if (!getenv("NOMETAMAIL")) { + int code; + + interp(cmd_buf,(sizeof cmd_buf),getval("MIMESHOW",MIMESHOW)); + termlib_reset(); + resetty(); + code = doshell(SH,cmd_buf); + noecho(); + crmode(); + termlib_init(); + return(code); + } + else return(1); + } + #endif + + + int do_article() { register char *s; *************** *** 96,105 **** --- 118,134 ---- bool notesfiles = FALSE; /* might there be notesfiles junk? */ char oldmode = mode; char *ctime(); + #ifndef NOMETAMAIL + bool tried_display_mime = FALSE; + #endif + #ifdef INNERSEARCH register int outputok; #endif + #ifndef NOMETAMAIL + mime_article = FALSE; + #endif if (fstat(fileno(artfp),&filestat)) /* get article file stats */ *************** *** 287,292 **** --- 316,326 ---- localtime(&curr_p_art->date)); } #endif + #ifndef NOMETAMAIL + else if (in_header == CONTENT_LINE) { + mime_article = nontext(art_buf+14); + } + #endif } if (in_header == SUBJ_LINE && htype[SUBJ_LINE].ht_flags & HT_MAGIC) { *************** *** 360,365 **** --- 394,405 ---- } #endif else { /* just a normal line */ + #ifndef NOMETAMAIL + if (mime_article && ! tried_display_mime) + if (display_mime() == 0) + return DA_NORM; + else tried_display_mime = TRUE; + #endif if (highlight==artline) { /* this line to be highlit? */ if (marking == STANDOUT) { #ifdef NOFIREWORKS *************** *** 1021,1025 **** --- 1061,1109 ---- return TRUE; } return FALSE; + } + #endif + #ifndef NOMETAMAIL + nontext(content_type) + char *content_type; + { + char *t; + + if (content_type[0] == '\n') return(0); + while (content_type && isspace(*content_type)) ++content_type; + t = index(content_type, ';'); + if (!t) t = index(content_type, '\n'); + if (t) *t-- = NULL; + while (t && *t && t > content_type && isspace(*t)) *t-- = NULL; + if (notplain(content_type)) return(1); + return(0); + } + + notplain(s) + char *s; + { + char *t; + if (!s) return(1); + while (*s && isspace(*s)) ++s; + for(t=s; *t; ++t) if (isupper(*t)) *t = tolower(*t); + while (t > s && isspace(*--t)) {;} + if (((t-s) == 3) && !strncmp(s, "text", 4)) return(0); + if (strncmp(s, "text/plain", 10)) return(1); + t = (char *) index(s, ';'); + while (t) { + ++t; + while (*t && isspace(*t)) ++t; + if (!strncmp(t, "charset", 7)) { + s = (char *) index(t, '='); + if (s) { + ++s; + while (*s && isspace(*s)) ++s; + if (!strncmp(s, "us-ascii", 8)) return(0); + } + return(1); + } + t = (char *) index(t, ';'); + } + return(0); /* no charset, was text/plain */ } #endif