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.

135 lines
5.9 KiB

  1. //#pragma title( "EnumVols.hpp - Volume Enumeration" )
  2. /*
  3. Copyright (c) 1995-1998, Mission Critical Software, Inc. All rights reserved.
  4. ===============================================================================
  5. Module - enumvols.hpp
  6. System - SDResolve
  7. Author - Christy Boles
  8. Created - 97/06/27
  9. Description - Classes used to generate a list of pathnames, given a list of paths and/or
  10. machine names.
  11. Updates -
  12. ===============================================================================
  13. */
  14. #ifndef ENUMVOLS_HEADER
  15. #define ENUMVOLS_HEADER
  16. #define MAXSIZE 30000
  17. #include <lmcons.h>
  18. #include "EaLen.hpp"
  19. #ifndef TNODEINCLUDED
  20. #include "Tnode.hpp"
  21. #define TNODEINCLUDED
  22. #endif
  23. #define VERIFY_EXISTS (0x00000001)
  24. #define VERIFY_BACKUPRESTORE (0x00000002)
  25. #define VERIFY_PERSISTENT_ACLS (0x00000004)
  26. /*******************************************************************************************
  27. class TPathNode is a TNode, containing a UNICODE pathname. A TNode is constructed to
  28. hold each path in the TPathList list
  29. ********************************************************************************************/
  30. class TPathNode:public TNode
  31. {
  32. protected:
  33. bool haswc; // these three fields are set by Verify
  34. bool validalone;
  35. bool iscontainer;
  36. bool isFirstFromServer; // This field is maintained by TPathList
  37. WCHAR path[MAX_PATH + 1]; // the pathname associated with this node
  38. WCHAR server[UNCLEN+1]; // server name for path
  39. public:
  40. TPathNode(const LPWSTR name);
  41. WCHAR * GetPathName() const { return ( LPWSTR ) path; }
  42. WCHAR * GetServerName() const { return (LPWSTR) server; }
  43. void SetServerName(UCHAR const * name);
  44. void Display() const;
  45. bool ContainsWC() { return haswc; }
  46. bool IsValidAlone() { return validalone; }
  47. void ContainsWC(bool val) { haswc = val; }
  48. void IsValidAlone(bool val) {validalone = val; }
  49. void IsContainer(bool val) { iscontainer = val; }
  50. bool IsContainer() { return iscontainer; }
  51. bool IsFirstPathFromMachine() { return isFirstFromServer; }
  52. void IsFirstPathFromMachine(bool val) { isFirstFromServer = val; }
  53. DWORD VerifyExists();
  54. DWORD VerifyBackupRestore();
  55. DWORD VerifyPersistentAcls();
  56. protected:
  57. void LookForWCChars(); // looks for wildcard, and sets value of haswc
  58. void FindServerName(); // looks for the name of the server
  59. };
  60. /*******************************************************************************************
  61. class TPathList
  62. BuildPathList: takes an argument list, and builds a list of paths as follows:
  63. for each path in the arglist, the path is added,
  64. and for each machine-name, a path is added for the root
  65. of each shared, security-enabled volume.
  66. ********************************************************************************************/
  67. class TPathList : public TNodeList
  68. {
  69. protected:
  70. DWORD numServers; // Stats: count the number of complete servers added
  71. DWORD numPaths; // Stats: the number of paths in the list
  72. TNodeListEnum tenum; // used to enumerate the paths in the list (OpenEnum, Next, CloseEnum)
  73. public:
  74. TPathList();
  75. ~TPathList();
  76. bool AddPath(const LPWSTR path,DWORD verifyFlags); // adds a single path (from args)
  77. // to the list
  78. void Clear(); // Removes all the paths in the list
  79. void Display() const; // printfs the pathname for each node
  80. DWORD GetNumPaths() const { return numPaths; }
  81. DWORD GetNumServers() const { return numServers; }
  82. void OpenEnum(); // To enumerate nodes in the list
  83. void CloseEnum(); // OpenEnum, GetItem for each node, CloseEnum
  84. LPWSTR Next(); // Returns the next pathname in the enumeration
  85. protected:
  86. void AddPathToList(TPathNode * newNode); // Helper function
  87. };
  88. // TVolumeEnum enumerates the administrative shares on a server
  89. class TVolumeEnum
  90. {
  91. private:
  92. DWORD numread; // number of volnames read this time
  93. DWORD total; // total # vols
  94. DWORD resume_handle;
  95. DWORD curr; // used to iterate through volumes
  96. LPBYTE pbuf;
  97. WCHAR * drivelist;
  98. LPBYTE shareptr;
  99. WCHAR currEntry[MAX_PATH];
  100. BOOL isOpen;
  101. BOOL verbose;
  102. UINT errmode;
  103. WCHAR server[32];
  104. DWORD verifyFlags;
  105. BOOL bLocalOnly;
  106. int nLeft;
  107. public:
  108. TVolumeEnum() { nLeft = 0; bLocalOnly = FALSE; isOpen = FALSE; pbuf = NULL; numread = 0; }
  109. ~TVolumeEnum() { if ( isOpen ) Close(); }
  110. DWORD Open(WCHAR const * server,DWORD verifyFlags,BOOL verbose);
  111. WCHAR * Next();
  112. void Close();
  113. void SetLocalMode(BOOL bLocal) { bLocalOnly = bLocal; }
  114. };
  115. #endif