mount_setattr.2: ffix
[man-pages.git] / man3 / getprotoent.3
bloba0a220a303f8b1da741735f7b8fef4af2b800eab
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 19:26:03 1993 by Rik Faith (faith@cs.unc.edu)
30 .TH GETPROTOENT 3  2021-03-22 "GNU" "Linux Programmer's Manual"
31 .SH NAME
32 getprotoent, getprotobyname, getprotobynumber, setprotoent,
33 endprotoent \- get protocol entry
34 .SH SYNOPSIS
35 .nf
36 .B #include <netdb.h>
37 .PP
38 .B struct protoent *getprotoent(void);
39 .PP
40 .BI "struct protoent *getprotobyname(const char *" name );
41 .BI "struct protoent *getprotobynumber(int " proto );
42 .PP
43 .BI "void setprotoent(int " stayopen );
44 .B void endprotoent(void);
45 .fi
46 .SH DESCRIPTION
47 The
48 .BR getprotoent ()
49 function reads the next entry from the protocols database (see
50 .BR protocols (5))
51 and returns a
52 .I protoent
53 structure
54 containing the broken-out fields from the entry.
55 A connection is opened to the database if necessary.
56 .PP
57 The
58 .BR getprotobyname ()
59 function returns a
60 .I protoent
61 structure
62 for the entry from the database
63 that matches the protocol name
64 .IR name .
65 A connection is opened to the database if necessary.
66 .PP
67 The
68 .BR getprotobynumber ()
69 function returns a
70 .I protoent
71 structure
72 for the entry from the database
73 that matches the protocol number
74 .IR number .
75 A connection is opened to the database if necessary.
76 .PP
77 The
78 .BR setprotoent ()
79 function opens a connection to the database,
80 and sets the next entry to the first entry.
82 .I stayopen
83 is nonzero,
84 then the connection to the database
85 will not be closed between calls to one of the
86 .BR getproto* ()
87 functions.
88 .PP
89 The
90 .BR endprotoent ()
91 function closes the connection to the database.
92 .PP
93 The
94 .I protoent
95 structure is defined in
96 .I <netdb.h>
97 as follows:
98 .PP
99 .in +4n
101 struct protoent {
102     char  *p_name;       /* official protocol name */
103     char **p_aliases;    /* alias list */
104     int    p_proto;      /* protocol number */
109 The members of the
110 .I protoent
111 structure are:
113 .I p_name
114 The official name of the protocol.
116 .I p_aliases
117 A NULL-terminated list of alternative names for the protocol.
119 .I p_proto
120 The protocol number.
121 .SH RETURN VALUE
123 .BR getprotoent (),
124 .BR getprotobyname (),
126 .BR getprotobynumber ()
127 functions return a pointer to a
128 statically allocated
129 .I protoent
130 structure, or a null pointer if an
131 error occurs or the end of the file is reached.
132 .SH FILES
133 .PD 0
135 .I /etc/protocols
136 protocol database file
138 .SH ATTRIBUTES
139 For an explanation of the terms used in this section, see
140 .BR attributes (7).
141 .ad l
144 allbox;
145 lb lb lbx
146 l l l.
147 Interface       Attribute       Value
149 .BR getprotoent ()
150 T}      Thread safety   T{
151 MT-Unsafe race:protoent
152 race:protoentbuf locale
155 .BR getprotobyname ()
156 T}      Thread safety   T{
157 MT-Unsafe race:protobyname
158 locale
161 .BR getprotobynumber ()
162 T}      Thread safety   T{
163 MT-Unsafe race:protobynumber
164 locale
167 .BR setprotoent (),
168 .BR endprotoent ()
169 T}      Thread safety   T{
170 MT-Unsafe race:protoent
171 locale
176 .sp 1
177 In the above table,
178 .I protoent
180 .I race:protoent
181 signifies that if any of the functions
182 .BR setprotoent (),
183 .BR getprotoent (),
185 .BR endprotoent ()
186 are used in parallel in different threads of a program,
187 then data races could occur.
188 .SH CONFORMING TO
189 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
190 .SH SEE ALSO
191 .BR getnetent (3),
192 .BR getprotoent_r (3),
193 .BR getservent (3),
194 .BR protocols (5)