summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getservent.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getservent.3')
-rw-r--r--src/lib/libc/net/getservent.362
1 files changed, 23 insertions, 39 deletions
diff --git a/src/lib/libc/net/getservent.3 b/src/lib/libc/net/getservent.3
index 9e0656be00..85e0d65352 100644
--- a/src/lib/libc/net/getservent.3
+++ b/src/lib/libc/net/getservent.3
@@ -1,4 +1,4 @@
1.\" $NetBSD: getservent.3,v 1.3 1995/02/25 06:20:38 cgd Exp $ 1.\" $OpenBSD: getservent.3,v 1.11 2000/12/24 00:30:56 aaron Exp $
2.\" 2.\"
3.\" Copyright (c) 1983, 1991, 1993 3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -31,11 +31,9 @@
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 32.\" SUCH DAMAGE.
33.\" 33.\"
34.\" @(#)getservent.3 8.3 (Berkeley) 1/12/94
35.\"
36.Dd January 12, 1994 34.Dd January 12, 1994
37.Dt GETSERVENT 3 35.Dt GETSERVENT 3
38.Os BSD 4.2 36.Os
39.Sh NAME 37.Sh NAME
40.Nm getservent , 38.Nm getservent ,
41.Nm getservbyport , 39.Nm getservbyport ,
@@ -46,26 +44,23 @@
46.Sh SYNOPSIS 44.Sh SYNOPSIS
47.Fd #include <netdb.h> 45.Fd #include <netdb.h>
48.Ft struct servent * 46.Ft struct servent *
49.Fn getservent 47.Fn getservent "void"
50.Ft struct servent * 48.Ft struct servent *
51.Fn getservbyname "char *name" "char *proto" 49.Fn getservbyname "char *name" "char *proto"
52.Ft struct servent * 50.Ft struct servent *
53.Fn getservbyport "int port" proto 51.Fn getservbyport "int port" "char *proto"
54.Ft void 52.Ft void
55.Fn setservent "int stayopen" 53.Fn setservent "int stayopen"
56.Ft void 54.Ft void
57.Fn endservent void 55.Fn endservent "void"
58.Sh DESCRIPTION 56.Sh DESCRIPTION
59The 57The
60.Fn getservent , 58.Fn getservent ,
61.Fn getservbyname , 59.Fn getservbyname ,
62and 60and
63.Fn getservbyport 61.Fn getservbyport
64functions 62functions each return a pointer to an object with the following structure
65each return a pointer to an object with the 63containing the broken-out fields of a line in the network services database,
66following structure
67containing the broken-out
68fields of a line in the network services data base,
69.Pa /etc/services . 64.Pa /etc/services .
70.Bd -literal -offset indent 65.Bd -literal -offset indent
71struct servent { 66struct servent {
@@ -81,59 +76,50 @@ The members of this structure are:
81.It Fa s_name 76.It Fa s_name
82The official name of the service. 77The official name of the service.
83.It Fa s_aliases 78.It Fa s_aliases
84A zero terminated list of alternate names for the service. 79A zero-terminated list of alternate names for the service.
85.It Fa s_port 80.It Fa s_port
86The port number at which the service resides. 81The port number at which the service resides.
87Port numbers are returned in network byte order. 82Port numbers are returned in network byte order.
88.It Fa s_proto 83.It Fa s_proto
89The name of the protocol to use when contacting the 84The name of the protocol to use when contacting the service.
90service.
91.El 85.El
92.Pp 86.Pp
93The 87The
94.Fn getservent 88.Fn getservent
95function 89function reads the next line of the file, opening the file if necessary.
96reads the next line of the file, opening the file if necessary.
97.Pp 90.Pp
98The 91The
99.Fn setservent 92.Fn setservent
100function 93function opens and rewinds the file.
101opens and rewinds the file. If the 94If the
102.Fa stayopen 95.Fa stayopen
103flag is non-zero, 96flag is non-zero,
104the net data base will not be closed after each call to 97the net database will not be closed after each call to
105.Fn getservbyname 98.Fn getservbyname
106or 99or
107.Fn getservbyport . 100.Fn getservbyport .
108.Pp 101.Pp
109The 102The
110.Fn endservent 103.Fn endservent
111function 104function closes the file.
112closes the file.
113.Pp 105.Pp
114The 106The
115.Fn getservbyname 107.Fn getservbyname
116and 108and
117.Fn getservbyport 109.Fn getservbyport
118functions 110functions sequentially search from the beginning of the file until a
119sequentially search from the beginning 111matching protocol name or port number (specified in network byte order)
120of the file until a matching 112is found, or until
121protocol name or
122port number is found,
123or until
124.Dv EOF 113.Dv EOF
125is encountered. 114is encountered.
126If a protocol name is also supplied (non- 115If a protocol name is also supplied (non-null),
127.Dv NULL ) ,
128searches must also match the protocol. 116searches must also match the protocol.
129.ne 1i
130.Sh FILES 117.Sh FILES
131.Bl -tag -width /etc/services -compact 118.Bl -tag -width /etc/services -compact
132.It Pa /etc/services 119.It Pa /etc/services
133.El 120.El
134.Sh DIAGNOSTICS 121.Sh DIAGNOSTICS
135Null pointer 122Null pointer (0) returned on
136(0) returned on
137.Dv EOF 123.Dv EOF
138or error. 124or error.
139.Sh SEE ALSO 125.Sh SEE ALSO
@@ -147,11 +133,9 @@ The
147.Fn setservent , 133.Fn setservent ,
148and 134and
149.Fn endservent 135.Fn endservent
150functions appeared in 136functions appeared in
151.Bx 4.2 . 137.Bx 4.2 .
152.Sh BUGS 138.Sh BUGS
153These functions use static data storage; 139These functions use static data storage; if the data is needed for future use,
154if the data is needed for future use, it should be 140it should be copied before any subsequent calls overwrite it.
155copied before any subsequent calls overwrite it. 141Expecting port numbers to fit in a 32-bit quantity is probably naive.
156Expecting port numbers to fit in a 32 bit
157quantity is probably naive.