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