/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#include "rcv.h"
#include <locale.h>
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
*
* Mail to others.
*/
static void statusput(register struct message *mp, register FILE *obuf, int doign, int (*fp)(const char *, FILE *));
/*
* Send message described by the passed pointer to the
* passed output buffer. Return -1 on error, but normally
* the number of lines written. Adjust the status: field
* if need be. If doign is set, suppress ignored header fields.
* Call (*fp)(line, obuf) to print the line.
*/
long
int flag,
{
long clen, n, c;
long lc;
ishead = 1;
dostat = 1;
doclen = 1;
infld = 0;
fline = 1;
lc = 0;
while (c > 0L) {
c -= nread;
lc++;
if (ishead) {
/*
* First line is the From line, so no headers
* there to worry about
*/
if (fline) {
fline = 0;
goto writeit;
}
/*
* If line is blank, we've reached end of
* headers, so force out status: field
* and note that we are no longer in header
* fields. Also force out Content-Length: field.
*/
if (line[0] == '\n') {
if (dostat) {
dostat = 0;
}
if (doclen &&
"Content-Length: %ld\n",
return(-1);
doclen = 0;
}
ishead = 0;
goto writeit;
}
/*
* If this line is a continuation
* of a previous header field, just echo it.
*/
if (oldign)
continue;
else
goto writeit;
infld = 0;
/*
* If we are no longer looking at real
* header lines, force out status:
* This happens in uucp style mail where
* there are no headers at all.
*/
if (dostat) {
dostat = 0;
}
ishead = 0;
goto writeit;
}
infld++;
/*
* Pick up the header field.
* If it is an ignored field and
* we care about such things, skip it.
*/
*cp2 = 0;
if (oldign)
continue;
/*
* If the field is "status," go compute and print the
* real Status: field
*/
if (dostat) {
dostat = 0;
}
continue;
}
if (doclen) {
"Content-Length: %ld\n",
return(-1);
doclen = 0;
}
continue;
}
}
if (line[0] == '\n')
for (;;) {
"\t(Unexpected end-of-file).\n"));
clen = 0;
} else {
"\tError writing to the new file.\n"));
return (-1);
}
}
clen -= n;
if (clen <= 0) {
break;
}
}
c = 0L;
} else {
return(-1);
}
}
return(-1);
return(lc);
}
/*
* Test if the passed line is a header line, RFC 822 style.
*/
int
{
cp++;
return(*cp == ':');
}
/*
* Output a reasonable looking status field.
* But if "status" is ignored and doign, forget it.
*/
static void
int doign,
{
return;
return;
}
/*
* Interface between the argument list and the mail1 routine
* which does all the dirty work.
*/
int
{
register int s;
*cp3++ = ',';
cp3++;
} else
cp3++;
}
*cp2++ = ',';
*cp2++ = ' ';
}
*cp2 = '\0';
return(0);
}
int
{
}
int
{
}
/*
* Interface to the mail1 routine for the -t flag
* (read headers from text).
*/
int
tmail(void)
{
return(0);
}
/*
* Send mail to a bunch of user names. The interface is through
* the mail routine below.
*/
static int
{
else
return(0);
}
/*
* Send mail to a bunch of user names. The interface is through
* the mail routine below.
* save a copy of the letter
*/
static int
{
else
return(0);
}
/*
* Walk the list of fds, closing all but one.
*/
static int
{
return (0);
}
/*
* Mail a message on standard input to the people indicated
* in the passed header. (Internal interface).
*/
void
{
int i, s, gotcha;
char **t;
char *deadletter;
/*
* Collect user's mail from standard input.
* Get the result as mtf.
*/
return;
goto out;
}
if (intty) {
flush();
}
/*
* If we need to use the To: line to determine the record
* file, save a copy of it before it's sorted below.
*/
orig_to = "";
/*
* Now, take the user names from the combined
* to and cc lists and do all the alias
* processing.
*/
senderr = 0;
if (!senderr)
gotcha++;
return;
}
printf("[yes] ");
goto dead;
}
if (senderr)
goto dead;
/*
* Look through the recipient list for names with /'s
* in them which we write to as files directly.
*/
if (!gotcha && !i) {
goto dead;
}
if (senderr)
goto dead;
if (!gotcha)
goto out;
if (debug) {
return;
}
/*
* Wait, to absorb a potential zombie, then
* fork, set up the temporary mail file as standard
* input for "mail" and exec with the user list we generated
* far above. Return the process id to caller in case he
* wants to await the completion of mail.
*/
#ifdef VMUNIX
;
#else
#ifdef preSVr4
wait((int *)0);
#else
;
#endif
#endif
perror("fork");
dead:
} else
goto out;
}
if (pid == 0) {
sigchild();
#ifdef SIGTSTP
if (remote == 0) {
}
#endif
(void) fdwalk(closefd_walk, &s);
close(0);
dup(s);
close(s);
#ifdef CC
#endif /* CC */
#ifdef SENDMAIL
#else
#endif
exit(1);
}
remote++;
out:
if (remote) {
;
if (s != 0)
senderr++;
pid = 0;
}
return;
}
/*
* Prepend a header in front of the collected stuff
* and return the new file.
*/
static FILE *
{
register int c;
return(fi);
}
return(fi);
}
if (returnaddr && *returnaddr)
else
}
perror("read");
return(fi);
}
return(fi);
}
return(nfi);
}
/*
* Dump the message header on the
* passed file buffer.
*/
int
{
register int gotcha;
gotcha = 0;
else
if (receipt_flg)
else
else
char **p;
gotcha++;
}
#ifndef preSVr4
if (w & GCLEN)
#endif
return(0);
}
/*
* Format the given text to not exceed 78 characters.
*/
static void
{
int len;
if (col > 4) {
col = 4;
} else {
col += 2;
}
}
}
}
/*
* Save the outgoing mail on the passed file.
*/
static int
{
char *n;
#ifdef preSVr4
#else
int c;
#endif
if (debug)
return(-1);
}
n = rflag;
if (n == NOSTR)
n = myname;
#ifdef preSVr4
}
#else
#endif
return(0);
}