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