/* output a message */ extern int m_print(message *mp, Biobuf *fp, char *remote, int mbox) { String *date, *sender; char *f[6]; int n; sender = unescapespecial(s_clone(mp->sender)); if (remote != 0){ if(print_remote_header(fp,s_to_c(sender),s_to_c(mp->date),remote) < 0){ s_free(sender); return -1; } } else { if(print_header(fp, s_to_c(sender), s_to_c(mp->date)) < 0){ s_free(sender); return -1; } } s_free(sender); if(!rmail && !mp->havedate){ /* add a date: line Date: Sun, 19 Apr 1998 12:27:52 -0400 */ date = s_copy(s_to_c(mp->date)); n = getfields(s_to_c(date), f, 6, 1, " \t"); if(n == 6) Bprint(fp, "Date: %s, %s %s %s %s %s\n", f[0], f[2], f[1], f[5], f[3], rewritezone(f[4])); } if(!rmail && !mp->havemime && isutf8(mp->body)) printutf8mime(fp); if(mp->to){ /* add the to: line */ if (Bprint(fp, "%s\n", s_to_c(mp->to)) < 0) return -1; /* add the from: line */ if (!mp->havefrom && printfrom(mp, fp) < 0) return -1; if(!mp->rfc822headers && *s_to_c(mp->body) != '\n') if (Bprint(fp, "\n") < 0) return -1; } else if(!rmail){ /* add the from: line */ if (!mp->havefrom && printfrom(mp, fp) < 0) return -1; if(!mp->rfc822headers && *s_to_c(mp->body) != '\n') if (Bprint(fp, "\n") < 0) return -1; } if (!mbox) return m_noescape(mp, fp); return m_escape(mp, fp); }
/* ----------------------------------------------------------------------- */ void do_a_file(FILE *f) { char *start; if ( (start = findstart(f)) != (char *)ERRVAL) /* find the starting point */ printfrom(start, f); /* print from there to end */ }