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.

156 lines
4.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: testsift.hxx
  7. //
  8. // Contents: Client-side sift header
  9. //
  10. // Classes: CTestSiftObj
  11. // CSiftDefault
  12. //
  13. // History: 6-01-94 t-chripi Created
  14. //
  15. //----------------------------------------------------------------------------
  16. #ifndef __TESTSIFT_HXX__
  17. #define __TESTSIFT_HXX__
  18. //Sift success/error values
  19. #define SIFT_NO_ERROR 0
  20. #define SIFT_ERROR_BASE 10000
  21. #define SIFT_ERROR_OUT_OF_MEMORY (SIFT_ERROR_BASE+3)
  22. #define SIFT_ERROR_INVALID_VALUE (SIFT_ERROR_BASE+4)
  23. #if defined(WIN16) || defined(WIN32S) || defined (_MAC) //Win16/Win32s/MAC
  24. #define SIFT_INIT
  25. #define SIFT_ON
  26. #define SIFT_OFF
  27. #define SIFT_DECLARE
  28. #define SVR_SIFT_INIT(name)
  29. #else // Win32 only
  30. // These flags can be unioned to form the value for the third parameter of
  31. // CTestSiftObj::Init. SIFT_FIRST is usually used for the client in a
  32. // client/server situation.
  33. // sift.
  34. #define SIFT_READ_INIFILE 0x1 // Read ini file if no sift switches in argv
  35. #define SIFT_FIRST 0x2 // Must be the first sift process
  36. #define SIFT_INIT \
  37. g_tsoTestSift.Init(argc, argv, SIFT_FIRST | SIFT_READ_INIFILE)
  38. #define SIFT_ON \
  39. g_tsoTestSift.Start()
  40. #define SIFT_OFF \
  41. g_tsoTestSift.Stop()
  42. #define SIFT_DECLARE \
  43. CTestSiftObj g_tsoTestSift
  44. #define SVR_SIFT_INIT(name) \
  45. SvrSiftInit((name))
  46. #include <sift.hxx>
  47. VOID SvrSiftInit(LPCSTR);
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Class: CTestSiftObj (tso)
  51. //
  52. // Purpose: Allow for sift testing using existing code
  53. //
  54. // Interface: CTestSiftObj -- Inits private variable.
  55. // ~CTestSiftObj -- Writes to log file
  56. // Init -- Interprets command line, initializes object
  57. // Start -- Instructs the object to start counting
  58. // Stop -- Intructs the object to stop counting
  59. //
  60. // History: 5-25-94 t-chripi Created
  61. // 10-12-94 XimingZ Added GetSettings, GetTempDir and
  62. // _pszTmpDir.
  63. //
  64. // Notes: At this point, the declaration of this object in the main
  65. // of existing test code will allow for memory sift testing
  66. // by utilizing the macros SIFT_ON and SIFT_OFF.
  67. //
  68. //----------------------------------------------------------------------------
  69. class CTestSiftObj
  70. {
  71. public:
  72. CTestSiftObj(VOID);
  73. ~CTestSiftObj(VOID);
  74. BOOL Init(int argc, char *argv[], DWORD dwFlags = NULL);
  75. VOID Start(VOID);
  76. VOID Stop(VOID);
  77. VOID GetSettings(LPCSTR pszProgName, INT *pArgc, LPSTR *aszArgv);
  78. private:
  79. ISift* _psftOleSift;
  80. TCHAR* _pszTmpDir;
  81. DWORD GetTempDir(LPTSTR pszInDir, LPTSTR pszOutDir, DWORD cchSize);
  82. };
  83. // Define global object as external
  84. extern CTestSiftObj g_tsoTestSift;
  85. // Debug function (file, line, comment)
  86. VOID SiftDbgOut(char *, unsigned, LPCSTR);
  87. //+---------------------------------------------------------------------------
  88. //
  89. // Class: CSiftDefault (sftd)
  90. //
  91. // Purpose: Allow sift testing of memory allocations.
  92. //
  93. // Interface: CSiftDefault - Contructs object with sifting turned off.
  94. // Init - Initializes the object for each test run.
  95. // SiftOn - Enables the counting mechanism.
  96. // SiftOff - Disables the counting mechanism.
  97. // GetCount - Gets current allocation count.
  98. //
  99. // History: 6-01-94 t-chripi Created
  100. //
  101. // Notes: This class contains the server implementation of sifting.
  102. //
  103. //----------------------------------------------------------------------------
  104. class CSiftDefault : public ISift
  105. {
  106. public:
  107. CSiftDefault(DWORD dwFlags);
  108. ~CSiftDefault();
  109. VOID Init(BOOL fPlay, LONG lFailCount);
  110. VOID SiftOn(DWORD dwResource);
  111. LONG SiftOff(DWORD dwResource);
  112. LONG GetCount(DWORD dwResource);
  113. BOOL SimFail(DWORD dwResource);
  114. // IUnknown:
  115. STDMETHODIMP_(ULONG) AddRef(THIS);
  116. STDMETHODIMP_(ULONG) Release(THIS);
  117. // BUGBUG: Not a valid implementation of QueryInterface
  118. STDMETHODIMP QueryInterface (THIS_ REFIID iid, void **ppv)
  119. { return(E_NOINTERFACE); };
  120. private:
  121. HRESULT _hStatus;
  122. LPLONG _lplCount;
  123. HANDLE _hFileMapCount;
  124. LONG _lFailCount;
  125. BOOL _fSift;
  126. BOOL _fPlay;
  127. ULONG _cRef;
  128. };
  129. #endif // !(WIN32S || WIN16 || MAC)
  130. #endif // __TESTSIFT_HXX__