1 | /* netdb.h,v 1.8 2004/09/14 22:27:34 bird Exp */
|
---|
2 | /** @file
|
---|
3 | * BSD
|
---|
4 | *
|
---|
5 | * @changed Modified for emx by hv and em 1994-1997
|
---|
6 | * @changed Modified for gcc by bird 2003
|
---|
7 | */
|
---|
8 |
|
---|
9 | /* netdb.h,v 1.8 2004/09/14 22:27:34 bird Exp */
|
---|
10 | /*-
|
---|
11 | *
|
---|
12 | * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
|
---|
13 | * All rights reserved.
|
---|
14 | *
|
---|
15 | * Redistribution and use in source and binary forms, with or without
|
---|
16 | * modification, are permitted provided that the following conditions
|
---|
17 | * are met:
|
---|
18 | * 1. Redistributions of source code must retain the above copyright
|
---|
19 | * notice, this list of conditions and the following disclaimer.
|
---|
20 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
21 | * notice, this list of conditions and the following disclaimer in the
|
---|
22 | * documentation and/or other materials provided with the distribution.
|
---|
23 | * 3. All advertising materials mentioning features or use of this software
|
---|
24 | * must display the following acknowledgement:
|
---|
25 | * This product includes software developed by the University of
|
---|
26 | * California, Berkeley and its contributors.
|
---|
27 | * 4. Neither the name of the University nor the names of its contributors
|
---|
28 | * may be used to endorse or promote products derived from this software
|
---|
29 | * without specific prior written permission.
|
---|
30 | *
|
---|
31 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
34 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
35 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
39 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
40 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
41 | * SUCH DAMAGE.
|
---|
42 | *
|
---|
43 | * from: @(#)netdb.h 5.15 (Berkeley) 4/3/91
|
---|
44 | * netdb.h,v 1.8 2004/09/14 22:27:34 bird Exp
|
---|
45 | */
|
---|
46 |
|
---|
47 | #ifndef _NETDB_H_
|
---|
48 | #define _NETDB_H_
|
---|
49 | #ifdef TCPV40HDRS
|
---|
50 | #define __NETDB_32H
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if defined (__cplusplus)
|
---|
54 | extern "C" {
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /* toolkit compatibility - start */
|
---|
58 | #include <sys/param.h>
|
---|
59 | #include <sys/cdefs.h>
|
---|
60 | /* toolkit compatibility - end */
|
---|
61 |
|
---|
62 | #ifndef _EMX_TCPIP
|
---|
63 | #define _EMX_TCPIP
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifdef __RSXNT__ /* convert some int values to short */
|
---|
67 | #define __INT_T short
|
---|
68 | #pragma pack(1)
|
---|
69 | #else /* emx */
|
---|
70 | #define __INT_T int
|
---|
71 | #endif
|
---|
72 |
|
---|
73 |
|
---|
74 | #define _PATH_HEQUIV "/@unixroot/etc/hosts.equiv"
|
---|
75 | #define _PATH_HOSTS "/@unixroot/etc/hosts"
|
---|
76 | #define _PATH_NETWORKS "/@unixroot/etc/networks"
|
---|
77 | #define _PATH_PROTOCOLS "/@unixroot/etc/protocols"
|
---|
78 | #define _PATH_SERVICES "/@unixroot/etc/services"
|
---|
79 |
|
---|
80 | #ifdef TCPV40HDRS
|
---|
81 | #define h_errno (tcp_h_errno()) /* __MT__ safe */
|
---|
82 | #else
|
---|
83 | #define h_errno (*tcp_h_errno1()) /* __MT__ safe */
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | /*
|
---|
87 | * Structures returned by network data base library. All addresses are
|
---|
88 | * supplied in host order, and returned in network order (suitable for
|
---|
89 | * use in system calls).
|
---|
90 | */
|
---|
91 | struct hostent {
|
---|
92 | char *h_name; /* official name of host */
|
---|
93 | char **h_aliases; /* alias list */
|
---|
94 | __INT_T h_addrtype; /* host address type */
|
---|
95 | __INT_T h_length; /* length of address */
|
---|
96 | char **h_addr_list; /* list of addresses from name server */
|
---|
97 | #define h_addr h_addr_list[0] /* address, for backward compatiblity */
|
---|
98 | };
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * Assumption here is that a network number
|
---|
102 | * fits in 32 bits -- probably a poor one.
|
---|
103 | */
|
---|
104 | struct netent {
|
---|
105 | char *n_name; /* official name of net */
|
---|
106 | char **n_aliases; /* alias list */
|
---|
107 | __INT_T n_addrtype; /* net address type */
|
---|
108 | unsigned long n_net; /* network # */
|
---|
109 | };
|
---|
110 |
|
---|
111 | struct servent {
|
---|
112 | char *s_name; /* official service name */
|
---|
113 | char **s_aliases; /* alias list */
|
---|
114 | __INT_T s_port; /* port # */
|
---|
115 | char *s_proto; /* protocol to use */
|
---|
116 | };
|
---|
117 |
|
---|
118 | struct protoent {
|
---|
119 | char *p_name; /* official protocol name */
|
---|
120 | char **p_aliases; /* alias list */
|
---|
121 | __INT_T p_proto; /* protocol # */
|
---|
122 | };
|
---|
123 |
|
---|
124 | /*
|
---|
125 | * Error return codes from gethostbyname() and gethostbyaddr()
|
---|
126 | * (left in extern int h_errno).
|
---|
127 | */
|
---|
128 | #ifndef TCPV40HDRS
|
---|
129 | #define NETDB_INTERNAL -1 /* see errno */
|
---|
130 | #define NETDB_SUCCESS 0 /* no problem */
|
---|
131 | #endif
|
---|
132 | #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
|
---|
133 | #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
|
---|
134 | #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
|
---|
135 | #define NO_DATA 4 /* Valid name, no data record of requested type */
|
---|
136 | #define NO_ADDRESS NO_DATA /* no address, look for MX record */
|
---|
137 |
|
---|
138 |
|
---|
139 | #ifdef TCPV40HDRS
|
---|
140 | #include <stdio.h>
|
---|
141 | #include <string.h>
|
---|
142 | #include <netinet\in.h>
|
---|
143 |
|
---|
144 | /* IBM addendum structures and functions */
|
---|
145 | #define _HOSTBUFSIZE (4096+1)
|
---|
146 | #define _MAXADDRS 35
|
---|
147 | #define _MAXALIASES 35
|
---|
148 | #define _MAXLINELEN 1024
|
---|
149 |
|
---|
150 | /* this is the internally used data structure to which pointers of
|
---|
151 | * struct hostent ponit to, after gethostbyname_r/gethostbyaddr_r were
|
---|
152 | * called. ATTENTION EMX: The component _opaque_ is a pointer to a data
|
---|
153 | * structure which is not accessible by EMX
|
---|
154 | */
|
---|
155 | struct hostent_data {
|
---|
156 | struct in_addr host_addr; /* host address pointer */
|
---|
157 | char *h_addr_ptrs[_MAXADDRS+1]; /* host address */
|
---|
158 | char hostaddr[_MAXADDRS];
|
---|
159 | char hostbuf[_HOSTBUFSIZE+1]; /* host data */
|
---|
160 | char *host_aliases[_MAXALIASES];
|
---|
161 | char *host_addrs[2];
|
---|
162 | void *_opaque_; /* EMX: dead component! */
|
---|
163 | int stayopen; /* AIX addon */
|
---|
164 | u_long host_addresses[_MAXADDRS]; /* Actual Addresses. */
|
---|
165 | };
|
---|
166 |
|
---|
167 | struct servent_data {
|
---|
168 | void *_opaque_;
|
---|
169 | char line[_MAXLINELEN];
|
---|
170 | char *serv_aliases[_MAXALIASES];
|
---|
171 | int _serv_stayopen;
|
---|
172 | };
|
---|
173 | #endif
|
---|
174 |
|
---|
175 |
|
---|
176 | /* BSD */
|
---|
177 | int TCPCALL gethostname( char *, int );
|
---|
178 | struct hostent * TCPCALL gethostbyname( const char * );
|
---|
179 | struct hostent * TCPCALL gethostbyaddr( const char *, int, int );
|
---|
180 | struct netent * TCPCALL getnetbyname( const char * );
|
---|
181 | struct netent * TCPCALL getnetbyaddr( unsigned long, int );
|
---|
182 | struct servent * TCPCALL getservbyname( const char *, const char * );
|
---|
183 | struct servent * TCPCALL getservbyport( int, const char * );
|
---|
184 | struct servent * TCPCALL getservent( void );
|
---|
185 | struct protoent * TCPCALL getprotobyname( const char * );
|
---|
186 | struct protoent * TCPCALL getprotobynumber( int );
|
---|
187 | void TCPCALL sethostent( int );
|
---|
188 | struct hostent * TCPCALL gethostent( void );
|
---|
189 | void TCPCALL endhostent(void);
|
---|
190 | void TCPCALL setnetent( int );
|
---|
191 | struct netent * TCPCALL getnetent( void );
|
---|
192 | void TCPCALL endnetent(void);
|
---|
193 | void TCPCALL setprotoent( int );
|
---|
194 | struct protoent * TCPCALL getprotoent( void );
|
---|
195 | void TCPCALL endprotoent(void);
|
---|
196 | void TCPCALL setservent( int );
|
---|
197 | struct servent * TCPCALL getservent( void );
|
---|
198 | void TCPCALL endservent(void);
|
---|
199 | #ifndef TCPV40HDRS
|
---|
200 | struct hostent * TCPCALL gethostbyname2( const char *, int );
|
---|
201 | #endif
|
---|
202 |
|
---|
203 | /* New BSD Additions. */
|
---|
204 | int innetgr(const char *, const char *, const char *, const char *);
|
---|
205 | void setnetgrent(const char *);
|
---|
206 | int getnetgrent(char **, char **, char **);
|
---|
207 | void endnetgrent(void);
|
---|
208 |
|
---|
209 |
|
---|
210 |
|
---|
211 | /* OS2 Additions */
|
---|
212 | #ifdef TCPV40HDRS
|
---|
213 | int TCPCALL tcp_h_errno(void);
|
---|
214 | struct hostent * TCPCALL Rgethostbyname(char *); /* Socks additions */
|
---|
215 | #else
|
---|
216 | const char * TCPCALL hstrerror(int);
|
---|
217 | /* void TCPCALL sethostfile(const char *); */
|
---|
218 | int * TCPCALL tcp_h_errno1(void);
|
---|
219 | #endif
|
---|
220 |
|
---|
221 | /* EMX/BSD additions. */
|
---|
222 | void TCPCALL herror(const char *);
|
---|
223 |
|
---|
224 | /* EMX/BSD stuff which isn't implemeneted */
|
---|
225 | #ifndef TCPV40HDRS
|
---|
226 | struct hostent_data;
|
---|
227 | struct servent_data;
|
---|
228 | #endif
|
---|
229 | int gethostbyname_r(char*, struct hostent*, struct hostent_data*);
|
---|
230 | int gethostbyaddr_r(char*, int, int, struct hostent*, struct hostent_data*);
|
---|
231 | int getservbyname_r(char*, char*, struct servent*, struct servent_data*);
|
---|
232 | struct hostent * _gethtbyname(char*);
|
---|
233 | struct hostent * _gethtbyaddr(char*, int, int);
|
---|
234 |
|
---|
235 |
|
---|
236 | #ifdef __RSXNT__
|
---|
237 | #pragma pack()
|
---|
238 | #endif
|
---|
239 | #undef __INT_T
|
---|
240 |
|
---|
241 | #if defined (__cplusplus)
|
---|
242 | }
|
---|
243 | #endif
|
---|
244 |
|
---|
245 | #endif /* !_NETDB_H_ */
|
---|
246 |
|
---|