Files
seta75D ff309bfe1c Init
2021-10-11 18:37:13 -03:00

135 lines
2.9 KiB
Plaintext

.\" @(#)getnetent.3n 1.1 94/10/31 SMI; from UCB 4.3
.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\"
.TH GETNETENT 3N "14 December 1987"
.SH NAME
getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry
.SH SYNOPSIS
.nf
.ft B
#include <netdb.h>
.ft
.fi
.LP
.nf
.ft B
struct netent *getnetent(\|)
.ft
.fi
.LP
.nf
.ft B
struct netent *getnetbyname(name)
char *name;
.ft
.fi
.LP
.nf
.ft B
struct netent *getnetbyaddr(net, type)
long net;
int type;
.ft
.fi
.LP
.nf
.ft B
setnetent (stayopen)
int stayopen;
.ft
.fi
.LP
.nf
.ft B
.BR endnetent (\|)
.ft R
.fi
.IX get "network entry \(em \fLgetnetent()\fR"
.IX "network entry, get \(em \fLgetnetent()\fR"
.IX "getnetent()" "" "\fLgetnetent()\fP \(em get network entry"
.IX "getnetbyaddr()" "" "\fLgetnetbyaddr()\fP \(em get network entry"
.IX "getnetbyname()" "" "\fLgetnetbyname()\fP \(em get network entry"
.IX "setnetent()" "" "\fLsetnetent()\fP \(em get network entry"
.IX "endnetent()" "" "\fLendnetent()\fP \(em get network entry"
.SH DESCRIPTION
.BR getnetent ,
.BR getnetbyname ,
and
.B getnetbyaddr(\|)
each return a pointer to an object with the following structure
containing the broken-out fields of a line in the network data base,
.BR /etc/networks .
.RS
.LP
.nf
.ft B
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
.LP
The members of this structure are:
.TP 20
.B n_name
The official name of the network.
.TP
.B n_aliases
A zero terminated list of alternate names for the network.
.TP
.B n_addrtype
The type of the network number returned; currently only
.BR \s-1AF_INET\s0 .
.TP
.B n_net
The network number. Network numbers are returned in machine byte order.
.LP
.B getnetent(\|)
reads the next line of the file, opening the file if necessary.
.LP
.B setnetent(\|)
opens and rewinds the file. If the
.I stayopen
flag is non-zero, the net data base will not be closed after each call to
.B setnetent(\|)
(either directly, or indirectly through one of
the other \*(lqgetnet\*(rq calls).
.LP
.B endnetent(\|)
closes the file.
.LP
.B getnetbyname(\|)
and
.B getnetbyaddr(\|)
sequentially search from the beginning of the file until a matching
net name or net address and type is found, or until end-of-file
is encountered.
Network numbers are supplied in host order.
.SH FILES
.PD 0
.TP 20
.B /etc/networks
.\" .TP
.\" .BI /var/yp/ domainname /networks.byname
.\" .TP
.\" .BI /var/yp/ domainname /networks.byaddr
.PD
.SH "SEE ALSO"
.BR networks (5),
.BR ypserv (8)
.SH DIAGNOSTICS
A
.SM NULL
pointer is returned on end-of-file or error.
.SH BUGS
All information is contained in a static area so it must be copied if it is
to be saved.
.LP
Only Internet network numbers are currently understood.