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.3130
1 files changed, 130 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..be257966a2
--- /dev/null
+++ b/src/lib/libc/net/getprotoent.3
@@ -0,0 +1,130 @@
1.\" $OpenBSD: getprotoent.3,v 1.9 2003/06/02 20:18:35 millert 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. Neither the name of the University nor the names of its contributors
15.\" may be used to endorse or promote products derived from this software
16.\" without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
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 SYNOPSIS
41.Fd #include <netdb.h>
42.Ft struct protoent *
43.Fn getprotoent "void"
44.Ft struct protoent *
45.Fn getprotobyname "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 each return a pointer to an object with the following structure
59containing the broken-out fields of a line in the network protocol database,
60.Pa /etc/protocols .
61.Bd -literal -offset indent
62.Pp
63struct protoent {
64 char *p_name; /* official name of protocol */
65 char **p_aliases; /* alias list */
66 int p_proto; /* protocol number */
67};
68.Ed
69.Pp
70The members of this structure are:
71.Bl -tag -width p_aliases
72.It Fa p_name
73The official name of the protocol.
74.It Fa p_aliases
75A zero-terminated list of alternate names for the protocol.
76.It Fa p_proto
77The protocol number.
78.El
79.Pp
80The
81.Fn getprotoent
82function reads the next line of the file, opening the file if necessary.
83.Pp
84The
85.Fn setprotoent
86function opens and rewinds the file.
87If the
88.Fa stayopen
89flag is non-zero,
90the net database will not be closed after each call to
91.Fn getprotobyname
92or
93.Fn getprotobynumber .
94.Pp
95The
96.Fn endprotoent
97function closes the file.
98.Pp
99The
100.Fn getprotobyname
101and
102.Fn getprotobynumber
103functions sequentially search from the beginning of the file until a
104matching protocol name or protocol number is found, or until
105.Dv EOF
106is encountered.
107.Sh RETURN VALUES
108Null pointer (0) returned on
109.Dv EOF
110or error.
111.Sh FILES
112.Bl -tag -width /etc/protocols -compact
113.It Pa /etc/protocols
114.El
115.Sh SEE ALSO
116.Xr protocols 5
117.Sh HISTORY
118The
119.Fn getprotoent ,
120.Fn getprotobynumber ,
121.Fn getprotobyname ,
122.Fn setprotoent ,
123and
124.Fn endprotoent
125functions appeared in
126.Bx 4.2 .
127.Sh BUGS
128These functions use a static data space; if the data is needed for future use,
129it should be copied before any subsequent calls overwrite it.
130Only the Internet protocols are currently understood.