* Copyright (c) 1983 Eric P. Allman
* Copyright (c) 1988 Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)udb.c 5.2 (Berkeley) %G%";
** UDBEXPAND -- look up user in database and expand
** a -- address to expand.
** sendq -- pointer to head of sendq to put the expansions in.
printf("expand(%s)\n", a
->q_paddr
);
/* make certain we are supposed to send to this address */
if (bitset(QDONTSEND
, a
->q_flags
))
CurEnv
->e_to
= a
->q_paddr
;
/* if necessary, open the database */
if (UdbFileName
== NULL
|| UdbFileName
[0] == '\0')
printf("no userdb specified\n");
dbp
= dbopen(UdbFileName
, O_RDONLY
, 0644, DB_HASH
, NULL
);
printf("cannot open %s: %d\n", UdbFileName
, errno
);
key
.size
= strlen(key
.data
);
i
= dbp
->get(dbp
, &key
, &info
, R_NOOVERWRITE
);
if (i
!= 0 || info
.size
<= 0)
syserr("udbexpand: db-get stat %s");
printf("expand: no match on %s\n", key
.data
);
/* extract the class (first string) and data (second string) */
i
= strlen((char *) info
.data
) + 1;
p
= (char *) info
.data
+ i
;
/* use internal buffer if it will fit; otherwise malloc */
printf("Class %s: %s\n", info
.data
, bp
);
/* do special processing based on class */
if (strcmp((char *) info
.data
, "user") == 0)
message(Arpa_Info
, "expanded to (%s) %s", info
.data
, bp
);
sendtolist(bp
, a
, sendq
);
/* free memory if we allocated it */