mailcompat.c revision e9af4bc0b1cc30cea75d6ad4aa2fde97d985e9be
1N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A * Copyright (c) 1983, 1984, 1986, 1986, 1987, 1988, 1989 AT&T 1N/A * All Rights Reserved 1N/A * Copyright (c) 1983 Eric P. Allman 1N/A * Berkeley, California 1N/A * Copyright (c) 1983 Regents of the University of California. 1N/A * All rights reserved. The Berkeley software License Agreement 1N/A * specifies the terms and conditions for redistribution. 1N/A * MAILCOMPAT -- Deliver mail to a user's mailbox with the "From's" stuffed. 1N/Achar *
myname;
/* person who is to have their mail filtered */ 1N/A /* process arguments */ 1N/A case 'd':
/* debug */ 1N/A /* verify recipient argument */ 1N/A usrerr(
"Usage: mailcompat username (or) mailcompat -r");
1N/A /* find user's home directory */ 1N/A /* read message from standard input (just from line) */ 1N/A** sendmessage -- read message from standard input do the from stuffing 1N/A** and forward to /bin/mail, Being sure to delete any 1N/A** content-length headers (/bin/mail recalculates them). 1N/A** Reads first line from standard input. 1N/A if (
line[0] == (
char)
'\n')
/* end of mail headers */ usrerr(
"No initial From line");
/* find the end of the sender address and terminate it */ * Strip all but the rightmost UUCP host * to prevent loops due to forwarding. * Start searching leftward from the leftmost '@'. * a!b!c!d yields a short name of c!d * a!b!c!d@e yields a short name of c!d@e * e@a!b!c yields the same short name at = p;
/* if none, use end of addr */ /* return the sender address */ ** USRERR -- print user error ** NEWSTR -- copy a string ** s -- the string to copy. usrerr(
"newstr: cannot alloc memory");
* When invoked with no arguments, we fall into an automatic installation * mode, stepping the user through a default installation. usrerr(
"Home directory unknown");
printf(
"This program can be used to store your mail in a format\n");
printf(
"that you can read with SunOS 4.X based mail readers\n");
printf(
"You have a .forward file in your home directory");
if (!
ask(
"Would you like to remove it and disable the mailcompat feature"))
perror(
"Error removing .forward file:");
printf(
"Back to normal reception of mail.\n");
printf(
"To enable the mailcompat feature a \".forward\" ");
if (!
ask(
"Would you like to enable the mailcompat feature")) {
printf(
"OK, mailcompat feature NOT enabled.\n");
perror(
"Error opening .forward file");
printf(
"Mailcompat feature ENABLED.");
printf(
"Run mailcompat with no arguments to remove it\n");
* Ask the user a question until we get a reasonable answer printf(
"Please reply \"yes\" or \"no\" (\'y\' or \'n\')\n");