gala_clients/integrator/msdev/integrator/mapnet/mapnet.cpp
/*****************************************************************************\
* GetSharedPath( wchar_t *pSharedPath, wchar_t *pSharedName, char *pszNeeded, 
*									  char *pszBuffer )
*
* Parameters: pSharedPath - local directory being shared (UNICODE string);
*							pSharedName - name of the share (UNICODE string);
*							pszNeeded - path we are trying to make visible from UNIX (non-UNICODE)
*							pszBuffer - buffer for a result string (non-UNICODE)
*							
* Return value: TRUE in case of success, FALSE in case of failure 
*
* This function checks if a given share contains a path we are trying to make
*	visible from UNIX and writes UNIX-style net name into a pszBuffer if posiible.
*
\*****************************************************************************/




Return value: TRUE in case of success, FALSE in case of failure

This function checks if a given share contains a path we are trying to make
visible from UNIX and writes UNIX-style net name into a pszBuffer if posiible.


Return value : TRUE in case of success FALSE in case of failure This function checks if a given share contains a path we are trying to make visible from UNIX and writes UNIX - style net name into a pszBuffer if posiible .
BOOL GetSharedPath( wchar_t *pSharedPath, wchar_t *pSharedName, char *pszNeeded, 
									  char *pszBuffer )
{
	char SharedDir[ MAX_PATH ];
	char NeededPath[ MAX_PATH ];
	char ShareName[ _MAX_FNAME ];
	char HostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
	BOOL fResult = FALSE;
	if( WideCharToMultiByte( CP_ACP, 0, pSharedPath, -1, SharedDir,
													 MAX_PATH, NULL, NULL )  && 
			WideCharToMultiByte( CP_ACP, 0, pSharedName, -1, ShareName,
													 _MAX_FNAME, NULL, NULL ) )
	{
		strupr( SharedDir );
		strcpy( NeededPath, pszNeeded );
		strupr( NeededPath );
		if( strstr( NeededPath, SharedDir ) == NeededPath ) 
		{
			fResult = TRUE;
			DWORD nLength = MAX_COMPUTERNAME_LENGTH + 1;
			if( !GetComputerName( HostName, &nLength ) )
				HostName[0] = '\0';
			wsprintf( pszBuffer, "/net/%s/%s%s", HostName, ShareName, 
								pszNeeded + strlen( SharedDir ) );
			ChangeSlashForward( pszBuffer );
		}
	}
	return fResult;
}
BOOL GetSharedPath ( wchar_t * pSharedPath , wchar_t * pSharedName , char * pszNeeded , char * pszBuffer ) { char SharedDir [ MAX_PATH ] ; char NeededPath [ MAX_PATH ] ; char ShareName [ _MAX_FNAME ] ; char HostName [ MAX_COMPUTERNAME_LENGTH + 1 ] ; BOOL fResult = FALSE ; if ( WideCharToMultiByte ( CP_ACP , 0 , pSharedPath , -1 , SharedDir , MAX_PATH , NULL , NULL ) && WideCharToMultiByte ( CP_ACP , 0 , pSharedName , -1 , ShareName , _MAX_FNAME , NULL , NULL ) ) { strupr ( SharedDir ) ; strcpy ( NeededPath , pszNeeded ) ; strupr ( NeededPath ) ; if ( strstr ( NeededPath , SharedDir ) == NeededPath ) { fResult = TRUE ; DWORD nLength = MAX_COMPUTERNAME_LENGTH + 1 ; if ( ! GetComputerName ( HostName , & nLength ) ) HostName [ 0 ] = ' \0 ' ; wsprintf ( pszBuffer , " " , HostName , ShareName , pszNeeded + strlen ( SharedDir ) ) ; ChangeSlashForward ( pszBuffer ) ; } } return fResult ; }
\
GetSharedPath( wchar_t *pSharedPath, wchar_t *pSharedName, char *pszNeeded,
char *pszBuffer )
\ GetSharedPath ( wchar_t * pSharedPath wchar_t * pSharedName char * pszNeeded char * pszBuffer )
// convert strings from UNICODE to one-byte-character strings // Convert needed path and shared path to uppercase since FAT and NTFS are // not case sensitive // shared directory contains // needed path