from Tom Newcomb (newcomb@arpa)
SCCS-vsn: usr.bin/mail/lex.c 5.9
SCCS-vsn: usr.bin/mail/send.c 5.7
SCCS-vsn: usr.bin/mail/cmd3.c 5.6
SCCS-vsn: usr.bin/mail/main.c 5.6
SCCS-vsn: usr.bin/mail/def.h 5.7
-static char sccsid[] = "@(#)cmd3.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd3.c 5.6 (Berkeley) %G%";
#endif /* notdef */
#include "rcv.h"
#endif /* notdef */
#include "rcv.h"
mail1(&head);
return(0);
}
mail1(&head);
return(0);
}
for (ap = argv; *ap != NOSTR; ap++) {
cp = *ap;
for (ap = argv; *ap != NOSTR; ap++) {
cp = *ap;
- if ((cp = expand(cp)) != NOSTR)
- printf("%s ", cp);
+ if ((cp = expand(cp)) != NOSTR) {
+ if (ap != argv)
+ putchar(' ');
+ printf("%s", cp);
+ }
head.h_seq++;
head.h_cc = NOSTR;
head.h_bcc = NOSTR;
head.h_seq++;
head.h_cc = NOSTR;
head.h_bcc = NOSTR;
mail1(&head);
return(0);
}
mail1(&head);
return(0);
}
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*
- * @(#)def.h 5.6 (Berkeley) %G%
+ * @(#)def.h 5.7 (Berkeley) %G%
*/
#include <sys/param.h> /* includes <sys/types.h> */
*/
#include <sys/param.h> /* includes <sys/types.h> */
char *h_subject; /* Subject string */
char *h_cc; /* Carbon copies string */
char *h_bcc; /* Blind carbon copies */
char *h_subject; /* Subject string */
char *h_cc; /* Carbon copies string */
char *h_bcc; /* Blind carbon copies */
+ char *h_smopts; /* Sendmail options */
int h_seq; /* Sequence for optimization */
};
int h_seq; /* Sequence for optimization */
};
-static char sccsid[] = "@(#)lex.c 5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c 5.9 (Berkeley) %G%";
#endif /* notdef */
#include "rcv.h"
#endif /* notdef */
#include "rcv.h"
printf(prompt);
}
fflush(stdout);
printf(prompt);
}
fflush(stdout);
+ if (!sourcing)
+ sreset();
/*
* Read a line of commands from the current input
/*
* Read a line of commands from the current input
#endif /* notdef */
#ifdef notdef
#endif /* notdef */
#ifdef notdef
-static char sccsid[] = "@(#)main.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.6 (Berkeley) %G%";
#endif /* notdef */
#include "rcv.h"
#endif /* notdef */
#include "rcv.h"
main(argc, argv)
char **argv;
{
main(argc, argv)
char **argv;
{
- register char *ef;
- register int i, argp;
- int mustsend, hdrstop(), (*prevint)(), f;
+ register char *ef, opt;
+ register int i;
+ struct name *to, *cc, *bcc, *smopts;
+ int mustsend, hdrstop(), (*prevint)(), f;
+ extern int getopt(), optind, opterr;
+ extern char *optarg;
/*
* Set up a reasonable environment.
/*
* Set up a reasonable environment.
+ to = NULL;
+ cc = NULL;
+ bcc = NULL;
+ smopts = NULL;
mustsend = 0;
if (argc > 0 && **argv == 'r')
rmail++;
mustsend = 0;
if (argc > 0 && **argv == 'r')
rmail++;
- for (i = 1; i < argc; i++) {
-
- /*
- * If current argument is not a flag, then the
- * rest of the arguments must be recipients.
- */
-
- if (*argv[i] != '-') {
- argp = i;
- break;
- }
- switch (argv[i][1]) {
+ while ((opt = getopt(argc, argv, "INT:b:c:dfh:inr:s:u:v")) != EOF) {
+ switch (opt) {
case 'r':
/*
* Next argument is address to be sent along
* to the mailer.
*/
case 'r':
/*
* Next argument is address to be sent along
* to the mailer.
*/
- if (i >= argc - 1) {
- fprintf(stderr, "Address required after -r\n");
- exit(1);
- }
- rflag = argv[i+1];
- i++;
case 'T':
/*
* Next argument is temp file to write which
* articles have been read/deleted for netnews.
*/
case 'T':
/*
* Next argument is temp file to write which
* articles have been read/deleted for netnews.
*/
- if (i >= argc - 1) {
- fprintf(stderr, "Name required after -T\n");
- exit(1);
- }
- Tflag = argv[i+1];
if ((f = creat(Tflag, 0600)) < 0) {
perror(Tflag);
exit(1);
}
close(f);
if ((f = creat(Tflag, 0600)) < 0) {
perror(Tflag);
exit(1);
}
close(f);
case 'u':
/*
* Next argument is person to pretend to be.
*/
case 'u':
/*
* Next argument is person to pretend to be.
*/
- if (i >= argc - 1) {
- fprintf(stderr, "Missing user name for -u\n");
- exit(1);
- }
- strcpy(myname, argv[i+1]);
- i++;
+ strcpy(myname, optarg);
case 'i':
/*
* User wants to ignore interrupts.
case 'i':
/*
* User wants to ignore interrupts.
*/
assign("ignore", "");
break;
*/
assign("ignore", "");
break;
case 'd':
debug++;
break;
case 'd':
debug++;
break;
case 'h':
/*
* Specified sequence number for network.
case 'h':
/*
* Specified sequence number for network.
* far (count of times message has been
* forwarded) to help avoid infinite mail loops.
*/
* far (count of times message has been
* forwarded) to help avoid infinite mail loops.
*/
- if (i >= argc - 1) {
- fprintf(stderr, "Number required for -h\n");
- exit(1);
- }
- hflag = atoi(argv[i+1]);
if (hflag == 0) {
fprintf(stderr, "-h needs non-zero number\n");
exit(1);
}
if (hflag == 0) {
fprintf(stderr, "-h needs non-zero number\n");
exit(1);
}
case 's':
/*
* Give a subject field for sending from
* non terminal
*/
case 's':
/*
* Give a subject field for sending from
* non terminal
*/
- if (i >= argc - 1) {
- fprintf(stderr, "Subject req'd for -s\n");
- exit(1);
- }
- sflag = argv[i+1];
- i++;
case 'f':
/*
* User is specifying file to "edit" with Mail,
* as opposed to reading system mailbox.
* If no argument is given after -f, we read his
* mbox file in his home directory.
case 'f':
/*
* User is specifying file to "edit" with Mail,
* as opposed to reading system mailbox.
* If no argument is given after -f, we read his
* mbox file in his home directory.
+ *
+ * getopt() can't handle optional arguments, so here
+ * is an ugly hack to get around it.
- if (i >= argc - 1)
- ef = mbox;
+ if ((argv[optind]) && (argv[optind][0] != '-'))
+ ef = argv[optind++];
- ef = argv[i + 1];
- i++;
case 'n':
/*
* User doesn't want to source /usr/lib/Mail.rc
*/
nosrc++;
break;
case 'n':
/*
* User doesn't want to source /usr/lib/Mail.rc
*/
nosrc++;
break;
case 'N':
/*
* Avoid initial header printing.
*/
noheader++;
break;
case 'N':
/*
* Avoid initial header printing.
*/
noheader++;
break;
case 'v':
/*
* Send mailer verbose flag
*/
assign("verbose", "");
break;
case 'v':
/*
* Send mailer verbose flag
*/
assign("verbose", "");
break;
case 'I':
/*
* We're interactive
*/
intty = 1;
break;
case 'I':
/*
* We're interactive
*/
intty = 1;
break;
-
- default:
- fprintf(stderr, "Unknown flag: %s\n", argv[i]);
+ case 'c':
+ /*
+ * Get Carbon Copy Recipient list
+ */
+ cc = cat(cc, nalloc(optarg));
+ mustsend++;
+ break;
+ case 'b':
+ /*
+ * Get Blind Carbon Copy Recipient list
+ */
+ bcc = cat(bcc, nalloc(optarg));
+ mustsend++;
+ break;
+ case '?':
+ fputs("Usage: XXX\n", stderr);
+ for (i = optind; (argv[i]) && (*argv[i] != '-'); i++)
+ to = cat(to, nalloc(argv[i]));
+ for (; argv[i]; i++)
+ smopts = cat(smopts, nalloc(argv[i]));
/*
* Check for inconsistent arguments.
*/
/*
* Check for inconsistent arguments.
*/
-
- if (ef != NOSTR && argp != -1) {
+ if (!to && (cc || bcc)) {
+ fputs("You must also specify direct recipients of mail.\n", stderr);
+ exit(1);
+ }
+ if ((ef != NOSTR) && to) {
fprintf(stderr, "Cannot give -f and people to send to.\n");
exit(1);
}
fprintf(stderr, "Cannot give -f and people to send to.\n");
exit(1);
}
- if (mustsend && argp == -1) {
fprintf(stderr, "The flags you gave make no sense since you're not sending mail.\n");
exit(1);
}
tinit();
setscreensize();
input = stdin;
fprintf(stderr, "The flags you gave make no sense since you're not sending mail.\n");
exit(1);
}
tinit();
setscreensize();
input = stdin;
if (!nosrc)
load(MASTER);
load(mailrc);
if (!nosrc)
load(MASTER);
load(mailrc);
- if (argp != -1) {
- mail(&argv[argp]);
+ if (!rcvmode) {
+ mail(to, cc, bcc, smopts);
-static char sccsid[] = "@(#)send.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)send.c 5.7 (Berkeley) %G%";
#endif /* notdef */
#include "rcv.h"
#endif /* notdef */
#include "rcv.h"
* which does all the dirty work.
*/
* which does all the dirty work.
*/
-mail(people)
- char **people;
+mail(to, cc, bcc, smopts)
+ struct name *to, *cc, *bcc, *smopts;
- register char *cp2;
- register int s;
- char *buf, **ap;
- for (s = 0, ap = people; *ap != 0; ap++)
- s += strlen(*ap) + 1;
- buf = salloc(s+1);
- cp2 = buf;
- for (ap = people; *ap != 0; ap++) {
- cp2 = copy(*ap, cp2);
- *cp2++ = ' ';
- }
- if (cp2 != buf)
- cp2--;
- *cp2 = '\0';
- head.h_to = buf;
+ head.h_to = detract(to, 0);
- head.h_cc = NOSTR;
- head.h_bcc = NOSTR;
+ head.h_cc = detract(cc, 0);
+ head.h_bcc = detract(bcc, 0);
+ head.h_smopts = detract(smopts, 0);
head.h_seq = 0;
(void) mail1(&head);
return(0);
head.h_seq = 0;
(void) mail1(&head);
return(0);
head.h_subject = NOSTR;
head.h_cc = NOSTR;
head.h_bcc = NOSTR;
head.h_subject = NOSTR;
head.h_cc = NOSTR;
head.h_bcc = NOSTR;
head.h_seq = 0;
(void) mail1(&head);
return(0);
head.h_seq = 0;
(void) mail1(&head);
return(0);
+ if (hp->h_subject == NOSTR)
+ hp->h_subject = sflag;
if ((mtf = collect(hp)) == NULL)
return(-1);
hp->h_seq = 1;
if ((mtf = collect(hp)) == NULL)
return(-1);
hp->h_seq = 1;
- if (hp->h_subject == NOSTR)
- hp->h_subject = sflag;
if (intty && value("askcc") != NOSTR)
grabh(hp, GCC);
else if (intty) {
if (intty && value("askcc") != NOSTR)
grabh(hp, GCC);
else if (intty) {
senderr = 0;
to = usermap(cat(extract(hp->h_bcc, GBCC),
senderr = 0;
to = usermap(cat(extract(hp->h_bcc, GBCC),
- cat(extract(hp->h_to, GTO), extract(hp->h_cc, GCC))));
+ cat(extract(hp->h_to, GTO), extract(hp->h_cc, GCC))));
if (to == NIL) {
printf("No recipients specified\n");
goto topdog;
if (to == NIL) {
printf("No recipients specified\n");
goto topdog;
+ namelist = unpack(cat(extract(hp->h_smopts, 0), to));
if (debug) {
printf("Recipients of message:\n");
for (t = namelist; *t != NOSTR; t++)
if (debug) {
printf("Recipients of message:\n");
for (t = namelist; *t != NOSTR; t++)
fprintf(stderr, "Should be inserting commas in recip lists\n");
hp->h_to = detract(tolist, GTO|f);
hp->h_cc = detract(tolist, GCC|f);
fprintf(stderr, "Should be inserting commas in recip lists\n");
hp->h_to = detract(tolist, GTO|f);
hp->h_cc = detract(tolist, GCC|f);
+ hp->h_bcc = detract(tolist, GBCC|f);
return(fi);
}
(void) remove(tempMail);
return(fi);
}
(void) remove(tempMail);
- (void) puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL);
+ (void) puthead(hp, nfo, GTO|GSUBJECT|GCC|GBCC|GNL);
c = getc(fi);
while (c != EOF) {
(void) putc(c, nfo);
c = getc(fi);
while (c != EOF) {
(void) putc(c, nfo);