* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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 the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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
"@(#) Copyright (c) 1988 Regents of the University of California.\n\
static char sccsid
[] = "@(#)newaliases.c 5.4 (Berkeley) 6/1/90";
static char SccsId
[] = "@(#)newaliases.c 5.4 6/1/90";
typedef struct { char *dptr
; int dsize
; } datum
;
char *aliases
= ALIASFILE
;
struct mailer
*Mailer
[MAXMAILERS
+1];
int naliases
, bytes
, longest
;
char *cffile
= _PATH_SENDMAILCF
;
if (argc
> 1 && strcmp(argv
[1], "-T") == 0)
(void) strcpy(dirbuf
, aliases
);
(void) strcat(dirbuf
, ".dir");
(void) strcpy(pagbuf
, aliases
);
(void) strcat(pagbuf
, ".pag");
if (dbminit(aliases
) < 0)
if (freopen(aliases
, "r", stdin
) == 0) {
/* read and interpret lines */
while (fgets(line
, sizeof (line
), stdin
) != NULL
)
usrerr("Non-continuation line starts with space");
for (p
= line
; *p
!= '\0' && *p
!= ':' && *p
!= '\n'; p
++)
if (*p
== '\0' || *p
== '\n')
if (parse(line
, &al
, 1) == NULL
)
/* do parsing & compression of addresses */
while (*p
!= '\n' && *p
!= ',' && *p
!= '\0')
/* see if there should be a continuation line */
/* read continuation line */
if (fgets(p
, sizeof line
- (p
- line
), stdin
) == NULL
)
usrerr("continuation line missing");
if (al
.q_mailer
!= MN_LOCAL
)
usrerr("cannot alias non-local names");
key
.dsize
= strlen(al
.q_user
) + 1;
content
.dsize
= strlen(rhs
) + 1;
if (content
.dsize
> longest
)
bytes
+= key
.dsize
+ content
.dsize
;
if (store(key
, content
), 0)
/* if (f = store(key, content)) */
usrerr("Dbm internal error return %d from store\n", f
);
fprintf(stderr
, "%d aliases, %d bytes, longest %d bytes, %d errors\n",
naliases
, bytes
, longest
, Errors
);
usrerr(fmt
, a
, b
, c
, d
, e
)
fprintf(stderr
, "line %d: ", LineNo
);
fprintf(stderr
, fmt
, a
, b
, c
, d
, e
);
syserr(fmt
, a
, b
, c
, d
, e
)
return (usrerr(fmt
, a
, b
, c
, d
, e
));