diff options
-rw-r--r-- | psutil/_psutil_windows.c | 1 | ||||
-rw-r--r-- | psutil/arch/windows/inet_ntop.c | 45 | ||||
-rw-r--r-- | psutil/arch/windows/inet_ntop.h | 17 | ||||
-rwxr-xr-x | setup.py | 1 |
4 files changed, 0 insertions, 64 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index 9c430c5f..ec8b0b2a 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -36,7 +36,6 @@ #include "arch/windows/disk.h" #include "arch/windows/cpu.h" #include "arch/windows/net.h" -#include "arch/windows/inet_ntop.h" #include "arch/windows/services.h" #include "arch/windows/socks.h" #include "arch/windows/wmi.h" diff --git a/psutil/arch/windows/inet_ntop.c b/psutil/arch/windows/inet_ntop.c deleted file mode 100644 index 3db507b9..00000000 --- a/psutil/arch/windows/inet_ntop.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2009, Giampaolo Rodola', Jeff Tang. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <Python.h> -#include "inet_ntop.h" - -// From: https://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/ -PCSTR WSAAPI -inet_ntop(INT family, PVOID pAddr, PSTR stringBuf, size_t strBufSize) { - DWORD dwAddressLength = 0; - struct sockaddr_storage srcaddr; - struct sockaddr_in *srcaddr4 = (struct sockaddr_in*) &srcaddr; - struct sockaddr_in6 *srcaddr6 = (struct sockaddr_in6*) &srcaddr; - - memset(&srcaddr, 0, sizeof(struct sockaddr_storage)); - srcaddr.ss_family = family; - - if (family == AF_INET) { - dwAddressLength = sizeof(struct sockaddr_in); - memcpy(&(srcaddr4->sin_addr), pAddr, sizeof(struct in_addr)); - } - else if (family == AF_INET6) { - dwAddressLength = sizeof(struct sockaddr_in6); - memcpy(&(srcaddr6->sin6_addr), pAddr, sizeof(struct in6_addr)); - } - else { - PyErr_SetString(PyExc_ValueError, "invalid family"); - return NULL; - } - - if (WSAAddressToStringA( - (LPSOCKADDR) &srcaddr, - dwAddressLength, - 0, - stringBuf, - (LPDWORD) &strBufSize) != 0) - { - PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError()); - return NULL; - } - return stringBuf; -} diff --git a/psutil/arch/windows/inet_ntop.h b/psutil/arch/windows/inet_ntop.h deleted file mode 100644 index 2d86c26c..00000000 --- a/psutil/arch/windows/inet_ntop.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2009, Giampaolo Rodola', Jeff Tang. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -// because of WSAAddressToStringA -#define _WINSOCK_DEPRECATED_NO_WARNINGS -#include <ws2tcpip.h> - -PCSTR WSAAPI -inet_ntop( - __in INT Family, - __in const VOID * pAddr, - __out_ecount(StringBufSize) PSTR pStringBuf, - __in size_t StringBufSize -); @@ -149,7 +149,6 @@ if WINDOWS: 'psutil/arch/windows/net.c', 'psutil/arch/windows/cpu.c', 'psutil/arch/windows/security.c', - 'psutil/arch/windows/inet_ntop.c', 'psutil/arch/windows/services.c', 'psutil/arch/windows/global.c', 'psutil/arch/windows/socks.c', |