summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2008-02-12 16:27:09 +0000
committerVladimir Glazounov <vg@openoffice.org>2008-02-12 16:27:09 +0000
commit889c47dab12d08228eceb4f7ab03dd28a6535d94 (patch)
tree405b380a31cf5c7187a267d95c7be2bf4157c37e /setup_native
parentc7d5db2e3afc4919e51f57fa037d45934fdc6695 (diff)
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
Diffstat (limited to 'setup_native')
-rw-r--r--setup_native/source/win32/stwrapper/stwrapper.cxx136
1 files changed, 95 insertions, 41 deletions
diff --git a/setup_native/source/win32/stwrapper/stwrapper.cxx b/setup_native/source/win32/stwrapper/stwrapper.cxx
index e833f9fe83af..b75e8da4cf79 100644
--- a/setup_native/source/win32/stwrapper/stwrapper.cxx
+++ b/setup_native/source/win32/stwrapper/stwrapper.cxx
@@ -96,7 +96,7 @@ static LPCTSTR GetOperatingSystemString()
ZeroMemory( &aOsVersion, sizeof( OSVERSIONINFO ));
aOsVersion.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
- _tcscpy( g_szOperatingSystem, TEXT( "Windows" ));
+ _tcscpy( g_szOperatingSystem, TEXT( "Microsoft Windows" ));
// Try to determine OS version
if ( GetVersionEx( &aOsVersion ))
@@ -147,7 +147,6 @@ static LPCTSTR GetOperatingSystemString()
}
break;
}
- _tcscat( g_szOperatingSystem, aOsVersion.szCSDVersion );
}
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 )
{
+ const DWORD ERR_NO_RECORDS_FOUND = 225;
+ const DWORD ERR_DUP_RECORD = 226;
+
DWORD dwExitCode = (DWORD)1;
int nArgs = 0;
@@ -247,20 +249,22 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
return 0;
}
- if ( nArgs == 11 )
+ if ( nArgs >= 11 )
{
TCHAR szTargetURN[1024] = {0};
TCHAR szProductName[1024] = {0};
TCHAR szProductVersion[1024] = {0};
TCHAR szParentProductName[1024] = {0};
TCHAR szProductSource[1024] = {0};
+ TCHAR szInstanceURN[1024] = {0};
+// -i) INSTANCE_URN="$2"; shift;;
// -t) TARGET_URN="$2"; shift;;
// -p) PRODUCT_NAME="$2"; shift;;
// -e) PRODUCT_VERSION="$2"; shift;;
// -P) PARENT_PRODUCT_NAME="$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;
while ( i < nArgs )
@@ -272,6 +276,14 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
{
switch ( lpArg[1] )
{
+ case 'i':
+ {
+ if ( i < nArgs )
+ ++i;
+ SafeCopy( szInstanceURN, lpArgs[i], elementsof( szInstanceURN ));
+ break;
+ }
+
case 't':
{
if ( i < nArgs )
@@ -319,59 +331,79 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
if ( RetrieveExecutablePath( g_szSTInstallationPath ) == PATHRESULT_OK )
{
+ BOOL bSuccess = TRUE;
+ BOOL bProcessStarted = FALSE;
+
STARTUPINFO aStartupInfo;
PROCESS_INFORMATION aProcessInfo;
+ LPTSTR lpCommandLine = 0;
ZeroMemory( &aStartupInfo, sizeof( aStartupInfo ));
aStartupInfo.cb = sizeof( aStartupInfo );
+ ZeroMemory( &aProcessInfo, sizeof( aProcessInfo ));
- // TEST=`${STCLIENT} -f -t ${TARGET_URN}`
- LPTSTR lpCommandLine = new TCHAR[MAXCMDLINELEN];
-
- _tcscpy( lpCommandLine, TEXT( "\"" ));
- _tcscat( lpCommandLine, g_szSTInstallationPath );
- _tcscat( lpCommandLine, TEXT( "\"" ));
- _tcscat( lpCommandLine, TEXT( " -f" ));
- _tcscat( lpCommandLine, TEXT( " -t "));
- _tcscat( lpCommandLine, TEXT( "\"" ));
- _tcscat( lpCommandLine, szTargetURN );
- _tcscat( lpCommandLine, TEXT( "\"" ));
-
- BOOL bSuccess = FALSE;
- bSuccess = CreateProcess(
- NULL,
- lpCommandLine,
- NULL,
- NULL,
- TRUE,
- CREATE_NO_WINDOW,
- NULL,
- NULL,
- &aStartupInfo,
- &aProcessInfo );
-
- // wait until process ends to receive exit code
- WaitForSingleObject( aProcessInfo.hProcess, INFINITE );
-
- delete []lpCommandLine;
+ if ( _tcslen( szInstanceURN ) == 0 )
+ {
+ // TEST=`${STCLIENT} -f -t ${TARGET_URN}`
+ lpCommandLine = new TCHAR[MAXCMDLINELEN];
+
+ _tcscpy( lpCommandLine, TEXT( "\"" ));
+ _tcscat( lpCommandLine, g_szSTInstallationPath );
+ _tcscat( lpCommandLine, TEXT( "\"" ));
+ _tcscat( lpCommandLine, TEXT( " -f" ));
+ _tcscat( lpCommandLine, TEXT( " -t "));
+ _tcscat( lpCommandLine, TEXT( "\"" ));
+ _tcscat( lpCommandLine, szTargetURN );
+ _tcscat( lpCommandLine, TEXT( "\"" ));
+
+ bSuccess = CreateProcess(
+ NULL,
+ lpCommandLine,
+ NULL,
+ NULL,
+ TRUE,
+ CREATE_NO_WINDOW,
+ NULL,
+ NULL,
+ &aStartupInfo,
+ &aProcessInfo );
+
+ bProcessStarted = TRUE;
+
+ // wait until process ends to receive exit code
+ WaitForSingleObject( aProcessInfo.hProcess, INFINITE );
+
+ delete []lpCommandLine;
+ }
if ( bSuccess )
{
- DWORD dwSTClientExitCode = 0;
- GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
+ DWORD dwSTClientExitCode( ERR_NO_RECORDS_FOUND );
+ if ( bProcessStarted )
+ {
+ GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
+ dwSTClientExitCode &= 0x000000ff;
- CloseHandle( aProcessInfo.hProcess );
- CloseHandle( aProcessInfo.hThread );
+ CloseHandle( aProcessInfo.hProcess );
+ CloseHandle( aProcessInfo.hThread );
+ }
- if ( dwSTClientExitCode != 0 )
+ if ( dwSTClientExitCode == ERR_NO_RECORDS_FOUND )
{
- // 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`
+ // 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];
_tcscpy( lpCommandLine, TEXT( "\"" ));
_tcscat( lpCommandLine, g_szSTInstallationPath );
_tcscat( lpCommandLine, TEXT( "\"" ));
_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( "\"" ));
_tcscat( lpCommandLine, szProductName );
@@ -422,14 +454,36 @@ int WINAPI _tWinMain( HINSTANCE /*hInstance*/, HINSTANCE, LPTSTR, int )
dwSTClientExitCode = 0;
GetExitCodeProcess( aProcessInfo.hProcess, &dwSTClientExitCode );
+ dwSTClientExitCode &= 0x000000ff;
CloseHandle( aProcessInfo.hProcess );
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
- dwExitCode = 0; // we are already registered
+ dwExitCode = 1; // other errors
}
+ else
+ dwExitCode = 1; // couldn't start stclient
}
else
dwExitCode = 1; // no executable found