update from main archive 961001
[glibc.git] / resolv / netdb.h
blob954085f97d586c4b0d27988cfbb1726ee28f2b50
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 59 Temple Place -
17 Suite 330, Boston, MA 02111-1307, USA. */
19 /* All data returned by the network data base library are supplied in
20 host order and returned in network order (suitable for use in
21 system calls). */
23 #ifndef _NETDB_H
25 #define _NETDB_H 1
26 #include <features.h>
28 /* This is necessary to make this include file properly replace the
29 Sun version. */
30 #include <rpc/netdb.h>
32 /* Absolute file name for network data base files. */
33 #define _PATH_HEQUIV "/etc/hosts.equiv"
34 #define _PATH_HOSTS "/etc/hosts"
35 #define _PATH_NETWORKS "/etc/networks"
36 #define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
37 #define _PATH_PROTOCOLS "/etc/protocols"
38 #define _PATH_SERVICES "/etc/services"
41 __BEGIN_DECLS
43 /* Error status for non-reentrant lookup functions. */
44 extern int h_errno;
46 #if defined __USE_REENTRANT && (!defined _LIBC || defined _LIBC_REENTRANT)
47 /* Function to access thread specific `h_errno' variable. */
48 extern int *__h_errno_location __P ((void)) __attribute__ ((__const__));
50 /* An alias name for above variable. */
51 extern int __h_errno;
53 /* Use a macro to access always the thread specific `h_errno' variable. */
54 #define h_errno (*__h_errno_location ())
56 /* Retain some binary compatibility with old libraries by having both the
57 global variable and the per-thread variable set on error. */
58 #define __set_h_errno(x) (h_errno = __h_errno = (x))
59 #else
60 #define __set_h_errno(x) (h_errno = (x))
61 #endif
63 /* Possible values left in `h_errno'. */
64 #define NETDB_INTERNAL -1 /* See errno. */
65 #define NETDB_SUCCESS 0 /* No problem. */
66 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
67 #define TRY_AGAIN 2 /* Non-Authoritive Host not found,
68 or SERVERFAIL. */
69 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
70 NOTIMP. */
71 #define NO_DATA 4 /* Valid name, no data record of requested
72 type. */
73 #define NO_ADDRESS NO_DATA /* No address, look for MX record. */
75 /* Print error indicated by `h_errno' variable on standard error. STR
76 if non-null is printed before the error string. */
77 extern void herror __P ((__const char *__str));
79 /* Return string associated with error ERR_NUM. */
80 extern __const char *hstrerror __P ((int __err_num));
84 /* Description of data base entry for a single host. */
85 struct hostent
87 char *h_name; /* Official name of host. */
88 char **h_aliases; /* Alias list. */
89 int h_addrtype; /* Host address type. */
90 int h_length; /* Length of address. */
91 char **h_addr_list; /* List of addresses from name server. */
92 #define h_addr h_addr_list[0] /* Address, for backward compatiblity. */
95 /* Open host data base files and mark them as staying open even after
96 a later search if STAY_OPEN is non-zero. */
97 extern void sethostent __P ((int __stay_open));
99 /* Close host data base files and clear `stay open' flag. */
100 extern void endhostent __P ((void));
102 /* Get next entry from host data base file. Open data base if
103 necessary. */
104 extern struct hostent *gethostent __P ((void));
106 /* Return entry from host data base which address match ADDR with
107 length LEN and type TYPE. */
108 extern struct hostent *gethostbyaddr __P ((__const char *__addr, int __len,
109 int __type));
111 /* Return entry from host data base for host with NAME. */
112 extern struct hostent *gethostbyname __P ((__const char *__name));
114 /* Return entry from host data base for host with NAME. AF must be
115 set to the address type which as `AF_INET' for IPv4 or `AF_INET6'
116 for IPv6. */
117 extern struct hostent *gethostbyname2 __P ((__const char *__name, int __af));
119 #ifdef __USE_REENTRANT
120 /* Reentrant versions of the functions above. The additional
121 arguments specify a buffer of BUFLEN starting at BUF. The last
122 argument is a pointer to a variable which gets the value which
123 would be stored in the global variable `herrno' by the
124 non-reentrant functions. */
125 extern struct hostent *__gethostent_r __P ((struct hostent *__result_buf,
126 char *__buf, int __buf_len,
127 int *__h_errnop));
128 extern struct hostent *gethostent_r __P ((struct hostent *__result_buf,
129 char *__buf, int __buf_len,
130 int *__h_errnop));
132 extern struct hostent *__gethostbyaddr_r __P ((__const char *__addr, int __len,
133 int __type,
134 struct hostent *__result_buf,
135 char *__buf, int __buflen,
136 int *__h_errnop));
137 extern struct hostent *gethostbyaddr_r __P ((__const char *__addr, int __len,
138 int __type,
139 struct hostent *__result_buf,
140 char *__buf, int __buflen,
141 int *__h_errnop));
143 extern struct hostent *__gethostbyname_r __P ((__const char *__name,
144 struct hostent *__result_buf,
145 char *__buf, int __buflen,
146 int *__h_errnop));
147 extern struct hostent *gethostbyname_r __P ((__const char *__name,
148 struct hostent *__result_buf,
149 char *__buf, int __buflen,
150 int *__h_errnop));
152 extern struct hostent *__gethostbyname2_r __P ((__const char *__name, int __af,
153 struct hostent *__result_buf,
154 char *__buf, int __buflen,
155 int *__h_errnop));
156 extern struct hostent *gethostbyname2_r __P ((__const char *__name, int __af,
157 struct hostent *__result_buf,
158 char *__buf, int __buflen,
159 int *__h_errnop));
160 #endif /* reentrant */
163 /* Description of data base entry for a single network. NOTE: here a
164 poor assumption is made. The network number is expected to fit
165 into an unsigned long int variable. */
166 struct netent
168 char *n_name; /* Official name of network. */
169 char **n_aliases; /* Alias list. */
170 int n_addrtype; /* Net address type. */
171 unsigned long int n_net; /* Network number. */
174 /* Open network data base files and mark them as staying open even
175 after a later search if STAY_OPEN is non-zero. */
176 extern void setnetent __P ((int __stay_open));
178 /* Close network data base files and clear `stay open' flag. */
179 extern void endnetent __P ((void));
181 /* Get next entry from network data base file. Open data base if
182 necessary. */
183 extern struct netent *getnetent __P ((void));
185 /* Return entry from network data base which address match NET and
186 type TYPE. */
187 extern struct netent *getnetbyaddr __P ((unsigned long int __net,
188 int __type));
190 /* Return entry from network data base for network with NAME. */
191 extern struct netent *getnetbyname __P ((__const char *__name));
193 #ifdef __USE_REENTRANT
194 /* Reentrant versions of the functions above. The additional
195 arguments specify a buffer of BUFLEN starting at BUF. The last
196 argument is a pointer to a variable which gets the value which
197 would be stored in the global variable `herrno' by the
198 non-reentrant functions. */
199 extern struct netent *__getnetent_r __P ((struct netent *__result_buf,
200 char *__buf, int __buf_len,
201 int *__h_errnop));
202 extern struct netent *getnetent_r __P ((struct netent *__result_buf,
203 char *__buf, int __buf_len,
204 int *__h_errnop));
206 extern struct netent *__getnetbyaddr_r __P ((unsigned long int __net,
207 int __type,
208 struct netent *__result_buf,
209 char *__buf, int __buflen,
210 int *__h_errnop));
211 extern struct netent *getnetbyaddr_r __P ((unsigned long int __net,
212 int __type,
213 struct netent *__result_buf,
214 char *__buf, int __buflen,
215 int *__h_errnop));
217 extern struct netent *__getnetbyname_r __P ((__const char *__name,
218 struct netent *__result_buf,
219 char *__buf, int __buflen,
220 int *__h_errnop));
221 extern struct netent *getnetbyname_r __P ((__const char *__name,
222 struct netent *__result_buf,
223 char *__buf, int __buflen,
224 int *__h_errnop));
225 #endif /* reentrant */
228 /* Description of data base entry for a single service. */
229 struct servent
231 char *s_name; /* Official service name. */
232 char **s_aliases; /* Alias list. */
233 int s_port; /* Port number. */
234 char *s_proto; /* Protocol to use. */
237 /* Open service data base files and mark them as staying open even
238 after a later search if STAY_OPEN is non-zero. */
239 extern void setservent __P ((int __stay_open));
241 /* Close service data base files and clear `stay open' flag. */
242 extern void endservent __P ((void));
244 /* Get next entry from service data base file. Open data base if
245 necessary. */
246 extern struct servent *getservent __P ((void));
248 /* Return entry from network data base for network with NAME and
249 protocol PROTO. */
250 extern struct servent *getservbyname __P ((__const char *__name,
251 __const char *__proto));
253 /* Return entry from service data base which matches port PORT and
254 protocol PROTO. */
255 extern struct servent *getservbyport __P ((int __port, __const char *__proto));
258 #ifdef __USE_REENTRANT
259 /* Reentrant versions of the functions above. The additional
260 arguments specify a buffer of BUFLEN starting at BUF. */
261 extern struct servent *__getservent_r __P ((struct servent *__result_buf,
262 char *__buf, int __buf_len));
263 extern struct servent *getservent_r __P ((struct servent *__result_buf,
264 char *__buf, int __buf_len));
266 extern struct servent *__getservbyname_r __P ((__const char *__name,
267 __const char *__proto,
268 struct servent *__result_buf,
269 char *__buf, int __buflen));
270 extern struct servent *getservbyname_r __P ((__const char *__name,
271 __const char *__proto,
272 struct servent *__result_buf,
273 char *__buf, int __buflen));
275 extern struct servent *__getservbyport_r __P ((int __port,
276 __const char *__proto,
277 struct servent *__result_buf,
278 char *__buf, int __buflen));
279 extern struct servent *getservbyport_r __P ((int __port, __const char *__proto,
280 struct servent *__result_buf,
281 char *__buf, int __buflen));
282 #endif /* reentrant */
285 /* Description of data base entry for a single service. */
286 struct protoent
288 char *p_name; /* Official protocol name. */
289 char **p_aliases; /* Alias list. */
290 int p_proto; /* Protocol number. */
293 /* Open protocol data base files and mark them as staying open even
294 after a later search if STAY_OPEN is non-zero. */
295 extern void setprotoent __P ((int __stay_open));
297 /* Close protocol data base files and clear `stay open' flag. */
298 extern void endprotoent __P ((void));
300 /* Get next entry from protocol data base file. Open data base if
301 necessary. */
302 extern struct protoent *getprotoent __P ((void));
304 /* Return entry from protocol data base for network with NAME. */
305 extern struct protoent *getprotobyname __P ((__const char *__name));
307 /* Return entry from protocol data base which number is PROTO. */
308 extern struct protoent *getprotobynumber __P ((int __proto));
311 #ifdef __USE_REENTRANT
312 /* Reentrant versions of the functions above. The additional
313 arguments specify a buffer of BUFLEN starting at BUF. */
314 extern struct protoent *__getprotoent_r __P ((struct protoent *__result_buf,
315 char *__buf, int __buf_len));
316 extern struct protoent *getprotoent_r __P ((struct protoent *__result_buf,
317 char *__buf, int __buf_len));
319 extern struct protoent *__getprotobyname_r __P ((__const char *__name,
320 struct protoent *__result_buf,
321 char *__buf, int __buflen));
322 extern struct protoent *getprotobyname_r __P ((__const char *__name,
323 struct protoent *__result_buf,
324 char *__buf, int __buflen));
326 extern struct protoent *__getprotobynumber_r __P ((int __proto,
327 struct protoent *__res_buf,
328 char *__buf, int __buflen));
329 extern struct protoent *getprotobynumber_r __P ((int __proto,
330 struct protoent *__result_buf,
331 char *__buf, int __buflen));
332 #endif /* reentrant */
335 /* Establish network group NETGROUP for enumeration. */
336 extern int setnetgrent __P ((__const char *__netgroup));
338 /* Free all space allocated by previous `setnetgrent' call. */
339 extern void endnetgrent __P ((void));
341 /* Get next member of netgroup established by last `setnetgrent' call
342 and return pointers to elements in HOSTP, USERP, and DOMAINP. */
343 extern int getnetgrent __P ((char **__hostp, char **__userp,
344 char **__domainp));
346 /* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). */
347 extern int innetgr __P ((__const char *__netgroup, __const char *__host,
348 __const char *__user, __const char *domain));
350 #ifdef __USE_REENTRANT
351 /* Reentrant version of `getnetgrent' where result is placed in BUFFER. */
352 extern int __getnetgrent_r __P ((char **__hostp, char **__userp,
353 char **__domainp,
354 char *__buffer, int __buflen));
355 extern int getnetgrent_r __P ((char **__hostp, char **__userp,
356 char **__domainp,
357 char *__buffer, int __buflen));
358 #endif
360 __END_DECLS
362 #endif /* netdb.h */