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