[PATCH 3/3] ws2_32: Implement get socket option SO_PROTOCOL_INFO
Alexandre Julliard
julliard at winehq.org
Mon Sep 2 12:59:22 CDT 2013
Bruno Jesus <00cpxxx at gmail.com> writes:
> + items = WSAEnumProtocolsW(NULL, NULL, &listsize);
> + if (items == SOCKET_ERROR && WSAGetLastError() == WSAENOBUFS &&
> + (buffer = HeapAlloc(GetProcessHeap(), 0, listsize)))
> + {
> + items = WSAEnumProtocolsW(NULL, buffer, &listsize);
> + for (i = 0; i < items; i++)
> + {
> + if (buffer[i].iAddressFamily == info.a->iAddressFamily &&
> + buffer[i].iSocketType == info.a->iSocketType &&
> + buffer[i].iProtocol == info.a->iProtocol)
> + {
> + if (unicode)
> + memcpy(info.w, &buffer[i], sz);
> + else
> + {
> + /* convert the structure from W to A */
> + memcpy(info.a, &buffer[i], FIELD_OFFSET(WSAPROTOCOL_INFOA, szProtocol));
> + WideCharToMultiByte(CP_ACP, 0, buffer[i].szProtocol, -1,
> + info.a->szProtocol, WSAPROTOCOL_LEN+1, NULL, NULL);
> + }
> + break;
> + }
> + }
> + }
There's no reason to enumerate the protocols since you already know the
one you want.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list