/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mail.h"
/*
* Print mail entries
*/
void
{
char *p, *getarg();
char *resp;
/*
* create working directory mbox name
*/
return;
}
/*
* If we are not using an alternate mailfile, then get
* the $MAIL value and build the filename for the mailfile.
* If $MAIL is set, but is NOT the 'standard' place, then
* use it but set flgf to circumvent :saved processing.
*/
if (!flgf) {
== NULL) {
return;
}
/* $MAIL not set, use standard path to mailfile */
mailfile = p;
} else {
flgf = 1;
nsmbox = 1;
mailfile);
}
free(p);
}
}
/*
* Get ACCESS and MODIFICATION times of mailfile BEFORE we
* use it. This allows us to put them back when we are
* done. If we didn't, the shell would think NEW mail had
* arrived since the file times would have changed.
*/
return;
}
}
/* Open the file as the real gid */
/*
* stat succeeded, but we cannot access the mailfile
*/
"Invalid permissions on %s", mailfile);
return;
} else
/*
* using an alternate mailfile, but we failed on access
*/
return;
}
/*
* we failed to access OR the file is empty
*/
printf("No mail.\n");
}
return;
}
if (flge)
return;
if (flgE) {
}
return;
}
/*
* Secure the mailfile to guarantee integrity
*/
/*
* copy mail to temp file and mark each letter in the
* let array --- mailfile is still locked !!!
*/
mktmp();
unlock(); /* All done, OK to unlock now */
changed = 0;
print = 1;
curlet = 0;
/*
* reverse order ?
*/
/* -h says to print the headers first */
if (flgh) {
flgh = 0; /* Only once */
/* set letter # to invalid # */
curlet--;
showlet =
} else {
/* Looking at new message. */
/* Reset flag to override */
/* non-display of binary */
/* contents */
pflg = 0;
}
}
}
/*
* print only
*/
if (flgp) {
curlet++;
continue;
}
/*
* Interactive
*/
interactive = 1;
/*
* New mail has arrived, load it
*/
k = nlet;
unlock();
if (++k < nlet)
printf("New mail loaded into letters %d - %d\n",
k, nlet);
else
printf("New mail loaded into letter %d\n",
nlet);
}
/* read the command */
printf("? ");
print = 1;
} else switch (resp[0]) {
default:
printf("Usage:\n");
/*
* help
*/
case '?':
print = 0;
break;
/*
* print message number of current message
*/
case '#':
print = 0;
printf("No message selected yet.\n");
} else {
printf("Current message number is %d\n",
showlet+1);
}
break;
/*
* headers
*/
case 'h':
print = 0;
}
break;
else rc = 0;
/*
* if (!validmsg(showlet)) break;
*/
break;
/*
* skip entry
*/
case '+':
case 'n':
case '\n':
curlet++;
break;
case 'P':
Pflg++;
break;
case 'p':
pflg++;
break;
case 'x':
changed = 0;
case 'q':
goto donep;
/*
* Previous entry
*/
case '^':
case '-':
break;
/*
* Save in file without header
*/
case 'y':
case 'w':
/*
* Save mail with header
*/
case 's':
print = 0;
printf("Invalid command\n");
break;
}
flg = 0;
}
p = resp + 1;
if (flg) {
"%s: File '%s' skipped\n",
continue;
}
}
"%s: Cannot append to %s\n",
flg++;
} else if (aret == 2) {
}
if (!flg &&
"%s: Cannot save mail to '%s'\n",
flg++;
} else
}
}
umask(7);
if (!flg) {
print = 1;
curlet++;
}
break;
/*
* Reply to a letter
*/
case 'r':
print = 0;
replying = 1;
++k);
sizeof (m_sendto));
replying = 0;
break;
/*
* Undelete
*/
case 'u':
print = 0;
else k--;
if (!validmsg(k)) break;
setletr(k, ' ');
break;
/*
* Mail letter to someone else
*/
case 'm':
{
print = 0;
flg = 0;
k = 0;
printf("Only users may be specified\n");
break;
}
p = resp + 1;
char *env;
if (lfil[0] == '$') {
"%s: %s has no value or is not exported.\n",
flg++;
} else
FALSE);
k++;
} else if (lfil[0] != '\0') {
k++;
}
}
if (k) {
if (!flg) {
print = 1;
curlet++;
}
} else
printf("Invalid command\n");
break;
}
/*
* Read new letters
*/
case 'a':
printf("No new mail\n");
print = 0;
break;
}
curlet = 0;
print = 1;
break;
/*
* Escape to shell
*/
case '!':
printf("!\n");
print = 0;
break;
/*
* Delete an entry
*/
case 'd':
print = 0;
k = 0;
if (k == 0) {
k = showlet;
print = 1;
curlet++;
} else k--;
setletr(k, 'd');
break;
}
}
/*
* Copy updated mailfile back
*/
if (changed) {
copyback();
stamp();
}
}