/***********************************************************************
* *
* This software is part of the BSD package *
*Copyright (c) 1978-2006 The Regents of the University of California an*
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* 1. Redistributions of source code must retain the above *
* copyright notice, this list of conditions and the *
* following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the *
* materials provided with the distribution. *
* *
* 3. Neither the name of The Regents of the University of California*
* names of its contributors may be used to endorse or *
* promote products derived from this software without *
* specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS *
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON *
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in *
* distribution. *
* 3. Neither the name of the University nor the names of its *
* contributors may be used to endorse or promote products derived *
* from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
* *
* Kurt Shoens (UCB) *
* gsf *
* *
***********************************************************************/
#pragma prototyped
/*
* Mail -- a mail program
*
* Auxiliary functions.
*
* So why isn't this stuff still in the file aux.c?
* What file base name is special on what system.
* I mean really special.
* Any wagers on whether aux is in the POSIX conformance test suite?
*/
#include "mailx.h"
#include <stdarg.h>
/*
* Note message.
*/
void
{
return;
}
else
abort();
exit(1);
}
/*
* Return a pointer to a dynamic copy of the argument.
*/
char*
{
char* p;
return p;
}
/*
* 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
{
else
}
/*
* Test to see if the passed file name is a directory.
*/
int
{
return 0;
}
/*
* Test to see if the passed file name is a regular file.
*/
int
{
return 0;
}
/*
* The following code deals with input stacking to do source
* commands. All but the current file pointer are saved on
* the stack.
*/
/*
* 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
{
return 1;
note(0, "Too much \"sourcing\" going on");
return 1;
}
return 0;
}
/*
* Pop the current input back to the previous level.
* Update the "sourcing" flag as appropriate.
*/
int
unstack(void)
{
note(0, "\"Source\" stack over-pop");
return 1;
}
note(0, "Unmatched \"if\"");
return 0;
}
/*
* Touch the indicated file.
* This is nifty for the shell.
*/
void
{
}
/*
* Examine the passed line buffer and
* return true if it is all blanks and tabs.
*/
int
{
register char* cp;
return 0;
return 1;
}
/*
* Start of a "comment".
* Ignore it.
*/
static char*
{
switch (*cp) {
case '\\':
if (cp[1])
cp++;
break;
case '(':
nesting++;
break;
case ')':
nesting--;
break;
}
}
return cp;
}
/*
* shorten host if it is part of the local domain
*/
char*
{
register char* lp;
register char* le;
register char* hx;
for (;;) {
*le = 0;
if (le)
*le = ',';
return 0;
}
*hx = 0;
if (le)
*le = ',';
return host;
}
break;
*lp++ = ',';
}
return host;
}
/*
* apply GCOMPARE, GDISPLAY, state.var.allnet, state.var.local
*/
char*
{
register char* p;
register char* e;
register int n;
char* uucp;
char* arpa;
char* user;
char* inet;
int hadarpa;
int hadinet;
addr++;
addr = p + 1;
addr = p + 1;
if (buf) {
n = size;
p = addr + n;
}
*p = 0;
return addr;
}
}
else {
*p++ = 0;
user = p;
p++;
uucp = p;
p = 0;
}
}
hadinet = 1;
*p++ = 0;
}
hadarpa = 1;
*p++ = 0;
}
if (uucp &&
uucp = 0;
arpa = 0;
if (inet)
uucp = 0;
else if (uucp) {
uucp = 0;
}
}
p = norm;
e = p + sizeof(norm);
if (uucp) {
p = strncopy(p, "!", e - p);
}
if (arpa) {
p = strncopy(p, "%", e - p);
}
if (inet) {
p = strncopy(p, "@", e - p);
}
}
}
/*
* Skin an arpa net address according to the RFC 822 interpretation
* of "host-phrase."
*/
char*
{
register int c;
register char* cp;
register char* cp2;
char* bufend;
int gotlt;
int lastsp;
if (!name)
return 0;
gotlt = 0;
lastsp = 0;
switch (c) {
case '(':
lastsp = 0;
break;
case '"':
/*
* Start of a "quoted-string".
* Copy it in its entirety.
*/
while (c = *cp) {
cp++;
if (c == '"')
break;
if (c != '\\')
*cp2++ = c;
else if (c = *cp) {
*cp2++ = c;
cp++;
}
}
lastsp = 0;
break;
case ' ':
else
lastsp = 1;
break;
case '<':
gotlt++;
lastsp = 0;
break;
case '>':
if (gotlt) {
gotlt = 0;
while ((c = *cp) && c != ',') {
cp++;
if (c == '(')
else if (c == '"')
while (c = *cp) {
cp++;
if (c == '"')
break;
if (c == '\\' && *cp)
cp++;
}
}
lastsp = 0;
break;
}
/* Fall into . . . */
default:
if (lastsp) {
lastsp = 0;
*cp2++ = ' ';
}
*cp2++ = c;
if (c == ',' && !gotlt) {
*cp2++ = ' ';
;
lastsp = 0;
}
}
}
*cp2 = 0;
}
/*
* Are any of the characters in the two strings the same?
*/
int
{
while (*s1)
return 1;
return 0;
}
/*
* Convert c to lower case
*/
int
lower(register int c)
{
}
/*
* Convert c to upper case
*/
int
upper(register int c)
{
}
/*
* Convert s to lower case
*/
char*
strlower(register char* s)
{
register char* b = s;
register int c;
while (c = *s)
return b;
}
/*
* 0 terminate tmp string stream, rewind, and return beginning of string
*/
char*
{
char* s;
return s;
}
/*
* See if the given header field is supposed to be ignored.
*/
int
{
return 1;
}
/*
* Allocate size more bytes of space and return the address of the
* first byte to the caller. An even number of bytes are always
* allocated so that the space will always be on a word boundary.
* The string spaces are of exponentially increasing size, to satisfy
* the occasional user with enormous string size requests.
*
* Strings handed out here are reclaimed at the top of the command
* loop each time, so they need not be freed.
*/
char*
{
register char* t;
int index;
return t;
}
size += 7;
size &= ~7;
index = 0;
break;
break;
index++;
}
}
t = sp->s_nextfree;
return t;
}
/*
* Reset the string area to be empty.
* Called to free all strings allocated
* since last reset.
*/
void
sreset(void)
{
register int index;
return;
index = 0;
continue;
index++;
}
dictreset();
}
/*
*/
char*
{
sfsprintf(state.counts, sizeof(state.counts), wide ? "%5ld/%-7ld" : "%3ld/%-5ld", (long)lines, (long)chars);
}
/*
* Check if s matches `all'.
*/
int
isall(register const char* s)
{
}
/*
* Check if name is a pipe command.
*/
char*
iscmd(register char* s)
{
if (!s)
return 0;
while (isspace(*s))
s++;
if (*s != '!' && *s != '|')
return 0;
do {
if (!*++s)
return 0;
} while (isspace(*s));
return s;
}
/*
*/
void
{
else {
if (clr)
if (set)
}
}
/*
* strncpy() with trailing nul, even if n==0
* pointer to the copied nul returned
*/
char*
{
register char* e = t + n - 1;
do
{
if (t >= e)
{
*t = 0;
return t;
}
} while (*t++ = *f++);
return t - 1;
}
/*
* quote s into sp according to sh syntax
*/
void
{
register char* t;
register char* b;
register int c;
register int q;
{
return;
}
q = 0;
b = 0;
for (t = s;;)
{
switch (c = *t++)
{
case 0:
break;
case '\n':
case ';':
case '&':
case '|':
case '<':
case '>':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
case '*':
case '?':
case ' ':
case '\t':
case '\\':
q |= 4;
continue;
case '\'':
q |= 1;
if (q & 2)
break;
continue;
case '"':
case '$':
q |= 2;
if (q & 1)
break;
continue;
case '=':
if (!q && !b && *(b = t) == '=')
b++;
continue;
default:
continue;
}
break;
}
if (!q)
else if (!(q & 1))
{
if (b)
else
}
else if (!(q & 2))
{
if (b)
else
}
else
for (t = s;;)
switch (c = *t++)
{
case 0:
return;
case '\n':
break;
case ';':
case '&':
case '|':
case '<':
case '>':
case '(':
case ')':
case '[':
case ']':
case '{':
case '}':
case '$':
case '*':
case '?':
case ' ':
case '\t':
case '\\':
case '\'':
case '"':
/*FALLTHROUGH*/
default:
break;
}
}