mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Remove some pre-vista code
This commit is contained in:
parent
95f8d34f9c
commit
8561680533
79
win32/inet.c
79
win32/inet.c
@ -1,83 +1,4 @@
|
||||
#include "config.w32.h"
|
||||
#include "php.h"
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <Ws2tcpip.h>
|
||||
|
||||
#include "inet.h"
|
||||
#if (_WIN32_WINNT < 0x0600) /* Vista/2k8 have these functions */
|
||||
|
||||
|
||||
PHPAPI int inet_pton(int af, const char* src, void* dst)
|
||||
{
|
||||
int address_length;
|
||||
struct sockaddr_storage sa;
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
|
||||
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
address_length = sizeof (struct sockaddr_in);
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
address_length = sizeof (struct sockaddr_in6);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (WSAStringToAddress ((LPTSTR) src, af, NULL, (LPSOCKADDR) &sa, &address_length) == 0) {
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
memcpy (dst, &sin->sin_addr, sizeof (struct in_addr));
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
memcpy (dst, &sin6->sin6_addr, sizeof (struct in6_addr));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size)
|
||||
{
|
||||
int address_length;
|
||||
DWORD string_length = size;
|
||||
struct sockaddr_storage sa;
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
|
||||
|
||||
memset (&sa, 0, sizeof (sa));
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
address_length = sizeof (struct sockaddr_in);
|
||||
sin->sin_family = af;
|
||||
memcpy (&sin->sin_addr, src, sizeof (struct in_addr));
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
address_length = sizeof (struct sockaddr_in6);
|
||||
sin6->sin6_family = af;
|
||||
memcpy (&sin6->sin6_addr, src, sizeof (struct in6_addr));
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (WSAAddressToString ((LPSOCKADDR) &sa, address_length, NULL, dst, &string_length) == 0) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int inet_aton(const char *cp, struct in_addr *inp) {
|
||||
inp->s_addr = inet_addr(cp);
|
||||
|
11
win32/inet.h
11
win32/inet.h
@ -1,11 +1,4 @@
|
||||
#if _MSC_VER >= 1500
|
||||
# include <In6addr.h>
|
||||
#endif
|
||||
#include <Ws2tcpip.h>
|
||||
|
||||
#if (_WIN32_WINNT <= 0x502)
|
||||
PHPAPI int inet_pton(int af, const char* src, void* dst);
|
||||
PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size);
|
||||
#endif
|
||||
#include <php.h>
|
||||
#include <Winsock2.h>
|
||||
|
||||
PHPAPI int inet_aton(const char *cp, struct in_addr *inp);
|
||||
|
Loading…
Reference in New Issue
Block a user