/***********************************************************************
* *
* This software is part of the BSD package *
*Copyright (c) 1978-2012 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
*
* Variable handling stuff.
*/
#include "mailx.h"
/*
* Initialize the variables before command line options and rc sourcing.
*/
void
varinit(void)
{
register int c;
register char* s;
register char* t;
int i;
else if (vp->initialize)
}
/*
* Get the local host name.
*/
#if _lib_gethostname
#endif
/*
* Get the local domain name.
*/
else
s = (char*)domains[i];
do {
while (isspace(*s))
s++;
if (((c = *s++) == 'd' || c == 'D') &&
((c = *s++) == 'o' || c == 'O') &&
((c = *s++) == 'm' || c == 'M') &&
((c = *s++) == 'a' || c == 'A') &&
((c = *s++) == 'i' || c == 'M') &&
((c = *s++) == 'n' || c == 'N') &&
while (isspace(*s))
s++;
t = s;
while (*t && !isspace(*t))
t++;
while (t > s && *(t - 1) == '.')
t--;
if (*t)
*t = 0;
if (*s)
{
break;
}
}
}
break;
}
}
/*
* Interactive.
*/
if (isatty(0))
}
/*
* Copy a variable value into permanent (ie, not collected after each
* command) space. Do not bother to alloc space for "".
*/
char*
{
char* p;
int len;
if (!val)
return 0;
if (!*val)
stresc(p);
return p;
}
/*
* List variable settings.
*/
int
{
else
putchar('\n');
}
}
else if (all) {
}
return 0;
}
/*
* Set a variable value.
*/
int
{
char* s;
int n;
int m;
if (name[0] == '-') {
name += 1;
value = 0;
}
name += 2;
value = 0;
}
for (;;) {
if (!(vp = (struct var*)strsearch(state.vartab, state.varnum, sizeof(struct var), stracmp, name, NiL))) {
return 0;
return 1;
}
break;
}
return 1;
}
return 1;
}
return 1;
}
if (!value)
}
else {
return 0;
if (!(s = newof(0, char, n, 0)))
s[m] = '\n';
value = (const char*)s;
}
}
else
value = 0;
}
return 0;
}
/*
* Get a variable value.
*/
char*
{
char* s;
for (;;) {
if (!(vp = (struct var*)strsearch(state.vartab, state.varnum, sizeof(struct var), stracmp, name, NiL))) {
return s;
return 0;
}
break;
}
}
}
/*
* Trap unimplemented variable assignment.
*/
void
{
if (value) {
}
}
/*
* Trap askbcc variable assignment.
*/
void
{
if (value)
else
}
/*
* Trap askcc variable assignment.
*/
void
{
if (value)
else
}
/*
* Low level for askheaders and editheaders.
*/
static unsigned long
{
register char* s;
register const char* t;
register char* b;
char* p;
unsigned long flags;
p = (char*)value;
break;
}
s = b;
if (upper(*s) == *t) {
while (lower(*++s) == *++t);
if (!*s && *t == ':') {
break;
}
}
}
return flags;
}
/*
* Trap askheaders variable assignment.
*/
void
{
}
/*
* Trap asksub variable assignment.
*/
void
{
if (value)
else
}
/*
* Trap coprocess variable assignment.
*/
void
{
if (value) {
if (!*value)
}
}
/*
* Trap crt variable assignment.
*/
void
{
}
/*
* Trap editheaders variable assignment.
*/
void
{
}
/*
* Trap justfrom variable assignment.
*/
void
{
if (value) {
}
}
/*
* Trap list variable assignment.
*/
void
{
register char* s;
while (s = strchr(s, ' '))
*s++ = ',';
}
/*
* Trap mail variable assignment.
*/
void
{
}
/*
* Trap mailcap variable assignment.
*/
void
{
}
/*
* Trap news variable assignment.
*/
void
{
if (value && *value && close(open(state.var.news, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY|O_cloexec, MAILMODE)))
}
/*
* Trap screen variable assignment.
*/
void
{
}
}
/*
* Trap sender variable assignment.
*/
void
{
char* v;
int c;
int d;
int n;
d = *value++;
while ((c = *value++) && c != d)
*v++ = c;
*v++ = 0;
n = 1;
value--;
while (c = *value++) {
if (c == d) {
*v++ = 0;
if (n == 1) {
n = 2;
}
else if (n == 2) {
n = 3;
}
break;
else if (c == '|') {
n = 1;
}
else if (c == '&') {
n = 1;
}
else
break;
}
else
*v++ = c;
}
if (c)
else {
}
}
else
}
/*
* Trap screen variable assignment.
*/
void
{
}
/*
* Trap sendmail variable assignment.
*/
void
{
}
}
/*
* Trap shell variable assignment.
*/
void
{
}
/*
* Trap spambody variable assignment.
*/
void
{
register char* s;
register char* t;
register int n;
}
s = (char*)value;
for (;;) {
if (t = strchr(s, '|'))
n = t - s;
else
n = strlen(s);
if (n) {
else
}
if (!t)
break;
s = t + 1;
}
}
/*
* Trap toplines variable assignment.
*/
void
{
}
/*
* Trap trace variable assignment.
*/
void
{
register int c;
register const char* s;
if (s = value)
while (c = *s++)
TRACE(c);
}
/*
* Trap user variable assignment.
*/
void
{
}
/*
* struct name case insensitive comparf
*/
static int
{
return strcasecmp(a, b);
}
/*
* struct name freef
*/
static void
{
else {
do {
}
}
}
/*
* The dict*() cdt wrappers create dictionaries as needed.
*
* op: LOOKUP lookup
* CREATE INSERT, return 0 if already there
* IGNORECASE case insensitive
* INSERT insert
* DELETE delete
* OBJECT name is punned object
* STACK object on stack
*/
struct name*
{
return 0;
if (!(dict = (op & STACK) ? (struct dict*)salloc(sizeof(struct dict)) : newof(0, struct dict, 1, 0)))
if (op & IGNORECASE)
}
}
}
else object = 0;
return 0;
if (!(xp = (op & STACK) ? (struct name*)salloc(sizeof(struct name) + strlen(name) + 1) : newof(0, struct name, 1, strlen(name) + 1)))
}
}
np = 0;
}
np = 0;
return np;
}
/*
* Apply walkf(node,handle) to each node in the dictionary.
* Non-zero return from walkf terminates walk with that value.
*/
int
{
}
/*
* Drop STACK dictionaries.
*/
void
dictreset(void)
{
}
}
/*
* Drop all entries from the dictionary.
*/
void
{
if (*dp)
}