Debian Codegraph @

upstream/debian-trixie/man3/getprotoent.3

raw
1 '\" t
2 .\" Copyright 1993 David Metcalfe ([email protected])
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
9 .\" 386BSD man pages
10 .\" Modified Sat Jul 24 19:26:03 1993 by Rik Faith ([email protected])
11 .TH getprotoent 3 2024-05-02 "Linux man-pages 6.9.1"
12 .SH NAME
13 getprotoent, getprotobyname, getprotobynumber, setprotoent,
14 endprotoent \- get protocol entry
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS
19 .nf
20 .B #include <netdb.h>
21 .P
22 .B struct protoent *getprotoent(void);
23 .P
24 .BI "struct protoent *getprotobyname(const char *" name );
25 .BI "struct protoent *getprotobynumber(int " proto );
26 .P
27 .BI "void setprotoent(int " stayopen );
28 .B void endprotoent(void);
29 .fi
30 .SH DESCRIPTION
31 The
32 .BR getprotoent ()
33 function reads the next entry from the protocols database (see
34 .BR protocols (5))
35 and returns a
36 .I protoent
37 structure
38 containing the broken-out fields from the entry.
39 A connection is opened to the database if necessary.
40 .P
41 The
42 .BR getprotobyname ()
43 function returns a
44 .I protoent
45 structure
46 for the entry from the database
47 that matches the protocol name
48 .IR name .
49 A connection is opened to the database if necessary.
50 .P
51 The
52 .BR getprotobynumber ()
53 function returns a
54 .I protoent
55 structure
56 for the entry from the database
57 that matches the protocol number
58 .IR number .
59 A connection is opened to the database if necessary.
60 .P
61 The
62 .BR setprotoent ()
63 function opens a connection to the database,
64 and sets the next entry to the first entry.
65 If
66 .I stayopen
67 is nonzero,
68 then the connection to the database
69 will not be closed between calls to one of the
70 .BR getproto* ()
71 functions.
72 .P
73 The
74 .BR endprotoent ()
75 function closes the connection to the database.
76 .P
77 The
78 .I protoent
79 structure is defined in
80 .I <netdb.h>
81 as follows:
82 .P
83 .in +4n
84 .EX
85 struct protoent {
86 char *p_name; /* official protocol name */
87 char **p_aliases; /* alias list */
88 int p_proto; /* protocol number */
89 }
90 .EE
91 .in
92 .P
93 The members of the
94 .I protoent
95 structure are:
96 .TP
97 .I p_name
98 The official name of the protocol.
99 .TP
100 .I p_aliases
101 A NULL-terminated list of alternative names for the protocol.
102 .TP
103 .I p_proto
104 The protocol number.
105 .SH RETURN VALUE
106 The
107 .BR getprotoent (),
108 .BR getprotobyname (),
109 and
110 .BR getprotobynumber ()
111 functions return a pointer to a
112 statically allocated
113 .I protoent
114 structure, or a null pointer if an
115 error occurs or the end of the file is reached.
116 .SH FILES
117 .PD 0
118 .TP
119 .I /etc/protocols
120 protocol database file
121 .PD
122 .SH ATTRIBUTES
123 For an explanation of the terms used in this section, see
124 .BR attributes (7).
125 .TS
126 allbox;
127 lb lb lbx
128 l l l.
129 Interface Attribute Value
130 T{
131 .na
132 .nh
133 .BR getprotoent ()
134 T} Thread safety T{
135 .na
136 .nh
137 MT-Unsafe race:protoent
138 race:protoentbuf locale
139 T}
140 T{
141 .na
142 .nh
143 .BR getprotobyname ()
144 T} Thread safety T{
145 .na
146 .nh
147 MT-Unsafe race:protobyname
148 locale
149 T}
150 T{
151 .na
152 .nh
153 .BR getprotobynumber ()
154 T} Thread safety T{
155 .na
156 .nh
157 MT-Unsafe race:protobynumber
158 locale
159 T}
160 T{
161 .na
162 .nh
163 .BR setprotoent (),
164 .BR endprotoent ()
165 T} Thread safety T{
166 .na
167 .nh
168 MT-Unsafe race:protoent
169 locale
170 T}
171 .TE
172 .P
173 In the above table,
174 .I protoent
175 in
176 .I race:protoent
177 signifies that if any of the functions
178 .BR setprotoent (),
179 .BR getprotoent (),
180 or
181 .BR endprotoent ()
182 are used in parallel in different threads of a program,
183 then data races could occur.
184 .SH STANDARDS
185 POSIX.1-2008.
186 .SH HISTORY
187 POSIX.1-2001, 4.3BSD.
188 .SH SEE ALSO
189 .BR getnetent (3),
190 .BR getprotoent_r (3),
191 .BR getservent (3),
192 .BR protocols (5)