cleaned up file handling code, now allows "mbox" variable
[unix-history] / usr / src / usr.bin / mail / v7.local.c
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifdef notdef
static char sccsid[] = "@(#)v7.local.c 5.5 (Berkeley) %G%";
#endif /* notdef */
/*
* Mail -- a mail program
*
* Version 7
*
* Local routines that are installation dependent.
*/
#include "rcv.h"
/*
* Locate the user's mailbox file (ie, the place where new, unread
* mail is queued).
*/
char *
findmail(user)
char *user;
{
static char buf[PATHSIZE];
strcpy(copy("/usr/spool/mail/", buf), user);
return buf;
}
/*
* Get rid of the queued mail.
*/
demail()
{
if (value("keep") != NOSTR)
close(creat(mailname, 0666));
else {
if (remove(mailname) < 0)
close(creat(mailname, 0666));
}
}
/*
* Discover user login name.
*/
username(uid, namebuf)
char namebuf[];
{
register char *np;
if (uid == getuid() && (np = getenv("USER")) != NOSTR) {
strncpy(namebuf, np, PATHSIZE);
return(0);
}
return(getname(uid, namebuf));
}