* Makefile.in (DLL_OFILES): Add inet_addr.o and inet_network.o.

* autoload.cc (inet_addr): Drop definition.
	(inet_ntoa): Ditto.
	* net.cc: Forward declare cygwin_inet_aton and cygwin_inet_ntop.
	(cygwin_inet_ntoa): Call cygwin_inet_ntop instead of Winsock inet_ntoa.
	(cygwin_inet_addr): Remove here.
	(cygwin_inet_aton): Ditto.
	(cygwin_inet_network): Ditto.
	* libc/inet_addr.c: New file implementing cygwin_inet_aton and
	cygwin_inet_addr.
	* libc/inet_network.c: New file implementing cygwin_inet_network.
This commit is contained in:
Corinna Vinschen
2006-07-07 09:14:15 +00:00
parent b4054e7706
commit 722031140a
6 changed files with 378 additions and 52 deletions

View File

@ -48,6 +48,8 @@ extern "C"
int __stdcall rcmd (char **ahost, unsigned short inport, char *locuser,
char *remuser, char *cmd, SOCKET * fd2p);
int sscanf (const char *, const char *, ...);
int cygwin_inet_aton(const char *, struct in_addr *);
const char *cygwin_inet_ntop (int, const void *, char *, socklen_t);
} /* End of "C" section */
static fhandler_socket *
@ -102,7 +104,8 @@ ntohs (unsigned short x)
extern "C" char *
cygwin_inet_ntoa (struct in_addr in)
{
char *res = inet_ntoa (in);
char buf[20];
const char *res = cygwin_inet_ntop (AF_INET, &in, buf, sizeof buf);
if (_my_tls.locals.ntoa_buf)
{
@ -114,46 +117,6 @@ cygwin_inet_ntoa (struct in_addr in)
return _my_tls.locals.ntoa_buf;
}
/* exported as inet_addr: BSD 4.3 */
extern "C" unsigned long
cygwin_inet_addr (const char *cp)
{
myfault efault;
if (efault.faulted (EFAULT))
return INADDR_NONE;
unsigned long res = inet_addr (cp);
return res;
}
/* exported as inet_aton: BSD 4.3
inet_aton is not exported by wsock32 and ws2_32,
so it has to be implemented here. */
extern "C" int
cygwin_inet_aton (const char *cp, struct in_addr *inp)
{
myfault efault;
if (efault.faulted (EFAULT))
return 0;
unsigned long res = inet_addr (cp);
if (res == INADDR_NONE && strcmp (cp, "255.255.255.255"))
return 0;
if (inp)
inp->s_addr = res;
return 1;
}
extern "C" unsigned int
cygwin_inet_network (const char *cp)
{
myfault efault;
if (efault.faulted (EFAULT))
return INADDR_NONE;
return ntohl (inet_addr (cp));
}
/* inet_netof is in the standard BSD sockets library. It is useless
for modern networks, since it assumes network values which are no
longer meaningful, but some existing code calls it. */