/*
* 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 1985-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "rcv.h"
#include <locale.h>
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
*
* Auxiliary functions.
*/
/*
* Return a pointer to a dynamic copy of the argument.
*/
char *
{
;
return(NOSTR);
*cp2 = 0;
return(top);
}
/*
* Announce a fatal error and die.
*/
void
{
exit(1);
/* NOTREACHED */
}
/*
* Touch the named message by setting its MTOUCH flag.
* Touched messages have the effect of not being sent
* back to the system mailbox on exit.
*/
void
{
return;
}
/*
* Test to see if the passed file name is a directory.
* Return true if it is.
*/
int
{
return(0);
}
/*
* Count the number of arguments in the given string raw list.
*/
int
{
register char **ap;
;
}
/*
* Return the desired header line from the passed message
* pointer (or NOSTR if the desired header field is not available).
* Read all the header lines and concatenate multiple instances of
* the requested header.
*/
char *
{
register long lc;
char *r = NOSTR;
return(NOSTR);
return(NOSTR);
lc--;
return r;
}
/*
* Return the next header field found in the given message.
* Return > 0 if something found, <= 0 elsewise.
* Must deal with \ continuations & other such fraud.
*/
int
register FILE *f,
char linebuf[],
register long rem)
{
register int c;
for (;;) {
if (rem <= 0)
return(-1);
return(-1);
rem--;
return(-1);
continue;
return(-1);
/*
* I guess we got a headline.
* Handle wraparounding
*/
for (;;) {
if (rem <= 0)
break;
c = getc(f);
ungetc(c, f);
if (!isspace(c) || c == '\n')
break;
break;
rem--;
;
(unsigned)LINESIZE-2)
break;
cp--;
*cp++ = ' ';
;
}
cp--;
*++cp = 0;
}
return(rem);
}
/* NOTREACHED */
}
/*
* Check whether the passed line is a header line of
* the desired breed.
*/
int
{
register char *cp;
return(0);
return(0);
*cp = 0;
*cp = ':';
return(1);
}
*cp = ':';
return(0);
}
/*
* Extract the non label information from the given header field
* and return it.
*/
char *
{
register char *cp;
return(NOSTR);
cp++;
cp++;
return(cp);
}
/*
* Compare two strings, ignoring case.
*/
int
{
if (*s2++ == 0)
return(1);
return(0);
}
/*
* Copy a string, lowercasing it as we go. Here dstsize is the size of
* the destination buffer dst.
*/
void
{
*cp2 = '\0';
}
/*
* The following code deals with input stacking to do source
* commands. All but the current file pointer are saved on
* the stack.
*/
static struct sstack {
} *sstack;
/*
* Pushdown current input file and switch to a new one.
* Set the global flag "sourcing" so that others will realize
* that they are no longer reading from a tty (in all probability).
*/
int
{
register char *cp;
return(1);
return(1);
}
if (!maxfiles) {
#ifndef _NFILE
#endif
"Couldn't allocate memory for sourcing stack\n"));
return(1);
}
}
loading = 0;
sourcing++;
return(0);
}
/*
* Pop the current input back to the previous level.
* Update the "sourcing" flag as appropriate.
*/
int
unstack(void)
{
if (ssp < 0) {
sourcing = 0;
return(1);
}
if (ssp < 0)
return(0);
}
/*
* Touch the indicated file.
* This is nifty for the shell.
* If we have the utime() system call, this is better served
* by using that, since it will work for empty files.
* On non-utime systems, we must sleep a second, then read.
*/
void
{
extern int errno;
if (rc != 0) {
name);
}
}
/*
* Examine the passed line buffer and
* return true if it is all blanks and tabs.
*/
int
{
register const char *cp;
return(0);
return(1);
}
/*
* Skin an arpa net address according to the RFC 822 interpretation
* of "host-phrase."
*/
static char *
{
register char c;
int nesting;
return(NOSTR);
else
gotlt = 0;
lastsp = 0;
switch (c) {
case '(':
/*
Start of a comment, ignore it.
*/
nesting = 1;
while ((c = *cp) != 0) {
cp++;
switch(c) {
case '\\':
cp++;
break;
case '(':
nesting++;
break;
case ')':
--nesting;
break;
}
if (nesting <= 0) break;
}
lastsp = 0;
break;
case '"':
/*
Start a quoted string.
Copy it in its entirety.
*/
didq = 0;
while ((c = *cp) != 0) {
cp++;
switch (c) {
case '\\':
cp++;
break;
case '"':
goto outqs;
}
if (lastsp) {
lastsp = 0;
*cp2++ = ' ';
}
if (!didq) {
*cp2++ = '"';
didq++;
}
*cp2++ = c;
}
}
if (didq)
*cp2++ = '"';
lastsp = 0;
break;
case ' ':
case '\t':
case '\n':
done:
cp[-1] = 0;
return cp;
}
lastsp = 1;
break;
case ',':
*cp2++ = c;
if (gotlt != '<') {
if (token)
goto done;
gotlt = 0;
}
break;
case '<':
gotlt = c;
lastsp = 0;
break;
case '>':
if (gotlt == '<') {
gotlt = c;
break;
}
/* FALLTHROUGH . . . */
default:
if (lastsp) {
lastsp = 0;
*cp2++ = ' ';
}
*cp2++ = c;
}
break;
}
}
*cp2 = 0;
}
char *
{
}
/*
* Here sz is the buffer size of word.
*/
char *
{
char *cp;
if (name == 0)
return 0;
name++;
if (*name == 0)
return 0;
return cp;
}
int
docomma(char *s)
{
return s && strpbrk(s, "(<,");
}
/*
* Fetch the sender's name from the passed message.
*/
char *
{
char *tmp;
;
cp++;
;
*cp2 = '\0';
for (;;) {
break;
continue;
if (linebuf[0] == 'F')
else if (linebuf[0] == '>')
else
break;
break;
if (first) {
first = 0;
} else {
cp);
}
goto newname;
} else
break;
}
}
else
}
/*
* Splice an address into a commented recipient header.
*/
char *
{
} else {
}
} else
}
static char *
{
register char *cp;
cp--;
*++cp = 0;
return buf;
}
/*
* Are any of the characters in the two strings the same?
*/
int
{
register int c;
while ((c = *s1++) != 0)
return(1);
return(0);
}
/*
* See if the given header field is supposed to be ignored.
* Fields of the form "Content-*" can't be ignored when saving.
*/
int
{
/*
* Lower-case the string, so that "Status" and "status"
* will hash to the same place.
*/
return (0);
if (nretained > 0)
else
}
int
{
return (1);
return (0);
}
/*
* This routine looks for string2 in string1.
* If found, it returns the position string2 is found at,
* otherwise it returns a -1.
*/
int
{
;
if (j == len2)
return(i);
}
return(-1);
}
/*
* Copies src to the dstsize buffer at dst. The copy will never
* overflow the destination buffer and the buffer will always be null
* terminated.
*/
char *
{
*cp2 = '\0';
return(dst);
}
/*
* Appends src to the dstsize buffer at dst. The append will never
* overflow the destination buffer and the buffer will always be null
* terminated.
*/
char *
{
while (*cp2 != '\0') {
cp2++;
dstsize--;
}
*cp2 = '\0';
return(dst);
}