Skip to content

Commit

Permalink
LibCore: Allow winsock2.h to be included after sockaddr-win.h
Browse files Browse the repository at this point in the history
  • Loading branch information
stasoid committed Dec 1, 2024
1 parent 52224b8 commit 83230ba
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion Libraries/LibCore/sockaddr-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#pragma once

typedef int INT;
typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef char CHAR;
Expand All @@ -16,7 +17,6 @@ typedef USHORT ADDRESS_FAMILY;
#define FAR
#include <inaddr.h>
#undef WINAPI_FAMILY_PARTITION
#undef FAR

#include <afunix.h>

Expand Down Expand Up @@ -64,6 +64,7 @@ struct sockaddr {
ADDRESS_FAMILY sa_family;
CHAR sa_data[14];
};
using LPSOCKADDR = sockaddr*;

struct addrinfo {
int ai_flags;
Expand All @@ -76,4 +77,41 @@ struct addrinfo {
addrinfo* ai_next;
};

struct SOCKET_ADDRESS {
sockaddr* lpSockaddr;
INT iSockaddrLength;
};

struct SOCKET_ADDRESS_LIST {
INT iAddressCount;
SOCKET_ADDRESS Address[1];
};
using PSOCKET_ADDRESS_LIST = SOCKET_ADDRESS_LIST*;

struct CSADDR_INFO {
SOCKET_ADDRESS LocalAddr;
SOCKET_ADDRESS RemoteAddr;
INT iSocketType;
INT iProtocol;
};
using LPCSADDR_INFO = CSADDR_INFO*;

struct WSABUF {
ULONG len;
CHAR* buf;
};
using LPWSABUF = WSABUF*;

struct WSAMSG {
LPSOCKADDR name;
INT namelen;
LPWSABUF lpBuffers;
ULONG dwBufferCount;
WSABUF Control;
ULONG dwFlags;
};
using LPWSAMSG = WSAMSG*;

extern "C" USHORT __stdcall htons(USHORT hostshort);

#define _WS2DEF_ // don't include ws2def.h

0 comments on commit 83230ba

Please sign in to comment.