/* Copyright (c) 1979 Regents of the University of California */
* Allocate a single element of a name list,
* initialize its name field to the passed
register struct name
*np
;
np
= (struct name
*) salloc(sizeof *np
);
np
->n_name
= savestr(str
);
* Find the tail of a list and return it.
register struct name
*np
;
while (np
->n_flink
!= NIL
)
* Extract a list of names from a line,
* and make a list of names from it.
* Return the list or NIL if none found.
register struct name
*top
, *np
, *t
;
while ((cp
= yankword(cp
, nbuf
)) != NOSTR
) {
* Grab a single word (liberal word)
* Throw away things between ()'s.
for (cp
= ap
; *cp
&& any(*cp
, " \t"); cp
++)
while (*cp
&& *cp
!= ')')
} while (any(*cp
, " \t("));
for (cp2
= wbuf
; *cp
&& !any(*cp
, " \t("); *cp2
++ = *cp
++)
* Verify that all the users in the list of names are
* legitimate. Bitch about and delink those who aren't.
register struct name
*np
, *top
, *t
, *x
;
if (any(':', np
->n_name
) || getuserid(np
->n_name
) != -1
|| strcmp(np
->n_name
, "msgs") == 0) {
fprintf(stderr
, "Can't send to %s\n", np
->n_name
);
* 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 him from the recipient list.
register struct name
*np
, *top
, *t
, *x
;
if (!any('/', np
->n_name
)) {
if ((fout
= fopen(np
->n_name
, "a")) == NULL
) {
fprintf(fout
, "From %s %s", myname
, date
);
while ((c
= getc(fo
)) != EOF
)
* Map all of the aliased users in the invoker's sendrc
* file and insert them into the list.
register struct name
*new, *np
, *cp
;
metoo
= (value("metoo") != NOSTR
);
if (np
->n_name
[0] == '\\') {
while (*np
->n_name
== '\\')
if ((gh
= findgroup(np
->n_name
)) != NOGRP
) {
for (gp
= gh
->g_list
; gp
!= NOGE
; gp
= gp
->ge_link
) {
if (!metoo
&& equal(gp
->ge_name
, myname
))
cp
= nalloc(gp
->ge_name
);
* Compute the length of the passed name list and
register struct name
*np
;
for (c
= 0, np
= name
; np
!= NIL
; c
++, np
= np
->n_flink
)
* Concatenate the two passed name lists, return the result.
register struct name
*tail
;
* Unpack the name list onto a vector of strings.
* Return an error if the name list won't fit.
register char **ap
, **top
;
if ((t
= lengthof(n
)) == 0)
panic("No names to unpack");
top
= (char **) salloc((t
+2) * sizeof cp
);
* 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.
register struct name
*np
;
if (getname(uid
, myname
) < 0)
for (np
= names
; np
!= NIL
; np
= np
->n_flink
)
if (equal(myname
, np
->n_name
)) {
* 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.
register struct name
*np
, *t
, *new;
while (strcmp(t
->n_name
, np
->n_name
) > 0) {
* If we ran out of t's, put the new entry after
* the current value of t.
if (strcmp(t
->n_name
, np
->n_name
) > 0) {
* 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.
* The normal case -- we are inserting into the
* Now the list headed up by new is sorted.
* Go through it and remove duplicates.
while (t
->n_flink
!=NIL
&& equal(np
->n_name
,t
->n_flink
->n_name
))
if (t
== np
|| t
== NIL
) {
* Now t points to the last entry with the same name
* as np. Make np point beyond t.
np
->n_flink
= t
->n_flink
;
t
->n_flink
->n_blink
= np
;
* Put another node onto a list of names and return
struct name
*list
, *node
;
* Determine the number of elements in
* a name list and return it.
register struct name
*np
;
* Pretty print a name list
* Uncomment it if you need it.
* register struct name *np;
* fprintf(stderr, "%s ", np->n_name);