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.

249 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module vssadmin.cpp | header of VSS demo
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 09/17/1999
  9. TBD:
  10. Add comments.
  11. Revision History:
  12. Name Date Comments
  13. aoltean 09/17/1999 Created
  14. --*/
  15. #ifndef __VSS_DEMO_H_
  16. #define __VSS_DEMO_H_
  17. /////////////////////////////////////////////////////////////////////////////
  18. // Defines and pragmas
  19. // C4290: C++ Exception Specification ignored
  20. #pragma warning(disable:4290)
  21. // warning C4511: copy constructor could not be generated
  22. #pragma warning(disable:4511)
  23. // warning C4127: conditional expression is constant
  24. #pragma warning(disable:4127)
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Includes
  27. #include <wtypes.h>
  28. #include <stddef.h>
  29. #include <oleauto.h>
  30. #include <comadmin.h>
  31. // Enabling asserts in ATL and VSS
  32. #include "vs_assert.hxx"
  33. // ATL
  34. #include <atlconv.h>
  35. #include <atlbase.h>
  36. // Application specific
  37. #include "vs_inc.hxx"
  38. // Generated MIDL headers
  39. #include "vs_idl.hxx"
  40. #include "copy.hxx"
  41. #include "pointer.hxx"
  42. #include "resource.h"
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Constants
  45. const WCHAR wszVssOptVssadmin[] = L"vssadmin";
  46. const WCHAR wszVssOptList[] = L"list";
  47. const WCHAR wszVssOptSnapshots[] = L"shadows";
  48. const WCHAR wszVssOptProviders[] = L"providers";
  49. const WCHAR wszVssOptWriters[] = L"writers";
  50. const WCHAR wszVssOptSet[] = L"/set=";
  51. const WCHAR wszVssFmtSpaces[] = L" \t";
  52. const WCHAR wszVssFmtNewline[] = L"\n";
  53. const nStringBufferSize = 1024; // Includes the zero character
  54. const nPollingInterval = 2500; // Three seconds
  55. const MAX_RETRIES_COUNT = 4; // Retries for polling
  56. /////////////////////////////////////////////////////////////////////////////
  57. // class CVssAdminCLI
  58. class CVssAdminCLI
  59. {
  60. // Enums and typedefs
  61. private:
  62. typedef enum _CMD_TYPE
  63. {
  64. VSS_CMD_UNKNOWN = 0,
  65. VSS_CMD_USAGE,
  66. VSS_CMD_LIST,
  67. VSS_CMD_CREATE,
  68. VSS_CMD_DELETE,
  69. } CMD_TYPE;
  70. typedef enum _LIST_TYPE
  71. {
  72. VSS_LIST_UNKNOWN = 0,
  73. VSS_LIST_SNAPSHOTS,
  74. VSS_LIST_WRITERS,
  75. VSS_LIST_PROVIDERS,
  76. } LIST_TYPE;
  77. enum _RETURN_VALUE
  78. {
  79. VSS_CMDRET_SUCCESS = 0,
  80. VSS_CMDRET_EMPTY_RESULT = 1,
  81. VSS_CMDRET_ERROR = 2,
  82. };
  83. // Constructors& destructors
  84. private:
  85. CVssAdminCLI(const CVssAdminCLI&);
  86. CVssAdminCLI();
  87. public:
  88. CVssAdminCLI(
  89. IN HINSTANCE hInstance
  90. );
  91. ~CVssAdminCLI();
  92. // Attributes
  93. private:
  94. LPWSTR GetCmdLine() const { return m_pwszCmdLine; };
  95. HINSTANCE GetInstance() const { return m_hInstance; };
  96. INT GetReturnValue() { return m_nReturnValue; };
  97. // Operations
  98. public:
  99. static HRESULT Main(
  100. IN HINSTANCE hInstance
  101. );
  102. private:
  103. void Initialize(
  104. IN CVssFunctionTracer& ft
  105. ) throw(HRESULT);
  106. void ParseCmdLine(
  107. IN CVssFunctionTracer& ft
  108. ) throw(HRESULT);
  109. void DoProcessing(
  110. IN CVssFunctionTracer& ft
  111. ) throw(HRESULT);
  112. void Finalize();
  113. // Processing
  114. private:
  115. void PrintUsage(
  116. IN CVssFunctionTracer& ft
  117. ) throw(HRESULT);
  118. void ListSnapshots(
  119. IN CVssFunctionTracer& ft
  120. ) throw(HRESULT);
  121. void ListWriters(
  122. IN CVssFunctionTracer& ft
  123. ) throw(HRESULT);
  124. void ListProviders(
  125. IN CVssFunctionTracer& ft
  126. ) throw(HRESULT);
  127. // Implementation
  128. private:
  129. LPCWSTR LoadString(
  130. IN CVssFunctionTracer& ft,
  131. IN UINT nStringId
  132. ) throw(HRESULT);
  133. LPCWSTR GetNextCmdlineToken(
  134. IN CVssFunctionTracer& ft,
  135. IN bool bFirstToken = false
  136. ) throw(HRESULT);
  137. bool Match(
  138. IN CVssFunctionTracer& ft,
  139. IN LPCWSTR wszString,
  140. IN LPCWSTR wszPatternString
  141. ) throw(HRESULT);
  142. bool ScanGuid(
  143. IN CVssFunctionTracer& ft,
  144. IN LPCWSTR wszString,
  145. IN VSS_ID& Guid
  146. ) throw(HRESULT);
  147. void Output(
  148. IN CVssFunctionTracer& ft,
  149. IN LPCWSTR wszFormat,
  150. ...
  151. ) throw(HRESULT);
  152. void Output(
  153. IN CVssFunctionTracer& ft,
  154. IN UINT uFormatStringId,
  155. ...
  156. ) throw(HRESULT);
  157. void OutputOnConsole(
  158. IN LPCWSTR wszStr
  159. );
  160. LPCWSTR GetProviderName(
  161. IN CVssFunctionTracer& ft,
  162. IN VSS_ID& ProviderId
  163. ) throw(HRESULT);
  164. // Data members
  165. private:
  166. HINSTANCE m_hInstance;
  167. HANDLE m_hConsoleOutput;
  168. CVssSimpleMap<UINT, LPCWSTR> m_mapCachedResourceStrings;
  169. CVssSimpleMap<VSS_ID, LPCWSTR> m_mapCachedProviderNames;
  170. LPWSTR m_pwszCmdLine;
  171. INT m_nReturnValue;
  172. CMD_TYPE m_eCommandType;
  173. LIST_TYPE m_eListType;
  174. VSS_OBJECT_TYPE m_eFilterObjectType;
  175. VSS_OBJECT_TYPE m_eListedObjectType;
  176. VSS_ID m_FilterSnapshotSetId;
  177. VSS_ID m_FilterSnapshotId;
  178. };
  179. #endif //__VSS_DEMO_H_