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.

267 lines
7.0 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bminput.cxx
  7. //
  8. // Contents: input class for benchmark config
  9. //
  10. // Classes: CTestinput
  11. //
  12. // Functions:
  13. //
  14. // History: 14-July-93 t-martig Created
  15. // 07-July-94 t-vadims Added GetConfigInt and changed
  16. // GetIterations to use it.
  17. //
  18. //--------------------------------------------------------------------------
  19. #include <benchmrk.hxx>
  20. #include <bminput.hxx>
  21. //+-------------------------------------------------------------------
  22. //
  23. // Member: CTestInput,public
  24. //
  25. // Synopsis: constructor for test input class
  26. //
  27. //+-------------------------------------------------------------------
  28. CTestInput::CTestInput (LPTSTR lpszFileName)
  29. {
  30. lstrcpy (m_szFileName, lpszFileName);
  31. }
  32. //+-------------------------------------------------------------------
  33. //
  34. // Member: GetConfigString,public
  35. //
  36. // Synopsis: returns profile string from specified section and
  37. // parameter.
  38. //
  39. //+-------------------------------------------------------------------
  40. LPTSTR CTestInput::GetConfigString (LPTSTR lpszSection, LPTSTR lpszEntry,
  41. LPTSTR lpszDefault, LPTSTR lpszDest,
  42. DWORD dwLen)
  43. {
  44. GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
  45. lpszDest, dwLen, m_szFileName);
  46. return lpszDest;
  47. }
  48. //+-------------------------------------------------------------------
  49. //
  50. // Member: GetConfigInt,public
  51. //
  52. // Synopsis: returns profile integer from specified section and
  53. // parameter.
  54. //
  55. //+-------------------------------------------------------------------
  56. DWORD CTestInput::GetConfigInt (LPTSTR lpszSection, LPTSTR lpszEntry,
  57. DWORD dwDefault)
  58. {
  59. return GetPrivateProfileInt (lpszSection, lpszEntry,
  60. dwDefault, m_szFileName);
  61. }
  62. //+-------------------------------------------------------------------
  63. //
  64. // Member: GetClassCtx,public
  65. //
  66. // Synopsis: Gets the custom class activation context from .ini
  67. // file (entry name = "ClsCtx")
  68. //
  69. // Parameters: [lpszTestName] Section under which "ClsCtx"
  70. // is listed
  71. //
  72. // Returns: CLSCTX_... mode according to entry:
  73. //
  74. // "InProc" CLSCTX_INPROC_SERVER
  75. // "Local" CLSCTX_LOCAL_SERVER,
  76. // "Handler" CLSCTX_INPROC_HANDLER
  77. // any other CLSCTX_INPROC_SERVER
  78. //
  79. // History: 12-July-93 t-martig Created
  80. //
  81. //--------------------------------------------------------------------
  82. DWORD CTestInput::GetClassCtx (LPTSTR lpszTestName)
  83. {
  84. TCHAR szMode[50];
  85. int i;
  86. GetConfigString (lpszTestName, TEXT("ClsCtx"), TEXT("InProc"),
  87. szMode, sizeof(szMode)/sizeof(TCHAR));
  88. i = 0;
  89. while (saModeNames[i])
  90. {
  91. if (lstrcmpi (saModeNames[i], szMode) == 0)
  92. return dwaModes[i];
  93. i++;
  94. }
  95. return dwaModes[0];
  96. }
  97. //+-------------------------------------------------------------------
  98. //
  99. // Member: GetOleInitFlag,public
  100. //
  101. // Synopsis: Gets OleInitialize flag
  102. //
  103. // Parameters:
  104. //
  105. // History: 13-August-93 t-martig Created
  106. //
  107. //--------------------------------------------------------------------
  108. DWORD CTestInput::GetOleInitFlag(void)
  109. {
  110. TCHAR szInitFlag[60];
  111. GetPrivateProfileString (TEXT("Driver"), TEXT("InitFlag"),
  112. TEXT("COINIT_APARTMENTTHREADED"),
  113. szInitFlag, sizeof(szInitFlag)/sizeof(TCHAR),
  114. m_szFileName);
  115. #ifdef THREADING_SUPPORT
  116. if (lstrlen(szInitFlag)==0)
  117. return COINIT_APARTMENTTHREADED;
  118. if (!lstrcmpi(szInitFlag, TEXT("COINIT_MULTITHREADED")))
  119. return COINIT_MULTITHREADED;
  120. else
  121. #endif
  122. return 2; // COINIT_APARTMENTTHREADED;
  123. }
  124. //+-------------------------------------------------------------------
  125. //
  126. // Member: GetInfoLevelFlag,public
  127. //
  128. // Synopsis: Gets InfoLevel flag
  129. //
  130. // Parameters:
  131. //
  132. // History: 13-August-93 t-martig Created
  133. //
  134. //--------------------------------------------------------------------
  135. DWORD CTestInput::GetInfoLevelFlag(void)
  136. {
  137. TCHAR szInfoFlag[60];
  138. GetPrivateProfileString (TEXT("Driver"), TEXT("InfoLevel"),
  139. TEXT("BASE"),
  140. szInfoFlag, sizeof(szInfoFlag)/sizeof(TCHAR),
  141. m_szFileName);
  142. if (lstrlen(szInfoFlag)==0)
  143. return 0;
  144. if (!lstrcmpi(szInfoFlag, TEXT("FULL")))
  145. return 1;
  146. else
  147. return 0;
  148. }
  149. //+-------------------------------------------------------------------
  150. //
  151. // Member: GetGUID,public
  152. //
  153. // Synopsis: Gets GUID from .ini file
  154. //
  155. // Parameters: [pClsID] Address where to put class ID
  156. // [lpszTestName] Section
  157. // [lpszEntry] Entry name
  158. //
  159. // History: 13-August-93 t-martig Created
  160. //
  161. //--------------------------------------------------------------------
  162. SCODE CTestInput::GetGUID (CLSID *pClsID, LPTSTR lpszTestName,
  163. LPTSTR lpszEntry)
  164. {
  165. TCHAR szClsID[60];
  166. LPOLESTR lpszClsID;
  167. GetConfigString (lpszTestName, lpszEntry, TEXT(""),
  168. szClsID, sizeof(szClsID)/sizeof(TCHAR));
  169. if (lstrlen(szClsID)==0)
  170. return E_FAIL;
  171. #ifdef UNICODE
  172. lpszClsID = szClsID;
  173. #else
  174. OLECHAR szTmp[60];
  175. MultiByteToWideChar(CP_ACP, 0, szClsID, -1, szTmp, 60);
  176. lpszClsID = szTmp;
  177. #endif
  178. return CLSIDFromString(lpszClsID, pClsID);
  179. }
  180. //+-------------------------------------------------------------------
  181. //
  182. // Member: GetClassID,public
  183. //
  184. // Synopsis: Gets the custom class ID from .ini file
  185. // (entry name = "ClsID")
  186. //
  187. // Parameters: [pClsID] Address where to put class ID
  188. // [lpszTestName] Section under which "ClsID"
  189. // is listed
  190. //
  191. // History: 13-July-93 t-martig Created
  192. //
  193. //--------------------------------------------------------------------
  194. SCODE CTestInput::GetClassID (CLSID *pClsID, LPTSTR lpszTestName)
  195. {
  196. return GetGUID(pClsID, lpszTestName, TEXT("ClsID"));
  197. }
  198. //+-------------------------------------------------------------------
  199. //
  200. // Member: GetIterations, public
  201. //
  202. // Synopsis: returns the iteration count for the test. if out of
  203. // range, it returns either 1 or TEST_MAX_ITERATIONS.
  204. //
  205. // History: 07-July-94 t-vadims Modified to use new GetConfigInt function.
  206. //
  207. //+-------------------------------------------------------------------
  208. DWORD CTestInput::GetIterations (LPTSTR lpszTestName, int iIterDefault)
  209. {
  210. int iIterations;
  211. iIterations = GetConfigInt (lpszTestName, TEXT("Iterations"), iIterDefault);
  212. if (iIterations > TEST_MAX_ITERATIONS)
  213. iIterations = TEST_MAX_ITERATIONS;
  214. return (iIterations > 0) ? iIterations : 1;
  215. }
  216. //+-------------------------------------------------------------------
  217. //
  218. // Member: GetRealIterations, public
  219. //
  220. // Synopsis: returns the iteration count for the test. Does not
  221. // range check.
  222. //
  223. // History: 07-July-94 t-vadims Modified to use new GetConfigInt function.
  224. //
  225. //+-------------------------------------------------------------------
  226. DWORD CTestInput::GetRealIterations (LPTSTR lpszTestName, int iIterDefault)
  227. {
  228. int iIterations;
  229. iIterations = GetConfigInt (lpszTestName, TEXT("Iterations"), iIterDefault);
  230. return (iIterations > 0) ? iIterations : 1;
  231. }