mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Hack for mswindows without getnameinfo
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25923 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
08c85d9f2e
commit
b9a02a2c3e
7 changed files with 264 additions and 77 deletions
|
@ -27,28 +27,13 @@
|
|||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <wininet.h>
|
||||
#if !defined(EAFNOSUPPORT)
|
||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
#endif
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include "GSNetwork.h"
|
||||
|
||||
|
||||
#if HAVE_ARPA_NAMESER_H
|
||||
#include <arpa/nameser.h>
|
||||
#endif
|
||||
|
||||
#ifndef INADDRSZ
|
||||
#define INADDRSZ 4
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
|
@ -71,7 +56,7 @@ static int inet_pton6(const char *src, uint8_t *dst);
|
|||
* Paul Vixie, 1996.
|
||||
*/
|
||||
int
|
||||
inet_pton(int af, const char *src, void *dst)
|
||||
GSPrivate_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
|
||||
switch (af) {
|
||||
|
@ -308,62 +293,3 @@ inet_pton6(const char *src, uint8_t *dst)
|
|||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdoanld <rfm@gnu.org>
|
||||
Date: January 2008
|
||||
|
||||
This is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
The remainder of this file is compatibility code for use under
|
||||
mswindows (which does not have inet_ntop()).
|
||||
*/
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
const char *
|
||||
inet_ntop(int af, const void *src, char *dst, socklen_t len)
|
||||
{
|
||||
if (af == AF_INET)
|
||||
{
|
||||
struct sockaddr_in in;
|
||||
|
||||
memset(&in, '\0', sizeof(in));
|
||||
in.sin_family = AF_INET;
|
||||
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
|
||||
getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in),
|
||||
dst, len, 0, 0, NI_NUMERICHOST);
|
||||
return dst;
|
||||
}
|
||||
#ifdef AF_INET6
|
||||
else if (af == AF_INET6)
|
||||
{
|
||||
struct sockaddr_in6 in;
|
||||
|
||||
memset(&in, '\0', sizeof(in));
|
||||
in.sin6_family = AF_INET6;
|
||||
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
|
||||
getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6),
|
||||
dst, len, 0, 0, NI_NUMERICHOST);
|
||||
return dst;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue