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.

125 lines
4.8 KiB

  1. #include "StdAfx.h"
  2. #include "Switch.h"
  3. namespace
  4. {
  5. //---------------------------------------------------------------------------
  6. // Switch Text Structure
  7. //---------------------------------------------------------------------------
  8. struct SSwitchText
  9. {
  10. int nSwitch;
  11. LPCTSTR pszText;
  12. };
  13. const SSwitchText s_SwitchText[] =
  14. {
  15. // tasks
  16. { SWITCH_TASK, _T("user,group,computer,security,service,report,key") },
  17. // general task options
  18. { SWITCH_OPTION_FILE, _T("o,OptionFile") },
  19. { SWITCH_TEST_MIGRATION, _T("tm,TestMigration") },
  20. { SWITCH_INTRA_FOREST, _T("if,IntraForest") },
  21. { SWITCH_SOURCE_DOMAIN, _T("sd,SourceDomain") },
  22. { SWITCH_SOURCE_OU, _T("so,SourceOu") },
  23. { SWITCH_TARGET_DOMAIN, _T("td,TargetDomain") },
  24. { SWITCH_TARGET_OU, _T("to,TargetOu") },
  25. { SWITCH_RENAME_OPTION, _T("ro,RenameOption") },
  26. { SWITCH_RENAME_PREFIX_OR_SUFFIX, _T("rt,RenamePrefixOrSuffix") },
  27. { SWITCH_PASSWORD_OPTION, _T("po,PasswordOption") },
  28. { SWITCH_PASSWORD_SERVER, _T("ps,PasswordServer") },
  29. { SWITCH_PASSWORD_FILE, _T("pf,PasswordFile") },
  30. { SWITCH_CONFLICT_OPTIONS, _T("co,ConflictOptions") },
  31. { SWITCH_CONFLICT_PREFIX_OR_SUFFIX, _T("ct,ConflictPrefixOrSuffix") },
  32. { SWITCH_USER_PROPERTIES_TO_EXCLUDE, _T("ux,UserPropertiesToExclude") },
  33. { SWITCH_GROUP_PROPERTIES_TO_EXCLUDE, _T("gx,GroupPropertiesToExclude") },
  34. { SWITCH_COMPUTER_PROPERTIES_TO_EXCLUDE, _T("cx,ComputerPropertiesToExclude") },
  35. // specific task options
  36. { SWITCH_DISABLE_OPTION, _T("dot,DisableOption") },
  37. { SWITCH_SOURCE_EXPIRATION, _T("sep,SourceExpiration") },
  38. { SWITCH_MIGRATE_SIDS, _T("mss,MigrateSids") },
  39. { SWITCH_TRANSLATE_ROAMING_PROFILE, _T("trp,TranslateRoamingProfile") },
  40. { SWITCH_UPDATE_USER_RIGHTS, _T("uur,UpdateUserRights") },
  41. { SWITCH_MIGRATE_GROUPS, _T("mgs,MigrateGroups") },
  42. { SWITCH_UPDATE_PREVIOUSLY_MIGRATED_OBJECTS, _T("umo,UpdatePreviouslyMigratedObjects") },
  43. { SWITCH_FIX_GROUP_MEMBERSHIP, _T("fgm,FixGroupMembership") },
  44. { SWITCH_MIGRATE_SERVICE_ACCOUNTS, _T("msa,MigrateServiceAccounts") },
  45. { SWITCH_UPDATE_GROUP_RIGHTS, _T("ugr,UpdateGroupRights") },
  46. { SWITCH_MIGRATE_MEMBERS, _T("mms,MigrateMembers") },
  47. { SWITCH_TRANSLATION_OPTION, _T("tot,TranslationOption") },
  48. { SWITCH_TRANSLATE_FILES_AND_FOLDERS, _T("tff,TranslateFilesAndFolders") },
  49. { SWITCH_TRANSLATE_LOCAL_GROUPS, _T("tlg,TranslateLocalGroups") },
  50. { SWITCH_TRANSLATE_PRINTERS, _T("tps,TranslatePrinters") },
  51. { SWITCH_TRANSLATE_REGISTRY, _T("trg,TranslateRegistry") },
  52. { SWITCH_TRANSLATE_SHARES, _T("tss,TranslateShares") },
  53. { SWITCH_TRANSLATE_USER_PROFILES, _T("tup,TranslateUserProfiles") },
  54. { SWITCH_TRANSLATE_USER_RIGHTS, _T("tur,TranslateUserRights") },
  55. { SWITCH_RESTART_DELAY, _T("rdl,RestartDelay") },
  56. { SWITCH_SID_MAPPING_FILE, _T("smf,SidMappingFile") },
  57. { SWITCH_REPORT_TYPE, _T("rpt,ReportType") },
  58. { SWITCH_REPORT_FOLDER, _T("rpf,ReportFolder") },
  59. // include switches
  60. { SWITCH_INCLUDE_NAME, _T("n,IncludeName") },
  61. { SWITCH_INCLUDE_FILE, _T("f,IncludeFile") },
  62. { SWITCH_INCLUDE_DOMAIN, _T("d,IncludeDomain") },
  63. // exclude switches
  64. { SWITCH_EXCLUDE_NAME, _T("en,ExcludeName") },
  65. { SWITCH_EXCLUDE_FILE, _T("ef,ExcludeFile") },
  66. // help
  67. { SWITCH_HELP, _T("?,h,help") },
  68. };
  69. const UINT SWITCH_COUNT = countof(s_SwitchText);
  70. }
  71. //---------------------------------------------------------------------------
  72. // Switch Map
  73. //---------------------------------------------------------------------------
  74. // constructor
  75. CSwitchMap::CSwitchMap()
  76. {
  77. static const _TCHAR DELIMITERS[] = _T(",");
  78. _TCHAR szSwitch[256];
  79. for (UINT i = 0; i < SWITCH_COUNT; i++)
  80. {
  81. int nSwitch = s_SwitchText[i].nSwitch;
  82. _ASSERT(_tcslen(s_SwitchText[i].pszText) < countof(szSwitch));
  83. _tcscpy(szSwitch, s_SwitchText[i].pszText);
  84. for (LPTSTR psz = _tcstok(szSwitch, DELIMITERS); psz; psz = _tcstok(NULL, DELIMITERS))
  85. {
  86. insert(value_type(_bstr_t(psz), nSwitch));
  87. }
  88. }
  89. }
  90. // GetSwitch Method
  91. int CSwitchMap::GetSwitch(LPCTSTR pszSwitch)
  92. {
  93. int nSwitch = -1;
  94. iterator it = find(_bstr_t(pszSwitch));
  95. if (it != end())
  96. {
  97. nSwitch = it->second;
  98. }
  99. return nSwitch;
  100. }