date and time created 88/12/16 11:12:32 by bostic
[unix-history] / usr / src / lib / libc / net / getnetent.3
CommitLineData
dc3d0ecb
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
ec178508 5.\" @(#)getnetent.3 6.3 (Berkeley) %G%
dc3d0ecb 6.\"
60557779 7.TH GETNETENT 3N ""
dc3d0ecb
KM
8.UC 5
9.SH NAME
10getnetent, getnetbyaddr, getnetbyname, setnetent, endnetent \- get network entry
11.SH SYNOPSIS
12.nf
13.ft B
14#include <netdb.h>
15.PP
16.ft B
17struct netent *getnetent()
18.PP
19.ft B
20struct netent *getnetbyname(name)
21char *name;
22.PP
23.ft B
f837eec2 24struct netent *getnetbyaddr(net, type)
dc3d0ecb 25long net;
f837eec2 26int type;
dc3d0ecb
KM
27.PP
28.ft B
29setnetent(stayopen)
f837eec2 30int stayopen;
dc3d0ecb
KM
31.PP
32.ft B
33endnetent()
34.fi
35.SH DESCRIPTION
36.IR Getnetent ,
37.IR getnetbyname ,
38and
39.I getnetbyaddr
40each return a pointer to an object with the
41following structure
42containing the broken-out
43fields of a line in the network data base,
44.IR /etc/networks .
45.RS
46.PP
47.nf
48struct netent {
f837eec2
JL
49 char *n_name; /* official name of net */
50 char **n_aliases; /* alias list */
51 int n_addrtype; /* net number type */
52 unsigned long n_net; /* net number */
dc3d0ecb
KM
53};
54.ft R
55.ad
56.fi
57.RE
58.PP
59The members of this structure are:
60.TP \w'n_addrtype'u+2n
61n_name
62The official name of the network.
63.TP \w'n_addrtype'u+2n
64n_aliases
65A zero terminated list of alternate names for the network.
66.TP \w'n_addrtype'u+2n
67n_addrtype
68The type of the network number returned; currently only AF_INET.
69.TP \w'n_addrtype'u+2n
70n_net
71The network number. Network numbers are returned in machine byte
72order.
73.PP
74.I Getnetent
75reads the next line of the file, opening the file if necessary.
76.PP
77.I Setnetent
78opens and rewinds the file. If the
79.I stayopen
80flag is non-zero,
81the net data base will not be closed after each call to
ec178508
JL
82.I getnetbyname
83or
84.IR getnetbyaddr .
dc3d0ecb
KM
85.PP
86.I Endnetent
87closes the file.
88.PP
89.I Getnetbyname
90and
91.I getnetbyaddr
92sequentially search from the beginning
93of the file until a matching
94net name or
f837eec2 95net address and type is found,
dc3d0ecb
KM
96or until EOF is encountered.
97Network numbers are supplied in host order.
98.SH FILES
99/etc/networks
100.SH "SEE ALSO"
101networks(5)
102.SH DIAGNOSTICS
103Null pointer
104(0) returned on EOF or error.
105.SH BUGS
106All information
107is contained in a static area
108so it must be copied if it is
109to be saved. Only Internet network
110numbers are currently understood.
111Expecting network numbers to fit
112in no more than 32 bits is probably
113naive.