xref: /freebsd/lib/libc/net/getprotoent.3 (revision 315ee00f)
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.\"     @(#)getprotoent.3	8.1 (Berkeley) 6/4/93
29.\"
30.Dd June 4, 1993
31.Dt GETPROTOENT 3
32.Os
33.Sh NAME
34.Nm getprotoent ,
35.Nm getprotobynumber ,
36.Nm getprotobyname ,
37.Nm setprotoent ,
38.Nm endprotoent
39.Nd get protocol entry
40.Sh LIBRARY
41.Lb libc
42.Sh SYNOPSIS
43.In netdb.h
44.Ft struct protoent *
45.Fn getprotoent void
46.Ft struct protoent *
47.Fn getprotobyname "const char *name"
48.Ft struct protoent *
49.Fn getprotobynumber "int proto"
50.Ft void
51.Fn setprotoent "int stayopen"
52.Ft void
53.Fn endprotoent void
54.Sh DESCRIPTION
55The
56.Fn getprotoent ,
57.Fn getprotobyname ,
58and
59.Fn getprotobynumber
60functions
61each return a pointer to an object with the
62following structure
63containing the broken-out
64fields of a line in the network protocol data base,
65.Pa /etc/protocols .
66.Bd -literal -offset indent
67struct protoent {
68	char	*p_name;	/* official name of protocol */
69	char	**p_aliases;	/* alias list */
70	int	p_proto;	/* protocol number */
71};
72.Ed
73.Pp
74The members of this structure are:
75.Bl -tag -width p_aliases
76.It Fa p_name
77The official name of the protocol.
78.It Fa p_aliases
79A zero terminated list of alternate names for the protocol.
80.It Fa p_proto
81The protocol number.
82.El
83.Pp
84The
85.Fn getprotoent
86function
87reads the next line of the file, opening the file if necessary.
88.Pp
89The
90.Fn setprotoent
91function
92opens and rewinds the file.
93If the
94.Fa stayopen
95flag is non-zero,
96the net data base will not be closed after each call to
97.Fn getprotobyname
98or
99.Fn getprotobynumber .
100.Pp
101The
102.Fn endprotoent
103function
104closes the file.
105.Pp
106The
107.Fn getprotobyname
108function
109and
110.Fn getprotobynumber
111sequentially search from the beginning
112of the file until a matching
113protocol name or
114protocol number is found,
115or until
116.Dv EOF
117is encountered.
118.Sh RETURN VALUES
119Null pointer returned on
120.Dv EOF
121or error.
122.Sh FILES
123.Bl -tag -width /etc/protocols -compact
124.It Pa /etc/protocols
125.El
126.Sh SEE ALSO
127.Xr protocols 5
128.Sh HISTORY
129The
130.Fn getprotoent ,
131.Fn getprotobynumber ,
132.Fn getprotobyname ,
133.Fn setprotoent ,
134and
135.Fn endprotoent
136functions appeared in
137.Bx 4.2 .
138.Sh BUGS
139These functions use a thread-specific data space;
140if the data is needed for future use, it should be
141copied before any subsequent calls overwrite it.
142Only the Internet
143protocols are currently understood.
144