Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Sep 2022 08:12:34 GMT
From:      Gordon Bergling <gbe@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a3c3c02244f4 - stable/13 - getnetent(3): Add missing reentrant functions
Message-ID:  <202209240812.28O8CYF9026486@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by gbe (doc committer):

URL: https://cgit.FreeBSD.org/src/commit/?id=a3c3c02244f4fe4c77c034ca3846b410dbbb1091

commit a3c3c02244f4fe4c77c034ca3846b410dbbb1091
Author:     Fernando ApesteguĂ­a <fernape@FreeBSD.org>
AuthorDate: 2021-05-21 15:25:25 +0000
Commit:     Gordon Bergling <gbe@FreeBSD.org>
CommitDate: 2022-09-24 08:12:08 +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
    
    (cherry picked from commit dc68997328ec6cec41ad3b818c1846c8217e0c68)
---
 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 04a055ea3b1c..9f7156b7cd9c 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
@@ -225,6 +234,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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209240812.28O8CYF9026486>