summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getprotoent.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getprotoent.3')
-rw-r--r--src/lib/libc/net/getprotoent.3153
1 files changed, 110 insertions, 43 deletions
diff --git a/src/lib/libc/net/getprotoent.3 b/src/lib/libc/net/getprotoent.3
index 8d607199ef..df4cd0c323 100644
--- a/src/lib/libc/net/getprotoent.3
+++ b/src/lib/libc/net/getprotoent.3
@@ -1,4 +1,4 @@
1.\" $NetBSD: getprotoent.3,v 1.3 1995/02/25 06:20:34 cgd Exp $ 1.\" $OpenBSD: getprotoent.3,v 1.17 2007/05/31 19:19:30 jmc 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.
@@ -11,11 +11,7 @@
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software 14.\" 3. Neither the name of the University nor the names of its contributors
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software 15.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission. 16.\" without specific prior written permission.
21.\" 17.\"
@@ -31,39 +27,51 @@
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
33.\" 29.\"
34.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 30.Dd $Mdocdate: May 31 2007 $
35.\"
36.Dd June 4, 1993
37.Dt GETPROTOENT 3 31.Dt GETPROTOENT 3
38.Os BSD 4.2 32.Os
39.Sh NAME 33.Sh NAME
40.Nm getprotoent , 34.Nm getprotoent ,
35.Nm getprotoent_r ,
41.Nm getprotobynumber , 36.Nm getprotobynumber ,
37.Nm getprotobynumber_r ,
42.Nm getprotobyname , 38.Nm getprotobyname ,
39.Nm getprotobyname_r ,
43.Nm setprotoent , 40.Nm setprotoent ,
44.Nm endprotoent 41.Nm setprotoent_r ,
42.Nm endprotoent ,
43.Nm endprotoent_r
45.Nd get protocol entry 44.Nd get protocol entry
46.Sh SYNOPSIS 45.Sh SYNOPSIS
47.Fd #include <netdb.h> 46.Fd #include <netdb.h>
48.Ft struct protoent * 47.Ft struct protoent *
49.Fn getprotoent 48.Fn getprotoent "void"
49.Ft int
50.Fn getprotoent_r "struct protoent *protoent" "struct protoent_data *protoent_data"
50.Ft struct protoent * 51.Ft struct protoent *
51.Fn getprotobyname "char *name" 52.Fn getprotobyname "const char *name"
53.Ft int
54.Fn getprotobyname_r "const char *name" "struct protoent *protoent" "struct protoent_data *protoent_data"
52.Ft struct protoent * 55.Ft struct protoent *
53.Fn getprotobynumber "int proto" 56.Fn getprotobynumber "int proto"
57.Ft int
58.Fn getprotobynumber_r "int proto" "struct protoent *protoent" "struct protoent_data *protoent_data"
59.Ft void
54.Fn setprotoent "int stayopen" 60.Fn setprotoent "int stayopen"
55.Fn endprotoent 61.Ft void
62.Fn setprotoent_r "int stayopen" "struct protoent_data *protoent_data"
63.Ft void
64.Fn endprotoent "void"
65.Ft void
66.Fn endprotoent_r "struct protoent_data *protoent_data"
56.Sh DESCRIPTION 67.Sh DESCRIPTION
57The 68The
58.Fn getprotoent , 69.Fn getprotoent ,
59.Fn getprotobyname , 70.Fn getprotobyname ,
60and 71and
61.Fn getprotobynumber 72.Fn getprotobynumber
62functions 73functions each return a pointer to an object with the following structure
63each return a pointer to an object with the 74containing the broken-out fields of a line in the network protocol database,
64following structure
65containing the broken-out
66fields of a line in the network protocol data base,
67.Pa /etc/protocols . 75.Pa /etc/protocols .
68.Bd -literal -offset indent 76.Bd -literal -offset indent
69.Pp 77.Pp
@@ -79,55 +87,106 @@ The members of this structure are:
79.It Fa p_name 87.It Fa p_name
80The official name of the protocol. 88The official name of the protocol.
81.It Fa p_aliases 89.It Fa p_aliases
82A zero terminated list of alternate names for the protocol. 90A null-terminated list of alternate names for the protocol.
83.It Fa p_proto 91.It Fa p_proto
84The protocol number. 92The protocol number.
85.El 93.El
86.Pp 94.Pp
87The 95The
88.Fn getprotoent 96.Fn getprotoent
89function 97function reads the next line of the file, opening the file if necessary.
90reads the next line of the file, opening the file if necessary.
91.Pp 98.Pp
92The 99The
93.Fn setprotoent 100.Fn setprotoent
94function 101function opens and rewinds the file.
95opens and rewinds the file. If the 102If the
96.Fa stayopen 103.Fa stayopen
97flag is non-zero, 104flag is non-zero,
98the net data base will not be closed after each call to 105the protocol database will not be closed after each call to
99.Fn getprotobyname 106.Fn getprotobyname
100or 107or
101.Fn getprotobynumber . 108.Fn getprotobynumber .
102.Pp 109.Pp
103The 110The
104.Fn endprotoent 111.Fn endprotoent
105function 112function closes the file.
106closes the file.
107.Pp 113.Pp
108The 114The
109.Fn getprotobyname 115.Fn getprotobyname
110function
111and 116and
112.Fn getprotobynumber 117.Fn getprotobynumber
113sequentially search from the beginning 118functions sequentially search from the beginning of the file until a
114of the file until a matching 119matching protocol name or protocol number is found, or until
115protocol name or
116protocol number is found,
117or until
118.Dv EOF 120.Dv EOF
119is encountered. 121is encountered.
122.Pp
123The
124.Fn getprotoent_r ,
125.Fn getprotobyport_r ,
126.Fn getprotobyname_r ,
127.Fn setprotoent_r ,
128and
129.Fn endprotoent_r
130functions are reentrant versions of the above functions that take a
131pointer to a
132.Vt protoent_data
133structure which is used to store state information.
134The structure must be zero-filled before it is used
135and should be considered opaque for the sake of portability.
136.Pp
137The
138.Fn getprotoent_r ,
139.Fn getprotobyport_r ,
140and
141.Fn getprotobyname_r
142functions
143also take a pointer to a
144.Vt protoent
145structure which is used to store the results of the database lookup.
120.Sh RETURN VALUES 146.Sh RETURN VALUES
121Null pointer 147The
122(0) returned on 148.Fn getprotoent ,
123.Dv EOF 149.Fn getprotobyport ,
124or error. 150and
151.Fn getprotobyname
152functions return a pointer to a
153.Vt protoent
154structure on success or a null pointer if end-of-file
155is reached or an error occurs.
156.Pp
157The
158.Fn getprotoent_r ,
159.Fn getprotobyport_r ,
160and
161.Fn getprotobyname_r
162functions return 0 on success or \-1 if end-of-file
163is reached or an error occurs.
125.Sh FILES 164.Sh FILES
126.Bl -tag -width /etc/protocols -compact 165.Bl -tag -width /etc/protocols -compact
127.It Pa /etc/protocols 166.It Pa /etc/protocols
128.El 167.El
129.Sh SEE ALSO 168.Sh SEE ALSO
130.Xr protocols 5 169.Xr protocols 5
170.Sh STANDARDS
171The
172.Fn getprotoent ,
173.Fn getprotobynumber ,
174.Fn getprotobyname ,
175.Fn setprotoent ,
176and
177.Fn endprotoent
178functions conform to
179.St -p1003.1-2004 .
180.Pp
181The
182.Fn getprotoent_r ,
183.Fn getprotobyport_r ,
184.Fn getprotobyname_r ,
185.Fn setprotoent_r ,
186and
187.Fn endprotoent_r
188functions are not currently standardized.
189This implementation follows the API used by HP, IBM, and Digital.
131.Sh HISTORY 190.Sh HISTORY
132The 191The
133.Fn getprotoent , 192.Fn getprotoent ,
@@ -136,11 +195,19 @@ The
136.Fn setprotoent , 195.Fn setprotoent ,
137and 196and
138.Fn endprotoent 197.Fn endprotoent
139functions appeared in 198functions appeared in
140.Bx 4.2 . 199.Bx 4.2 .
200.Pp
201The
202.Fn getprotoent_r ,
203.Fn getprotobyport_r ,
204.Fn getprotobyname_r ,
205.Fn setprotoent_r ,
206and
207.Fn endprotoent_r
208functions appeared in
209.Ox 3.7 .
141.Sh BUGS 210.Sh BUGS
142These functions use a static data space; 211The non-reentrant functions use a static data space; if the data is needed
143if the data is needed for future use, it should be 212for future use, it should be copied before any subsequent calls overwrite it.
144copied before any subsequent calls overwrite it. 213Only the Internet protocols are currently understood.
145Only the Internet
146protocols are currently understood.