Debian Codegraph @

upstream/debian-unstable/man3/getprotoent.3

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