git: dc68997328ec - main - getnetent(3): Add missing reentrant functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Jun 2022 05:30:41 UTC
The branch main has been updated by fernape (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=dc68997328ec6cec41ad3b818c1846c8217e0c68 commit dc68997328ec6cec41ad3b818c1846c8217e0c68 Author: Fernando Apesteguía <fernape@FreeBSD.org> AuthorDate: 2021-05-21 15:25:25 +0000 Commit: Fernando Apesteguía <fernape@FreeBSD.org> CommitDate: 2022-06-20 05:23:53 +0000 getnetent(3): Add missing reentrant functions Add documentation for gethostbyname_r, gethostbyname2_r and gethostbyaddr_r Create proper MLINKs for the new functions. PR: 249154 Reported by: asomers@ Approved by: manpages (0mp@), Pau Amma Differential Revision: https://reviews.freebsd.org/D30469 --- lib/libc/net/Makefile.inc | 7 ++++--- lib/libc/net/gethostbyname.3 | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index 6628028ccc83..683e2826c401 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -59,9 +59,10 @@ MLINKS+=eui64.3 eui64_aton.3 eui64.3 eui64_hostton.3 \ eui64.3 eui64_ntoa.3 eui64.3 eui64_ntohost.3 MLINKS+=getaddrinfo.3 freeaddrinfo.3 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 gethostbyaddr_r.3 gethostbyname.3 gethostbyname2.3 \ + gethostbyname.3 gethostbyname2_r.3 gethostbyname.3 gethostbyname_r.3 \ + gethostbyname.3 gethostent.3 gethostbyname.3 herror.3 \ + gethostbyname.3 hstrerror.3 gethostbyname.3 sethostent.3 MLINKS+=getifaddrs.3 freeifaddrs.3 MLINKS+=getifmaddrs.3 freeifmaddrs.3 MLINKS+=getipnodebyname.3 getipnodebyaddr.3 getipnodebyname.3 freehostent.3 diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3 index 8a624e90cbdc..883e033971fb 100644 --- a/lib/libc/net/gethostbyname.3 +++ b/lib/libc/net/gethostbyname.3 @@ -28,7 +28,7 @@ .\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 .\" $FreeBSD$ .\" -.Dd October 4, 2017 +.Dd June 20, 2022 .Dt GETHOSTBYNAME 3 .Os .Sh NAME @@ -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 @@ function returns a string which is the message text corresponding to the 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