if (dlErr != 0) { ErrorHandler(dlErr, nil); return (void*) nil; } ClearDLProgControls(false); DisableNavButtons();  SetPort(oldPort);
if (dlErr != 0) { ErrorHandler(dlErr, nil); return (void*) nil; } } else bCoreExists = true;   while (FindRunningAppBySignature('MOSS', &theSpec, &thePSN) == noErr || FindRunningAppBySignature('MOZZ', &theSpec, &thePSN) == noErr) { Str255 itemText; SInt16 itemHit; short itemType; Handle item; Rect itemBox, iconRect, windRect; CIconHandle cicn;  if ( pDlg == nil ) { pDlg = GetNewDialog(151, NULL, (WindowPtr) -1);  ShowWindow(pDlg); SelectWindow(pDlg);  GetDialogItem(pDlg, 3, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sExecuting); SetDialogItemText( item, itemText );  GetDialogItem(pDlg, 2, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sNextBtn); SetControlTitle((ControlRecord **)item, itemText);  GetDialogItem(pDlg, 1, &itemType, &item, &itemBox); GetResourcedString(itemText, rInstList, sQuitBtn); SetControlTitle((ControlRecord **)item, itemText);  #if 1 GetDialogItem(pDlg, 4, &itemType, &item, &itemBox); cicn = GetCIcon( 129 ); windRect = pDlg->portRect; LocalToGlobal((Point *) &windRect.top); LocalToGlobal((Point *) &windRect.bottom); SetRect(&iconRect, windRect.left + itemBox.left, windRect.top + itemBox.top, windRect.left + itemBox.left + itemBox.right, windRect.top + itemBox.top + itemBox.bottom );  if ( cicn != nil ) PlotCIcon( &iconRect, cicn ); SysBeep( 20L ); #endif } do { EventRecord evt;  if(WaitNextEvent(everyEvent, &evt, 1, nil)) { if ( IsDialogEvent( &evt ) == false ) {  HandleNextEvent(&evt); } else {  DialogPtr tDlg; DialogSelect( &evt, &tDlg, &itemHit ); } } } while(itemHit != 1 && itemHit != 2);  if ( itemHit == 1 ) { DisposeDialog(pDlg); gDone = true; return (void*) nil; } else { itemHit = 0; SysBeep( 20L ); } }  if (pDlg != nil ) DisposeDialog(pDlg);  SetPort(oldPort);  ClearDLProgControls(false); DisableNavButtons();
pascal void* Install(void* unused){		short			vRefNum, srcVRefNum;	long			dirID, srcDirID, modulesDirID;	OSErr 			err;	FSSpec			coreFileSpec;	short			dlErr;	short           siteIndex;#ifdef MIW_DEBUG	FSSpec			tmpSpec;#endif /* MIW_DEBUG */	Str255			pIDIfname, pModulesDir;	StringPtr		coreFile = NULL;	THz				ourHZ = NULL;	Boolean 		isDir = false, bCoreExists = false;	GrafPtr			oldPort = NULL;#ifndef MIW_DEBUG	/* get "Temporary Items" folder path */	ERR_CHECK_RET(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID), (void*)0);#else	/* for DEBUG builds dump downloaded items in "<currProcessVolume>:Temp NSInstall:" */	vRefNum = gControls->opt->vRefNum;	err = FSMakeFSSpec( vRefNum, 0, kTempFolder, &tmpSpec );	if (err != noErr)	{		err = FSpDirCreate(&tmpSpec, smSystemScript, &dirID);		if (err != noErr)		{			ErrorHandler(err, nil);			return (void*)0;		}	}	else	{		err = FSpGetDirectoryID( &tmpSpec, &dirID, &isDir );		if (!isDir || err!=noErr)		{			ErrorHandler(err, nil);			return (void*)0;		}	}	#endif /* MIW_DEBUG */		err = GetCWD(&srcDirID, &srcVRefNum);	if (err != noErr)	{		ErrorHandler(err, nil);		return (void*)nil;	}		/* get the "Installer Modules" relative subdir */	GetIndString(pModulesDir, rStringList, sInstModules);	isDir = false;  /* reuse */	modulesDirID = 0;	GetDirectoryID(srcVRefNum, srcDirID, pModulesDir, &modulesDirID, &isDir);	srcDirID = modulesDirID;		if (!isDir || !ExistArchives(srcVRefNum, srcDirID))	{			bXPIsExisted = false;		GetIndString(pIDIfname, rStringList, sTempIDIName);			/* preparing to download */		ourHZ = GetZone();		GetPort(&oldPort);	    /* otherwise if site selector exists, replace global URL with selected site */        if (gControls->cfg->numSites > 0)        {	        if (gControls->cfg->globalURL[0])	            DisposeHandle(gControls->cfg->globalURL[0]);            gControls->cfg->globalURL[0] = NewHandleClear(kValueMaxLen);                        siteIndex = gControls->opt->siteChoice - 1;            HLock(gControls->cfg->globalURL[0]);            HLock(gControls->cfg->site[siteIndex].domain);            strcpy(*(gControls->cfg->globalURL[0]), *(gControls->cfg->site[siteIndex].domain));            HUnlock(gControls->cfg->globalURL[0]);            HUnlock(gControls->cfg->site[siteIndex].domain);	    }                if (gControls->state != eResuming)            InitDLProgControls(false);        dlErr = DownloadXPIs(srcVRefNum, srcDirID);        if (dlErr == nsFTPConn::E_USER_CANCEL)        {            return (void *) nil;        }		if (dlErr != 0)		{		    ErrorHandler(dlErr, nil);			return (void*) nil;		}        ClearDLProgControls(false);        DisableNavButtons();        		SetPort(oldPort);			if (gWPtr)		{			GetPort(&oldPort);			SetPort(gWPtr);			BeginUpdate(gWPtr);			DrawControls(gWPtr);			ShowLogo(false);			UpdateTerminalWin();			EndUpdate(gWPtr);					SetPort(oldPort);		}		SetZone(ourHZ);    }	else		bCoreExists = true;    /* otherwise core exists in cwd:Installer Modules, different from extraction location */	/* check if coreFile was downloaded */	HLock(gControls->cfg->coreFile);	if (*gControls->cfg->coreFile != NULL)	{		coreFile = CToPascal(*gControls->cfg->coreFile);		if (!coreFile)			return (void*) memFullErr;	}	HUnlock(gControls->cfg->coreFile);			if (coreFile != NULL && *coreFile > 0) /* core file was specified */	{		err = FSMakeFSSpec(srcVRefNum, srcDirID, coreFile, &coreFileSpec);		if (err==noErr) /* core file was downloaded or packaged with installer */		{			InitProgressBar();						/* extract contents of downloaded or packaged core file */			err = ExtractCoreFile(srcVRefNum, srcDirID, vRefNum, dirID);			if (err!=noErr) 			{				ErrorHandler(err, nil);				if (coreFile)					DisposePtr((Ptr)coreFile);				return (void*) nil;			}					/* run all .xpi's through XPInstall */			err = RunAllXPIs(srcVRefNum, srcDirID, vRefNum, dirID);			if (err!=noErr)				ErrorHandler(err, nil);							CleanupExtractedFiles(vRefNum, dirID);		}				if (coreFile)			DisposePtr((Ptr)coreFile);	}		/* launch the downloaded apps who had the LAUNCHAPP attr set */	if (err == noErr)		LaunchApps(srcVRefNum, srcDirID);		/* run apps that were set in RunAppsX sections */	if (err == noErr && gControls->cfg->numRunApps > 0)		RunApps();	 	// cleanup downloaded .xpis 	if (!gControls->opt->saveBits  && !bXPIsExisted)		DeleteXPIs(srcVRefNum, srcDirID);  // "Installer Modules" folder location is supplied 	/* wind down app */	gDone = true;		return (void*) 0;}