Lines Matching defs:hp

52 hostent_free(struct hostent *hp)
56 free(hp->h_name);
57 hp->h_name = NULL;
58 if (hp->h_aliases != NULL) {
59 for (ii = 0; hp->h_aliases[ii] != NULL; ii++)
60 free(hp->h_aliases[ii]);
61 free(hp->h_aliases);
62 hp->h_aliases = NULL;
64 if (hp->h_addr_list != NULL) {
65 for (ii = 0; hp->h_addr_list[ii] != NULL; ii++)
66 free(hp->h_addr_list[ii]);
67 free(hp->h_addr_list);
68 hp->h_addr_list = NULL;
73 hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
79 hostent_free(hp);
81 hp->h_name = strdup(nvlist_get_string(nvl, "name"));
82 if (hp->h_name == NULL)
84 hp->h_addrtype = (int)nvlist_get_number(nvl, "addrtype");
85 hp->h_length = (int)nvlist_get_number(nvl, "length");
88 hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
89 if (hp->h_aliases == NULL)
94 hp->h_aliases[ii] =
96 if (hp->h_aliases[ii] == NULL)
99 hp->h_aliases[ii] = NULL;
102 hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
103 if (hp->h_addr_list == NULL)
106 hp->h_addr_list[ii] = malloc(hp->h_length);
107 if (hp->h_addr_list[ii] == NULL)
112 hp->h_addr_list[ii], hp->h_length);
114 hp->h_addr_list[ii] = NULL;
116 return (hp);
118 hostent_free(hp);
133 struct hostent *hp;
151 hp = hostent_unpack(nvl, &hent);
153 return (hp);
160 struct hostent *hp;
177 hp = hostent_unpack(nvl, &hent);
179 return (hp);
434 hostent_pack(const struct hostent *hp, nvlist_t *nvl)
440 nvlist_add_string(nvl, "name", hp->h_name);
441 nvlist_add_number(nvl, "addrtype", (uint64_t)hp->h_addrtype);
442 nvlist_add_number(nvl, "length", (uint64_t)hp->h_length);
444 if (hp->h_aliases == NULL) {
447 for (ii = 0; hp->h_aliases[ii] != NULL; ii++) {
450 nvlist_add_string(nvl, nvlname, hp->h_aliases[ii]);
455 if (hp->h_addr_list == NULL) {
458 for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) {
461 nvlist_add_binary(nvl, nvlname, hp->h_addr_list[ii],
462 (size_t)hp->h_length);
472 struct hostent *hp;
483 hp = gethostbyname2(nvlist_get_string(nvlin, "name"), family);
484 if (hp == NULL)
486 hostent_pack(hp, nvlout);
494 struct hostent *hp;
508 hp = gethostbyaddr(addr, (socklen_t)addrsize, family);
509 if (hp == NULL)
511 hostent_pack(hp, nvlout);