summaryrefslogtreecommitdiff
path: root/lib/libc/net/getservent.3
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/net/getservent.3')
-rw-r--r--lib/libc/net/getservent.359
1 files changed, 54 insertions, 5 deletions
diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3
index af75f5037bf..f5294b8f708 100644
--- a/lib/libc/net/getservent.3
+++ b/lib/libc/net/getservent.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: getservent.3,v 1.13 2003/12/30 10:35:36 jmc Exp $
+.\" $OpenBSD: getservent.3,v 1.14 2004/10/17 20:24:23 millert Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,28 +27,43 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 12, 1994
+.Dd October 13, 2004
.Dt GETSERVENT 3
.Os
.Sh NAME
.Nm getservent ,
+.Nm getservent_r ,
.Nm getservbyport ,
+.Nm getservbyport_r ,
.Nm getservbyname ,
+.Nm getservbyname_r ,
.Nm setservent ,
-.Nm endservent
+.Nm setservent_r ,
+.Nm endservent ,
+.Nm endservent_r
.Nd get service entry
.Sh SYNOPSIS
.Fd #include <netdb.h>
.Ft struct servent *
.Fn getservent "void"
.Ft struct servent *
+.Fn getservent_r "struct servent *servent" "struct servent_data *servent_data"
+.Ft struct servent *
.Fn getservbyname "const char *name" "const char *proto"
.Ft struct servent *
+.Fn getservbyname_r "const char *name" "const char *proto" "struct servent *servent" "struct servent_data *servent_data"
+.Ft struct servent *
.Fn getservbyport "int port" "const char *proto"
+.Ft struct servent *
+.Fn getservbyport_r "int port" "const char *proto" "struct servent *servent" "struct servent_data *servent_data"
.Ft void
.Fn setservent "int stayopen"
.Ft void
+.Fn setservent_r "int stayopen" "struct servent_data *servent_data"
+.Ft void
.Fn endservent "void"
+.Ft void
+.Fn endservent_r "struct servent_data *servent_data"
.Sh DESCRIPTION
The
.Fn getservent ,
@@ -110,6 +125,30 @@ is found, or until
is encountered.
If a protocol name is also supplied (non-null),
searches must also match the protocol.
+.Pp
+The
+.Fn getservent_r ,
+.Fn getservbyport_r ,
+.Fn getservbyname_r ,
+.Fn setservent_r ,
+and
+.Fn endservent_r
+functions are reentrant versions of the above functions that take a
+pointer to a
+.Fa servent_data
+structure which is used to store state information.
+The structure must be zero-filled before it is used
+and should be considered opaque for the sake of portability.
+.Pp
+The
+.Fn getservent_r ,
+.Fn getservbyport_r ,
+and
+.Fn getservbyname_r
+functions
+also take a pointer to a
+.Fa servent
+structure which is used to store the results of the database lookup.
.Sh FILES
.Bl -tag -width /etc/services -compact
.It Pa /etc/services
@@ -130,8 +169,18 @@ The
and
.Fn endservent
functions appeared in
+.Pp
.Bx 4.2 .
+The
+.Fn getservent_r ,
+.Fn getservbyport_r ,
+.Fn getservbyname_r ,
+.Fn setservent_r ,
+and
+.Fn endservent_r
+functions appeared in
+.Ox 3.7 .
.Sh BUGS
-These functions use static data storage; if the data is needed for future use,
-it should be copied before any subsequent calls overwrite it.
+The non-reentrant functions use static data storage; if the data is needed
+for future use, it should be copied before any subsequent calls overwrite it.
Expecting port numbers to fit in a 32-bit quantity is probably naive.