Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

780 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998 - 2000.
  5. //
  6. // File: CatCnfg.cxx
  7. //
  8. // Contents: Support for adding catalogs during setup.
  9. //
  10. // History: 13-May-1998 KyleP Added copyright
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "pch.cxx"
  14. #pragma hdrstop
  15. #include <ciregkey.hxx>
  16. #include "catcnfg.hxx"
  17. //+-------------------------------------------------------------------------
  18. //
  19. // Member: CCatalogConfig::CCatalogConfig
  20. //
  21. // Synopsis: Constructor
  22. //
  23. // History: 9-10-97 mohamedn
  24. //
  25. //--------------------------------------------------------------------------
  26. CCatalogConfig::CCatalogConfig(CError & Err) :
  27. _Err( Err ),
  28. _cDrive( 0 ),
  29. _pwszCatalogDrive( 0 ),
  30. _cIncludedScopes( 0 ), _xaIncludedScopes( 10 ),
  31. _cExcludedScopes( 0 ), _xaExcludedScopes( 10 )
  32. {
  33. RtlZeroMemory( _DriveList, sizeof _DriveList );
  34. }
  35. //+-------------------------------------------------------------------------
  36. //
  37. // Member: CCatalogConfig::InitDriveList, public
  38. //
  39. // Synopsis: Initialize drive list with local drive names, types, and
  40. // available/free space.
  41. //
  42. // Arguments: none
  43. //
  44. // Returns: ERROR_SUCCESS upon sucess,
  45. // none zero upon failure.
  46. //
  47. // History: 6-27-97 mohamedn created
  48. // 9/10/97 mohamedn rewritten catalog configuration
  49. //
  50. //--------------------------------------------------------------------------
  51. BOOL CCatalogConfig::InitDriveList()
  52. {
  53. // 26 drive letters * 4 characters per drive + terminating NULL.
  54. const DWORD dwSize = MAX_DRIVES * CHARS_PER_DRIVE + 1;
  55. WCHAR wszListOfAllDrives[ dwSize ];
  56. unsigned iDriveNumber = 0;
  57. DWORD dwRetVal = 0;
  58. RtlZeroMemory( wszListOfAllDrives, sizeof wszListOfAllDrives );
  59. dwRetVal = GetLogicalDriveStrings(dwSize, wszListOfAllDrives);
  60. if ( dwRetVal == 0 || dwRetVal > dwSize )
  61. {
  62. DWORD dwErr = GetLastError();
  63. isDebugOut(( "GetLogicalDriveStrings Failed: dwRetVal: %d, GetLastError(): %d\n",
  64. dwRetVal, dwErr ));
  65. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dwErr );
  66. return FALSE;
  67. }
  68. for ( WCHAR *pwszTmp = wszListOfAllDrives;
  69. *pwszTmp;
  70. pwszTmp += CHARS_PER_DRIVE )
  71. {
  72. switch (GetDriveType(pwszTmp))
  73. {
  74. case DRIVE_FIXED: // The disk cannot be removed from the drive.
  75. break;
  76. default:
  77. isDebugOut(( "InitDriveList: Unexpected drive type %d\n",
  78. GetDriveType(pwszTmp) ));
  79. case 0: // The drive type cannot be determined.
  80. case 1: // The root directory does not exist.
  81. case DRIVE_REMOVABLE: // The media can be removed from the drive.
  82. case DRIVE_REMOTE: // The drive is a remote (network) drive.
  83. case DRIVE_CDROM: // drive is a CD-ROM drive.
  84. case DRIVE_RAMDISK: // The drive is a RAM disk.
  85. continue;
  86. }
  87. _DriveList[iDriveNumber].SetDriveName(pwszTmp);
  88. if ( ! _DriveList[iDriveNumber].SetDriveInfo( ) )
  89. {
  90. continue;
  91. }
  92. else
  93. {
  94. iDriveNumber++;
  95. }
  96. }
  97. _cDrive = iDriveNumber;
  98. ReservePageFileData();
  99. return ( _cDrive > 0 ? TRUE : FALSE );
  100. }
  101. //+-------------------------------------------------------------------------
  102. //
  103. // Member: CCatalogConfig::ReservePageFileData, private
  104. //
  105. // Synopsis: Reserve unallocated space for page files.
  106. //
  107. // Arguments: none
  108. //
  109. // Returns: TRUE upon sucess, FALSE upon failure.
  110. //
  111. // History: 26 Oct 1998 AlanwW Created
  112. //
  113. //--------------------------------------------------------------------------
  114. const WCHAR wszPagingFileKey[] =
  115. L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management";
  116. const WCHAR wszPagingFileValueName[] = L"PagingFiles";
  117. BOOL CCatalogConfig::ReservePageFileData()
  118. {
  119. WCHAR awcPagingFiles[2000];
  120. awcPagingFiles[0] = L'\0';
  121. //
  122. // Get the original page file info from
  123. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessonManager
  124. //
  125. CWin32RegAccess reg( HKEY_LOCAL_MACHINE, wszPagingFileKey );
  126. if ( ! reg.Get( wszPagingFileValueName,
  127. awcPagingFiles,
  128. sizeof awcPagingFiles/sizeof awcPagingFiles[0] ) )
  129. return FALSE;
  130. //
  131. // Iterate through all paging files, reserve any difference between
  132. // the max size and currently allocated size.
  133. //
  134. WCHAR * pwsz = &awcPagingFiles[0];
  135. while ( *pwsz )
  136. {
  137. WCHAR *pwszPageFile = pwsz;
  138. pwsz = wcschr(pwsz, L' ');
  139. if ( ! pwsz )
  140. break;
  141. *pwsz++ = L'\0';
  142. ULONG ulMinAlloc = _wtoi( pwsz );
  143. WCHAR *pwsz2 = wcschr(pwsz, L' ');
  144. ULONG ulMaxAlloc = ulMinAlloc + MAXOVERMINFACTOR;
  145. if ( pwsz2 )
  146. ulMaxAlloc = _wtoi( pwsz2 );
  147. while ( *pwsz )
  148. pwsz++;
  149. pwsz++;
  150. CDriveInformation * pDriveInfo = GetDriveInfo( pwszPageFile );
  151. if ( !pDriveInfo )
  152. continue;
  153. //
  154. // For some reason, GetFileAttributesEx will get a sharing violation
  155. // on an open paging file. FindFirstFile will work to get the very
  156. // same information.
  157. //
  158. HANDLE hFind;
  159. WIN32_FIND_DATA FindData;
  160. if ( (hFind = FindFirstFile(pwszPageFile, &FindData)) ==
  161. INVALID_HANDLE_VALUE )
  162. {
  163. isDebugOut(( "ReservePageFileData: FindFirstFile %ws failed: %x\n",
  164. pwszPageFile,
  165. GetLastError() ));
  166. continue;
  167. }
  168. FindClose(hFind);
  169. ULARGE_INTEGER ullFileSize;
  170. ullFileSize.LowPart = FindData.nFileSizeLow;
  171. ullFileSize.HighPart = FindData.nFileSizeHigh;
  172. pDriveInfo->ReservePagingData( ulMaxAlloc * ONE_MB,
  173. ullFileSize.QuadPart );
  174. }
  175. return TRUE;
  176. }
  177. //+-------------------------------------------------------------------------
  178. //
  179. // Member: CDriveInformation::GetDriveInfo, public
  180. //
  181. // Synopsis: Returns pointer to drive information structure.
  182. //
  183. // Arguments: [pwszPath] - path name to be looked up
  184. //
  185. // Returns: CDriveInformation* - pointer to drive information; 0 if not found
  186. //
  187. // History: 29 Oct 1998 AlanW Created
  188. //
  189. //--------------------------------------------------------------------------
  190. CDriveInformation * CCatalogConfig::GetDriveInfo(WCHAR const * pwszPath)
  191. {
  192. WCHAR wcDriveLetter = (WCHAR)toupper( *pwszPath );
  193. for (unsigned i = 0; i < _cDrive; i++ )
  194. {
  195. if (toupper( _DriveList[i].GetDriveLetter() ) == wcDriveLetter )
  196. return &_DriveList[i];
  197. }
  198. return 0;
  199. }
  200. //+-------------------------------------------------------------------------
  201. //
  202. // Member: CDriveInformation::SetDriveInfo, public
  203. //
  204. // Synopsis: Obtains drive info
  205. //
  206. // Arguments: [none]
  207. //
  208. // Returns: TRUE upon success, False upon failure.
  209. //
  210. // History: 6-27-97 mohamedn created
  211. // 26 Oct 1998 AlanwW Enhanced and made a CDriveInfo method.
  212. //
  213. //--------------------------------------------------------------------------
  214. static WCHAR pwszBootFile1[] = L"x:\\NTLDR"; // x86
  215. static WCHAR pwszBootFile2[] = L"x:\\OS\\WINNT50\\OSLOADER.EXE"; // risc
  216. static WCHAR * apwszBootFiles[] = {
  217. pwszBootFile1,
  218. pwszBootFile2,
  219. };
  220. BOOL CDriveInformation::SetDriveInfo()
  221. {
  222. Win4Assert( 0 != GetDriveLetter() );
  223. _cbFreeSpace = _cbTotalSpace = _cbReservedSpace = 0;
  224. ULARGE_INTEGER cbFreeBytesToCaller;
  225. ULARGE_INTEGER cbTotalNumberOfBytes;
  226. ULARGE_INTEGER cbTotalNumberOfFreeBytes;
  227. cbFreeBytesToCaller.QuadPart = 0;
  228. cbTotalNumberOfBytes.QuadPart = 0;
  229. cbTotalNumberOfFreeBytes.QuadPart = 0;
  230. //
  231. // returns 0 upon failure, none-zero upon success.
  232. //
  233. BOOL fSuccess = GetDiskFreeSpaceEx( _wszDriveName,
  234. &cbFreeBytesToCaller,
  235. &cbTotalNumberOfBytes,
  236. &cbTotalNumberOfFreeBytes );
  237. if (!fSuccess)
  238. {
  239. isDebugOut(( "SetDriveInfo: GetDiskFreeSapceEx %ws failed: %x\n",
  240. _wszDriveName,
  241. GetLastError() ));
  242. return fSuccess;
  243. }
  244. _cbFreeSpace= cbTotalNumberOfFreeBytes.QuadPart;
  245. _cbTotalSpace= cbTotalNumberOfBytes.QuadPart;
  246. //
  247. // Determine if the volume supports security (i.e., if it's NTFS)
  248. //
  249. fSuccess = GetVolumeInformationW( _wszDriveName,
  250. 0, 0, // volume name
  251. 0, // volume serial number
  252. 0, // max filename length
  253. &_dwFileSystemFlags,
  254. 0, 0 ); // file system name
  255. if (!fSuccess)
  256. {
  257. isDebugOut(( "SetDriveInfo: GetFileSystemInfo failed: %x\n",GetLastError() ));
  258. return fSuccess;
  259. }
  260. for (unsigned i=0; i < NUMELEM( apwszBootFiles ); i++)
  261. {
  262. if (Exists(apwszBootFiles[i]))
  263. {
  264. _fIsBootDrive = TRUE;
  265. break;
  266. }
  267. }
  268. return fSuccess;
  269. }
  270. //+-------------------------------------------------------------------------
  271. //
  272. // Member: CDriveInformation::Exists, public
  273. //
  274. // Synopsis: Determines if a file or directory exists
  275. //
  276. // Arguments: [pwszPath] - path name of the file to check
  277. //
  278. // Notes: The [pwszPath] must be a full path name starting with a
  279. // drive letter. The drive letter is overwritten by this
  280. // method.
  281. //
  282. // Returns: TRUE if the file exists, FALSE upon failure or non-existance.
  283. //
  284. // History: 26 Oct 1998 AlanW Created
  285. //
  286. //--------------------------------------------------------------------------
  287. BOOL CDriveInformation::Exists(WCHAR * pwszPath)
  288. {
  289. *pwszPath = GetDriveLetter();
  290. DWORD attr = GetFileAttributes( pwszPath );
  291. // If we couldn't determine file's attributes, don't consider it found
  292. // unless the error code indirectly indicates that it exists.
  293. if ( 0xffffffff == attr )
  294. {
  295. isDebugOut(( DEB_TRACE, "Exists: GetFileAttributes( %ws ) Failed: %d\n",
  296. pwszPath, GetLastError() ));
  297. if (GetLastError() == ERROR_SHARING_VIOLATION)
  298. return TRUE; // It must exist
  299. return FALSE;
  300. }
  301. return TRUE;
  302. }
  303. //+-------------------------------------------------------------------------
  304. //
  305. // Member: CCatalogConfig::ConfigureDefaultCatalog
  306. //
  307. // Synopsis: Creates a single default catalog if sufficient disk space
  308. // exists on one drive.
  309. //
  310. // Arguments: [wszPrimaryScope] -- Path name of primary indexed directory
  311. //
  312. // Returns: TRUE upon success, FALSE upon Failure,
  313. //
  314. // History: 9-10-97 mohamedn
  315. //
  316. //--------------------------------------------------------------------------
  317. static WCHAR wszUpgradeDir[] = L"x:\\$WIN_NT$.~LS";
  318. BOOL CCatalogConfig::ConfigureDefaultCatalog(
  319. WCHAR const * pwszPrimaryScope )
  320. {
  321. {
  322. //
  323. // Reserve space for a net upgrade of the OS if we're not currently
  324. // doing one (in which case the space for it will already be in use).
  325. // Because we will preferably use an NTFS drive for the catalog, try
  326. // using a FAT drive for the upgrade files.
  327. //
  328. int iUpgradeFiles = -1;
  329. int iBestFitForUpgrade = -1;
  330. ULONGLONG cbBestFitForUpgrade = 0;
  331. BOOL fBestFitOnNtfs = FALSE;
  332. for ( unsigned i = 0 ; i < _cDrive; i++ )
  333. {
  334. if ( iUpgradeFiles == -1 && _DriveList[i].Exists( wszUpgradeDir ) )
  335. {
  336. iUpgradeFiles = i;
  337. break;
  338. }
  339. ULONGLONG cbAvail = _DriveList[i].GetAvailableSpace();
  340. if ( cbAvail < MIN_UPGRADE_SPACE )
  341. continue;
  342. if ( iBestFitForUpgrade == -1 ||
  343. ( cbAvail < cbBestFitForUpgrade && fBestFitOnNtfs ) ||
  344. ( ! _DriveList[i].IsNtfs() && fBestFitOnNtfs ) )
  345. {
  346. cbBestFitForUpgrade = cbAvail;
  347. iBestFitForUpgrade = i;
  348. fBestFitOnNtfs = _DriveList[i].IsNtfs();
  349. }
  350. }
  351. if ( iUpgradeFiles == -1 && iBestFitForUpgrade != -1 )
  352. _DriveList[iBestFitForUpgrade].AddReservedSpace( MIN_UPGRADE_SPACE );
  353. else if ( iUpgradeFiles == -1 )
  354. {
  355. isDebugOut(( DEB_TRACE, "Not enough room for net upgrade!\n" ));
  356. return FALSE;
  357. }
  358. }
  359. //
  360. // Determine which drive to put the catalog on.
  361. //
  362. int iBiggestFreeNTFS = -1;
  363. int iBiggestFreeFAT = -1;
  364. ULONGLONG cbMaxFreeSpaceOnNTFS = 0;
  365. ULONGLONG cbMaxFreeSpaceOnFAT = 0;
  366. for ( unsigned i = 0 ; i < _cDrive; i++ )
  367. {
  368. if ( _DriveList[i].IsSmallBootPartition() )
  369. continue;
  370. int * piBiggestFree = &iBiggestFreeFAT;
  371. ULONGLONG * pcbMaxFree = &cbMaxFreeSpaceOnFAT;
  372. if ( _DriveList[i].IsNtfs() )
  373. {
  374. piBiggestFree = &iBiggestFreeNTFS;
  375. pcbMaxFree = &cbMaxFreeSpaceOnNTFS;
  376. }
  377. if ( *pcbMaxFree < _DriveList[i].GetAvailableSpace() )
  378. {
  379. *pcbMaxFree = _DriveList[i].GetAvailableSpace();
  380. *piBiggestFree = i;
  381. }
  382. }
  383. BOOL fAddNtfsDrives = FALSE;
  384. CDriveInformation * pCatalogDrive = 0;
  385. double dblCatalogSizeRatio;
  386. if ( iBiggestFreeNTFS != -1 )
  387. {
  388. //
  389. // There is an NTFS drive on the system; need to put the catalog
  390. // there.
  391. //
  392. pCatalogDrive = &_DriveList[iBiggestFreeNTFS];
  393. dblCatalogSizeRatio = CATALOG_SIZE_RATIO_NTFS;
  394. fAddNtfsDrives = TRUE;
  395. }
  396. else if ( iBiggestFreeFAT != -1 )
  397. {
  398. pCatalogDrive = &_DriveList[iBiggestFreeFAT];
  399. dblCatalogSizeRatio = CATALOG_SIZE_RATIO_FAT;
  400. fAddNtfsDrives = FALSE;
  401. }
  402. if ( 0 == pCatalogDrive ||
  403. pCatalogDrive->GetAvailableSpace() < MIN_CATALOG_SPACE )
  404. {
  405. isDebugOut(( DEB_TRACE, "Not enough room for minimal catalog!\n" ));
  406. return FALSE;
  407. }
  408. _pwszCatalogDrive = pCatalogDrive->GetDriveName();
  409. pCatalogDrive->AddReservedSpace( MIN_CATALOG_SPACE );
  410. // Add the primary scope directory for the catalog.
  411. if ( pwszPrimaryScope && *pwszPrimaryScope )
  412. AddIncludedDir( pwszPrimaryScope );
  413. //
  414. // Iterate through the list of drives once or twice, depending on
  415. // whether all drives are FAT.
  416. //
  417. unsigned maxLoop = _cDrive * ( (fAddNtfsDrives == TRUE) + 1);
  418. for ( i = 0 ; i < maxLoop; i++ )
  419. {
  420. // If end of NTFS enumeration, go back around the loop for FAT drives.
  421. if (i == _cDrive)
  422. fAddNtfsDrives = FALSE;
  423. CDriveInformation & DriveToCheck = _DriveList[i % _cDrive];
  424. if ( DriveToCheck.IsSmallBootPartition() )
  425. continue;
  426. if ( DriveToCheck.IsNtfs() != fAddNtfsDrives )
  427. continue;
  428. ULONGLONG cbUsed = DriveToCheck.GetUsedSpace();
  429. cbUsed = (ULONGLONG) ((LONGLONG)cbUsed * dblCatalogSizeRatio);
  430. if ( cbUsed < pCatalogDrive->GetAvailableSpace() )
  431. {
  432. AddIncludedDir( DriveToCheck.GetDriveName() );
  433. pCatalogDrive->AddReservedSpace( cbUsed );
  434. }
  435. }
  436. return TRUE;
  437. }
  438. //+-------------------------------------------------------------------------
  439. //
  440. // Member: CCatalogConfig::SaveState
  441. //
  442. // Synopsis: Saves the state of the catalog configuration in the registry.
  443. //
  444. // Arguments: - NONE -
  445. //
  446. // Returns: TRUE upon success, FALSE upon Failure,
  447. //
  448. // History: 19 Nov 1998 AlanW Created
  449. //
  450. //--------------------------------------------------------------------------
  451. BOOL CCatalogConfig::SaveState( )
  452. {
  453. Win4Assert( 0 != GetName() && 0 != GetLocation() );
  454. CCatReg catReg(_Err);
  455. if ( !catReg.Init( GetName(), GetLocation() ) )
  456. return FALSE;
  457. //
  458. // Add all the included scopes
  459. //
  460. WCHAR const * pwszScope;
  461. for (unsigned i = 0; pwszScope = GetIncludedScope( i ); i++)
  462. {
  463. if ( !catReg.AddScope( pwszScope, L",,5" ) )
  464. {
  465. return FALSE;
  466. }
  467. }
  468. //
  469. // Now add the excluded scopes
  470. //
  471. for (i = 0; pwszScope = GetExcludedScope( i ); i++)
  472. {
  473. if ( !catReg.AddScope( pwszScope, L",,4" ) )
  474. {
  475. return FALSE;
  476. }
  477. }
  478. return TRUE;
  479. }
  480. //+-------------------------------------------------------------------------
  481. //
  482. // Member: CCatalogConfig::AddStringToArray, private static
  483. //
  484. // Synopsis: Adds a string to an XArray
  485. //
  486. // Arguments: [c] - current count of strings in array
  487. // [xa] - the XArray of strings
  488. // [pwsz] - string to be added
  489. //
  490. // Returns: BOOL - FALSE if any problems, TRUE otherwise
  491. //
  492. // Notes: Can throw on allocation failures.
  493. //
  494. // History: 04 Nov 1998 AlanW Created
  495. //
  496. //--------------------------------------------------------------------------
  497. BOOL CCatalogConfig::AddStringToArray(
  498. ULONG & c,
  499. XArray<WCHAR const *> & xa,
  500. WCHAR const * pwsz )
  501. {
  502. XPtrST<WCHAR> xpwsz;
  503. if (pwsz)
  504. {
  505. WCHAR * pwszCopy = new WCHAR[ wcslen(pwsz) + 1 ];
  506. xpwsz.Set(pwszCopy);
  507. wcscpy( pwszCopy, pwsz );
  508. pwsz = pwszCopy;
  509. }
  510. if ( c >= xa.Count() )
  511. xa.ReSize( c*2 );
  512. xa[c] = pwsz;
  513. c++;
  514. xpwsz.Acquire();
  515. return TRUE;
  516. }
  517. //+-------------------------------------------------------------------------
  518. //
  519. // Member: CCatReg::Init
  520. //
  521. // Synopsis: Initializes catalog registry key configurator
  522. //
  523. // Arguments: [ pwszCatName ] - catalog name
  524. // [ pwszLocation] - catalog location
  525. //
  526. // Returns: none - throws upon fatal errors.
  527. //
  528. // History: 9-10-97 mohamedn
  529. //
  530. //--------------------------------------------------------------------------
  531. BOOL CCatReg::Init( WCHAR const *pwszCatName, WCHAR const *pwszLocation)
  532. {
  533. ISAssert( pwszCatName );
  534. // create a catalog for the drive
  535. BOOL fExisted = FALSE;
  536. CWin32RegAccess reg( HKEY_LOCAL_MACHINE, wcsRegCatalogsSubKey );
  537. if ( !reg.CreateKey( pwszCatName, fExisted ) )
  538. {
  539. DWORD dwErr = GetLastError();
  540. isDebugOut(( "created catalogs\\%ws subkey Failed: %d\n",
  541. pwszCatName, dwErr ));
  542. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dwErr );
  543. return FALSE;
  544. }
  545. isDebugOut(( DEB_TRACE, "created catalogs\\%ws subkey\n", pwszCatName ));
  546. wcscpy( _wszCatRegSubKey, wcsRegCatalogsSubKey );
  547. wcscat( _wszCatRegSubKey, L"\\" );
  548. wcscat( _wszCatRegSubKey, pwszCatName );
  549. CWin32RegAccess regSystem( reg.GetHKey(), pwszCatName );
  550. if ( !regSystem.Set( L"Location", pwszLocation ) )
  551. {
  552. DWORD dw = GetLastError();
  553. isDebugOut(( "Failed to set Cat Location valued:%ws, %d\n",
  554. pwszLocation, dw ));
  555. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dw );
  556. return FALSE;
  557. }
  558. if ( !regSystem.Set( wcsIsIndexingW3Roots, (DWORD) 0 ) ||
  559. !regSystem.Set( wcsIsIndexingNNTPRoots, (DWORD) 0 )
  560. )
  561. {
  562. DWORD dw = GetLastError();
  563. isDebugOut(( "Failed to set Cat values: %d\n", dw ));
  564. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dw );
  565. return FALSE;
  566. }
  567. // Create a "Scopes" key so a watch can be established in cicat
  568. // It needs no entries.
  569. if ( !regSystem.CreateKey( wcsCatalogScopes, fExisted ) )
  570. {
  571. DWORD dw = GetLastError();
  572. isDebugOut(( "created scopes subkey Failed: %d\n", dw ));
  573. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dw );
  574. return FALSE;
  575. }
  576. //
  577. // initialize the reg scopes subkey name
  578. //
  579. wcscpy( _wszCatScopeRegSubKey, _wszCatRegSubKey );
  580. wcscat( _wszCatScopeRegSubKey, L"\\" );
  581. wcscat( _wszCatScopeRegSubKey, wcsCatalogScopes );
  582. return TRUE;
  583. }
  584. //+-------------------------------------------------------------------------
  585. //
  586. // Member: CCatReg::AddScope
  587. //
  588. // Synopsis: Adds a scope for the current catalog
  589. //
  590. // Arguments: [ pwszScopeName ] - scope name
  591. // [ pwszScopeAttrib] - scope attributes
  592. //
  593. // Returns: none - throws upon fatal errors.
  594. //
  595. // History: 9-10-97 mohamedn
  596. //
  597. //--------------------------------------------------------------------------
  598. BOOL CCatReg::AddScope( WCHAR const * pwszScopeName,
  599. WCHAR const * pwszScopeAttrib )
  600. {
  601. CWin32RegAccess regScopes( HKEY_LOCAL_MACHINE, _wszCatScopeRegSubKey );
  602. if ( !regScopes.Set( pwszScopeName, pwszScopeAttrib ) )
  603. {
  604. DWORD dwRetVal = GetLastError();
  605. isDebugOut(( "Failed to set scope value:\\%ws, %d\n",
  606. pwszScopeName, dwRetVal ));
  607. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dwRetVal );
  608. return FALSE;
  609. }
  610. else
  611. {
  612. return TRUE;
  613. }
  614. }
  615. //+-------------------------------------------------------------------------
  616. //
  617. // Member: CCatReg::TrackW3Svc, public
  618. //
  619. // Synopsis: Configures catalog to be a 'web' catalog.
  620. //
  621. // Arguments: [dwInstance] -- WWW Virtual Server instance number
  622. //
  623. // Returns: TRUE if setup succeeded.
  624. //
  625. // History: 13-May-1998 KyleP Created
  626. //
  627. //--------------------------------------------------------------------------
  628. BOOL CCatReg::TrackW3Svc( DWORD dwInstance )
  629. {
  630. CWin32RegAccess regSystem( HKEY_LOCAL_MACHINE, _wszCatRegSubKey );
  631. // Fix for 249655. For a web catalog, wcsGenerateCharacterization and
  632. // wcsFilterFilesWithUnknownExtensions should be set as follows.
  633. if ( !regSystem.Set( wcsIsIndexingW3Roots, 1 ) ||
  634. !regSystem.Set( wcsW3SvcInstance, dwInstance ) ||
  635. !regSystem.Set( wcsGenerateCharacterization, 1 ) ||
  636. !regSystem.Set( wcsFilterFilesWithUnknownExtensions, (DWORD)0 ) ||
  637. !regSystem.Set( wcsMaxCharacterization, 320 ) )
  638. {
  639. DWORD dw = GetLastError();
  640. isDebugOut(( "Failed to set Cat values: %d\n", dw ));
  641. ISError( IS_MSG_COULD_NOT_CONFIGURE_CATALOGS, _Err, LogSevFatalError, dw );
  642. return FALSE;
  643. }
  644. return TRUE;
  645. }