Zebediah Figura : ws2_32: Move byte order conversion functions to protocol.c.

Alexandre Julliard julliard at winehq.org
Tue May 4 16:23:34 CDT 2021


Module: wine
Branch: master
Commit: ec6940cd3fd1f88e0365ae16e5ee9d2add445bd8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ec6940cd3fd1f88e0365ae16e5ee9d2add445bd8

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon May  3 21:42:51 2021 -0500

ws2_32: Move byte order conversion functions to protocol.c.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/protocol.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++
 dlls/ws2_32/socket.c   | 97 --------------------------------------------------
 2 files changed, 90 insertions(+), 97 deletions(-)

diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c
index fe30f26db53..abbe5738b88 100644
--- a/dlls/ws2_32/protocol.c
+++ b/dlls/ws2_32/protocol.c
@@ -2022,3 +2022,93 @@ WS_u_long WINAPI WS_inet_addr( const char *cp )
     if (!cp) return INADDR_NONE;
     return inet_addr( cp );
 }
+
+
+/***********************************************************************
+ *      htonl   (ws2_32.8)
+ */
+WS_u_long WINAPI WS_htonl( WS_u_long hostlong )
+{
+    return htonl( hostlong );
+}
+
+
+/***********************************************************************
+ *      htons   (ws2_32.9)
+ */
+WS_u_short WINAPI WS_htons( WS_u_short hostshort )
+{
+    return htons( hostshort );
+}
+
+
+/***********************************************************************
+ *      WSAHtonl   (ws2_32.@)
+ */
+int WINAPI WSAHtonl( SOCKET s, WS_u_long hostlong, WS_u_long *netlong )
+{
+    if (netlong)
+    {
+        *netlong = htonl( hostlong );
+        return 0;
+    }
+    SetLastError( WSAEFAULT );
+    return -1;
+}
+
+
+/***********************************************************************
+ *      WSAHtons   (ws2_32.@)
+ */
+int WINAPI WSAHtons( SOCKET s, WS_u_short hostshort, WS_u_short *netshort )
+{
+    if (netshort)
+    {
+        *netshort = htons( hostshort );
+        return 0;
+    }
+    SetLastError( WSAEFAULT );
+    return -1;
+}
+
+
+/***********************************************************************
+ *      ntohl   (ws2_32.14)
+ */
+WS_u_long WINAPI WS_ntohl( WS_u_long netlong )
+{
+    return ntohl( netlong );
+}
+
+
+/***********************************************************************
+ *      ntohs   (ws2_32.15)
+ */
+WS_u_short WINAPI WS_ntohs( WS_u_short netshort )
+{
+    return ntohs( netshort );
+}
+
+
+/***********************************************************************
+ *      WSANtohl   (ws2_32.@)
+ */
+int WINAPI WSANtohl( SOCKET s, WS_u_long netlong, WS_u_long *hostlong )
+{
+    if (!hostlong) return WSAEFAULT;
+
+    *hostlong = ntohl( netlong );
+    return 0;
+}
+
+
+/***********************************************************************
+ *      WSANtohs   (ws2_32.@)
+ */
+int WINAPI WSANtohs( SOCKET s, WS_u_short netshort, WS_u_short *hostshort )
+{
+    if (!hostshort) return WSAEFAULT;
+
+    *hostshort = ntohs( netshort );
+    return 0;
+}
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 3d930d13bb6..3c63b93d737 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -3837,78 +3837,6 @@ INT WINAPI WS_getsockopt(SOCKET s, INT level,
     } /* end switch(level) */
 }
 
-/***********************************************************************
- *		htonl			(WS2_32.8)
- */
-WS_u_long WINAPI WS_htonl(WS_u_long hostlong)
-{
-    return htonl(hostlong);
-}
-
-
-/***********************************************************************
- *		htons			(WS2_32.9)
- */
-WS_u_short WINAPI WS_htons(WS_u_short hostshort)
-{
-    return htons(hostshort);
-}
-
-/***********************************************************************
- *		WSAHtonl		(WS2_32.46)
- *  From MSDN description of error codes, this function should also
- *  check if WinSock has been initialized and the socket is a valid
- *  socket. But why? This function only translates a host byte order
- *  u_long into a network byte order u_long...
- */
-int WINAPI WSAHtonl(SOCKET s, WS_u_long hostlong, WS_u_long *lpnetlong)
-{
-    if (lpnetlong)
-    {
-        *lpnetlong = htonl(hostlong);
-        return 0;
-    }
-    SetLastError(WSAEFAULT);
-    return SOCKET_ERROR;
-}
-
-/***********************************************************************
- *		WSAHtons		(WS2_32.47)
- *  From MSDN description of error codes, this function should also
- *  check if WinSock has been initialized and the socket is a valid
- *  socket. But why? This function only translates a host byte order
- *  u_short into a network byte order u_short...
- */
-int WINAPI WSAHtons(SOCKET s, WS_u_short hostshort, WS_u_short *lpnetshort)
-{
-
-    if (lpnetshort)
-    {
-        *lpnetshort = htons(hostshort);
-        return 0;
-    }
-    SetLastError(WSAEFAULT);
-    return SOCKET_ERROR;
-}
-
-
-/***********************************************************************
- *		ntohl			(WS2_32.14)
- */
-WS_u_long WINAPI WS_ntohl(WS_u_long netlong)
-{
-    return ntohl(netlong);
-}
-
-
-/***********************************************************************
- *		ntohs			(WS2_32.15)
- */
-WS_u_short WINAPI WS_ntohs(WS_u_short netshort)
-{
-    return ntohs(netshort);
-}
-
 
 static const char *debugstr_wsaioctl(DWORD code)
 {
@@ -6544,31 +6472,6 @@ INT WINAPI WSALookupServiceNextW( HANDLE lookup, DWORD flags, LPDWORD len, LPWSA
     return SOCKET_ERROR;
 }
 
-/***********************************************************************
- *              WSANtohl                                   (WS2_32.64)
- */
-INT WINAPI WSANtohl( SOCKET s, WS_u_long netlong, WS_u_long* lphostlong )
-{
-    TRACE( "(%04lx 0x%08x %p)\n", s, netlong, lphostlong );
-
-    if (!lphostlong) return WSAEFAULT;
-
-    *lphostlong = ntohl( netlong );
-    return 0;
-}
-
-/***********************************************************************
- *              WSANtohs                                   (WS2_32.65)
- */
-INT WINAPI WSANtohs( SOCKET s, WS_u_short netshort, WS_u_short* lphostshort )
-{
-    TRACE( "(%04lx 0x%08x %p)\n", s, netshort, lphostshort );
-
-    if (!lphostshort) return WSAEFAULT;
-
-    *lphostshort = ntohs( netshort );
-    return 0;
-}
 
 /***********************************************************************
  *              WSAProviderConfigChange                     (WS2_32.66)




More information about the wine-cvs mailing list