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 08337a4 commit 8506667
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions Libraries/LibCore/sockaddr-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ typedef unsigned short USHORT;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef USHORT ADDRESS_FAMILY;
typedef int INT;

#define WINAPI_FAMILY_PARTITION(x) 1
#define FAR
#include <inaddr.h>
#undef WINAPI_FAMILY_PARTITION
#undef FAR

#include <afunix.h>

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

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

extern "C" USHORT __stdcall htons(USHORT hostshort);
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" __declspec(dllimport) USHORT __stdcall htons(USHORT hostshort);

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

0 comments on commit 8506667

Please sign in to comment.