]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/net/getprotoent.3
sqlite3: Vendor import of sqlite3 3.43.1
[FreeBSD/FreeBSD.git] / lib / libc / net / getprotoent.3
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
55 The
56 .Fn getprotoent ,
57 .Fn getprotobyname ,
58 and
59 .Fn getprotobynumber
60 functions
61 each return a pointer to an object with the
62 following structure
63 containing the broken-out
64 fields of a line in the network protocol data base,
65 .Pa /etc/protocols .
66 .Bd -literal -offset indent
67 struct 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
74 The members of this structure are:
75 .Bl -tag -width p_aliases
76 .It Fa p_name
77 The official name of the protocol.
78 .It Fa p_aliases
79 A zero terminated list of alternate names for the protocol.
80 .It Fa p_proto
81 The protocol number.
82 .El
83 .Pp
84 The
85 .Fn getprotoent
86 function
87 reads the next line of the file, opening the file if necessary.
88 .Pp
89 The
90 .Fn setprotoent
91 function
92 opens and rewinds the file.
93 If the
94 .Fa stayopen
95 flag is non-zero,
96 the net data base will not be closed after each call to
97 .Fn getprotobyname
98 or
99 .Fn getprotobynumber .
100 .Pp
101 The
102 .Fn endprotoent
103 function
104 closes the file.
105 .Pp
106 The
107 .Fn getprotobyname
108 function
109 and
110 .Fn getprotobynumber
111 sequentially search from the beginning
112 of the file until a matching
113 protocol name or
114 protocol number is found,
115 or until
116 .Dv EOF
117 is encountered.
118 .Sh RETURN VALUES
119 Null pointer returned on
120 .Dv EOF
121 or 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
129 The
130 .Fn getprotoent ,
131 .Fn getprotobynumber ,
132 .Fn getprotobyname ,
133 .Fn setprotoent ,
134 and
135 .Fn endprotoent
136 functions appeared in
137 .Bx 4.2 .
138 .Sh BUGS
139 These functions use a thread-specific data space;
140 if the data is needed for future use, it should be
141 copied before any subsequent calls overwrite it.
142 Only the Internet
143 protocols are currently understood.