Leaked source code of windows server 2003
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.

176 lines
4.7 KiB

  1. #include "pch.hxx"
  2. #include "tbtest.hxx"
  3. DWORD g_NoOpenStg = FALSE;
  4. DWORD g_CreateStg = FALSE;
  5. DWORD g_AnyStorage = FALSE;
  6. DWORD g_ReleaseStg = FALSE;
  7. DWORD g_AddRefStg = FALSE;
  8. DWORD g_NoOpenStm = FALSE;
  9. DWORD g_CreateStm = FALSE;
  10. DWORD g_ReadStm = FALSE;
  11. DWORD g_WriteStm = FALSE;
  12. DWORD g_AddRefStm = FALSE;
  13. DWORD g_SetClass = FALSE;
  14. DWORD g_Stat = FALSE;
  15. DWORD g_OplockFile = FALSE;
  16. DWORD g_UseUpdater = FALSE;
  17. DWORD g_Pause = FALSE;
  18. DWORD g_SuppressTime = FALSE;
  19. DWORD g_CheckTime = FALSE;
  20. DWORD g_CheckIsStg = FALSE;
  21. WCHAR g_tszFileName[ MAX_PATH ] = { L"001.bmp" };
  22. void
  23. StrLower( char *sz)
  24. {
  25. while('\0' != *sz)
  26. {
  27. if(*sz >= 'A' && *sz <= 'Z')
  28. *sz += ('a' - 'A');
  29. sz++;
  30. }
  31. }
  32. void
  33. Usage(WCHAR *wszApp)
  34. {
  35. wprintf(L"%s options:\n", wszApp);
  36. printf(" -noopenstg\tDon't Open the file with IStorage.\n");
  37. printf("\t\tpstg->operations are not allowed.\n");
  38. printf(" -createstg\tOpen IStorage file for CreateStg(CREATE).\n");
  39. printf("\t\t\tOtherwise open with OpenStg()\n");
  40. printf(" -any\t\tOpen with STGFMT_ANY. Otherwise use STGFMT_FILE\n");
  41. printf(" -releasestg\t\tRelease Storage before stream R/W\n");
  42. printf(" -addrefstg\t\tExtra Addref and release after creation\n");
  43. printf("\n");
  44. printf(" -noopenstm\tDon't open a stream.");
  45. printf(" pstm->operations not allowed\n");
  46. printf(" -createstm\tOpen w/ CreateStm(CREATE). (otherwise OpenStm())\n");
  47. printf(" -readstm\tRead from the stream. Mode is R/W\n");
  48. printf(" -writestm\tWrite to the stream. Mode is R/W\n");
  49. printf(" -addrefstm\t\tExtra Addref and release after creation\n");
  50. printf("\n");
  51. printf(" -setclass\tCall pstg->SetClass()\n");
  52. printf(" -stat\t\tCall pstg->Stat()\n");
  53. printf("\n");
  54. printf(" -oplock\tOpen IStorage for Oplocking\n");
  55. printf(" -useupdater\tStart Updater and call IFilterStatus::PreFilter()\n");
  56. printf(" -pause\tPause before IO operations\n");
  57. printf(" -suppresstime\tCall ITimeAndNotifyControl->SuppressChanges\n");
  58. printf(" -checktime\tGet and print the FileTime before and after test\n");
  59. printf(" -checkisstg\tCall StgIsStorageFile before tring to Open Storage\n");
  60. }
  61. void
  62. ParseArgs(
  63. int cArgs,
  64. WCHAR **pwszArgs)
  65. {
  66. WCHAR *wszApp = *pwszArgs;
  67. ++pwszArgs;
  68. while( (--cArgs > 0) && ( ('-' == **pwszArgs) || ('/' == **pwszArgs) ) )
  69. {
  70. WCHAR *wszArg = *pwszArgs;
  71. ++wszArg; // Advance over the '-'
  72. _wcslwr(wszArg);
  73. if(0 == wcscmp(L"noopenstg", wszArg))
  74. g_NoOpenStg = TRUE;
  75. else if(0 == wcscmp(L"createstg", wszArg))
  76. g_CreateStg = TRUE;
  77. else if(0 == wcscmp(L"any", wszArg))
  78. g_AnyStorage = TRUE;
  79. else if(0 == wcscmp(L"releasestg", wszArg))
  80. g_ReleaseStg = TRUE;
  81. else if(0 == wcscmp(L"addrefstg", wszArg))
  82. g_AddRefStg = TRUE;
  83. else if(0 == wcscmp(L"noopenstream", wszArg))
  84. g_NoOpenStm = TRUE;
  85. else if(0 == wcscmp(L"createstm", wszArg))
  86. g_CreateStm = TRUE;
  87. else if(0 == wcscmp(L"readstm", wszArg))
  88. g_ReadStm = TRUE;
  89. else if(0 == wcscmp(L"writestm", wszArg))
  90. g_WriteStm = TRUE;
  91. else if(0 == wcscmp(L"addrefstm", wszArg))
  92. g_AddRefStm = TRUE;
  93. else if(0 == wcscmp(L"setclass", wszArg))
  94. g_SetClass = TRUE;
  95. else if(0 == wcscmp(L"stat", wszArg))
  96. g_Stat = TRUE;
  97. else if(0 == wcscmp(L"oplock", wszArg))
  98. g_OplockFile = TRUE;
  99. else if(0 == wcscmp(L"useupdater", wszArg))
  100. g_UseUpdater = TRUE;
  101. else if(0 == wcscmp(L"pause", wszArg))
  102. g_Pause = TRUE;
  103. else if(0 == wcscmp(L"suppresstime", wszArg))
  104. g_SuppressTime = TRUE;
  105. else if(0 == wcscmp(L"checktime", wszArg))
  106. g_CheckTime = TRUE;
  107. else if(0 == wcscmp(L"checkisstg", wszArg))
  108. g_CheckIsStg = TRUE;
  109. else
  110. {
  111. printf("unknown argument '%s'\n", *pwszArgs);
  112. Usage(wszApp);
  113. exit(0);
  114. }
  115. ++pwszArgs;
  116. }
  117. if(0 < cArgs)
  118. {
  119. wcscpy( g_tszFileName, *pwszArgs );
  120. ++pwszArgs;
  121. --cArgs;
  122. }
  123. if(0 < cArgs)
  124. {
  125. printf("extra arguments ignored: ");
  126. while(--cArgs >= 0)
  127. {
  128. wprintf( L" %s", *pwszArgs);
  129. ++pwszArgs;
  130. }
  131. Usage(wszApp);
  132. printf("\n");
  133. exit(0);
  134. }
  135. return;
  136. }