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