Re: [PATCH 3/3] ws2_32: Implement get socket option SO_PROTOCOL_INFO
Bruno Jesus <00cpxxx(a)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(a)winehq.org
participants (1)
-
Alexandre Julliard