struct hostent * gethostbyname2_p(const char *name, int af, struct net_data *net_data) { struct irs_ho *ho; char tmp[NS_MAXDNAME]; struct hostent *hp; const char *cp; char **hap; if (!net_data || !(ho = net_data->ho)) return (NULL); if (net_data->ho_stayopen && net_data->ho_last && net_data->ho_last->h_addrtype == af) { if (ns_samename(name, net_data->ho_last->h_name) == 1) return (net_data->ho_last); for (hap = net_data->ho_last->h_aliases; hap && *hap; hap++) if (ns_samename(name, *hap) == 1) return (net_data->ho_last); } if (!strchr(name, '.') && (cp = res_hostalias(net_data->res, name, tmp, sizeof tmp))) name = cp; if ((hp = fakeaddr(name, af, net_data)) != NULL) return (hp); net_data->ho_last = (*ho->byname2)(ho, name, af); if (!net_data->ho_stayopen) endhostent(); return (net_data->ho_last); }
struct netent * getnetbyname_p(const char *name, struct net_data *net_data) { struct irs_nw *nw; struct netent *np; char **nap; if (!net_data || !(nw = net_data->nw)) return (NULL); if (net_data->nw_stayopen && net_data->nw_last) { if (!strcmp(net_data->nw_last->n_name, name)) return (net_data->nw_last); for (nap = net_data->nw_last->n_aliases; nap && *nap; nap++) if (!strcmp(name, *nap)) return (net_data->nw_last); } if ((np = fakeaddr(name, AF_INET, net_data)) != NULL) return (np); net_data->nww_last = (*nw->byname)(nw, name, AF_INET); net_data->nw_last = nw_to_net(net_data->nww_last, net_data); if (!net_data->nw_stayopen) endnetent(); return (net_data->nw_last); }