source: branches/libc-0.6/src/emx/include/netdb.h

Last change on this file was 3809, checked in by bird, 11 years ago

0.6: s/const/const/g - just use the (now) standard 'const' everywhere in emx and kLIBC code. Avoid changing external code too much. fixes #279.

  • Property cvs2svn:cvs-rev set to 1.9
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.9 KB
Line 
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)
54extern "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 */
91struct 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 */
104struct 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
111struct 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
118struct 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 */
155struct 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
167struct 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 */
177int TCPCALL gethostname( char *, int );
178struct hostent * TCPCALL gethostbyname( const char * );
179struct hostent * TCPCALL gethostbyaddr( const char *, int, int );
180struct netent * TCPCALL getnetbyname( const char * );
181struct netent * TCPCALL getnetbyaddr( unsigned long, int );
182struct servent * TCPCALL getservbyname( const char *, const char * );
183struct servent * TCPCALL getservbyport( int, const char * );
184struct servent * TCPCALL getservent( void );
185struct protoent * TCPCALL getprotobyname( const char * );
186struct protoent * TCPCALL getprotobynumber( int );
187void TCPCALL sethostent( int );
188struct hostent * TCPCALL gethostent( void );
189void TCPCALL endhostent(void);
190void TCPCALL setnetent( int );
191struct netent * TCPCALL getnetent( void );
192void TCPCALL endnetent(void);
193void TCPCALL setprotoent( int );
194struct protoent * TCPCALL getprotoent( void );
195void TCPCALL endprotoent(void);
196void TCPCALL setservent( int );
197struct servent * TCPCALL getservent( void );
198void TCPCALL endservent(void);
199#ifndef TCPV40HDRS
200struct hostent * TCPCALL gethostbyname2( const char *, int );
201#endif
202
203/* New BSD Additions. */
204int innetgr(const char *, const char *, const char *, const char *);
205void setnetgrent(const char *);
206int getnetgrent(char **, char **, char **);
207void endnetgrent(void);
208
209
210
211/* OS2 Additions */
212#ifdef TCPV40HDRS
213int TCPCALL tcp_h_errno(void);
214struct hostent * TCPCALL Rgethostbyname(char *); /* Socks additions */
215#else
216const char * TCPCALL hstrerror(int);
217/* void TCPCALL sethostfile(const char *); */
218int * TCPCALL tcp_h_errno1(void);
219#endif
220
221/* EMX/BSD additions. */
222void TCPCALL herror(const char *);
223
224/* EMX/BSD stuff which isn't implemeneted */
225#ifndef TCPV40HDRS
226struct hostent_data;
227struct servent_data;
228#endif
229int gethostbyname_r(char*, struct hostent*, struct hostent_data*);
230int gethostbyaddr_r(char*, int, int, struct hostent*, struct hostent_data*);
231int getservbyname_r(char*, char*, struct servent*, struct servent_data*);
232struct hostent * _gethtbyname(char*);
233struct 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
Note: See TracBrowser for help on using the repository browser.