#ifndef lint
#ifdef USERDB
-static char sccsid [] = "@(#)udb.c 8.2 (Berkeley) %G% (with USERDB)";
+static char sccsid [] = "@(#)udb.c 8.3 (Berkeley) %G% (with USERDB)";
#else
-static char sccsid [] = "@(#)udb.c 8.2 (Berkeley) %G% (without USERDB)";
+static char sccsid [] = "@(#)udb.c 8.3 (Berkeley) %G% (without USERDB)";
#endif
#endif
char *
udbsender(sender)
char *sender;
+{
+ extern char *udbmatch();
+
+ return udbmatch(sender, "mailname");
+}
+
+
+char *
+udbmatch(user, field)
+ char *user;
+ char *field;
{
register char *p;
register struct udbent *up;
char keybuf[MAXKEY];
if (tTd(28, 1))
- printf("udbsender(%s)\n", sender);
+ printf("udbmatch(%s, %s)\n", user, field);
if (!UdbInitialized)
{
return NULL;
/* long names can never match and are a pain to deal with */
- if (strlen(sender) > sizeof keybuf - 12)
+ if ((strlen(user) + strlen(field)) > sizeof keybuf - 4)
return NULL;
/* names beginning with colons indicate metadata */
- if (sender[0] == ':')
+ if (user[0] == ':')
return NULL;
/* build database key */
- (void) strcpy(keybuf, sender);
- (void) strcat(keybuf, ":mailname");
+ (void) strcpy(keybuf, user);
+ (void) strcat(keybuf, ":");
+ (void) strcat(keybuf, field);
keylen = strlen(keybuf);
for (up = UdbEnts; up->udb_type != UDB_EOLIST; up++)
if (i != 0 || info.size <= 0)
{
if (tTd(28, 2))
- printf("udbsender: no match on %s (%d)\n",
+ printf("udbmatch: no match on %s (%d)\n",
keybuf, keylen);
continue;
}
bcopy(info.data, p, info.size);
p[info.size] = '\0';
if (tTd(28, 1))
- printf("udbsender ==> %s\n", p);
+ printf("udbmatch ==> %s\n", p);
return p;
}
}
+ if (strcmp(field, "mailname") != 0)
+ return NULL;
+
/*
** Nothing yet. Search again for a default case. But only
** use it if we also have a forward (:maildrop) pointer already
*/
/* build database key */
- (void) strcpy(keybuf, sender);
+ (void) strcpy(keybuf, user);
(void) strcat(keybuf, ":maildrop");
keylen = strlen(keybuf);
}
/* they exist -- build the actual address */
- p = xalloc(strlen(sender) + strlen(up->udb_default) + 2);
- (void) strcpy(p, sender);
+ p = xalloc(strlen(user) + strlen(up->udb_default) + 2);
+ (void) strcpy(p, user);
(void) strcat(p, "@");
(void) strcat(p, up->udb_default);
if (tTd(28, 1))
- printf("udbsender ==> %s\n", p);
+ printf("udbmatch ==> %s\n", p);
return p;
}
}