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.3134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/lib/libc/net/getprotoent.3 b/src/lib/libc/net/getprotoent.3
new file mode 100644
index 0000000000..1f95529532
--- /dev/null
+++ b/src/lib/libc/net/getprotoent.3
@@ -0,0 +1,134 @@
1.\" $OpenBSD: getprotoent.3,v 1.8 2000/12/24 00:30:56 aaron Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
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
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt GETPROTOENT 3
36.Os
37.Sh NAME
38.Nm getprotoent ,
39.Nm getprotobynumber ,
40.Nm getprotobyname ,
41.Nm setprotoent ,
42.Nm endprotoent
43.Nd get protocol entry
44.Sh SYNOPSIS
45.Fd #include <netdb.h>
46.Ft struct protoent *
47.Fn getprotoent "void"
48.Ft struct protoent *
49.Fn getprotobyname "char *name"
50.Ft struct protoent *
51.Fn getprotobynumber "int proto"
52.Ft void
53.Fn setprotoent "int stayopen"
54.Ft void
55.Fn endprotoent "void"
56.Sh DESCRIPTION
57The
58.Fn getprotoent ,
59.Fn getprotobyname ,
60and
61.Fn getprotobynumber
62functions each return a pointer to an object with the following structure
63containing the broken-out fields of a line in the network protocol database,
64.Pa /etc/protocols .
65.Bd -literal -offset indent
66.Pp
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 reads the next line of the file, opening the file if necessary.
87.Pp
88The
89.Fn setprotoent
90function opens and rewinds the file.
91If the
92.Fa stayopen
93flag is non-zero,
94the net database will not be closed after each call to
95.Fn getprotobyname
96or
97.Fn getprotobynumber .
98.Pp
99The
100.Fn endprotoent
101function closes the file.
102.Pp
103The
104.Fn getprotobyname
105and
106.Fn getprotobynumber
107functions sequentially search from the beginning of the file until a
108matching protocol name or protocol number is found, or until
109.Dv EOF
110is encountered.
111.Sh RETURN VALUES
112Null pointer (0) returned on
113.Dv EOF
114or error.
115.Sh FILES
116.Bl -tag -width /etc/protocols -compact
117.It Pa /etc/protocols
118.El
119.Sh SEE ALSO
120.Xr protocols 5
121.Sh HISTORY
122The
123.Fn getprotoent ,
124.Fn getprotobynumber ,
125.Fn getprotobyname ,
126.Fn setprotoent ,
127and
128.Fn endprotoent
129functions appeared in
130.Bx 4.2 .
131.Sh BUGS
132These functions use a static data space; if the data is needed for future use,
133it should be copied before any subsequent calls overwrite it.
134Only the Internet protocols are currently understood.