static char SccsId
[] = "@(#)alias.c 1.2 %G%";
** ALIAS -- Compute aliases.
** Scans the file /usr/lib/mailaliases for a set of aliases.
** If found, it arranges to deliver to them by inserting the
** new names onto the SendQ queue.
** Aliases found on SendQ are removed and put onto
** AliasQ; replacements are added to SendQ. This is
** done until no such replacement occurs.
** MAXRCRSN -- the maximum recursion depth.
** ALIASFILE -- the pathname of the alias file.
** /usr/lib/mailaliases -- the mail aliases.
** If NoAlias (the "-n" flag) is set, no aliasing is
** It should complain about names that are aliased to
** It is unsophisticated about line overflows.
** 3/5/80 -- extensive mods to change internal address
# define ALIASFILE "/usr/lib/mailaliases"
printf("--- alias ---\n");
/* open alias file if not already open */
if (Debug
&& (af
= fopen("mailaliases", "r")) != NULL
)
printf(" [using local alias file]\n");
if ((af
= fopen(ALIASFILE
, "r")) == NULL
)
printf("Can't open %s\n", ALIASFILE
);
** If we find any user that any line matches any user, we
** will send to the line rather than to the user.
** We pass through the file several times. Didalias tells
** us if we took some alias on this pass through the file;
** when it goes false at the top of the loop we don't have
** to scan any more. Gotmatch tells the same thing, but
** on a line-by-line basis; it is used for processing
while (fgets(line
, sizeof line
, af
) != NULL
)
/* comments begin with `#' */
/* check for continuation lines */
printf(" ... also aliased to %s", line
);
** Check to see if this pseudonym exists in SendQ.
** Turn the alias into canonical form.
** Then scan SendQ until you do (or do not)
/* Get a canonical form for the alias. */
for (p
= line
; *p
!= '\0' && *p
!= ':' && *p
!= '\n'; p
++)
if (*p
== '\0' || *p
== '\n')
syserr("Bad alias line `%s'", line
);
if (parse(line
, &al
, -1) == NULL
)
/* Scan SendQ for that canonical form. */
for (q
= &SendQ
; (q
= nxtinq(q
)) != NULL
; )
if (sameaddr(&al
, q
, TRUE
))
** Deliver to the target list.
** Remove the alias from the send queue
** and put it on the Alias queue.
printf("%s (%s, %s) aliased to %s (%s,%s,%s)\n",
q
->q_paddr
, q
->q_host
, q
->q_user
,
p
, al
.q_paddr
, al
.q_host
, al
.q_user
);
** FORWARD -- Try to forward mail
** This is similar but not identical to aliasing.
** Currently it is undefined, until the protocol for userinfo
** databases is finalized.
** user -- the name of the user who's mail we
** would like to forward to.
** TRUE -- we have forwarded it somewhere.
** FALSE -- not forwarded; go ahead & deliver.
** New names are added to SendQ.
** 3/5/80 -- return value changed.
** 1/23/80 -- null version written.