mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 23:07:47 +00:00
dpwsockx: Implementation of SPInit.
This commit is contained in:
parent
ec09345523
commit
5a9ecdef43
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
||||||
SRCDIR = @srcdir@
|
SRCDIR = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
MODULE = dpwsockx.dll
|
MODULE = dpwsockx.dll
|
||||||
IMPORTS = dxguid kernel32
|
IMPORTS = dxguid kernel32 ws2_32
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
dpwsockx_main.c
|
dpwsockx_main.c
|
||||||
|
|
|
@ -21,10 +21,78 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winsock2.h"
|
||||||
#include "winnt.h"
|
#include "winnt.h"
|
||||||
#include "wine/dplaysp.h"
|
#include "wine/dplaysp.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct tagDPWS_THREADDATA
|
||||||
|
{
|
||||||
|
BOOL is_running;
|
||||||
|
SOCKET sock;
|
||||||
|
SOCKADDR_IN addr;
|
||||||
|
HANDLE handle;
|
||||||
|
LPDIRECTPLAYSP lpISP;
|
||||||
|
} DPWS_THREADDATA, *LPDPWS_THREADDATA;
|
||||||
|
|
||||||
|
typedef struct tagDPWS_DATA
|
||||||
|
{
|
||||||
|
SOCKET sock;
|
||||||
|
DPWS_THREADDATA tcp_listener, udp_listener, dplaysrv;
|
||||||
|
SOCKADDR_IN nameserverAddr;
|
||||||
|
LPDIRECTPLAYSP lpISP;
|
||||||
|
} DPWS_DATA, *LPDPWS_DATA;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
static inline u_short __dpws_ushort_swap(u_short s)
|
||||||
|
{
|
||||||
|
return (s >> 8) | (s << 8);
|
||||||
|
}
|
||||||
|
static inline u_long __dpws_ulong_swap(u_long l)
|
||||||
|
{
|
||||||
|
return ((u_long)__dpws_ushort_swap((u_short)l) << 16) | __dpws_ushort_swap((u_short)(l >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define dpws_letohl(l) __dpws_ulong_swap(l)
|
||||||
|
#define dpws_letohs(s) __dpws_ushort_swap(s)
|
||||||
|
#define dpws_htolel(l) __dpws_ulong_swap(l)
|
||||||
|
#define dpws_htoles(s) __dpws_ushort_swap(s)
|
||||||
|
|
||||||
|
#else /* WORDS_BIGENDIAN */
|
||||||
|
|
||||||
|
#define dpws_letohl(l) ((u_long)(l))
|
||||||
|
#define dpws_letohs(s) ((u_short)(s))
|
||||||
|
#define dpws_htolel(l) ((u_long)(l))
|
||||||
|
#define dpws_htoles(s) ((u_short)(s))
|
||||||
|
|
||||||
|
#endif /* WORDS_BIGENDIAN */
|
||||||
|
|
||||||
|
|
||||||
|
#include "pshpack1.h"
|
||||||
|
|
||||||
|
typedef struct tagDPSP_MSG_HEADER
|
||||||
|
{
|
||||||
|
DWORD mixed;
|
||||||
|
SOCKADDR_IN SockAddr;
|
||||||
|
} DPSP_MSG_HEADER, *LPDPSP_MSG_HEADER;
|
||||||
|
typedef const DPSP_MSG_HEADER* LPCDPSP_MSG_HEADER;
|
||||||
|
|
||||||
|
#include "poppack.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DPSP_MSG_TOKEN_REMOTE 0xFAB00000
|
||||||
|
#define DPSP_MSG_TOKEN_FORWARDED 0xCAB00000
|
||||||
|
#define DPSP_MSG_TOKEN_SERVER 0xBAB00000
|
||||||
|
|
||||||
|
#define DPSP_MSG_MAKE_MIXED(s,t) dpws_htolel((s) | (t))
|
||||||
|
#define DPSP_MSG_SIZE(m) (dpws_letohl(m) & 0x000FFFFF)
|
||||||
|
#define DPSP_MSG_TOKEN(m) (dpws_letohl(m) & 0xFFF00000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT WINAPI SPInit( LPSPINITDATA );
|
HRESULT WINAPI SPInit( LPSPINITDATA );
|
||||||
|
|
||||||
#endif /* __WINE_DPWSOCKX_DLL_H */
|
#endif /* __WINE_DPWSOCKX_DLL_H */
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winsock2.h"
|
||||||
#include "dpwsockx_dll.h"
|
#include "dpwsockx_dll.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "dplay.h"
|
#include "dplay.h"
|
||||||
|
@ -205,6 +206,9 @@ static void setup_callbacks( LPDPSP_SPCALLBACKS lpCB )
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
|
HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
|
||||||
{
|
{
|
||||||
|
WSADATA wsaData;
|
||||||
|
DPWS_DATA dpwsData;
|
||||||
|
|
||||||
TRACE( "Initializing library for %s (%s)\n",
|
TRACE( "Initializing library for %s (%s)\n",
|
||||||
wine_dbgstr_guid(lpspData->lpGuid), debugstr_w(lpspData->lpszName) );
|
wine_dbgstr_guid(lpspData->lpGuid), debugstr_w(lpspData->lpszName) );
|
||||||
|
|
||||||
|
@ -217,5 +221,21 @@ HRESULT WINAPI SPInit( LPSPINITDATA lpspData )
|
||||||
/* Assign callback functions */
|
/* Assign callback functions */
|
||||||
setup_callbacks( lpspData->lpCB );
|
setup_callbacks( lpspData->lpCB );
|
||||||
|
|
||||||
|
/* Load Winsock 2.0 DLL */
|
||||||
|
if ( WSAStartup( MAKEWORD(2, 0), &wsaData ) != 0 )
|
||||||
|
{
|
||||||
|
ERR( "WSAStartup() failed\n" );
|
||||||
|
return DPERR_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize internal data */
|
||||||
|
memset( &dpwsData, 0, sizeof(DPWS_DATA) );
|
||||||
|
dpwsData.lpISP = lpspData->lpISP;
|
||||||
|
IDirectPlaySP_SetSPData( lpspData->lpISP, &dpwsData, sizeof(DPWS_DATA),
|
||||||
|
DPSET_LOCAL );
|
||||||
|
|
||||||
|
/* dplay needs to know the size of the header */
|
||||||
|
lpspData->dwSPHeaderSize = sizeof(DPSP_MSG_HEADER);
|
||||||
|
|
||||||
return DP_OK;
|
return DP_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue