static char sccsid
[] = "@(#)rmail.c 4.5 (Berkeley) %G%";
** RMAIL -- UUCP mail server.
** This program reads the >From ... remote from ... lines that
** UUCP is so fond of and turns them into something reasonable.
** It calls sendmail giving it a -f option built from these
# define MAILER "/usr/lib/sendmail"
FILE *out
; /* output to sendmail */
char lbuf
[512]; /* one line of the message */
char from
[512]; /* accumulated path of sender */
char ufrom
[64]; /* user on remote system */
char sys
[64]; /* a system in path */
char junk
[512]; /* scratchpad */
register char *uf
; /* ptr into ufrom */
if (argc
> 1 && strcmp(argv
[1], "-T") == 0)
fprintf(stderr
, "Usage: rmail user ...\n");
(void) strcpy(ufrom
, "/dev/null");
(void) fgets(lbuf
, sizeof lbuf
, stdin
);
if (strncmp(lbuf
, "From ", 5) != 0 && strncmp(lbuf
, ">From ", 6) != 0)
(void) sscanf(lbuf
, "%s %s", junk
, ufrom
);
register char *p
= rindex(uf
, '!');
cp
= "remote from somewhere";
if (strncmp(cp
, "remote from ", 12)==0)
(void) sscanf(cp
, "remote from %s", sys
);
(void) strcat(from
, sys
);
(void) strcat(from
, "!");
printf("ufrom='%s', sys='%s', from now '%s'\n", uf
, sys
, from
);
(void) sprintf(cmd
, "%s -ee -f%s", MAILER
, from
);
(void) strcat(cmd
, " '");
(void) strncat(cmd
, *argv
+ 1, strlen(*argv
) - 2);
(void) strcat(cmd
, *argv
);
printf("cmd='%s'\n", cmd
);
while (fgets(lbuf
, sizeof lbuf
, stdin
))
fprintf(stderr
, "pclose: status 0%o\n", i
);