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