/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 1983, 1984, 1986, 1986, 1987, 1988, 1989 AT&T
* All Rights Reserved
*/
/*
* Vacation
* Copyright (c) 1983 Eric P. Allman
* Berkeley, California
*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <pwd.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <sysexits.h>
#include <string.h>
#include <ctype.h>
#include "conf.h"
/*
* MAILCOMPAT -- Deliver mail to a user's mailbox with the "From's" stuffed.
*/
typedef int bool;
#define FALSE 0
char *fromp;
char *fromuser;
int AliasCount = 0;
static char *newstr();
int ask(char *);
int sendmessage(char *);
void AutoInstall(void);
void usrerr(const char *, ...);
int
int argc;
char **argv;
{
register char *p;
extern char *getfrom();
/* process arguments */
{
switch (*++p)
{
case 'd': /* debug */
break;
default:
usrerr("Unknown flag -%s", p);
}
}
/* verify recipient argument */
if (argc != 1)
{
if (argc == 0)
AutoInstall();
else
usrerr("Usage: mailcompat username (or) mailcompat -r");
}
myname = p;
/* find user's home directory */
{
}
/* read message from standard input (just from line) */
return (sendmessage(fromuser));
}
/*
** sendmessage -- read message from standard input do the from stuffing
**
**
** Parameters:
** none.
**
**
** Side Effects:
** Reads first line from standard input.
*/
int
char *from;
{
myname);
/* read the line */
{
}
}
char *
char **shortp;
{
char saveat;
/* read the from line */
{
usrerr("No initial From line");
}
/* find the end of the sender address and terminate it */
if (p == NULL)
{
}
*p = '\0';
/*
* 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
*/
#ifdef VDEBUG
#endif /* VDEBUG */
at = p; /* if none, use end of addr */
*at = '\0';
char *bang2;
*bang = '\0';
*bang = '!';
}
#ifdef VDEBUG
#endif /* VDEBUG */
/* return the sender address */
}
/*
** USRERR -- print user error
**
** Parameters:
** f -- format.
**
** Returns:
** none.
**
** Side Effects:
** none.
*/
void
usrerr(const char *f, ...)
{
}
/*
** NEWSTR -- copy a string
**
** Parameters:
** s -- the string to copy.
**
** Returns:
** A copy of the string.
**
** Side Effects:
** none.
*/
char *
newstr(s)
char *s;
{
char *p;
if (p == NULL)
{
usrerr("newstr: cannot alloc memory");
}
return (p);
}
/*
* When invoked with no arguments, we fall into an automatic installation
* mode, stepping the user through a default installation.
*/
void
{
FILE *f;
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");
if (f) {
printf("You have a .forward file in your home directory");
printf(" containing:\n");
fclose(f);
if (!ask("Would you like to remove it and disable the mailcompat feature"))
exit(0);
perror("Error removing .forward file:");
else
printf("Back to normal reception of mail.\n");
exit(0);
}
printf("To enable the mailcompat feature a \".forward\" ");
printf("file is created.\n");
if (!ask("Would you like to enable the mailcompat feature")) {
printf("OK, mailcompat feature NOT enabled.\n");
exit(0);
}
if (f == NULL) {
perror("Error opening .forward file");
}
fclose(f);
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
*/
int
char *prompt;
{
for (;;) {
return (TRUE);
return (FALSE);
printf("Please reply \"yes\" or \"no\" (\'y\' or \'n\')\n");
}
/* NOTREACHED */
}