Author: cwittich
Date: Sun Feb 16 08:02:38 2014
New Revision: 62204
URL:
http://svn.reactos.org/svn/reactos?rev=62204&view=rev
Log:
[ws2_32]
merge startup version checks from ws2_32_new/src/startup.c
[ws2_32_new]
fix typo
Modified:
trunk/reactos/dll/win32/ws2_32/misc/dllmain.c
trunk/reactos/dll/win32/ws2_32_new/src/startup.c
Modified: trunk/reactos/dll/win32/ws2_32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/dllm…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/misc/dllmain.c [iso-8859-1] Sun Feb 16 08:02:38 2014
@@ -55,7 +55,8 @@
WSAStartup(IN WORD wVersionRequested,
OUT LPWSADATA lpWSAData)
{
- BYTE Low, High;
+ WORD VersionReturned = 0;
+ DWORD ErrorCode = ERROR_SUCCESS;
WS_DbgPrint(MAX_TRACE, ("WSAStartup of ws2_32.dll\n"));
@@ -65,48 +66,56 @@
if (lpWSAData == NULL)
return WSAEFAULT;
- Low = LOBYTE(wVersionRequested);
- High = HIBYTE(wVersionRequested);
-
- if (Low < 1)
- {
- WS_DbgPrint(MAX_TRACE, ("Bad winsock version requested, %d,%d", Low,
High));
- return WSAVERNOTSUPPORTED;
- }
-
- if (Low == 1)
- {
- if (High == 0)
- {
- lpWSAData->wVersion = wVersionRequested;
- }
- else
- {
- lpWSAData->wVersion = MAKEWORD(1, 1);
- }
- }
- else if (Low == 2)
- {
- if (High <= 2)
- {
- lpWSAData->wVersion = MAKEWORD(2, High);
- }
- else
- {
- lpWSAData->wVersion = MAKEWORD(2, 2);
- }
- }
- else
- {
- lpWSAData->wVersion = MAKEWORD(2, 2);
- }
-
- lpWSAData->wVersion = wVersionRequested;
+ /* Check which version is being requested */
+ switch (LOBYTE(wVersionRequested))
+ {
+ case 0:
+
+ /* We don't support this unknown version */
+ ErrorCode = WSAVERNOTSUPPORTED;
+ break;
+
+ case 1:
+ /* We support only 1.0 and 1.1 */
+ if (HIBYTE(wVersionRequested) == 0)
+ {
+ /* Caller wants 1.0, return it */
+ VersionReturned = wVersionRequested;
+ }
+ else
+ {
+ /* The only other version we support is 1.1 */
+ VersionReturned = MAKEWORD(1, 1);
+ }
+ break;
+
+ case 2:
+ /* We support only 2.0, 2.1 and 2.2 */
+ if (HIBYTE(wVersionRequested) <= 2)
+ {
+ /* Caller wants 2.0-2.2, return it */
+ VersionReturned = MAKEWORD(2, HIBYTE(wVersionRequested));
+ }
+ else
+ {
+ /* The highest version we support is 2.2 */
+ VersionReturned = MAKEWORD(2, 2);
+ }
+ break;
+
+ default:
+
+ /* Return 2.2 */
+ VersionReturned = MAKEWORD(2, 2);;
+ break;
+ }
+
+ /* Return the Version Requested, unless error */
+ lpWSAData->wVersion = VersionReturned;
+
lpWSAData->wHighVersion = MAKEWORD(2,2);
lstrcpyA(lpWSAData->szDescription, "WinSock 2.0");
lstrcpyA(lpWSAData->szSystemStatus, "Running");
- lpWSAData->iMaxSockets = 0;
- lpWSAData->iMaxUdpDg = 0;
lpWSAData->lpVendorInfo = NULL;
if (LOBYTE(wVersionRequested) == 1)
@@ -124,7 +133,7 @@
WSASETINITIALIZED;
- return NO_ERROR;
+ return ErrorCode;
}
Modified: trunk/reactos/dll/win32/ws2_32_new/src/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/src/s…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/src/startup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/src/startup.c [iso-8859-1] Sun Feb 16 08:02:38
2014
@@ -160,7 +160,7 @@
break;
}
- /* Return the Version Requsted, unless error */
+ /* Return the Version Requested, unless error */
lpWSAData->wVersion = VersionReturned;
/* We support Winsock 2.2 */