names.c revision 5422785d352a2bb398daceab3d1898a8aa64d006
/*
* 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 2001 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* 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.
*/
/*
* mailx -- a modified version of a University of California at Berkeley
* mail program
*
* Handle name lists.
*/
#include "rcv.h"
#include <locale.h>
static int isfileaddr(char *name);
int nbangs);
/*
* Allocate a single element of a name list,
* initialize its name field to the passed
* name and return it.
*/
static struct name *
{
return (np);
}
/*
* Find the tail of a list and return it.
*/
struct name *
{
return (NIL);
return (np);
}
/*
* Extract a list of names from a line,
* and make a list of names from it.
* Return the list or NIL if none found.
*/
struct name *
{
register char *cp;
int comma;
return (NIL);
goto normal;
}
nbuf);
continue;
}
top = t;
else
np = t;
}
return (top);
}
/*
* Turn a list of names into a string of the same names.
*/
char *
{
register int s;
register struct name *p;
return (NOSTR);
s = 0;
continue;
}
if (s == 0)
return (NOSTR);
continue;
*cp++ = ',';
*cp++ = ' ';
}
*cp = 0;
return (top);
}
struct name *
{
return (to);
}
/*
* For each recipient in the passed name list with a /
* in the name, append the message to the end of the named file
* and remove them from the recipient list.
*
* Recipients whose name begins with | are piped through the given
* program and removed.
*/
int
{
register int c;
int ispipe;
int nout = 0;
int fd = 0;
#ifdef preSVr4
#endif
return (nout);
continue;
nout++;
if (ispipe)
else
/*
* See if we have copied the complete message out yet.
* If not, do so.
*/
if (image < 0) {
0600);
0600)) < 0) {
senderr++;
goto cant;
}
}
senderr++;
goto cant;
}
if (image < 0) {
senderr++;
goto cant;
} else {
}
}
/*
* Now either copy "image" to the desired file
* or give it as the standard input to the desired
* program as appropriate.
*/
if (ispipe) {
switch (fork()) {
case 0:
sigchild();
close(0);
lseek(0, 0L, 0);
*shell == '\0')
(char *)0);
exit(1);
break;
case (pid_t)-1:
perror("fork");
senderr++;
goto cant;
}
} else {
senderr++;
goto cant;
}
gettext("Can't reopen image\n"));
senderr++;
goto cant;
}
#ifdef preSVr4
}
#else
#endif
}
cant:
/*
* In days of old we removed the entry from the
* the list; now for sake of header expansion
* we leave it in and mark it as deleted.
*/
#ifdef CRAZYWOW
{
register struct name *t, *x;
continue;
}
x->n_flink = t;
if (t != NIL)
t->n_blink = x;
np = t;
}
#endif
}
if (image >= 0) {
image = -1;
}
return (nout);
}
/*
* Determine if the passed address is a local "send to file" address.
* If any of the network metacharacters precedes any slashes, it can't
* be a filename. We cheat with .'s to allow path names like ./...
* If "fcc" has been unset, then short-circuit those tests, but not
* the +... test.
*/
static int
isfileaddr(char *name)
{
register char *cp;
return (0);
if (*name == '+')
return (1);
return (0);
if (*cp == '.')
continue;
return (0);
if (*cp == '/')
return (1);
}
return (0);
}
/*
* Map all of the aliased users in the invoker's mailrc
* file and insert them into the list.
* Changed after all these months of service to recursively
* expand names (2/14/80).
*/
struct name *
{
register int metoo;
continue;
}
else
}
return (newnames);
}
/*
* Recursively expand a group name. We limit the expansion to some
* fixed level to keep things from going haywire.
* Direct recursion is not expanded for convenience.
*/
static struct name *
{
static int depth;
register char *cp;
MAXEXP);
return (nlist);
}
depth++;
if (*cp == '\\')
goto quote;
goto quote;
continue;
}
/*
* At this point should allow to expand
* to self if only person in group
*/
goto skip;
skip:
}
depth--;
return (nlist);
}
/*
* Normalize a network name for comparison purposes.
*/
static char *
{
register char *cp;
int inubuf = 0;
while (*user++ == '!')
;
user--;
inubuf++;
}
if (nbangs) {
while (nbangs--)
;
/*
* Now strip off all Internet-type
* hosts.
*/
if (!inubuf) {
} else
*cp = '\0';
}
}
return (user);
}
/*
* Implement allnet options.
*/
int
{
int i;
for (i = 0; ubuf[i]; i++)
for (i = 0; abuf[i]; i++)
}
}
/*
* Compute the length of the passed name list and
* return it.
*/
static int
{
register int c;
;
return (c);
}
/*
* Concatenate the two passed name lists, return the result.
*/
struct name *
{
return (n2);
return (n1);
return (n1);
}
/*
* Unpack the name list onto a vector of strings.
* Return an error if the name list won't fit.
*/
char **
{
register struct name *n;
char hbuf[10];
n = np;
if ((t = lengthof(n)) == 0)
panic("No names to unpack");
/*
* Compute the number of extra arguments we will need. We need at least
* 3 extra -- one for "mail", one for a terminating -- to stop sendmail
* option processing, and one for the terminating 0 pointer.
*
* Additional spots may be needed to pass along -r and -f to the host
* mailer.
*/
extra = 3;
extra += 2;
extra++;
if (metoo)
extra++;
if (verbose)
extra++;
if (hflag)
extra += 2;
*ap++ = "sendmail";
*ap++ = "-r";
}
*ap++ = "-i";
if (metoo)
*ap++ = "-m";
if (verbose)
*ap++ = "-v";
if (hflag) {
*ap++ = "-h";
}
*ap++ = "--";
while (n != NIL) {
n = n->n_flink;
continue;
}
n = n->n_flink;
}
return (top);
}
/*
* See if the user named himself as a destination
* for outgoing mail. If so, set the global flag
* selfsent so that we avoid removing his mailbox.
*/
void
{
selfsent++;
return;
}
}
/*
* Remove all of the duplicates from the passed name list by
* insertion sorting them, then checking for dups.
* Return the head of the new list.
*/
struct name *
{
struct name *x;
return (NIL);
t = newnames;
break;
t = t->n_flink;
}
/*
* If we ran out of t's, put the new entry after
* the current value of t.
*/
t = np;
continue;
}
/*
* Otherwise, put the new entry in front of the
* current t. If at the front of the list,
* the new guy becomes the new head of the list.
*/
if (t == newnames) {
t = np;
newnames = t;
continue;
}
/*
* The normal case -- we are inserting into the
* middle of the list.
*/
x = np;
x->n_flink = t;
t->n_blink = x;
}
/*
* Now the list headed up by new is sorted.
* Go through it and remove duplicates.
* Remember the best "type" among all the
* duplicates of a name.
*/
int type;
t = np;
t = t->n_flink;
/* "To" before "Cc" before "Bcc" */
}
continue;
}
/*
* Now t points to the last entry with the same name
* as np. Make np point beyond t.
*/
}
return (newnames);
}
/*
* Put another node onto a list of names and return
* the list.
*/
static struct name *
{
return (node);
}
/*
* Delete the given name from a namelist.
*/
struct name *
{
register struct name *p;
continue;
}
continue;
}
}
return (np);
}
/*
* Call the given routine on each element of the name
* list, replacing said value if need be.
*/
void
{
register struct name *p;
}
}