INTEGRATION: CWS fwk84_SRC680 (1.3.22); FILE MERGED
2008/02/01 13:00:37 cd 1.3.22.1: #153871# Make argument -i <instance urn> optional. Check error code of stclient
This commit is contained in:
@@ -96,7 +96,7 @@ static LPCTSTR GetOperatingSystemString()
|
|||||||
ZeroMemory( &aOsVersion, sizeof( OSVERSIONINFO ));
|
ZeroMemory( &aOsVersion, sizeof( OSVERSIONINFO ));
|
||||||
aOsVersion.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
|
aOsVersion.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
|
||||||
|
|
||||||
_tcscpy( g_szOperatingSystem, TEXT( "Windows" ));
|
_tcscpy( g_szOperatingSystem, TEXT( "Microsoft Windows" ));
|
||||||
|
|
||||||
// Try to determine OS version
|
// Try to determine OS version
|
||||||
if ( GetVersionEx( &aOsVersion ))
|
if ( GetVersionEx( &aOsVersion ))
|
||||||
@@ -147,7 +147,6 @@ static LPCTSTR GetOperatingSystemString()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_tcscat( g_szOperatingSystem, aOsVersion.szCSDVersion );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_szOperatingSystem;
|
return g_szOperatingSystem;
|
||||||
@@ -235,6 +234,9 @@ static void SafeCopy( LPTSTR lpTarget, LPCSTR lpSource, size_t nMaxLen )
|
|||||||
|
|
||||||
int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
||||||
{
|
{
|
||||||
|
const DWORD ERR_NO_RECORDS_FOUND = 225;
|
||||||
|
const DWORD ERR_DUP_RECORD = 226;
|
||||||
|
|
||||||
DWORD dwExitCode = (DWORD)1;
|
DWORD dwExitCode = (DWORD)1;
|
||||||
|
|
||||||
int nArgs = 0;
|
int nArgs = 0;
|
||||||
@@ -247,20 +249,22 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nArgs == 11 )
|
if ( nArgs >= 11 )
|
||||||
{
|
{
|
||||||
TCHAR szTargetURN[1024] = {0};
|
TCHAR szTargetURN[1024] = {0};
|
||||||
TCHAR szProductName[1024] = {0};
|
TCHAR szProductName[1024] = {0};
|
||||||
TCHAR szProductVersion[1024] = {0};
|
TCHAR szProductVersion[1024] = {0};
|
||||||
TCHAR szParentProductName[1024] = {0};
|
TCHAR szParentProductName[1024] = {0};
|
||||||
TCHAR szProductSource[1024] = {0};
|
TCHAR szProductSource[1024] = {0};
|
||||||
|
TCHAR szInstanceURN[1024] = {0};
|
||||||
|
|
||||||
|
// -i) INSTANCE_URN="$2"; shift;;
|
||||||
// -t) TARGET_URN="$2"; shift;;
|
// -t) TARGET_URN="$2"; shift;;
|
||||||
// -p) PRODUCT_NAME="$2"; shift;;
|
// -p) PRODUCT_NAME="$2"; shift;;
|
||||||
// -e) PRODUCT_VERSION="$2"; shift;;
|
// -e) PRODUCT_VERSION="$2"; shift;;
|
||||||
// -P) PARENT_PRODUCT_NAME="$2"; shift;;
|
// -P) PARENT_PRODUCT_NAME="$2"; shift;;
|
||||||
// -S) PRODUCT_SOURCE="$2"; shift;;
|
// -S) PRODUCT_SOURCE="$2"; shift;;
|
||||||
// "usage: $0 -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name>"
|
// "usage: $0 [-i <instance urn>] -p <product name> -e <product version> -t <urn> -S <source> -P <parent product name>"
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while ( i < nArgs )
|
while ( i < nArgs )
|
||||||
@@ -272,6 +276,14 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
|||||||
{
|
{
|
||||||
switch ( lpArg[1] )
|
switch ( lpArg[1] )
|
||||||
{
|
{
|
||||||
|
case 'i':
|
||||||
|
{
|
||||||
|
if ( i < nArgs )
|
||||||
|
++i;
|
||||||
|
SafeCopy( szInstanceURN, lpArgs[i], elementsof( szInstanceURN ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
{
|
{
|
||||||
if ( i < nArgs )
|
if ( i < nArgs )
|
||||||
@@ -319,59 +331,79 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
|||||||
|
|
||||||
if ( RetrieveExecutablePath( g_szSTInstallationPath ) == PATHRESULT_OK )
|
if ( RetrieveExecutablePath( g_szSTInstallationPath ) == PATHRESULT_OK )
|
||||||
{
|
{
|
||||||
|
BOOL bSuccess = TRUE;
|
||||||
|
BOOL bProcessStarted = FALSE;
|
||||||
|
|
||||||
STARTUPINFO aStartupInfo;
|
STARTUPINFO aStartupInfo;
|
||||||
PROCESS_INFORMATION aProcessInfo;
|
PROCESS_INFORMATION aProcessInfo;
|
||||||
|
LPTSTR lpCommandLine = 0;
|
||||||
|
|
||||||
ZeroMemory( &aStartupInfo, sizeof( aStartupInfo ));
|
ZeroMemory( &aStartupInfo, sizeof( aStartupInfo ));
|
||||||
aStartupInfo.cb = sizeof( aStartupInfo );
|
aStartupInfo.cb = sizeof( aStartupInfo );
|
||||||
|
ZeroMemory( &aProcessInfo, sizeof( aProcessInfo ));
|
||||||
|
|
||||||
// TEST=`${STCLIENT} -f -t ${TARGET_URN}`
|
if ( _tcslen( szInstanceURN ) == 0 )
|
||||||
LPTSTR lpCommandLine = new TCHAR[MAXCMDLINELEN];
|
{
|
||||||
|
// TEST=`${STCLIENT} -f -t ${TARGET_URN}`
|
||||||
|
lpCommandLine = new TCHAR[MAXCMDLINELEN];
|
||||||
|
|
||||||
_tcscpy( lpCommandLine, TEXT( "\"" ));
|
_tcscpy( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, g_szSTInstallationPath );
|
_tcscat( lpCommandLine, g_szSTInstallationPath );
|
||||||
_tcscat( lpCommandLine, TEXT( "\"" ));
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, TEXT( " -f" ));
|
_tcscat( lpCommandLine, TEXT( " -f" ));
|
||||||
_tcscat( lpCommandLine, TEXT( " -t "));
|
_tcscat( lpCommandLine, TEXT( " -t "));
|
||||||
_tcscat( lpCommandLine, TEXT( "\"" ));
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, szTargetURN );
|
_tcscat( lpCommandLine, szTargetURN );
|
||||||
_tcscat( lpCommandLine, TEXT( "\"" ));
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
|
|
||||||
BOOL bSuccess = FALSE;
|
bSuccess = CreateProcess(
|
||||||
bSuccess = CreateProcess(
|
NULL,
|
||||||
NULL,
|
lpCommandLine,
|
||||||
lpCommandLine,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
TRUE,
|
||||||
TRUE,
|
CREATE_NO_WINDOW,
|
||||||
CREATE_NO_WINDOW,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
&aStartupInfo,
|
||||||
&aStartupInfo,
|
&aProcessInfo );
|
||||||
&aProcessInfo );
|
|
||||||
|
|
||||||
// wait until process ends to receive exit code
|
bProcessStarted = TRUE;
|
||||||
WaitForSingleObject( aProcessInfo.hProcess, INFINITE );
|
|
||||||
|
|
||||||
delete []lpCommandLine;
|
// wait until process ends to receive exit code
|
||||||
|
WaitForSingleObject( aProcessInfo.hProcess, INFINITE );
|
||||||
|
|
||||||
|
delete []lpCommandLine;
|
||||||
|
}
|
||||||
|
|
||||||
if ( bSuccess )
|
if ( bSuccess )
|
||||||
{
|
{
|
||||||
DWORD dwSTClientExitCode = 0;
|
DWORD dwSTClientExitCode( ERR_NO_RECORDS_FOUND );
|
||||||
GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
|
if ( bProcessStarted )
|
||||||
|
|
||||||
CloseHandle( aProcessInfo.hProcess );
|
|
||||||
CloseHandle( aProcessInfo.hThread );
|
|
||||||
|
|
||||||
if ( dwSTClientExitCode != 0 )
|
|
||||||
{
|
{
|
||||||
// output=`${STCLIENT} -a -p "${PRODUCT_NAME}" -e "${PRODUCT_VERSION}" -t "${TARGET_URN}" -S "${PRODUCT_SOURCE}" -P "${PARENT_PRODUCT_NAME}" -m "Sun Microsystems, Inc." -A ${uname} -z global`
|
GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
|
||||||
|
dwSTClientExitCode &= 0x000000ff;
|
||||||
|
|
||||||
|
CloseHandle( aProcessInfo.hProcess );
|
||||||
|
CloseHandle( aProcessInfo.hThread );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( dwSTClientExitCode == ERR_NO_RECORDS_FOUND )
|
||||||
|
{
|
||||||
|
// output=`${STCLIENT} -a [-i "${INSTANCE_URN}"] -p "${PRODUCT_NAME}" -e "${PRODUCT_VERSION}" -t "${TARGET_URN}" -S "${PRODUCT_SOURCE}" -P "${PARENT_PRODUCT_NAME}" -m "Sun Microsystems, Inc." -A ${uname} -z global`
|
||||||
lpCommandLine = new TCHAR[MAXCMDLINELEN];
|
lpCommandLine = new TCHAR[MAXCMDLINELEN];
|
||||||
|
|
||||||
_tcscpy( lpCommandLine, TEXT( "\"" ));
|
_tcscpy( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, g_szSTInstallationPath );
|
_tcscat( lpCommandLine, g_szSTInstallationPath );
|
||||||
_tcscat( lpCommandLine, TEXT( "\"" ));
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, TEXT( " -a" ));
|
_tcscat( lpCommandLine, TEXT( " -a" ));
|
||||||
|
if ( _tcslen( szInstanceURN ) > 0 )
|
||||||
|
{
|
||||||
|
_tcscat( lpCommandLine, TEXT( " -i " ));
|
||||||
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
|
_tcscat( lpCommandLine, szInstanceURN );
|
||||||
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
|
}
|
||||||
_tcscat( lpCommandLine, TEXT( " -p " ));
|
_tcscat( lpCommandLine, TEXT( " -p " ));
|
||||||
_tcscat( lpCommandLine, TEXT( "\"" ));
|
_tcscat( lpCommandLine, TEXT( "\"" ));
|
||||||
_tcscat( lpCommandLine, szProductName );
|
_tcscat( lpCommandLine, szProductName );
|
||||||
@@ -422,14 +454,36 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
|
|||||||
|
|
||||||
dwSTClientExitCode = 0;
|
dwSTClientExitCode = 0;
|
||||||
GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
|
GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
|
||||||
|
dwSTClientExitCode &= 0x000000ff;
|
||||||
|
|
||||||
CloseHandle( aProcessInfo.hProcess );
|
CloseHandle( aProcessInfo.hProcess );
|
||||||
CloseHandle( aProcessInfo.hThread );
|
CloseHandle( aProcessInfo.hThread );
|
||||||
return dwSTClientExitCode;
|
|
||||||
|
if ( !bSuccess )
|
||||||
|
dwExitCode = 1; // couldn't start stclient process
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( _tcslen( szInstanceURN ) > 0 )
|
||||||
|
{
|
||||||
|
// don't register again if we registered in a previous run
|
||||||
|
// or we called stclient successfully.
|
||||||
|
if (( dwSTClientExitCode == ERR_DUP_RECORD ) ||
|
||||||
|
( dwSTClientExitCode == 0 ))
|
||||||
|
dwExitCode = 0;
|
||||||
|
else
|
||||||
|
dwExitCode = 1; // other errors
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dwExitCode = ( dwSTClientExitCode == 0 ) ? 0 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if ( dwSTClientExitCode == 0 )
|
||||||
|
dwExitCode = 0; // already registered
|
||||||
else
|
else
|
||||||
dwExitCode = 0; // we are already registered
|
dwExitCode = 1; // other errors
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
dwExitCode = 1; // couldn't start stclient
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dwExitCode = 1; // no executable found
|
dwExitCode = 1; // no executable found
|
||||||
|
Reference in New Issue
Block a user