OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / original / man3 / getnetent.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 21:48:06 1993 by Rik Faith (faith@cs.unc.edu)
30 .TH GETNETENT 3  2008-08-19 "GNU" "Linux Programmer's Manual"
31 .SH NAME
32 getnetent, getnetbyname, getnetbyaddr, setnetent, endnetent \-
33 get network entry
34 .SH SYNOPSIS
35 .nf
36 .B #include <netdb.h>
37 .sp
38 .B struct netent *getnetent(void);
39 .sp
40 .BI "struct netent *getnetbyname(const char *" name );
41 .sp
42 .BI "struct netent *getnetbyaddr(uint32_t " net ", int " type );
43 .sp
44 .BI "void setnetent(int " stayopen );
45 .sp
46 .B void endnetent(void);
47 .fi
48 .SH DESCRIPTION
49 The
50 .BR getnetent ()
51 function reads the next entry from the networks database
52 and returns a
53 .I netent
54 structure containing
55 the broken-out fields from the entry.
56 A connection is opened to the database if necessary.
57 .PP
58 The
59 .BR getnetbyname ()
60 function returns a
61 .I netent
62 structure
63 for the entry from the database
64 that matches the network
65 .IR name .
66 .PP
67 The
68 .BR getnetbyaddr ()
69 function returns a
70 .I netent
71 structure
72 for the entry from the database
73 that matches the network number
74 .I net
75 of type
76 .IR type .
77 The
78 .I net
79 argument must be in host byte order.
80 .PP
81 The
82 .BR setnetent ()
83 function opens a connection to the database,
84 and sets the next entry to the first entry.
85 If
86 .I stayopen
87 is nonzero,
88 then the connection to the database
89 will not be closed between calls to one of the
90 .BR getnet* ()
91 functions.
92 .PP
93 The
94 .BR endnetent ()
95 function closes the connection to the database.
96 .PP
97 The
98 .I netent
99 structure is defined in
100 .I <netdb.h>
101 as follows:
102 .sp
103 .in +4n
104 .nf
105 struct netent {
106     char      *n_name;     /* official network name */
107     char     **n_aliases;  /* alias list */
108     int        n_addrtype; /* net address type */
109     uint32_t   n_net;      /* network number */
110 }
111 .fi
112 .in
113 .PP
114 The members of the
115 .I netent
116 structure are:
117 .TP
118 .I n_name
119 The official name of the network.
120 .TP
121 .I n_aliases
122 A NULL-terminated list of alternative names for the network.
123 .TP
124 .I n_addrtype
125 The type of the network number; always
126 .BR AF_INET .
127 .TP
128 .I n_net
129 The network number in host byte order.
130 .SH RETURN VALUE
131 The
132 .BR getnetent (),
133 .BR getnetbyname ()
134 and
135 .BR getnetbyaddr ()
136 functions return a pointer to a
137 statically allocated
138 .I netent
139 structure, or a null pointer if an
140 error occurs or the end of the file is reached.
141 .SH FILES
142 .TP
143 .I /etc/networks
144 networks database file
145 .SH CONFORMING TO
146 4.3BSD, POSIX.1-2001.
147 .SH NOTES
148 In glibc versions before 2.2, the
149 .I net
150 argument of
151 .BR getnetbyaddr ()
152 was of type
153 .IR long .
154 .SH SEE ALSO
155 .BR getnetent_r (3),
156 .BR getprotoent (3),
157 .BR getservent (3)
158 .\" .BR networks (5)
159 .br
160 RFC\ 1101
161 .SH COLOPHON
162 This page is part of release 3.79 of the Linux
163 .I man-pages
164 project.
165 A description of the project,
166 information about reporting bugs,
167 and the latest version of this page,
168 can be found at
169 \%http://www.kernel.org/doc/man\-pages/.