summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/getnetent.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/getnetent.3')
-rw-r--r--src/lib/libc/net/getnetent.3153
1 files changed, 153 insertions, 0 deletions
diff --git a/src/lib/libc/net/getnetent.3 b/src/lib/libc/net/getnetent.3
new file mode 100644
index 0000000000..d4f0bedbf9
--- /dev/null
+++ b/src/lib/libc/net/getnetent.3
@@ -0,0 +1,153 @@
1.\" $NetBSD: getnetent.3,v 1.3 1995/02/25 06:20:32 cgd Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93
35.\"
36.Dd June 4, 1993
37.Dt GETNETENT 3
38.Os BSD 4.2
39.Sh NAME
40.Nm getnetent ,
41.Nm getnetbyaddr ,
42.Nm getnetbyname ,
43.Nm setnetent ,
44.Nm endnetent
45.Nd get network entry
46.Sh SYNOPSIS
47.Fd #include <netdb.h>
48.Ft struct netent *
49.Fn getnetent
50.Ft struct netent *
51.Fn getnetbyname "char *name"
52.Ft struct netent *
53.Fn getnetbyaddr "long net" "int type"
54.Fn setnetent "int stayopen"
55.Fn endnetent
56.Sh DESCRIPTION
57The
58.Fn getnetent ,
59.Fn getnetbyname ,
60and
61.Fn getnetbyaddr
62functions
63each return a pointer to an object with the
64following structure
65containing the broken-out
66fields of a line in the network data base,
67.Pa /etc/networks .
68.Bd -literal -offset indent
69struct netent {
70 char *n_name; /* official name of net */
71 char **n_aliases; /* alias list */
72 int n_addrtype; /* net number type */
73 unsigned long n_net; /* net number */
74};
75.Ed
76.Pp
77The members of this structure are:
78.Bl -tag -width n_addrtype
79.It Fa n_name
80The official name of the network.
81.It Fa n_aliases
82A zero terminated list of alternate names for the network.
83.It Fa n_addrtype
84The type of the network number returned; currently only AF_INET.
85.It Fa n_net
86The network number. Network numbers are returned in machine byte
87order.
88.El
89.Pp
90The
91.Fn getnetent
92function
93reads the next line of the file, opening the file if necessary.
94.Pp
95The
96.Fn setnetent
97function
98opens and rewinds the file. If the
99.Fa stayopen
100flag is non-zero,
101the net data base will not be closed after each call to
102.Fn getnetbyname
103or
104.Fn getnetbyaddr .
105.Pp
106The
107.Fn endnetent
108function
109closes the file.
110.Pp
111The
112.Fn getnetbyname
113function
114and
115.Fn getnetbyaddr
116sequentially search from the beginning
117of the file until a matching
118net name or
119net address and type is found,
120or until
121.Dv EOF
122is encountered.
123Network numbers are supplied in host order.
124.Sh FILES
125.Bl -tag -width /etc/networks -compact
126.It Pa /etc/networks
127.El
128.Sh DIAGNOSTICS
129Null pointer
130(0) returned on
131.Dv EOF
132or error.
133.Sh SEE ALSO
134.Xr networks 5
135.Sh HISTORY
136The
137.Fn getnetent ,
138.Fn getnetbyaddr ,
139.Fn getnetbyname ,
140.Fn setnetent ,
141and
142.Fn endnetent
143functions appeared in
144.Bx 4.2 .
145.Sh BUGS
146The data space used by
147these functions is static; if future use requires the data, it should be
148copied before any subsequent calls to these functions overwrite it.
149Only Internet network
150numbers are currently understood.
151Expecting network numbers to fit
152in no more than 32 bits is probably
153naive.