[1/2] dplayx: Reorder the code to avoid forward declarations.
Francois Gouget
fgouget at free.fr
Thu May 14 18:55:28 CDT 2009
---
Putting static in the prototype and not where the function is actually
implemented was pretty confusing too. Now it's much clearer.
dlls/dplayx/dplayx_global.c | 700 +++++++++++++++++++++----------------------
1 files changed, 343 insertions(+), 357 deletions(-)
diff --git a/dlls/dplayx/dplayx_global.c b/dlls/dplayx/dplayx_global.c
index 938ade9..9035902 100644
--- a/dlls/dplayx/dplayx_global.c
+++ b/dlls/dplayx/dplayx_global.c
@@ -174,19 +174,181 @@ static DPLAYX_LOBBYDATA* lobbyData = NULL;
static DPSESSIONDESC2* sessionData = NULL;
/* static DPSESSIONDESC2* sessionData[ numSupportedSessions ]; */
-/* Function prototypes */
-static DWORD DPLAYX_SizeOfLobbyDataA( const DPLCONNECTION *lpDplData );
-static DWORD DPLAYX_SizeOfLobbyDataW( const DPLCONNECTION *lpDplData );
-static void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, const DPLCONNECTION *src );
-static void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, const DPLCONNECTION *src );
-static BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppId, LPDPLAYX_LOBBYDATA* dplData );
-static void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData );
-static BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
- LPCDPSESSIONDESC2 lpSessionSrc );
-static BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart, LPHANDLE lphDeath,
- LPHANDLE lphConnRead, BOOL bClearSetHandles );
+static void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData )
+{
+ ZeroMemory( lpData, sizeof( *lpData ) );
+}
+
+/* NOTE: This must be called with the semaphore acquired.
+ * TRUE/FALSE with a pointer to it's data returned. Pointer data is
+ * is only valid if TRUE is returned.
+ */
+static BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData )
+{
+ UINT i;
+
+ *lplpDplData = NULL;
+
+ if( dwAppID == 0 )
+ {
+ dwAppID = GetCurrentProcessId();
+ TRACE( "Translated dwAppID == 0 into 0x%08x\n", dwAppID );
+ }
+
+ for( i=0; i < numSupportedLobbies; i++ )
+ {
+ if( lobbyData[ i ].dwAppID == dwAppID )
+ {
+ /* This process is lobbied */
+ TRACE( "Found 0x%08x @ %u\n", dwAppID, i );
+ *lplpDplData = &lobbyData[ i ];
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+/* Reserve a spot for the new application. TRUE means success and FALSE failure. */
+BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID )
+{
+ UINT i;
+
+ /* 0 is the marker for unused application data slots */
+ if( dwAppID == 0 )
+ {
+ return FALSE;
+ }
+
+ DPLAYX_AcquireSemaphore();
+
+ /* Find an empty space in the list and insert the data */
+ for( i=0; i < numSupportedLobbies; i++ )
+ {
+ if( lobbyData[ i ].dwAppID == 0 )
+ {
+ /* This process is now lobbied */
+ TRACE( "Setting lobbyData[%u] for (0x%08x,0x%08x)\n",
+ i, dwAppID, GetCurrentProcessId() );
+
+ lobbyData[ i ].dwAppID = dwAppID;
+ lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId();
+
+ /* FIXME: Where is the best place for this? In interface or here? */
+ lobbyData[ i ].hInformOnAppStart = 0;
+ lobbyData[ i ].hInformOnAppDeath = 0;
+ lobbyData[ i ].hInformOnSettingRead = 0;
+
+ DPLAYX_ReleaseSemaphore();
+ return TRUE;
+ }
+ }
+
+ ERR( "No empty lobbies\n" );
+
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+}
+
+BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID,
+ HANDLE hStart, HANDLE hDeath, HANDLE hConnRead )
+{
+ LPDPLAYX_LOBBYDATA lpLData;
+
+ /* Need to explicitly give lobby application. Can't set for yourself */
+ if( dwAppID == 0 )
+ {
+ return FALSE;
+ }
+
+ DPLAYX_AcquireSemaphore();
+
+ if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ lpLData->hInformOnAppStart = hStart;
+ lpLData->hInformOnAppDeath = hDeath;
+ lpLData->hInformOnSettingRead = hConnRead;
+
+ DPLAYX_ReleaseSemaphore();
+
+ return TRUE;
+}
+
+static BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart,
+ LPHANDLE lphDeath,
+ LPHANDLE lphConnRead,
+ BOOL bClearSetHandles )
+{
+ LPDPLAYX_LOBBYDATA lpLData;
+
+ DPLAYX_AcquireSemaphore();
+
+ if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ if( lphStart != NULL )
+ {
+ if( lpLData->hInformOnAppStart == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphStart = lpLData->hInformOnAppStart;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnAppStart );
+ lpLData->hInformOnAppStart = 0;
+ }
+ }
+
+ if( lphDeath != NULL )
+ {
+ if( lpLData->hInformOnAppDeath == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphDeath = lpLData->hInformOnAppDeath;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnAppDeath );
+ lpLData->hInformOnAppDeath = 0;
+ }
+ }
+
+ if( lphConnRead != NULL )
+ {
+ if( lpLData->hInformOnSettingRead == 0 )
+ {
+ DPLAYX_ReleaseSemaphore();
+ return FALSE;
+ }
+
+ *lphConnRead = lpLData->hInformOnSettingRead;
+
+ if( bClearSetHandles )
+ {
+ CloseHandle( lpLData->hInformOnSettingRead );
+ lpLData->hInformOnSettingRead = 0;
+ }
+ }
+
+ DPLAYX_ReleaseSemaphore();
+ return TRUE;
+}
/***************************************************************************
* Called to initialize the global data. This will only be used on the
@@ -272,7 +434,7 @@ BOOL DPLAYX_ConstructData(void)
else
{
/* Presently the shared data structures use pointers. If the
- * files are no mapped into the same area, the pointers will no
+ * files are not mapped into the same area, the pointers will no
* longer make any sense :(
* FIXME: In the future make the shared data structures have some
* sort of fixup to make them independent between data spaces.
@@ -374,182 +536,241 @@ BOOL DPLAYX_DestructData(void)
}
-void DPLAYX_InitializeLobbyDataEntry( LPDPLAYX_LOBBYDATA lpData )
+/* Assumption: Enough contiguous space was allocated at dest */
+static void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, const DPLCONNECTION *src )
{
- ZeroMemory( lpData, sizeof( *lpData ) );
-}
+ BYTE* lpStartOfFreeSpace;
-/* NOTE: This must be called with the semaphore acquired.
- * TRUE/FALSE with a pointer to it's data returned. Pointer data is
- * is only valid if TRUE is returned.
- */
-BOOL DPLAYX_IsAppIdLobbied( DWORD dwAppID, LPDPLAYX_LOBBYDATA* lplpDplData )
-{
- UINT i;
+ *dest = *src;
- *lplpDplData = NULL;
+ lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION );
- if( dwAppID == 0 )
+ /* Copy the LPDPSESSIONDESC2 structure if it exists */
+ if( src->lpSessionDesc )
{
- dwAppID = GetCurrentProcessId();
- TRACE( "Translated dwAppID == 0 into 0x%08x\n", dwAppID );
+ dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
+ *dest->lpSessionDesc = *src->lpSessionDesc;
+
+ /* Session names may or may not exist */
+ if( src->lpSessionDesc->u1.lpszSessionNameA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionNameA );
+ dest->lpSessionDesc->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpSessionDesc->u1.lpszSessionNameA ) + 1;
+ }
+
+ if( src->lpSessionDesc->u2.lpszPasswordA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPasswordA );
+ dest->lpSessionDesc->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpSessionDesc->u2.lpszPasswordA ) + 1;
+ }
}
- for( i=0; i < numSupportedLobbies; i++ )
+ /* DPNAME structure is optional */
+ if( src->lpPlayerName )
{
- if( lobbyData[ i ].dwAppID == dwAppID )
+ dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPNAME );
+ *dest->lpPlayerName = *src->lpPlayerName;
+
+ if( src->lpPlayerName->u1.lpszShortNameA )
{
- /* This process is lobbied */
- TRACE( "Found 0x%08x @ %u\n", dwAppID, i );
- *lplpDplData = &lobbyData[ i ];
- return TRUE;
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortNameA );
+ dest->lpPlayerName->u1.lpszShortNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( dest->lpPlayerName->u1.lpszShortNameA ) + 1;
+ }
+
+ if( src->lpPlayerName->u2.lpszLongNameA )
+ {
+ strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongNameA );
+ dest->lpPlayerName->u2.lpszLongNameA = (LPSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace +=
+ strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ;
}
+
}
- return FALSE;
+ /* Copy address if it exists */
+ if( src->lpAddress )
+ {
+ dest->lpAddress = lpStartOfFreeSpace;
+ CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
+ /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
+ }
}
-/* Reserve a spot for the new application. TRUE means success and FALSE failure. */
-BOOL DPLAYX_CreateLobbyApplication( DWORD dwAppID )
+/* Assumption: Enough contiguous space was allocated at dest */
+static void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, const DPLCONNECTION *src )
{
- UINT i;
+ BYTE* lpStartOfFreeSpace;
- /* 0 is the marker for unused application data slots */
- if( dwAppID == 0 )
- {
- return FALSE;
- }
+ *dest = *src;
- DPLAYX_AcquireSemaphore();
+ lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION );
- /* Find an empty space in the list and insert the data */
- for( i=0; i < numSupportedLobbies; i++ )
+ /* Copy the LPDPSESSIONDESC2 structure if it exists */
+ if( src->lpSessionDesc )
{
- if( lobbyData[ i ].dwAppID == 0 )
- {
- /* This process is now lobbied */
- TRACE( "Setting lobbyData[%u] for (0x%08x,0x%08x)\n",
- i, dwAppID, GetCurrentProcessId() );
-
- lobbyData[ i ].dwAppID = dwAppID;
- lobbyData[ i ].dwAppLaunchedFromID = GetCurrentProcessId();
+ dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
+ *dest->lpSessionDesc = *src->lpSessionDesc;
- /* FIXME: Where is the best place for this? In interface or here? */
- lobbyData[ i ].hInformOnAppStart = 0;
- lobbyData[ i ].hInformOnAppDeath = 0;
- lobbyData[ i ].hInformOnSettingRead = 0;
+ /* Session names may or may not exist */
+ if( src->lpSessionDesc->u1.lpszSessionName )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionName );
+ dest->lpSessionDesc->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpSessionDesc->u1.lpszSessionName ) + 1 );
+ }
- DPLAYX_ReleaseSemaphore();
- return TRUE;
+ if( src->lpSessionDesc->u2.lpszPassword )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPassword );
+ dest->lpSessionDesc->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpSessionDesc->u2.lpszPassword ) + 1 );
}
}
- ERR( "No empty lobbies\n" );
+ /* DPNAME structure is optional */
+ if( src->lpPlayerName )
+ {
+ dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof( DPNAME );
+ *dest->lpPlayerName = *src->lpPlayerName;
- DPLAYX_ReleaseSemaphore();
- return FALSE;
-}
+ if( src->lpPlayerName->u1.lpszShortName )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortName );
+ dest->lpPlayerName->u1.lpszShortName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpPlayerName->u1.lpszShortName ) + 1 );
+ }
-BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID,
- HANDLE hStart, HANDLE hDeath, HANDLE hConnRead )
-{
- LPDPLAYX_LOBBYDATA lpLData;
+ if( src->lpPlayerName->u2.lpszLongName )
+ {
+ strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongName );
+ dest->lpPlayerName->u2.lpszLongName = (LPWSTR)lpStartOfFreeSpace;
+ lpStartOfFreeSpace += sizeof(WCHAR) *
+ ( strlenW( dest->lpPlayerName->u2.lpszLongName ) + 1 );
+ }
- /* Need to explicitly give lobby application. Can't set for yourself */
- if( dwAppID == 0 )
- {
- return FALSE;
}
- DPLAYX_AcquireSemaphore();
-
- if( !DPLAYX_IsAppIdLobbied( dwAppID, &lpLData ) )
+ /* Copy address if it exists */
+ if( src->lpAddress )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dest->lpAddress = lpStartOfFreeSpace;
+ CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
+ /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
}
- lpLData->hInformOnAppStart = hStart;
- lpLData->hInformOnAppDeath = hDeath;
- lpLData->hInformOnSettingRead = hConnRead;
-
- DPLAYX_ReleaseSemaphore();
-
- return TRUE;
}
-static BOOL DPLAYX_GetThisLobbyHandles( LPHANDLE lphStart,
- LPHANDLE lphDeath,
- LPHANDLE lphConnRead,
- BOOL bClearSetHandles )
+static DWORD DPLAYX_SizeOfLobbyDataA( const DPLCONNECTION *lpConn )
{
- LPDPLAYX_LOBBYDATA lpLData;
-
- DPLAYX_AcquireSemaphore();
+ DWORD dwTotalSize = sizeof( DPLCONNECTION );
- if( !DPLAYX_IsAppIdLobbied( 0, &lpLData ) )
+ /* Just a safety check */
+ if( lpConn == NULL )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ ERR( "lpConn is NULL\n" );
+ return 0;
}
- if( lphStart != NULL )
+ if( lpConn->lpSessionDesc != NULL )
{
- if( lpLData->hInformOnAppStart == 0 )
+ dwTotalSize += sizeof( DPSESSIONDESC2 );
+
+ if( lpConn->lpSessionDesc->u1.lpszSessionNameA )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += strlen( lpConn->lpSessionDesc->u1.lpszSessionNameA ) + 1;
}
- *lphStart = lpLData->hInformOnAppStart;
-
- if( bClearSetHandles )
+ if( lpConn->lpSessionDesc->u2.lpszPasswordA )
{
- CloseHandle( lpLData->hInformOnAppStart );
- lpLData->hInformOnAppStart = 0;
+ dwTotalSize += strlen( lpConn->lpSessionDesc->u2.lpszPasswordA ) + 1;
}
}
- if( lphDeath != NULL )
+ if( lpConn->lpPlayerName != NULL )
{
- if( lpLData->hInformOnAppDeath == 0 )
+ dwTotalSize += sizeof( DPNAME );
+
+ if( lpConn->lpPlayerName->u1.lpszShortNameA )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += strlen( lpConn->lpPlayerName->u1.lpszShortNameA ) + 1;
}
- *lphDeath = lpLData->hInformOnAppDeath;
-
- if( bClearSetHandles )
+ if( lpConn->lpPlayerName->u2.lpszLongNameA )
{
- CloseHandle( lpLData->hInformOnAppDeath );
- lpLData->hInformOnAppDeath = 0;
+ dwTotalSize += strlen( lpConn->lpPlayerName->u2.lpszLongNameA ) + 1;
}
+
}
- if( lphConnRead != NULL )
+ dwTotalSize += lpConn->dwAddressSize;
+
+ return dwTotalSize;
+}
+
+static DWORD DPLAYX_SizeOfLobbyDataW( const DPLCONNECTION *lpConn )
+{
+ DWORD dwTotalSize = sizeof( DPLCONNECTION );
+
+ /* Just a safety check */
+ if( lpConn == NULL )
{
- if( lpLData->hInformOnSettingRead == 0 )
+ ERR( "lpConn is NULL\n" );
+ return 0;
+ }
+
+ if( lpConn->lpSessionDesc != NULL )
+ {
+ dwTotalSize += sizeof( DPSESSIONDESC2 );
+
+ if( lpConn->lpSessionDesc->u1.lpszSessionName )
{
- DPLAYX_ReleaseSemaphore();
- return FALSE;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpSessionDesc->u1.lpszSessionName ) + 1 );
}
- *lphConnRead = lpLData->hInformOnSettingRead;
+ if( lpConn->lpSessionDesc->u2.lpszPassword )
+ {
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 );
+ }
+ }
- if( bClearSetHandles )
+ if( lpConn->lpPlayerName != NULL )
+ {
+ dwTotalSize += sizeof( DPNAME );
+
+ if( lpConn->lpPlayerName->u1.lpszShortName )
{
- CloseHandle( lpLData->hInformOnSettingRead );
- lpLData->hInformOnSettingRead = 0;
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpPlayerName->u1.lpszShortName ) + 1 );
}
+
+ if( lpConn->lpPlayerName->u2.lpszLongName )
+ {
+ dwTotalSize += sizeof( WCHAR ) *
+ ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 );
+ }
+
}
- DPLAYX_ReleaseSemaphore();
+ dwTotalSize += lpConn->dwAddressSize;
- return TRUE;
+ return dwTotalSize;
}
-
HRESULT DPLAYX_GetConnectionSettingsA
( DWORD dwAppID,
LPVOID lpData,
@@ -606,74 +827,6 @@ HRESULT DPLAYX_GetConnectionSettingsA
return DP_OK;
}
-/* Assumption: Enough contiguous space was allocated at dest */
-void DPLAYX_CopyConnStructA( LPDPLCONNECTION dest, const DPLCONNECTION *src )
-{
- BYTE* lpStartOfFreeSpace;
-
- *dest = *src;
-
- lpStartOfFreeSpace = ((BYTE*)dest) + sizeof( DPLCONNECTION );
-
- /* Copy the LPDPSESSIONDESC2 structure if it exists */
- if( src->lpSessionDesc )
- {
- dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
- *dest->lpSessionDesc = *src->lpSessionDesc;
-
- /* Session names may or may not exist */
- if( src->lpSessionDesc->u1.lpszSessionNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionNameA );
- dest->lpSessionDesc->u1.lpszSessionNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( dest->lpSessionDesc->u1.lpszSessionNameA ) + 1;
- }
-
- if( src->lpSessionDesc->u2.lpszPasswordA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPasswordA );
- dest->lpSessionDesc->u2.lpszPasswordA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( dest->lpSessionDesc->u2.lpszPasswordA ) + 1;
- }
- }
-
- /* DPNAME structure is optional */
- if( src->lpPlayerName )
- {
- dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPNAME );
- *dest->lpPlayerName = *src->lpPlayerName;
-
- if( src->lpPlayerName->u1.lpszShortNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortNameA );
- dest->lpPlayerName->u1.lpszShortNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( dest->lpPlayerName->u1.lpszShortNameA ) + 1;
- }
-
- if( src->lpPlayerName->u2.lpszLongNameA )
- {
- strcpy( (LPSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongNameA );
- dest->lpPlayerName->u2.lpszLongNameA = (LPSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace +=
- strlen( (LPSTR)dest->lpPlayerName->u2.lpszLongName ) + 1 ;
- }
-
- }
-
- /* Copy address if it exists */
- if( src->lpAddress )
- {
- dest->lpAddress = lpStartOfFreeSpace;
- CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
- /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
- }
-}
-
HRESULT DPLAYX_GetConnectionSettingsW
( DWORD dwAppID,
LPVOID lpData,
@@ -728,75 +881,6 @@ HRESULT DPLAYX_GetConnectionSettingsW
return DP_OK;
}
-/* Assumption: Enough contiguous space was allocated at dest */
-void DPLAYX_CopyConnStructW( LPDPLCONNECTION dest, const DPLCONNECTION *src )
-{
- BYTE* lpStartOfFreeSpace;
-
- *dest = *src;
-
- lpStartOfFreeSpace = ( (BYTE*)dest) + sizeof( DPLCONNECTION );
-
- /* Copy the LPDPSESSIONDESC2 structure if it exists */
- if( src->lpSessionDesc )
- {
- dest->lpSessionDesc = (LPDPSESSIONDESC2)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPSESSIONDESC2 );
- *dest->lpSessionDesc = *src->lpSessionDesc;
-
- /* Session names may or may not exist */
- if( src->lpSessionDesc->u1.lpszSessionName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u1.lpszSessionName );
- dest->lpSessionDesc->u1.lpszSessionName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( dest->lpSessionDesc->u1.lpszSessionName ) + 1 );
- }
-
- if( src->lpSessionDesc->u2.lpszPassword )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpSessionDesc->u2.lpszPassword );
- dest->lpSessionDesc->u2.lpszPassword = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( dest->lpSessionDesc->u2.lpszPassword ) + 1 );
- }
- }
-
- /* DPNAME structure is optional */
- if( src->lpPlayerName )
- {
- dest->lpPlayerName = (LPDPNAME)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof( DPNAME );
- *dest->lpPlayerName = *src->lpPlayerName;
-
- if( src->lpPlayerName->u1.lpszShortName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u1.lpszShortName );
- dest->lpPlayerName->u1.lpszShortName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( dest->lpPlayerName->u1.lpszShortName ) + 1 );
- }
-
- if( src->lpPlayerName->u2.lpszLongName )
- {
- strcpyW( (LPWSTR)lpStartOfFreeSpace, src->lpPlayerName->u2.lpszLongName );
- dest->lpPlayerName->u2.lpszLongName = (LPWSTR)lpStartOfFreeSpace;
- lpStartOfFreeSpace += sizeof(WCHAR) *
- ( strlenW( dest->lpPlayerName->u2.lpszLongName ) + 1 );
- }
-
- }
-
- /* Copy address if it exists */
- if( src->lpAddress )
- {
- dest->lpAddress = lpStartOfFreeSpace;
- CopyMemory( lpStartOfFreeSpace, src->lpAddress, src->dwAddressSize );
- /* No need to advance lpStartOfFreeSpace as there is no more "dynamic" data */
- }
-
-}
-
/* Store the structure into the shared data structure. Ensure that allocs for
* variable length strings come from the shared data structure.
* FIXME: We need to free information as well.
@@ -911,108 +995,10 @@ HRESULT DPLAYX_SetConnectionSettingsW
return DP_OK;
}
-DWORD DPLAYX_SizeOfLobbyDataA( const DPLCONNECTION *lpConn )
-{
- DWORD dwTotalSize = sizeof( DPLCONNECTION );
-
- /* Just a safety check */
- if( lpConn == NULL )
- {
- ERR( "lpConn is NULL\n" );
- return 0;
- }
-
- if( lpConn->lpSessionDesc != NULL )
- {
- dwTotalSize += sizeof( DPSESSIONDESC2 );
-
- if( lpConn->lpSessionDesc->u1.lpszSessionNameA )
- {
- dwTotalSize += strlen( lpConn->lpSessionDesc->u1.lpszSessionNameA ) + 1;
- }
-
- if( lpConn->lpSessionDesc->u2.lpszPasswordA )
- {
- dwTotalSize += strlen( lpConn->lpSessionDesc->u2.lpszPasswordA ) + 1;
- }
- }
-
- if( lpConn->lpPlayerName != NULL )
- {
- dwTotalSize += sizeof( DPNAME );
-
- if( lpConn->lpPlayerName->u1.lpszShortNameA )
- {
- dwTotalSize += strlen( lpConn->lpPlayerName->u1.lpszShortNameA ) + 1;
- }
-
- if( lpConn->lpPlayerName->u2.lpszLongNameA )
- {
- dwTotalSize += strlen( lpConn->lpPlayerName->u2.lpszLongNameA ) + 1;
- }
-
- }
-
- dwTotalSize += lpConn->dwAddressSize;
-
- return dwTotalSize;
-}
-
-DWORD DPLAYX_SizeOfLobbyDataW( const DPLCONNECTION *lpConn )
-{
- DWORD dwTotalSize = sizeof( DPLCONNECTION );
-
- /* Just a safety check */
- if( lpConn == NULL )
- {
- ERR( "lpConn is NULL\n" );
- return 0;
- }
-
- if( lpConn->lpSessionDesc != NULL )
- {
- dwTotalSize += sizeof( DPSESSIONDESC2 );
-
- if( lpConn->lpSessionDesc->u1.lpszSessionName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpSessionDesc->u1.lpszSessionName ) + 1 );
- }
-
- if( lpConn->lpSessionDesc->u2.lpszPassword )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpSessionDesc->u2.lpszPassword ) + 1 );
- }
- }
-
- if( lpConn->lpPlayerName != NULL )
- {
- dwTotalSize += sizeof( DPNAME );
-
- if( lpConn->lpPlayerName->u1.lpszShortName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpPlayerName->u1.lpszShortName ) + 1 );
- }
-
- if( lpConn->lpPlayerName->u2.lpszLongName )
- {
- dwTotalSize += sizeof( WCHAR ) *
- ( strlenW( lpConn->lpPlayerName->u2.lpszLongName ) + 1 );
- }
-
- }
-
- dwTotalSize += lpConn->dwAddressSize;
-
- return dwTotalSize;
-}
-
/* Copy an ANSI session desc structure to the given buffer */
-BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
+static BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest,
LPCDPSESSIONDESC2 lpSessionSrc )
{
CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) );
--
1.6.2.1
More information about the wine-patches
mailing list