/* * Utility Functions _________________________________________________________________ * */ static BOOL OnSalvage() { if (IsButtonChecked(hDlg, IDC_SERVER)) { pszPartitionName = 0; pszVolumeName = 0; } else if (IsButtonChecked(hDlg, IDC_PARTITION)) { pszPartitionName = szPartitionName; pszVolumeName = 0; } else if (IsButtonChecked(hDlg, IDC_VOLUME)) { pszPartitionName = szPartitionName; pszVolumeName = szVolumeName; } nNumProcesses = DEFAULT_NUM_PROCESSES; if (IsButtonChecked(hDlg, IDC_NUM_PROCESSES_CHECKBOX)) { nNumProcesses = _ttoi(szNumProcesses); if ((nNumProcesses < MIN_NUM_PROCESSES) || (nNumProcesses > MAX_NUM_PROCESSES)) { ShowError(hDlg, 0, IDS_INVALID_NUM_SALVAGE_PROCESSSES); return FALSE; } } if (!g_CfgData.bReuseAdminInfo) { if (!GetAdminInfo(hDlg, GAIO_LOGIN_ONLY)) return FALSE; if (!GetHandles(hDlg)) return FALSE; } return TRUE; }
static BOOL PrepareToConfig() { BOOL bMustExit = FALSE; // Use a local copy of the config info to decide what should be configured // or unconfigured. We do this so that if the user cancels for some reason, // the real config state will still be what the user expects (what was // previously read from the system plus the user's changes). CONFIG_STATE configFS = g_CfgData.configFS; // File server CONFIG_STATE configDB = g_CfgData.configDB; // Database server CONFIG_STATE configBak = g_CfgData.configBak; // Backup server CONFIG_STATE configSCS = g_CfgData.configSCS; // System Control server CONFIG_STATE configSCC = g_CfgData.configSCC; // System Control client BOOL bWorkToDo = FALSE; bWorkToDo |= PrepareToConfig(configFS, bFsRunning, bFsOn, IDC_FS_SERVICE); bWorkToDo |= PrepareToConfig(configDB, bDbRunning, bDbOn, IDC_DB_SERVICE); bWorkToDo |= PrepareToConfig(configBak, bBakRunning, bBakOn, IDC_BK_SERVICE); bWorkToDo |= PrepareToConfig(configSCS, bScsRunning, bScsOn, IDC_SCS); bWorkToDo |= PrepareToConfig(configSCC, bSccRunning, bSccOn, IDC_SCC); // If there is nothing to do, then just return TRUE. if (!bWorkToDo) return TRUE; // If we are unconfiguring the last DB server: // 1) Warn user and ask for confirmation // 2) Unconfigure all other servers that are running on this machine // 3) Tell them (after unconfiguring) that they must run the Wizard if they // wish to reconfigure the machine, then exit the program. if (configDB == CS_UNCONFIGURE) { if (g_CfgData.bLastDBServer) { int nChoice = MsgBox(hDlg, IDS_LAST_DB_SERVER, GetAppTitleID(), MB_YESNO | MB_ICONEXCLAMATION); if (nChoice == IDNO) return FALSE; // Make sure these all get unconfigured as well. If they are not configured, then // nothing bad will happen because the config calls are idempotent. configFS = CS_UNCONFIGURE; configBak = CS_UNCONFIGURE; configSCS = CS_UNCONFIGURE; configSCC = CS_UNCONFIGURE; } } // Get additional needed information from the user GET_ADMIN_INFO_OPTIONS eOptions; BOOL bDB = (ShouldConfig(configDB) || ShouldUnconfig(configDB)); // Use this as our default eOptions = GAIO_LOGIN_ONLY; // If we already have a sys control machine, then we don't need to ask for it if (ShouldConfig(configSCC)) { if (szScMachine[0] == 0) { ShowWarning(hDlg, IDS_MUST_ENTER_SCS_NAME); return FALSE; } lstrcpy(g_CfgData.szSysControlMachine, szScMachine); } else if (bDB && !g_CfgData.bLastDBServer) { // We need to know the name of the SCM machine. Are we the SCM machine? if (bScsRunning) lstrcpy(g_CfgData.szSysControlMachine, g_CfgData.szHostname); else eOptions = GAIO_GET_SCS; } // If doing a login only and the admin info is reusable if ((eOptions != GAIO_LOGIN_ONLY) || !g_CfgData.bReuseAdminInfo) { if (!GetAdminInfo(hDlg, eOptions)) return FALSE; // Use the admin info to get new handles if (!GetHandles(hDlg)) return FALSE; } // Now that we are ready to configure, copy our local config info // into the structure that the config engine uses. g_CfgData.configFS = configFS; g_CfgData.configDB = configDB; g_CfgData.configBak = configBak; g_CfgData.configSCS = configSCS; g_CfgData.configSCC = configSCC; // Configure the server BOOL bConfigSucceeded = Configure(hDlg, bMustExit); if (bConfigSucceeded) { if (bMustExit) { PostQuitMessage(0); return TRUE; } g_CfgData.bReuseAdminInfo = TRUE; } else g_CfgData.szAdminPW[0] = 0; // Get current config status BOOL bCanceled = FALSE; DWORD dwStatus = GetCurrentConfig(hDlg, bCanceled); if (dwStatus || bCanceled) { if (!bCanceled) ErrorDialog(dwStatus, IDS_CONFIG_CHECK_FAILED); } // Show the initial services config ShowInitialConfig(); ShowServiceStates(); return TRUE; }