4 #include "../src/common.h"
8 struct hostent *ret, char *buf, size_t buflen,
9 struct hostent **result, int *h_errnop);
11 Glibc2 also has reentrant versions gethostent_r(), gethostbyaddr_r(),
12 gethostbyname_r() and gethostbyname2_r().
14 The caller supplies a hostent structure ret which will be filled in on success,
15 and a temporary work buffer buf of size buflen.
16 After the call, result will point to the result on success.
17 In case of an error or if no entry is found result will be NULL.
18 The functions return 0 on success and a nonzero error number on failure.
19 In addition to the errors returned by the nonreentrant versions of these functions,
20 if buf is too small, the functions will return ERANGE, and the call should be retried
22 The global variable h_errno is not modified, but the address of a variable in which
23 to store error numbers is passed in h_errnop.
26 void printhostent(struct hostent
*hp
) {
28 pc_stringfromipv4(hp
->h_addr_list
[0], ipbuf
);
29 printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
39 int main(int argc
, char** argv
) {
40 struct hostent he_buf
;
41 struct hostent
*he_res
;
46 ret
= gethostent_r(&he_buf
, h_buf
, sizeof(h_buf
), &he_res
, &ch_errno
);
47 printf("ret: %d, h_errno: %d\n", ret
, ch_errno
);
53 perror("gethostent_r");