Index: lib/libc/net/Makefile.inc =================================================================== --- lib/libc/net/Makefile.inc +++ lib/libc/net/Makefile.inc @@ -61,7 +61,9 @@ MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \ gethostbyname.3 gethostbyname2.3 gethostbyname.3 gethostent.3 \ gethostbyname.3 herror.3 gethostbyname.3 hstrerror.3 \ - gethostbyname.3 sethostent.3 + gethostbyname.3 sethostent.3 \ + gethostbyname.3 gethostbyname_r.3 gethostbyname.3 gethostbyname2_r.3 \ + gethostbyname.3 gethostbyaddr_r.3 MLINKS+=getifaddrs.3 freeifaddrs.3 MLINKS+=getifmaddrs.3 freeifmaddrs.3 MLINKS+=getipnodebyname.3 getipnodebyaddr.3 getipnodebyname.3 freehostent.3 Index: lib/libc/net/gethostbyname.3 =================================================================== --- lib/libc/net/gethostbyname.3 +++ lib/libc/net/gethostbyname.3 @@ -39,7 +39,10 @@ .Nm sethostent , .Nm endhostent , .Nm herror , -.Nm hstrerror +.Nm hstrerror , +.Nm gethostbyname_r , +.Nm gethostbyname2_r , +.Nm gethostbyaddr_r .Nd get network host entry .Sh LIBRARY .Lb libc @@ -62,6 +65,12 @@ .Fn herror "const char *string" .Ft const char * .Fn hstrerror "int err" +.Ft int +.Fn gethostbyname_r "const char *name" "struct hostent *he" "char *buffer" "size_t buflen" "struct hostent **result" "int *h_errnop" +.Ft int +.Fn gethostbyname2_r "const char *name" "int af" "struct hostent *he" "char *buffer" "size_t buflen" "struct hostent **result" "int *h_errnop" +.Ft int +.Fn gethostbyaddr_r "const void *addr" "socklen_t len" "int af" "struct hostent *hp" "char *buf" "size_t buflen" "struct hostent **result" "int *h_errno"p .Sh DESCRIPTION .Bf -symbolic The @@ -227,6 +236,26 @@ value of the .Fa err argument. +.Pp +Functions with the +.Em _r +suffix provide reentrant versions of their respective counterparts. +The caller must supply five additional parameters: a +.Vt struct hostent +variable to be filled on success, a +.Va buffer +of +.Va buflen +bytes in size, a +.Vt struct hostent +.Va result +variable that will point to the result on success or be set to +.Dv NULL +on failure or if the name is not found. +The +.Va h_errnop +variable will be filled with the error code if any. +All these functions return 0 on success. .Sh FILES .Bl -tag -width /etc/nsswitch.conf -compact .It Pa /etc/hosts