Teach boring old mail(1) about the use of the REPLYTO environment

variable which is de-facto standard for MUAs.

Teach bomail to generate an in-reply-to header so threading MUAs and
mail->news gateways won't lose context.

While i was at it, removed two gratuitous standard violations for
functions starting with an underscore.
This commit is contained in:
joerg 1998-01-02 16:44:13 +00:00
parent 66e8854450
commit 9c35be2c44
9 changed files with 64 additions and 22 deletions

View File

@ -187,9 +187,9 @@ respond(msgvec)
int *msgvec;
{
if (value("Replyall") == NOSTR)
return (_respond(msgvec));
return (dorespond(msgvec));
else
return (_Respond(msgvec));
return (doRespond(msgvec));
}
/*
@ -197,7 +197,7 @@ respond(msgvec)
* message header and send them off to mail1()
*/
int
_respond(msgvec)
dorespond(msgvec)
int *msgvec;
{
struct message *mp;
@ -252,6 +252,9 @@ _respond(msgvec)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
head.h_replyto = NOSTR;
head.h_inreplyto = skin(hfield("message-id", mp));
mail1(&head, 1);
return(0);
}
@ -581,9 +584,9 @@ Respond(msgvec)
int *msgvec;
{
if (value("Replyall") == NOSTR)
return (_Respond(msgvec));
return (doRespond(msgvec));
else
return (_respond(msgvec));
return (dorespond(msgvec));
}
/*
@ -592,13 +595,14 @@ Respond(msgvec)
* reply.
*/
int
_Respond(msgvec)
doRespond(msgvec)
int msgvec[];
{
struct header head;
struct message *mp;
register int *ap;
register char *cp;
char *mid;
head.h_to = NIL;
for (ap = msgvec; *ap != 0; ap++) {
@ -608,6 +612,7 @@ _Respond(msgvec)
if ((cp = skin(hfield("from", mp))) == NOSTR)
cp = skin(nameof(mp, 2));
head.h_to = cat(head.h_to, extract(cp, GTO));
mid = skin(hfield("message-id", mp));
}
if (head.h_to == NIL)
return 0;
@ -618,6 +623,9 @@ _Respond(msgvec)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
head.h_replyto = NOSTR;
head.h_inreplyto = mid;
mail1(&head, 1);
return 0;
}

View File

@ -232,13 +232,22 @@ collect(hp, printheaders)
break;
case 's':
/*
* Set the Subject list.
* Set the Subject line.
*/
cp = &linebuf[2];
while (isspace(*cp))
cp++;
hp->h_subject = savestr(cp);
break;
case 'R':
/*
* Set the Reply-To line.
*/
cp = &linebuf[2];
while (isspace(*cp))
cp++;
hp->h_replyto = savestr(cp);
break;
case 'c':
/*
* Add to the CC list.

View File

@ -155,12 +155,14 @@ struct headline {
#define GSUBJECT 2 /* Likewise, Subject: line */
#define GCC 4 /* And the Cc: line */
#define GBCC 8 /* And also the Bcc: line */
#define GMASK (GTO|GSUBJECT|GCC|GBCC)
#define GREPLYTO 0x10 /* And the Reply-To: line */
#define GINREPLYTO 0x20 /* The In-Reply-To: line */
#define GMASK (GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO)
/* Mask of places from whence */
#define GNL 16 /* Print blank line after */
#define GDEL 32 /* Entity removed from list */
#define GCOMMA 64 /* detract puts in commas */
#define GNL 0x40 /* Print blank line after */
#define GDEL 0x80 /* Entity removed from list */
#define GCOMMA 0x100 /* detract puts in commas */
/*
* Structure used to pass about the current
@ -172,6 +174,8 @@ struct header {
char *h_subject; /* Subject string */
struct name *h_cc; /* Carbon copies string */
struct name *h_bcc; /* Blind carbon copies */
char *h_replyto; /* Reply address */
char *h_inreplyto; /* Reference */
struct name *h_smopts; /* Sendmail options */
};

View File

