mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
win32: Remove all remaining WinXP compat code
Remove all code which is no longer built with Windows 7+
This commit is contained in:
@@ -376,98 +376,6 @@ g_inet_address_init (GInetAddress *address)
|
|||||||
address->priv = g_inet_address_get_instance_private (address);
|
address->priv = g_inet_address_get_instance_private (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These are provided so that we can use inet_pton() and inet_ntop() on Windows
|
|
||||||
* if they are available (i.e. Vista and later), and use the existing code path
|
|
||||||
* on Windows XP/Server 2003. We can drop this portion when we drop support for
|
|
||||||
* XP/Server 2003.
|
|
||||||
*/
|
|
||||||
#if defined(G_OS_WIN32) && _WIN32_WINNT < 0x0600
|
|
||||||
static gint
|
|
||||||
inet_pton (gint family,
|
|
||||||
const gchar *addr_string,
|
|
||||||
gpointer addr)
|
|
||||||
{
|
|
||||||
/* For Vista/Server 2008 and later, there is native inet_pton() in Winsock2 */
|
|
||||||
if (ws2funcs.pInetPton != NULL)
|
|
||||||
return ws2funcs.pInetPton (family, addr_string, addr);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Fallback codepath for XP/Server 2003 */
|
|
||||||
struct sockaddr_storage sa;
|
|
||||||
struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
|
|
||||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
|
|
||||||
gint len = sizeof (sa);
|
|
||||||
|
|
||||||
if (family != AF_INET && family != AF_INET6)
|
|
||||||
{
|
|
||||||
WSASetLastError (WSAEAFNOSUPPORT);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* WSAStringToAddress() will accept various not-an-IP-address
|
|
||||||
* strings like "127.0.0.1:80", "[1234::5678]:80", "127.1", etc.
|
|
||||||
*/
|
|
||||||
if (!g_hostname_is_ip_address (addr_string))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (WSAStringToAddress ((LPTSTR) addr_string, family, NULL, (LPSOCKADDR) &sa, &len) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (family == AF_INET)
|
|
||||||
*(IN_ADDR *)addr = sin->sin_addr;
|
|
||||||
else
|
|
||||||
*(IN6_ADDR *)addr = sin6->sin6_addr;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const gchar *
|
|
||||||
inet_ntop (gint family,
|
|
||||||
const gpointer addr,
|
|
||||||
gchar *addr_str,
|
|
||||||
socklen_t size)
|
|
||||||
{
|
|
||||||
/* On Vista/Server 2008 and later, there is native inet_ntop() in Winsock2 */
|
|
||||||
if (ws2funcs.pInetNtop != NULL)
|
|
||||||
return ws2funcs.pInetNtop (family, addr, addr_str, size);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Fallback codepath for XP/Server 2003 */
|
|
||||||
DWORD buflen = size, addrlen;
|
|
||||||
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));
|
|
||||||
sa.ss_family = family;
|
|
||||||
if (sa.ss_family == AF_INET)
|
|
||||||
{
|
|
||||||
struct in_addr *addrv4 = (struct in_addr *) addr;
|
|
||||||
|
|
||||||
addrlen = sizeof (*sin);
|
|
||||||
memcpy (&sin->sin_addr, addrv4, sizeof (sin->sin_addr));
|
|
||||||
}
|
|
||||||
else if (sa.ss_family == AF_INET6)
|
|
||||||
{
|
|
||||||
struct in6_addr *addrv6 = (struct in6_addr *) addr;
|
|
||||||
|
|
||||||
addrlen = sizeof (*sin6);
|
|
||||||
memcpy (&sin6->sin6_addr, addrv6, sizeof (sin6->sin6_addr));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WSASetLastError (WSAEAFNOSUPPORT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (WSAAddressToString ((LPSOCKADDR) &sa, addrlen, NULL, addr_str, &buflen) == 0)
|
|
||||||
return addr_str;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_inet_address_new_from_string:
|
* g_inet_address_new_from_string:
|
||||||
* @string: a string representation of an IP address
|
* @string: a string representation of an IP address
|
||||||
|
@@ -211,47 +211,6 @@
|
|||||||
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XXX: Remove once XP support really dropped */
|
|
||||||
#if _WIN32_WINNT < 0x0600
|
|
||||||
|
|
||||||
typedef enum _FILE_INFO_BY_HANDLE_CLASS
|
|
||||||
{
|
|
||||||
FileBasicInfo = 0,
|
|
||||||
FileStandardInfo = 1,
|
|
||||||
FileNameInfo = 2,
|
|
||||||
FileRenameInfo = 3,
|
|
||||||
FileDispositionInfo = 4,
|
|
||||||
FileAllocationInfo = 5,
|
|
||||||
FileEndOfFileInfo = 6,
|
|
||||||
FileStreamInfo = 7,
|
|
||||||
FileCompressionInfo = 8,
|
|
||||||
FileAttributeTagInfo = 9,
|
|
||||||
FileIdBothDirectoryInfo = 10,
|
|
||||||
FileIdBothDirectoryRestartInfo = 11,
|
|
||||||
FileIoPriorityHintInfo = 12,
|
|
||||||
FileRemoteProtocolInfo = 13,
|
|
||||||
FileFullDirectoryInfo = 14,
|
|
||||||
FileFullDirectoryRestartInfo = 15,
|
|
||||||
FileStorageInfo = 16,
|
|
||||||
FileAlignmentInfo = 17,
|
|
||||||
FileIdInfo = 18,
|
|
||||||
FileIdExtdDirectoryInfo = 19,
|
|
||||||
FileIdExtdDirectoryRestartInfo = 20,
|
|
||||||
MaximumFileInfoByHandlesClass
|
|
||||||
} FILE_INFO_BY_HANDLE_CLASS;
|
|
||||||
|
|
||||||
typedef struct _FILE_NAME_INFO
|
|
||||||
{
|
|
||||||
DWORD FileNameLength;
|
|
||||||
WCHAR FileName[1];
|
|
||||||
} FILE_NAME_INFO;
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI fGetFileInformationByHandleEx) (HANDLE,
|
|
||||||
FILE_INFO_BY_HANDLE_CLASS,
|
|
||||||
LPVOID,
|
|
||||||
DWORD);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (_MSC_VER) && (_MSC_VER >=1400)
|
#if defined (_MSC_VER) && (_MSC_VER >=1400)
|
||||||
/* This is ugly, but we need it for isatty() in case we have bad fd's,
|
/* This is ugly, but we need it for isatty() in case we have bad fd's,
|
||||||
* otherwise Windows will abort() the program on msvcrt80.dll and later
|
* otherwise Windows will abort() the program on msvcrt80.dll and later
|
||||||
@@ -1539,34 +1498,13 @@ win32_is_pipe_tty (int fd)
|
|||||||
wchar_t *name = NULL;
|
wchar_t *name = NULL;
|
||||||
gint length;
|
gint length;
|
||||||
|
|
||||||
/* XXX: Remove once XP support really dropped */
|
|
||||||
#if _WIN32_WINNT < 0x0600
|
|
||||||
HANDLE h_kerneldll = NULL;
|
|
||||||
fGetFileInformationByHandleEx *GetFileInformationByHandleEx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
h_fd = (HANDLE) _get_osfhandle (fd);
|
h_fd = (HANDLE) _get_osfhandle (fd);
|
||||||
|
|
||||||
if (h_fd == INVALID_HANDLE_VALUE || GetFileType (h_fd) != FILE_TYPE_PIPE)
|
if (h_fd == INVALID_HANDLE_VALUE || GetFileType (h_fd) != FILE_TYPE_PIPE)
|
||||||
goto done_query;
|
goto done_query;
|
||||||
|
|
||||||
/* The following check is available on Vista or later, so on XP, no color support */
|
|
||||||
/* mintty uses a pipe, in the form of \{cygwin|msys}-xxxxxxxxxxxxxxxx-ptyN-{from|to}-master */
|
/* mintty uses a pipe, in the form of \{cygwin|msys}-xxxxxxxxxxxxxxxx-ptyN-{from|to}-master */
|
||||||
|
|
||||||
/* XXX: Remove once XP support really dropped */
|
|
||||||
#if _WIN32_WINNT < 0x0600
|
|
||||||
h_kerneldll = LoadLibraryW (L"kernel32.dll");
|
|
||||||
|
|
||||||
if (h_kerneldll == NULL)
|
|
||||||
goto done_query;
|
|
||||||
|
|
||||||
GetFileInformationByHandleEx =
|
|
||||||
(fGetFileInformationByHandleEx *) GetProcAddress (h_kerneldll, "GetFileInformationByHandleEx");
|
|
||||||
|
|
||||||
if (GetFileInformationByHandleEx == NULL)
|
|
||||||
goto done_query;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
info = g_try_malloc (info_size);
|
info = g_try_malloc (info_size);
|
||||||
|
|
||||||
if (info == NULL ||
|
if (info == NULL ||
|
||||||
@@ -1614,12 +1552,6 @@ done_query:
|
|||||||
if (info != NULL)
|
if (info != NULL)
|
||||||
g_free (info);
|
g_free (info);
|
||||||
|
|
||||||
/* XXX: Remove once XP support really dropped */
|
|
||||||
#if _WIN32_WINNT < 0x0600
|
|
||||||
if (h_kerneldll != NULL)
|
|
||||||
FreeLibrary (h_kerneldll);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user