xref: /freebsd/lib/libc/net/getprotoent.3 (revision 35b53f8c989f62286aad075ef2e97bba358144f8)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd June 4, 1993
29.Dt GETPROTOENT 3
30.Os
31.Sh NAME
32.Nm getprotoent ,
33.Nm getprotobynumber ,
34.Nm getprotobyname ,
35.Nm setprotoent ,
36.Nm endprotoent
37.Nd get protocol entry
38.Sh LIBRARY
39.Lb libc
40.Sh SYNOPSIS
41.In netdb.h
42.Ft struct protoent *
43.Fn getprotoent void
44.Ft struct protoent *
45.Fn getprotobyname "const char *name"
46.Ft struct protoent *
47.Fn getprotobynumber "int proto"
48.Ft void
49.Fn setprotoent "int stayopen"
50.Ft void
51.Fn endprotoent void
52.Sh DESCRIPTION
53The
54.Fn getprotoent ,
55.Fn getprotobyname ,
56and
57.Fn getprotobynumber
58functions
59each return a pointer to an object with the
60following structure
61containing the broken-out
62fields of a line in the network protocol data base,
63.Pa /etc/protocols .
64.Bd -literal -offset indent
65struct protoent {
66	char	*p_name;	/* official name of protocol */
67	char	**p_aliases;	/* alias list */
68	int	p_proto;	/* protocol number */
69};
70.Ed
71.Pp
72The members of this structure are:
73.Bl -tag -width p_aliases
74.It Fa p_name
75The official name of the protocol.
76.It Fa p_aliases
77A zero terminated list of alternate names for the protocol.
78.It Fa p_proto
79The protocol number.
80.El
81.Pp
82The
83.Fn getprotoent
84function
85reads the next line of the file, opening the file if necessary.
86.Pp
87The
88.Fn setprotoent
89function
90opens and rewinds the file.
91If the
92.Fa stayopen
93flag is non-zero,
94the net data base will not be closed after each call to
95.Fn getprotobyname
96or
97.Fn getprotobynumber .
98.Pp
99The
100.Fn endprotoent
101function
102closes the file.
103.Pp
104The
105.Fn getprotobyname
106function
107and
108.Fn getprotobynumber
109sequentially search from the beginning
110of the file until a matching
111protocol name or
112protocol number is found,
113or until
114.Dv EOF
115is encountered.
116.Sh RETURN VALUES
117Null pointer returned on
118.Dv EOF
119or error.
120.Sh FILES
121.Bl -tag -width /etc/protocols -compact
122.It Pa /etc/protocols
123.El
124.Sh SEE ALSO
125.Xr protocols 5
126.Sh HISTORY
127The
128.Fn getprotoent ,
129.Fn getprotobynumber ,
130.Fn getprotobyname ,
131.Fn setprotoent ,
132and
133.Fn endprotoent
134functions appeared in
135.Bx 4.2 .
136.Sh BUGS
137These functions use a thread-specific data space;
138if the data is needed for future use, it should be
139copied before any subsequent calls overwrite it.
140Only the Internet
141protocols are currently understood.
142