(get_pobox): try to handle old and new hesiod APIs

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5728 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-03-24 03:37:02 +00:00
parent 402f08ad92
commit a468b60640

View File

@@ -531,15 +531,16 @@ do_v4 (char *host,
}
#endif /* KRB4 */
static char *
get_pobox (char **user)
{
char *ret = NULL;
#ifdef HESIOD
{
#ifdef HESIOD_INTERFACES
static char *
hesiod_get_pobox (char **user)
{
void *context;
struct hesiod_postoffice *hpo;
char *ret = NULL;
if(hesiod_init (&context) != 0)
err (1, "hesiod_init");
@@ -560,7 +561,45 @@ get_pobox (char **user)
hesiod_free_postoffice (context, hpo);
}
hesiod_end (context);
return ret;
}
#else /* !HESIOD_INTERFACES */
static char *
hesiod_get_pobox (char **user)
{
char *ret = NULL;
struct hes_postoffice *hpo;
hpo = hes_getmailhost (*user);
if (hpo == NULL) {
warn ("hes_getmailhost %s", *user);
} else {
if (strcasecmp(hpo->po_type, "pop") != 0)
errx (1, "Unsupported po type %s", hpo->po_type);
ret = strdup(hpo->po_host);
if(ret == NULL)
errx (1, "strdup: out of memory");
*user = strdup(hpo->po_name);
if (*user == NULL)
errx (1, "strdup: out of memory");
}
return ret;
}
#endif /* HESIOD_INTERFACES */
#endif /* HESIOD */
static char *
get_pobox (char **user)
{
char *ret = NULL;
#ifdef HESIOD
ret = hesiod_get_pobox (user);
#endif
if (ret == NULL)