.\" @(#)getnetent 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} getnetent 3N "" "\&"
.if \nX=1 .ds x} getnetent 3N ""
.if \nX=2 .ds x} getnetent 3N "" "\&"
.if \nX=3 .ds x} getnetent "" "" "\&"
.TH \*(x}
.SH NAME
\f4getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent\fP \- get network entry
.SH SYNOPSIS
.nf
.ft 4
.\" please check the location of the following include file
#include <netdb.h>
.P
.ft 4
struct netent *getnetent(\|)
.P
.ft 4
struct netent *getnetbyname(name)
char *name;
.P
.ft 4
struct netent *getnetbyaddr(net, type)
long net;
int type;
.P
.ft 4
setnetent(stayopen)
int stayopen;
.P
.ft 4
endnetent(\|)
.ft R
.fi
.SH DESCRIPTION
.P
\f4getnetent(\|)\f1,
\f4getnetbyname(\|)\f1,
and
\f4getnetbyaddr(\|)\f1
each return a pointer to an object with the following structure
containing the broken-out fields of a line in the network data base,
\f4/etc/networks\f1.
.P
.RS
.nf
.ft 4
struct	netent {
	char	*n_name;        /* official name of net */
	char	**n_aliases;    /* alias list */
	int	n_addrtype;     /* net number type */
	long	n_net;          /* net number */
};
.ft R
.fi
.RE
.P
The members of this structure are:
.RS
.TP .75i
\f2n_name\f1
The official name of the network.
.TP
\f2n_aliases\f1
A zero terminated list of alternate names for the network.
.TP
\f2n_addrtype\f1
The type of the network number returned; currently only
\f4\s-1AF_INET\s0\f1.
.TP
\f2n_net\f1
The network number.
Network numbers are returned in machine byte order.
.RE
.P
\f4getnetent(\|)\f1
reads the next line of the file, opening the file if necessary.
.P
\f4setnetent(\|)\f1
opens and rewinds the file.
If the
\f2stayopen\f1
flag is non-zero,
the net data base will not be closed after each call to
\f4getnetent(\|)\f1
(either directly, or indirectly through one of
the other \*(lqgetnet\*(rq calls).
.P
\f4endnetent(\|)\f1
closes the file.
.P
\f4getnetbyname(\|)\f1
and
\f4getnetbyaddr(\|)\f1
sequentially search from the beginning of the file until a matching
net name or net address and type is found, or until 
\s-1EOF\s0
is encountered.
Network numbers are supplied in host order.
.SH FILES
.PD 0
.TP 20
\f4/etc/networks\f1
.PD
.SH "SEE ALSO"
\f4networks\f1(4)
.SH DIAGNOSTICS
.P
A
\s-1NULL\s0
pointer is returned on 
\s-1EOF\s0
or error.
.br
.ne 5
.SH BUGS
.P
All information is contained in a static area so it must be copied if it is
to be saved.
.P
Only Internet network numbers are currently understood.
