diff -crN mail.2.2.8.orig/aux.c mail.2.2.8/aux.c *** mail.2.2.8.orig/aux.c Mon Jul 28 15:43:47 1997 --- mail.2.2.8/aux.c Fri Jan 8 04:32:38 1999 *************** *** 185,190 **** --- 185,220 ---- return oldhfield; } + #if MAILX + /* + * Return the desired header line from file + * pointer (or NOSTR if the desired header field is not available). + */ + char * + ffield(field, f) + char field[]; + FILE *f; + { + register FILE *ibuf; + char linebuf[LINESIZE]; + register int lc; + register char *hfield; + char *colon, *oldhfield = NOSTR; + + rewind(f); + ibuf = f; + lc = 999999; + do { + if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0) { + return oldhfield; + } + if (hfield = ishfield(linebuf, colon, field)) + oldhfield = save2str(hfield, oldhfield); + } while (lc > 0); + return oldhfield; + } + #endif /* MAILX */ + /* * Return the next header field found in the given message. * Return >= 0 if something found, < 0 elsewise. *************** *** 548,553 **** --- 578,612 ---- return(savestr(nbuf)); } + + #if MAILX + /* + * Erase <> brakets at In-Replay-To: field + */ + char * + erase_braket(name) + char *name; + { + register int c; + register char *cp, *cp2; + char *bufend; + int gotlt, lastsp; + char nbuf[BUFSIZ]; + + if (name == NOSTR) + return(NOSTR); + if ((cp = index(name, '<')) == NOSTR) + return(name); + ++cp; + for (cp2 = nbuf; *cp; ) { + if (*cp == '>') + break; + *cp2++ = *cp++; + } + *cp2 = 0; + return(savestr(nbuf)); + } + #endif /* MAILX */ /* * Fetch the sender's name from the passed message. diff -crN mail.2.2.8.orig/cmd1.c mail.2.2.8/cmd1.c *** mail.2.2.8.orig/cmd1.c Fri Jul 17 13:19:25 1998 --- mail.2.2.8/cmd1.c Fri Jan 8 04:34:25 1999 *************** *** 44,49 **** --- 44,67 ---- * User commands. */ + #if MAILX + /* + * Print the current active headings, but subject only. + */ + static int subject_only = 0; + int + headers2(msgvec) + int *msgvec; + { + int r; + + subject_only = 1; + r = headers(msgvec); + subject_only = 0; + return r; + } + #endif /* MAILX */ + /* * Print the current active headings. * Don't change dot if invoker didn't give an argument. *************** *** 194,199 **** --- 212,229 ---- if (mp->m_flag & MBOX) dispc = 'M'; parse(headline, &hl, pbuf); + #if MAILX + if (subject_only) { + subjlen = screenwidth - 10; + if (subjline == NOSTR || subjlen < 0) /* pretty pathetic */ + printf("%c%c%3d \n", + curind, dispc, mesg); + else + printf("%c%c%3d \"%.*s\"\n", + curind, dispc, mesg, subjlen, subjline); + return; + } + #endif /* MAILX */ sprintf(wcount, "%3ld/%-5ld", mp->m_lines, mp->m_size); subjlen = screenwidth - 50 - strlen(wcount); name = value("show-rcpt") != NOSTR ? *************** *** 342,347 **** --- 372,436 ---- return(0); } + #if MAILX + /* + * Type out the messages (~p). + */ + int + typep(collf, hp) + FILE *collf; + struct header *hp; + { + register *ip; + register struct message *mp; + register char *cp; + int nlines; + FILE *obuf; + int t; + + obuf = stdout; + if (setjmp(pipestop)) + goto close_pipe; + if (value("interactive") != NOSTR && + (cp = value("crt")) != NOSTR) { + nlines = 0; + rewind(collf); + /* printf("-------\nMessage contains:\n"); */ + nlines += 2; + while ((t = getc(collf)) != EOF) { + if (t == '\n') + ++nlines; + } + if (nlines > (*cp ? atoi(cp) : realscreenheight)) { + cp = value("PAGER"); + if (cp == NULL || *cp == '\0') + cp = _PATH_MORE; + obuf = Popen(cp, "w"); + if (obuf == NULL) { + perror(cp); + obuf = stdout; + } else + signal(SIGPIPE, brokpipe); + } + } + rewind(collf); + + fprintf(obuf, "-------\nMessage contains:\n"); + while ((t = getc(collf)) != EOF) + (void) putc(t, obuf); + close_pipe: + if (obuf != stdout) { + /* + * Ignore SIGPIPE so it can't cause a duplicate close. + */ + signal(SIGPIPE, SIG_IGN); + Pclose(obuf); + signal(SIGPIPE, SIG_DFL); + } + return(0); + } + #endif /* MAILX */ + /* * Respond to a broken pipe signal -- * probably caused by quitting more. *************** *** 352,357 **** --- 441,484 ---- { longjmp(pipestop, 1); } + + #if MAILX + do_pipe(str, msgvec) + char *str; + int *msgvec; + { + register *ip; + register struct message *mp; + char *cp; + FILE *obuf; + int t; + + if (setjmp(pipestop)) + goto close_pipe; + obuf = Popen(str, "w"); + if (obuf == NULL) { + perror(cp); + return(0); + } + signal(SIGPIPE, brokpipe); + for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) { + mp = &message[*ip - 1]; + touch(mp); + dot = mp; + if (value("quiet") == NOSTR) + fprintf(obuf, "Message %d:\n", *ip); + (void) send(mp, obuf, 0, NOSTR); + } + close_pipe: + /* + * Ignore SIGPIPE so it can't cause a duplicate close. + */ + signal(SIGPIPE, SIG_IGN); + Pclose(obuf); + signal(SIGPIPE, SIG_DFL); + return(0); + } + #endif /* MAILX */ /* * Print the top so many lines of each desired message. diff -crN mail.2.2.8.orig/cmd2.c mail.2.2.8/cmd2.c *** mail.2.2.8.orig/cmd2.c Sun Mar 8 18:46:25 1998 --- mail.2.2.8/cmd2.c Fri Jan 8 04:32:39 1999 *************** *** 137,142 **** --- 137,156 ---- return save1(str, 1, "save", saveignore); } + #if MAILX + /* + * Save a message in a file whose name is derived from the author + * of the message to be saved. Mark the message as saved + * so we can discard when the user quits. + */ + int + Save(str) + char str[]; + { + return Save1(str, 1, "Save", saveignore); + } + #endif /* MAILX */ + /* * Copy a message to a file without affected its saved-ness */ *************** *** 148,153 **** --- 162,180 ---- return save1(str, 0, "copy", saveignore); } + #if MAILX + /* + * Copy a message to a file without affected its saved-ness + */ + int + Copycmd(str) + char str[]; + { + + return Save1(str, 0, "Copy", saveignore); + } + #endif /* MAILX */ + /* * Save/copy the indicated messages at the end of the passed file name. * If mark is true, mark the message "saved." *************** *** 208,213 **** --- 235,304 ---- printf("%s\n", disp); return(0); } + + #if MAILX + /* + * Save/copy the indicated messages at the end of the file whose name + * is derived from the first message to be saved or copied. + * If mark is true, mark the message "saved." + */ + int + Save1(str, mark, cmd, ignore) + char str[]; + int mark; + char *cmd; + struct ignoretab *ignore; + { + register int *ip; + register struct message *mp; + char *file, *disp, *p; + int f, *msgvec; + FILE *obuf; + + msgvec = (int *) salloc((msgCount + 2) * sizeof *msgvec); + if (*str == 0) { + *msgvec = first(0, MMNORM); + if (*msgvec == NULL) { + printf("No messages to %s.\n", cmd); + return(1); + } + msgvec[1] = NULL; + } else { + if (getmsglist(str, msgvec, 0) < 0) + return(1); + } + file = nameof(&message[*msgvec - 1], 2); + if((p = strchr(file, '@')) != NULL) *p = 0; + if (access(file, 0) >= 0) + disp = "[Appended]"; + else + disp = "[New file]"; + printf("\"%s\" ", file); + fflush(stdout); + if ((obuf = Fopen(file, "a")) == NULL) { + perror(NOSTR); + return(1); + } + + for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) { + mp = &message[*ip - 1]; + touch(mp); + if (send(mp, obuf, ignore, NOSTR) < 0) { + perror(file); + Fclose(obuf); + return(1); + } + if (mark) + mp->m_flag |= MSAVED; + } + fflush(obuf); + if (ferror(obuf)) + perror(file); + Fclose(obuf); + printf("%s\n", disp); + return(0); + } + #endif /* MAILX */ /* * Write the indicated messages at the end of the passed diff -crN mail.2.2.8.orig/cmdtab.c mail.2.2.8/cmdtab.c *** mail.2.2.8.orig/cmdtab.c Mon Sep 15 17:41:43 1997 --- mail.2.2.8/cmdtab.c Fri Jan 8 04:32:39 1999 *************** *** 69,77 **** --- 69,83 ---- "unread", unread, MSGLIST, 0, MMNDEL, "!", shell, I|STRLIST, 0, 0, "copy", copycmd, M|STRLIST, 0, 0, + #if MAILX + "Copy", Copycmd, M|STRLIST, 0, 0, + #endif /* MAILX */ "chdir", schdir, M|RAWLIST, 0, 1, "cd", schdir, M|RAWLIST, 0, 1, "save", save, STRLIST, 0, 0, + #if MAILX + "Save", Save, STRLIST, 0, 0, + #endif /* MAILX */ "source", source, M|RAWLIST, 1, 1, "set", set, M|RAWLIST, 0, 1000, "shell", dosh, I|NOLIST, 0, 0, *************** *** 85,90 **** --- 91,99 ---- "?", help, M|NOLIST, 0, 0, "z", scroll, M|STRLIST, 0, 0, "headers", headers, MSGLIST, 0, MMNDEL, + #if MAILX + "hsubject", headers2, MSGLIST, 0, MMNDEL, + #endif /* MAILX */ "help", help, M|NOLIST, 0, 0, "=", pdot, NOLIST, 0, 0, "Reply", Respond, R|I|MSGLIST, 0, MMNDEL, *************** *** 113,117 **** --- 122,130 ---- "core", core, M|NOLIST, 0, 0, "#", null, M|NOLIST, 0, 0, "clobber", clobber, M|RAWLIST, 0, 1, + #if MAILX + "pipe", do_pipe, PIPELIST, 0, 1, + "|", do_pipe, PIPELIST, 0, 1, + #endif /* MAILX */ 0, 0, 0, 0, 0 }; diff -crN mail.2.2.8.orig/collect.c mail.2.2.8/collect.c *** mail.2.2.8.orig/collect.c Sun Mar 8 18:46:35 1998 --- mail.2.2.8/collect.c Wed Jan 20 00:11:52 1999 *************** *** 77,85 **** --- 77,91 ---- int lc, cc, escape, eofcount; register int c, t; char linebuf[LINESIZE], *cp; + #if MAILX + char *cpe; + #endif /* MAILX */ extern char tempMail[]; char getsub; int omask; + #if MAILX + int mod_header = 0; + #endif /* MAILX */ void collint(), collhup(), collstop(); collf = NULL; *************** *** 132,137 **** --- 138,158 ---- if (!setjmp(colljmp)) { if (getsub) grabh(hp, GSUBJECT); + #if MAILX + if (value("interactive") != NOSTR) { + if (value("askcc") != NOSTR) + grabh(hp, GCC); + if (value("askbcc") != NOSTR) + grabh(hp, GBCC); + } + puthead(hp, collf, + GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA); + hp->h_to = NIL; + hp->h_cc = NIL; + hp->h_bcc = NIL; + hp->h_replyto = NOSTR; /* 1998/07/11 */ + hp->h_inreplyto = NOSTR; /* 1998/07/11 */ + #endif /* MAILX */ } else { /* * Come here for printing the after-signal message. *************** *** 218,234 **** --- 239,271 ---- hadintr++; collint(SIGINT); exit(1); + #if MAILX + /* + * Force a quit of sending mail + * without save of the message in ~/dead.letter. + */ + case 'x': + hadintr++; + collintx(SIGINT); + exit(1); + #endif /* MAILX */ case 'h': /* * Grab a bunch of headers. */ grabh(hp, GTO|GSUBJECT|GCC|GBCC); + #if MAILX + mod_header = 1; + #endif /* MAILX */ goto cont; case 't': /* * Add to the To list. */ hp->h_to = cat(hp->h_to, extract(&linebuf[2], GTO)); + #if MAILX + mod_header = 1; + #endif /* MAILX */ break; case 's': /* *************** *** 238,243 **** --- 275,283 ---- while (isspace(*cp)) cp++; hp->h_subject = savestr(cp); + #if MAILX + mod_header = 1; + #endif /* MAILX */ break; case 'R': /* *************** *** 247,264 **** --- 287,313 ---- while (isspace(*cp)) cp++; hp->h_replyto = savestr(cp); + #if MAILX + mod_header = 1; + #endif /* MAILX */ break; case 'c': /* * Add to the CC list. */ hp->h_cc = cat(hp->h_cc, extract(&linebuf[2], GCC)); + #if MAILX + mod_header = 1; + #endif /* MAILX */ break; case 'b': /* * Add stuff to blind carbon copies list. */ hp->h_bcc = cat(hp->h_bcc, extract(&linebuf[2], GBCC)); + #if MAILX + mod_header = 1; + #endif /* MAILX */ break; case 'd': strcpy(linebuf + 2, getdeadletter()); *************** *** 315,320 **** --- 364,375 ---- } if ((cp = expand(cp)) == NOSTR) break; + #if MAILX + if (mod_header) { + collf = rewrite_header(hp, collf); + mod_header = 0; + } + #endif /* MAILX */ rewind(collf); exwrite(cp, collf, 1); break; *************** *** 345,361 **** --- 400,431 ---- * Print out the current state of the * message without altering anything. */ + #if MAILX + if (mod_header) { + collf = rewrite_header(hp, collf); + mod_header = 0; + } + rewind(collf); + typep(collf, hp); + #else rewind(collf); printf("-------\nMessage contains:\n"); puthead(hp, stdout, GTO|GSUBJECT|GCC|GBCC|GNL); while ((t = getc(collf)) != EOF) (void) putchar(t); + #endif /* MAILX */ goto cont; case '|': /* * Pipe message through command. * Collect output as new message. */ + #if MAILX + if (mod_header) { + collf = rewrite_header(hp, collf); + mod_header = 0; + } + #endif /* MAILX */ rewind(collf); mespipe(collf, &linebuf[2]); goto cont; *************** *** 366,374 **** --- 436,488 ---- * 'e' means to use EDITOR * 'v' means to use VISUAL */ + #if MAILX + if (mod_header) { + collf = rewrite_header(hp, collf); + mod_header = 0; + } + #endif /* MAILX */ rewind(collf); mesedit(collf, c); + #if MAILX + if ((cp = ffield("subject", collf)) != NOSTR) { + hp->h_subject = cp; + } + #endif /* MAILX */ + goto cont; + #if MAILX + case 'a': + /* + * Insert the string of the variable 'sign' + * to the cirrent message. + */ + insvar(collf, "sign"); + goto cont; + case 'A': + /* + * Insert the string of the variable 'Sign' + * to the cirrent message. + */ + insvar(collf, "Sign"); + goto cont; + case 'i': + /* + * Insert the string of the variable + * to the cirrent message. + */ + cp = &linebuf[2]; + while (isspace(*cp)) + cp++; + cpe = cp; + while (!(isspace(*cpe)||*cpe == '\0')) + cpe++; + *cpe = '\0'; + if(*cp == '\0') + fprintf(stderr, "Insert what variable!?\n"); + else + insvar(collf, cp); goto cont; + #endif /* MAILX */ } } goto out; *************** *** 378,385 **** collf = NULL; } out: ! if (collf != NULL) rewind(collf); noreset--; sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); signal(SIGINT, saveint); --- 492,506 ---- collf = NULL; } out: ! if (collf != NULL) { ! #if MAILX ! if (mod_header) { ! collf = rewrite_header(hp, collf); ! mod_header = 0; ! } ! #endif /* MAILX */ rewind(collf); + } noreset--; sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); signal(SIGINT, saveint); *************** *** 391,396 **** --- 512,533 ---- return collf; } + #ifdef MAILX + char * + insvar(fp, name) + FILE *fp; + char *name; + { + char *str; + + if ((str = value(name)) == NOSTR) + fprintf(stderr, "Variable \"%s\" isn't set.\n", name); + else + putline(fp, str); + return(str); + } + #endif /* MAILX */ + /* * Write a file, ex-like if f set. */ *************** *** 607,612 **** --- 744,772 ---- longjmp(collabort, 1); } + #ifdef MAILX + /*ARGSUSED*/ + void + collintx(s) + int s; + { + /* + * the control flow is subtle, because we can be called from ~x. + */ + if (!hadintr) { + if (value("ignore") != NOSTR) { + puts("@"); + fflush(stdout); + clearerr(stdin); + return; + } + hadintr = 1; + longjmp(colljmp, 1); + } + longjmp(collabort, 1); + } + #endif /* MAILX */ + /*ARGSUSED*/ void collhup(s) *************** *** 640,644 **** --- 800,827 ---- while ((c = getc(fp)) != EOF) (void) putc(c, dbuf); Fclose(dbuf); + #if MAILX + fprintf(stderr, "saved the message in %s\n", cp); + #endif /* MAILX */ rewind(fp); } + + #if MAILX + /* + * rewrite header info. + */ + FILE * + rewrite_header(hp, fi) + struct header *hp; + FILE *fi; + { + getheader(hp, fi, 0); + fi = infix(hp, fi); + hp->h_to = NIL; + hp->h_cc = NIL; + hp->h_bcc = NIL; + hp->h_replyto = NOSTR; /* 1998/07/11 */ + hp->h_inreplyto = NOSTR; /* 1998/07/11 */ + return fi; + } + #endif /* MAILX */ diff -crN mail.2.2.8.orig/def.h mail.2.2.8/def.h *** mail.2.2.8.orig/def.h Sun Mar 8 18:46:42 1998 --- mail.2.2.8/def.h Fri Jan 8 04:32:39 1999 *************** *** 52,57 **** --- 52,59 ---- #include #include "pathnames.h" + #define MAILX 1 /* mailx mode */ /* 1994/08/31 (Wed) */ + #define APPEND /* New mail goes to end of mailbox */ #define ESCAPE '~' /* Default escape for sending */ *************** *** 124,129 **** --- 126,134 ---- #define RAWLIST 2 /* Shell string list */ #define NOLIST 3 /* Just plain 0 */ #define NDMLIST 4 /* Message list, no defaults */ + #if MAILX + #define PIPELIST 5 /* Pipe command & Message list */ + #endif /* MAILX */ #define P 040 /* Autoprint dot after command */ #define I 0100 /* Interactive command bit */ diff -crN mail.2.2.8.orig/extern.h mail.2.2.8/extern.h *** mail.2.2.8.orig/extern.h Sun Mar 8 18:46:46 1998 --- mail.2.2.8/extern.h Wed Jan 20 00:12:02 1999 *************** *** 51,56 **** --- 51,59 ---- char *copyin __P((char *, char **)); char *detract __P((struct name *, int)); char *expand __P((char *)); + #if MAILX + char *ffield __P((char[], FILE *)); + #endif /* MAILX */ char *getdeadletter __P((void)); char *getname __P((int)); char *hfield __P((char [], struct message *)); *************** *** 61,71 **** --- 64,80 ---- char *nextword __P((char *, char *)); char *readtty __P((char [], char [])); char *reedit __P((char *)); + #if MAILX + FILE *rewrite_header __P((struct header *, FILE *)); + #endif /* MAILX */ FILE *run_editor __P((FILE *, off_t, int, int)); char *salloc __P((int)); char *savestr __P((char *)); FILE *setinput __P((struct message *)); char *skin __P((char *)); + #if MAILX + char *erase_braket __P((char *name)); + #endif /* MAILX */ char *skip_comment __P((char *)); char *snarf __P((char [], int *)); char *username __P((void)); *************** *** 97,105 **** --- 106,120 ---- int cmatch __P((char *, char *)); void collhup __P((int)); void collint __P((int)); + #if MAILX + void collintx __P((int)); + #endif /* MAILX */ void collstop __P((int)); void commands __P((void)); int copycmd __P((char [])); + #if MAILX + int Copycmd __P((char [])); + #endif /* MAILX */ int core __P((void)); int count __P((struct name *)); int delete __P((int [])); *************** *** 131,136 **** --- 146,154 ---- int from __P((int *)); off_t fsize __P((FILE *)); int getfold __P((char *)); + #if MAILX + void getheader __P((struct header *, FILE *, int)); + #endif /* MAILX */ int gethfield __P((FILE *, char [], int, char **)); int getmsglist __P((char *, int *, int)); int getrawlist __P((char [], char **, int)); *************** *** 141,146 **** --- 159,167 ---- int hash __P((char *)); void hdrstop __P((int)); int headers __P((int *)); + #if MAILX + int headers2 __P((int *)); + #endif /* MAILX */ int help __P((void)); void holdsigs __P((void)); int ifcmd __P((char **)); *************** *** 205,210 **** --- 226,235 ---- int run_command __P((char *, int, int, int, char *, char *, char *)); int save __P((char [])); int save1 __P((char [], int, char *, struct ignoretab *)); + #if MAILX + int Save __P((char [])); + int Save1 __P((char [], int, char *, struct ignoretab *)); + #endif /* MAILX */ void savedeadletter __P((FILE *)); int saveigfield __P((char *[])); int savemail __P((char [], FILE *)); *************** *** 239,244 **** --- 264,272 ---- void ttystop __P((int)); int type __P((int *)); int type1 __P((int *, int, int)); + #if MAILX + int typep __P((FILE *, struct header *)); + #endif /* MAILX */ int undelete_messages __P((int *)); void unmark __P((int)); char **unpack __P((struct name *)); *************** *** 251,253 **** --- 279,287 ---- int wait_child __P((int)); int wait_command __P((int)); int writeback __P((FILE *)); + #if MAILX + int do_pipe __P((char *, int [])); + #endif /* MAILX */ + #if MAILX + char *insvar __P((FILE *, char *)); + #endif /* MAILX */ diff -crN mail.2.2.8.orig/lex.c mail.2.2.8/lex.c *** mail.2.2.8.orig/lex.c Sun Mar 8 18:46:49 1998 --- mail.2.2.8/lex.c Fri Jan 8 04:32:40 1999 *************** *** 209,214 **** --- 209,223 ---- break; linebuf[n++] = ' '; } + #if MAILX + if (n != -1) { + char *p; + for (p=linebuf; *p && isspace(*p); p++) + ; + if (*p == '#') + continue; + } + #endif /* MAILX */ reset_on_stop = 0; if (n < 0) { /* eof */ *************** *** 328,333 **** --- 337,396 ---- goto out; } switch (com->c_argtype & ~(F|P|I|M|T|W|R)) { + #if MAILX + case PIPELIST: + { char dlmt = 0; + char *cp_h = cp; + cp = cp + strlen(cp) - 1; + /* + * Strip away trailing blanks. + */ + while (cp > cp_h && isspace(*cp)) + cp--; + *++cp = 0; + + if (*--cp == '"') { + dlmt = 1; + *cp = '\0'; + } + /* + * Now search for the beginning of the command name. + */ + while (cp > cp_h && (dlmt ? (*cp != '"') : !isspace(*cp))) + cp--; + if (dlmt && *cp == '"') + *cp++ = '\0'; + else if (dlmt == 0 && isspace(*cp)) + *cp++ = '\0'; + else { + printf("No applicable command\n"); + break; + } + cp2 = cp; + cp = cp_h; + /* + * A message list defaulting to nearest forward + * legal message. + */ + if (msgvec == 0) { + printf("Illegal use of \"message list\"\n"); + break; + } + if ((c = getmsglist(cp_h, msgvec, com->c_msgflag)) < 0) + break; + if (c == 0) { + *msgvec = first(com->c_msgflag, + com->c_msgmask); + msgvec[1] = NULL; + } + if (*msgvec == NULL) { + printf("No applicable messages\n"); + break; + } + e = (*com->c_func)(cp2, msgvec); + break; + } + #endif /* MAILX */ case MSGLIST: /* * A message list defaulting to nearest forward diff -crN mail.2.2.8.orig/mail.1 mail.2.2.8/mail.1 *** mail.2.2.8.orig/mail.1 Tue Apr 14 10:00:35 1998 --- mail.2.2.8/mail.1 Tue Jan 19 01:50:03 1999 *************** *** 381,386 **** --- 381,394 ---- .Ic save does, except that it does not mark the messages it is used on for deletion when you quit. + .It Ic Copy + .Pq Ic C + The + .Ic Copy + command does the same thing that + .Ic Save + does, except that it does not mark the messages it + is used on for deletion when you quit. .It Ic delete .Pq Ic d Takes a list of messages as argument and marks them all as deleted. *************** *** 565,570 **** --- 573,585 ---- turn to the end of the file. The filename in quotes, followed by the line count and character count is echoed on the user's terminal. + .It Ic Save + .Pq Ic S + Takes a message list and appends each message in + turn to the end of the file whose name is derived from the author of + the first message to be saved. + The filename in quotes, followed by the line + count and character count is echoed on the user's terminal. .It Ic set .Pq Ic se With no arguments, prints all variable values. *************** *** 697,702 **** --- 712,721 ---- .Bl -tag -width Ds .It Ic \&~! Ns Ar command Execute the indicated shell command, then return to the message. + .It Ic \&~a + Insert the string of the variable ``sign''. + .It Ic \&~A + Insert the string of the variable ''Sign''. .It Ic \&~b Ns Ar name ... Add the given names to the list of carbon copy recipients but do not make the names visible in the Cc: line ("blind" carbon copy). *************** *** 727,732 **** --- 746,753 ---- Edit the message header fields by typing each one in turn and allowing the user to append text to the end or modify the field by using the current terminal erase and kill characters. + .It Ic \&~i Ns variable + Insert the string of the variable. .It Ic \&~m Ns Ar messages Read the named messages into the message being sent, indented by a tab or by the value of *************** *** 772,777 **** --- 793,801 ---- text to the end of your message. .It Ic \&~w Ns Ar filename Write the message onto the named file. + .It Ic \&~x + Abort the message being sent without copying the message to + .Dq Pa dead.letter. .It Ic \&~\&| Ns Ar command Pipe the message through the command as a filter. If the command gives *************** *** 991,996 **** --- 1015,1026 ---- with the .Ic top command; normally, the first five lines are printed. + .It Ar sign + String used by the ``~a'' tilde escape, + the value is inserted in the message. + .It Ar Sign + String used by the ``~A'' tilde escape, + the value is inserted in the message. .El .Sh ENVIRONMENT .Nm Mail diff -crN mail.2.2.8.orig/names.c mail.2.2.8/names.c *** mail.2.2.8.orig/names.c Sun Mar 8 18:47:02 1998 --- mail.2.2.8/names.c Fri Jan 8 04:32:40 1999 *************** *** 261,268 **** --- 261,270 ---- } (void) fcntl(image, F_SETFD, 1); fprintf(fout, "From %s %s", myname, date); + #if !MAILX puthead(hp, fout, GTO|GSUBJECT|GCC|GREPLYTO|GINREPLYTO|GNL); + #endif /* MAILX */ while ((c = getc(fo)) != EOF) (void) putc(c, fout); rewind(fo); *************** *** 501,514 **** --- 503,522 ---- top = (char **) salloc((t + extra) * sizeof *top); ap = top; *ap++ = "send-mail"; + #if MAILX + *ap++ = "-t"; + #else *ap++ = "-i"; + #endif /* MAILX */ if (metoo) *ap++ = "-m"; if (verbose) *ap++ = "-v"; + #if !MAILX for (; n != NIL; n = n->n_flink) if ((n->n_type & GDEL) == 0) *ap++ = n->n_name; + #endif /* MAILX */ *ap = NOSTR; return(top); } diff -crN mail.2.2.8.orig/send.c mail.2.2.8/send.c *** mail.2.2.8.orig/send.c Sun Mar 8 18:47:07 1998 --- mail.2.2.8/send.c Fri Jan 8 04:32:40 1999 *************** *** 312,321 **** --- 312,328 ---- */ if ((mtf = collect(hp, printheaders)) == NULL) return; + #if MAILX + getheader(hp, mtf, 1); + #endif /* MAILX */ if (value("interactive") != NOSTR) + #if MAILX + { + #else if (value("askcc") != NOSTR) grabh(hp, GCC); else { + #endif /* MAILX */ printf("EOT\n"); (void) fflush(stdout); } *************** *** 324,329 **** --- 331,340 ---- printf("No message, no subject; hope that's ok\n"); else printf("Null message body; hope that's ok\n"); + #if MAILX + senderr = 0; + to = cat(hp->h_bcc, cat(hp->h_to, hp->h_cc)); + #else /* * Now, take the user names from the combined * to and cc lists and do all the alias *************** *** 335,340 **** --- 346,352 ---- printf("No recipients specified\n"); senderr++; } + #endif /* MAILX */ /* * Look through the recipient list for names with /'s * in them which we write to as files directly. *************** *** 407,413 **** hp->h_to = NIL; hp->h_cc = NIL; hp->h_bcc = NIL; ! for (np = tolist; np != NIL; np = np->n_flink) if ((np->n_type & GMASK) == GTO) hp->h_to = cat(hp->h_to, nalloc(np->n_name, np->n_type)); --- 419,429 ---- hp->h_to = NIL; hp->h_cc = NIL; hp->h_bcc = NIL; ! for (np = tolist; np != NIL; np = np->n_flink) { ! #if MAILX ! if (np->n_type & GDEL) ! continue; ! #endif /* MAILX */ if ((np->n_type & GMASK) == GTO) hp->h_to = cat(hp->h_to, nalloc(np->n_name, np->n_type)); *************** *** 417,428 **** --- 433,561 ---- else if ((np->n_type & GMASK) == GBCC) hp->h_bcc = cat(hp->h_bcc, nalloc(np->n_name, np->n_type)); + } + } + + #if MAILX + /* + * get header info from file. + */ + void + getheader(hp, fi, um) + struct header *hp; + FILE *fi; + int um; + { + char *cp; + + rewind(fi); + if ((cp = skin(ffield("to", fi))) != NOSTR) { + hp->h_to = cat(hp->h_to, extract(cp, GTO)); + if (um) + hp->h_to = usermap(hp->h_to); + } + if ((cp = ffield("reply-to", fi)) != NOSTR) { /* 1998/07/11 */ + hp->h_replyto = cp; + } + if ((cp = erase_braket(ffield("in-reply-to", fi))) != NOSTR) { /* 1998/07/11 */ + hp->h_inreplyto = cp; + } + if ((cp = skin(ffield("cc", fi))) != NOSTR) { + hp->h_cc = cat(hp->h_cc, extract(cp, GCC)); + if (um) + hp->h_cc = usermap(hp->h_cc); + } + if ((cp = skin(ffield("bcc", fi))) != NOSTR) { + hp->h_bcc = cat(hp->h_bcc, extract(cp, GBCC)); + if (um) + hp->h_bcc = usermap(hp->h_bcc); + } + rewind(fi); } + #endif /* MAILX */ /* * Prepend a header in front of the collected stuff * and return the new file. */ + #if MAILX + FILE * + infix(hp, fi) + struct header *hp; + FILE *fi; + { + extern char tempMail[]; + register FILE *nfo, *nfi; + register int c; + char linebuf[LINESIZE]; + register char *cp; + + if ((nfo = Fopen(tempMail, "w")) == NULL) { + perror(tempMail); + return(fi); + } + if ((nfi = Fopen(tempMail, "r")) == NULL) { + perror(tempMail); + (void) Fclose(nfo); + return(fi); + } + (void) rm(tempMail); + rewind(fi); + (void) puthead(hp, nfo, + GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GCOMMA); + for (;;) { + if (readline(fi, linebuf, LINESIZE) < 0) + return(fi); + for (cp = linebuf; isprint(*cp) && *cp != ' ' && *cp != ':'; + cp++) + ; + if (cp == linebuf) { + putline(nfo, linebuf); /* NL put */ + break; + } + if (*cp == ':') { + if (ishfield(linebuf, cp, "to") != 0 || + ishfield(linebuf, cp, "subject") != 0 || + ishfield(linebuf, cp, "cc") != 0 || + ishfield(linebuf, cp, "bcc") != 0 || + ishfield(linebuf, cp, "reply-to") != 0 || /* 1998/07/11 */ + ishfield(linebuf, cp, "in-reply-to") != 0) { /* 1998/07/11 */ + for (;;) { + ungetc(c = getc(fi), fi); + if (c != ' ' && c != '\t') + break; + if (readline(fi, linebuf, LINESIZE) < 0) + return(fi); + } + continue; + } + } + putline(nfo, linebuf); + } + c = getc(fi); + while (c != EOF) { + (void) putc(c, nfo); + c = getc(fi); + } + if (ferror(fi)) { + perror("read"); + rewind(fi); + return(fi); + } + (void) fflush(nfo); + if (ferror(nfo)) { + perror(tempMail); + (void) Fclose(nfo); + (void) Fclose(nfi); + rewind(fi); + return(fi); + } + (void) Fclose(nfo); + (void) Fclose(fi); + rewind(nfi); + return(nfi); + } + #else /* MAILX */ FILE * infix(hp, fi) struct header *hp; *************** *** 467,472 **** --- 600,606 ---- rewind(nfi); return(nfi); } + #endif /* MAILX */ /* * Dump the to, subject, cc header on the *************** *** 483,499 **** --- 617,643 ---- gotcha = 0; if (hp->h_to != NIL && w & GTO) fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; + #if !MAILX if (hp->h_subject != NOSTR && w & GSUBJECT) fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; + #endif /* MAILX */ if (hp->h_cc != NIL && w & GCC) fmt("Cc:", hp->h_cc, fo, w&GCOMMA), gotcha++; if (hp->h_bcc != NIL && w & GBCC) fmt("Bcc:", hp->h_bcc, fo, w&GCOMMA), gotcha++; + #if MAILX + if (hp->h_subject != NOSTR && w & GSUBJECT) + fprintf(fo, "Subject: %s\n", hp->h_subject), gotcha++; + #endif /* MAILX */ if (hp->h_replyto != NOSTR && w & GREPLYTO) fprintf(fo, "Reply-To: %s\n", hp->h_replyto), gotcha++; if (hp->h_inreplyto != NOSTR && w & GINREPLYTO) fprintf(fo, "In-Reply-To: <%s>\n", hp->h_inreplyto), gotcha++; + #if MAILX + if (fo != stdout && gotcha && w & GNL) + #else if (gotcha && w & GNL) + #endif /* MAILX */ (void) putc('\n', fo); return(0); }