@ -77,8 +77,8 @@ int More __P((int *));
int Pclose __P((FILE *));
int Respond __P((int *));
int Type __P((int *));
int _Respond __P((int []));
int _respond __P((int *));
int doRespond __P((int []));
int dorespond __P((int *));
void alter __P((char *));
int alternates __P((char **));
void announce __P((void));
@ -162,7 +162,7 @@ void load __P((char *));
struct var *
lookup __P((char []));
int mail __P((struct name *,
struct name *, struct name *, struct name *, char *));
struct name *, struct name *, struct name *, char *, char *));
void mail1 __P((struct header *, int));
void makemessage __P((FILE *));
void mark __P((int));

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)mail.1 8.2 (Berkeley) 12/30/93
.\" $Id: mail.1,v 1.12 1997/02/22 19:56:06 peter Exp $
.\" $Id: mail.1,v 1.13 1997/11/01 00:56:15 jraynard Exp $
.\"
.Dd December 30, 1993
.Dt MAIL 1
@ -752,6 +752,10 @@ in your home directory if
is set.
.It Ic \&~r Ns Ar filename
Read the named file into the message.
.It Ic \&~R Ns Ar string
Use
.Ar string
as the Reply-To field.
.It Ic \&~s Ns Ar string
Cause the named string to become the current subject field.
.It Ic \&~\&t Ns Ar name ...
@ -924,6 +928,9 @@ variable is set.
The default paginator
.Xr more 1
is used if this option is not defined.
.It Ev REPLYTO
If set, will be used to initialize the Reply-To field for outgoing
messages.
.It Ev SHELL
Pathname of the shell to use in the
.Ic \&!

View File

@ -61,8 +61,8 @@ main(argc, argv)
{
register int i;
struct name *to, *cc, *bcc, *smopts;
char *subject;
char *ef;
char *subject, *replyto;
char *ef, *cp;
char nosrc = 0;
void hdrstop();
sig_t prevint;
@ -90,6 +90,7 @@ main(argc, argv)
bcc = NIL;
smopts = NIL;
subject = NOSTR;
replyto = NOSTR;
while ((i = getopt(argc, argv, "INT:b:c:dfins:u:v")) != -1) {
switch (i) {
case 'T':
@ -220,6 +221,8 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
if (*s != '\0')
load(s);
}
if ((cp = getenv("REPLYTO")) != NULL)
replyto = cp;
/*
* Expand returns a savestr, but load only uses the file name
@ -227,7 +230,7 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
*/
load(expand("~/.mailrc"));
if (!rcvmode) {
mail(to, cc, bcc, smopts, subject);
mail(to, cc, bcc, smopts, subject, replyto);
/*
* why wait?
*/

View File

@ -12,6 +12,7 @@ The following ~ escapes are defined:
~p Print the message buffer
~m messages Read in messages, right shifted by a tab
~M messages Same as ~m, but keep all header lines
~R address Set reply-to
~s subject Set subject
~t users Add users to to list
~v Invoke display editor on message

View File

@ -261,7 +261,8 @@ outof(names, fo, hp)
}
(void) fcntl(image, F_SETFD, 1);
fprintf(fout, "From %s %s", myname, date);
puthead(hp, fout, GTO|GSUBJECT|GCC|GNL);
puthead(hp, fout,
GTO|GSUBJECT|GCC|GREPLYTO|GINREPLYTO|GNL);
while ((c = getc(fo)) != EOF)
(void) putc(c, fout);
rewind(fo);

View File

@ -251,9 +251,9 @@ statusput(mp, obuf, prefix)
* which does all the dirty work.
*/
int
mail(to, cc, bcc, smopts, subject)
mail(to, cc, bcc, smopts, subject, replyto)
struct name *to, *cc, *bcc, *smopts;
char *subject;
char *subject, *replyto;
{
struct header head;
@ -262,6 +262,8 @@ mail(to, cc, bcc, smopts, subject)
head.h_cc = cc;
head.h_bcc = bcc;
head.h_smopts = smopts;
head.h_replyto = replyto;
head.h_inreplyto = NOSTR;
mail1(&head, 0);
return(0);
}
@ -282,6 +284,9 @@ sendmail(str)
head.h_cc = NIL;
head.h_bcc = NIL;
head.h_smopts = NIL;
if ((head.h_replyto = getenv("REPLYTO")) == NULL)
head.h_replyto = NOSTR;
head.h_inreplyto = NOSTR;
mail1(&head, 0);
return(0);
}
@ -437,7 +442,7 @@ infix(hp, fi)
return(fi);
}
(void) rm(tempMail);
(void) puthead(hp, nfo, GTO|GSUBJECT|GCC|GBCC|GNL|GCOMMA);
(void) puthead(hp, nfo, GTO|GSUBJECT|GCC|GBCC|GREPLYTO|GINREPLYTO|GNL|GCOMMA);
c = getc(fi);
while (c != EOF) {
(void) putc(c, nfo);
@ -483,6 +488,10 @@ puthead(hp, fo, w)
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 (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 (gotcha && w & GNL)
(void) putc('\n', fo);
return(0);