Lines Matching defs:hp

127 static struct hostent	*copy_decode_hostent_static(struct hostent *hp,
132 static struct hostent *copy_decode_hostent_dynamic(struct hostent *hp,
134 static void free_copied_hostent(struct hostent *hp);
218 copy_decode_hostent_static(struct hostent *hp, struct hostent *newhp,
222 * Copy "struct hostent" data referenced by 'hp' to 'newhp'.
223 * It's a deep-copy, meaning all the data referenced by 'hp' are
225 * The domain names ('hp->h_name' and 'hp->h_aliases') are
233 if (hp == NULL)
236 *newhp = *hp;
238 if (hp->h_aliases != NULL) {
244 while (hp->h_aliases[naliases] != NULL)
257 if (hp->h_addr_list != NULL) {
264 while (hp->h_addr_list[naddrs] != NULL)
279 sz = hp->h_length * naddrs;
285 memcpy(buf, hp->h_addr_list[i], hp->h_length);
286 buf += hp->h_length;
294 if (hp->h_name != NULL) {
303 r = idn_decodename(IDN_DECODE_APP, hp->h_name,
310 /* Copy hp->h_name verbatim. */
311 if (strlen(hp->h_name) + 1 <= buflen) {
313 strcpy(buf, hp->h_name);
326 if (hp->h_aliases != NULL) {
330 char **aliases = hp->h_aliases;
348 /* Copy hp->h_name verbatim. */
393 copy_decode_hostent_dynamic(struct hostent *hp, int *errp) {
395 * Make a deep-copy of the data referenced by 'hp', and return
398 * The domain names ('hp->h_name' and 'hp->h_aliases') are
410 if (hp == NULL)
413 if (hp->h_aliases != NULL) {
414 while (hp->h_aliases[naliases] != NULL)
418 if (hp->h_addr_list != NULL) {
419 while (hp->h_addr_list[naddrs] != NULL)
426 hp->h_length * naddrs;
429 return (hp);
436 if (hp->h_name != NULL) {
437 newhp->h_name = decode_name_dynamic(hp->h_name);
442 newhp->h_addrtype = hp->h_addrtype;
443 newhp->h_length = hp->h_length;
445 if (hp->h_aliases != NULL) {
449 decode_name_dynamic(hp->h_aliases[i]);
457 if (hp->h_addr_list != NULL) {
466 memcpy(p, hp->h_addr_list[i], hp->h_length);
467 p += hp->h_length;
475 free_copied_hostent(hp);
481 free_copied_hostent(struct hostent *hp) {
485 if (hp->h_name != NULL)
486 free(hp->h_name);
487 if (hp->h_aliases != NULL) {
488 char **pp = hp->h_aliases;
492 free(hp);
539 struct hostent *hp;
553 hp = copy_decode_hostent_static(REAL(gethostbyname)(name),
557 return (hp);
567 struct hostent *hp;
581 hp = copy_decode_hostent_static(REAL(gethostbyname2)(name, af),
585 return (hp);
594 struct hostent *hp;
602 hp = copy_decode_hostent_static(REAL(gethostbyaddr)(addr, len, type),
606 return (hp);
789 struct hostent *hp, he;
818 hp = REAL(gethostbyname_r)(name, &he, data, datalen, errp);
820 if (hp != NULL)
821 hp = copy_decode_hostent_static(hp, result, buffer, buflen,
828 return (hp);
840 struct hostent *hp, he;
863 hp = REAL(gethostbyaddr_r)(addr, len, type, &he, data, datalen, errp);
865 if (hp != NULL)
866 hp = copy_decode_hostent_static(hp, result, buffer, buflen,
873 return (hp);
884 struct hostent *hp;
898 hp = REAL(getipnodebyname)(name, af, flags, errp);
899 if (hp != NULL) {
900 struct hostent *newhp = copy_decode_hostent_dynamic(hp, errp);
901 if (newhp != hp) {
902 REAL(freehostent)(hp);
904 hp = newhp;
908 return (hp);
915 struct hostent *hp;
923 hp = REAL(getipnodebyaddr)(src, len, af, errp);
924 if (hp != NULL) {
925 struct hostent *newhp = copy_decode_hostent_dynamic(hp, errp);
926 if (newhp != hp) {
927 REAL(freehostent)(hp);
929 hp = newhp;
933 return (hp);
939 ENTRY(freehostent)(struct hostent *hp) {
940 TRACE(("freehostent(hp=%p)\n", (void *)hp));
942 if (obj_islocked(hp)) {
946 obj_unlock(hp);
947 free_copied_hostent(hp);
952 REAL(freehostent)(hp);