| 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.4 2003/07/11 11:39:47 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 | #ifndef TCPCALL
|
|---|
| 168 | #define TCPCALL _System
|
|---|
| 169 | #endif
|
|---|
| 170 |
|
|---|
| 171 | /* BSD */
|
|---|
| 172 | int TCPCALL gethostname( char *, int );
|
|---|
| 173 | struct hostent * TCPCALL gethostbyname( __const__ char * );
|
|---|
| 174 | struct hostent * TCPCALL gethostbyaddr( __const__ char *, int, int );
|
|---|
| 175 | struct netent * TCPCALL getnetbyname( __const__ char * );
|
|---|
| 176 | struct netent * TCPCALL getnetbyaddr( unsigned long, int );
|
|---|
| 177 | struct servent * TCPCALL getservbyname( __const__ char *, char * );
|
|---|
| 178 | struct servent * TCPCALL getservbyport( int, __const__ char * );
|
|---|
| 179 | struct servent * TCPCALL getservent( void );
|
|---|
| 180 | struct protoent * TCPCALL getprotobyname( __const__ char * );
|
|---|
| 181 | struct protoent * TCPCALL getprotobynumber( int );
|
|---|
| 182 | void TCPCALL sethostent( int );
|
|---|
| 183 | struct hostent * TCPCALL gethostent( void );
|
|---|
| 184 | void TCPCALL endhostent(void);
|
|---|
| 185 | void TCPCALL setnetent( int );
|
|---|
| 186 | struct netent * TCPCALL getnetent( void );
|
|---|
| 187 | void TCPCALL endnetent(void);
|
|---|
| 188 | void TCPCALL setprotoent( int );
|
|---|
| 189 | struct protoent * TCPCALL getprotoent( void );
|
|---|
| 190 | void TCPCALL endprotoent(void);
|
|---|
| 191 | void TCPCALL setservent( int );
|
|---|
| 192 | struct servent * TCPCALL getservent( void );
|
|---|
| 193 | void TCPCALL endservent(void);
|
|---|
| 194 | #ifndef TCPV40HDRS
|
|---|
| 195 | struct hostent * TCPCALL gethostbyname2( __const__ char *, int );
|
|---|
| 196 | #endif
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 | /* OS2 Additions */
|
|---|
| 200 | #ifdef TCPV40HDRS
|
|---|
| 201 | int TCPCALL tcp_h_errno(void);
|
|---|
| 202 | struct hostent * TCPCALL Rgethostbyname(char *); /* Socks additions */
|
|---|
| 203 | #else
|
|---|
| 204 | const char * TCPCALL hstrerror(int);
|
|---|
| 205 | /* void TCPCALL sethostfile(const char *); */
|
|---|
| 206 | int * TCPCALL tcp_h_errno1(void);
|
|---|
| 207 | #endif
|
|---|
| 208 |
|
|---|
| 209 | /* EMX/BSD additions. */
|
|---|
| 210 | void herror (__const__ char *);
|
|---|
| 211 |
|
|---|
| 212 | /* EMX/BSD stuff which isn't implemeneted */
|
|---|
| 213 | #ifndef TCPV40HDRS
|
|---|
| 214 | struct hostent_data;
|
|---|
| 215 | struct servent_data;
|
|---|
| 216 | #endif
|
|---|
| 217 | int gethostbyname_r(char*, struct hostent*, struct hostent_data*);
|
|---|
| 218 | int gethostbyaddr_r(char*, int, int, struct hostent*, struct hostent_data*);
|
|---|
| 219 | int getservbyname_r(char*, char*, struct servent*, struct servent_data*);
|
|---|
| 220 | struct hostent * _gethtbyname(char*);
|
|---|
| 221 | struct hostent * _gethtbyaddr(char*, int, int);
|
|---|
| 222 |
|
|---|
| 223 |
|
|---|
| 224 | #ifdef __RSXNT__
|
|---|
| 225 | #pragma pack()
|
|---|
| 226 | #endif
|
|---|
| 227 | #undef __INT_T
|
|---|
| 228 |
|
|---|
| 229 | #if defined (__cplusplus)
|
|---|
| 230 | }
|
|---|
| 231 | #endif
|
|---|
| 232 |
|
|---|
| 233 | #endif /* !_NETDB_H_ */
|
|---|
| 234 |
|
|---|