man-pages/man3/getprotoent.3.html
2021-03-31 01:06:50 +01:00

280 lines
5.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GETPROTOENT</TITLE>
</HEAD><BODY>
<H1>GETPROTOENT</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
getprotoent, getprotobyname, getprotobynumber, setprotoent,
endprotoent - get protocol entry
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/netdb.h">netdb.h</A>&gt;</B>
<B>struct protoent *getprotoent(void);</B>
<B>struct protoent *getprotobyname(const char *</B><I>name</I><B>);</B>
<B>struct protoent *getprotobynumber(int </B><I>proto</I><B>);</B>
<B>void setprotoent(int </B><I>stayopen</I><B>);</B>
<B>void endprotoent(void);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>getprotoent</B>()
function reads the next entry from the protocols database (see
<B><A HREF="/cgi-bin/man/man2html?5+protocols">protocols</A></B>(5))
and returns a
<I>protoent</I>
structure
containing the broken-out fields from the entry.
A connection is opened to the database if necessary.
<P>
The
<B>getprotobyname</B>()
function returns a
<I>protoent</I>
structure
for the entry from the database
that matches the protocol name
<I>name</I>.
A connection is opened to the database if necessary.
<P>
The
<B>getprotobynumber</B>()
function returns a
<I>protoent</I>
structure
for the entry from the database
that matches the protocol number
<I>number</I>.
A connection is opened to the database if necessary.
<P>
The
<B>setprotoent</B>()
function opens a connection to the database,
and sets the next entry to the first entry.
If
<I>stayopen</I>
is nonzero,
then the connection to the database
will not be closed between calls to one of the
<B>getproto*</B>()
functions.
<P>
The
<B>endprotoent</B>()
function closes the connection to the database.
<P>
The
<I>protoent</I>
structure is defined in
<I>&lt;<A HREF="file:///usr/include/netdb.h">netdb.h</A>&gt;</I>
as follows:
<P>
struct protoent {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;&nbsp;*p_name;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;official&nbsp;protocol&nbsp;name&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;**p_aliases;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;alias&nbsp;list&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;p_proto;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;protocol&nbsp;number&nbsp;*/
}
<P>
The members of the
<I>protoent</I>
structure are:
<DL COMPACT>
<DT id="1"><I>p_name</I>
<DD>
The official name of the protocol.
<DT id="2"><I>p_aliases</I>
<DD>
A NULL-terminated list of alternative names for the protocol.
<DT id="3"><I>p_proto</I>
<DD>
The protocol number.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The
<B>getprotoent</B>(),
<B>getprotobyname</B>()
and
<B>getprotobynumber</B>()
functions return a pointer to a
statically allocated
<I>protoent</I>
structure, or a null pointer if an
error occurs or the end of the file is reached.
<A NAME="lbAF">&nbsp;</A>
<H2>FILES</H2>
<DL COMPACT>
<DT id="4"><I>/etc/protocols</I>
<DD>
protocol database file
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>getprotoent</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:protoent
<BR>
race:protoentbuf locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getprotobyname</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:protobyname
<BR>
locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getprotobynumber</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:protobynumber
<BR>
locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>setprotoent</B>(),
<BR>
<B>endprotoent</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:protoent
<BR>
locale
<BR></TD></TR>
</TABLE>
<P>
In the above table,
<I>protoent</I>
in
<I>race:protoent</I>
signifies that if any of the functions
<B>setprotoent</B>(),
<B>getprotoent</B>(),
or
<B>endprotoent</B>()
are used in parallel in different threads of a program,
then data races could occur.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008, 4.3BSD.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+getnetent">getnetent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getprotoent_r">getprotoent_r</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+getservent">getservent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?5+protocols">protocols</A></B>(5)
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="9"><A HREF="#lbAF">FILES</A><DD>
<DT id="10"><A HREF="#lbAG">ATTRIBUTES</A><DD>
<DT id="11"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="12"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="13"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:44 GMT, March 31, 2021
</BODY>
</HTML>