summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-02 15:40:51 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-02 15:40:51 -0800
commitad620104e778642e8a1fa5a5d725283baf376b55 (patch)
tree85b6b765446c922add2aa4254cbe8201802dcda9
parent1358fb7d734878b7e238c39af93ec19dfbe7c77e (diff)
downloadpsutil-ad620104e778642e8a1fa5a5d725283baf376b55.tar.gz
#1652: remove inet_ntop.c
-rw-r--r--psutil/_psutil_windows.c1
-rw-r--r--psutil/arch/windows/inet_ntop.c45
-rw-r--r--psutil/arch/windows/inet_ntop.h17
-rwxr-xr-xsetup.py1
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
-);
diff --git a/setup.py b/setup.py
index 51e9516d..9e63db68 100755
--- a/setup.py
+++ b/setup.py
@@ -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',