.\" @(#)getprotoent 40.6 90/01/29 SMI; from UCB 4.3
.\" Copyright 1989 AT&T
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved.  The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.nr X
.if \nX=0 .ds x} getprotoent 3N "" "\&"
.if \nX=1 .ds x} getprotoent 3N ""
.if \nX=2 .ds x} getprotoent 3N "" "\&"
.if \nX=3 .ds x} getprotoent "" "" "\&"
.TH \*(x}
.SH NAME
\f4getprotoent, getprotobynumber, getprotobyname, setprotoent, endprotoent\fP \- get protocol entry
.SH SYNOPSIS
.nf
.ft 4
.\"please check the location of the following include file
\f4#include <netdb.h>\fR
.P
.ft 4
struct protoent *getprotoent(\|)
.P
.ft 4
struct protoent *getprotobyname(name)
char *name;
.P
.ft 4
struct protoent *getprotobynumber(proto)
int proto;
.P
.ft 4
setprotoent(stayopen)
int stayopen;
.P
.ft 4
endprotoent(\|)
.fi
.SH DESCRIPTION
.P
\f4getprotoent(\|)\fR,
\f4getprotobyname(\|)\fR,
and
\f4getprotobynumber(\|)\fR
each return a pointer to an object with the
following structure containing the broken-out
fields of a line in the network protocol data base,
\f4/etc/protocols\fR.
.P
.RS
.nf
.ft 4
struct	protoent {
	char	*p_name;        /* official name of protocol */
	char	**p_aliases;    /* alias list */
	int	p_proto;        /* protocol number */
};
.ft R
.fi
.RE
.P
The members of this structure are:
.RS
.TP 20
\f2p_name\fR
The official name of the protocol.
.TP
\f2p_aliases\fR
A zero terminated list of alternate names for the protocol.
.TP
\f2p_proto\fR
The protocol number.
.RE
.P
\f4getprotoent(\|)\fR
reads the next line of the file, opening the file if necessary.
.P
\f4setprotoent(\|)\fR
opens and rewinds the file.
If the
\f2stayopen\fR
flag is non-zero,
the net data base will not be closed after each call to
\f4getprotoent(\|)\fR
(either directly, or indirectly through one of
the other \*(lqgetproto\*(rq calls).
.P
\f4endprotoent(\|)\fR
closes the file.
.P
\f4getprotobyname(\|)\fR
and
\f4getprotobynumber(\|)\fR
sequentially search from the beginning
of the file until a matching protocol name or
protocol number is found, or until an
\s-1EOF\s0
is encountered.
.SH FILES
.PD 0
.TP 20
\f4/etc/protocols\fR
.PD
.SH "SEE ALSO"
\f4protocols\fR(4)
.SH DIAGNOSTICS
.P
A
\s-1NULL\s0
pointer is returned on an
\s-1EOF\s0
or error.
.P
All information is contained in a static area
so it must be copied if it is to be saved.
Only the Internet protocols are currently understood.
