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.

398 lines
12 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. wnetenum.hxx
  7. Header file for WNetEnum functions
  8. FILE HISTORY:
  9. terryk 01-Nov-1991 Created
  10. terryk 04-Nov-1991 Code review change. Attend: Johnl
  11. Davidhov Chuckc
  12. terryk 18-Nov-1991 Another code review changed.
  13. terryk 10-Dec-1991 Added other domain string list
  14. terryk 28-Dec-1991 Changed DWORD to UINT
  15. anirudhs 7-Mar-1996 Added context enum (moved from ctxenum.hxx)
  16. */
  17. #ifndef _WNETENUM_HXX_
  18. #define _WNETENUM_HXX_
  19. #include <domenum.hxx> // for BROWSE_DOMAIN_ENUM
  20. #include <dfsenum.hxx>
  21. /* Semaphore locking functions for winnet
  22. */
  23. APIERR WNetEnterCriticalSection( void ) ;
  24. void WNetLeaveCriticalSection( void ) ;
  25. APIERR GetLMProviderName (void);
  26. /*************************************************************************
  27. NAME: NET_ENUMNODE
  28. SYNOPSIS: Base class for SHARE,USE and SERVER EnumNode
  29. INTERFACE:
  30. NET_ENUMNODE() - constructor
  31. GetInfo() - initialize the enum within the child class
  32. GetNetResource() - get the NETRESOURCE data structure
  33. IsFirstGetInfo() - check whether it is the first time to call
  34. WNetResourceEnum().
  35. SetGetInfo() - set the first ime flag to FALSE
  36. PackString() - put the string in the end of the buffer
  37. QueryType() - return the node type
  38. QueryScope() - return the scope
  39. QueryUsage() - return the usage of the node
  40. QueryNetResource() - return the net resource pointer
  41. PARENT: BASE
  42. USES: LPNETRESOURCE
  43. CAVEATS:
  44. Base class for SHARE_ENUMNODE, USE_ENUMNODE and
  45. SERVER_ENUMNODE.
  46. HISTORY:
  47. terryk 04-Nov-1991 Code review change. Attend:
  48. johnl davidhov chuckc
  49. **************************************************************************/
  50. class NET_ENUMNODE : public BASE
  51. {
  52. private:
  53. BOOL _fFirstGetInfo; // First time flag. If the
  54. // object is first time GetInfo,
  55. // initialize the enum
  56. UINT _dwType; // bitmask field for type,
  57. // either DISK or PRINT
  58. UINT _dwScope; // either GLOBALNET or CONNECTED
  59. UINT _dwUsage; // either CONNECTABLE or CONTAINER
  60. LPNETRESOURCE _lpNetResource; // net resource pointer
  61. protected:
  62. VOID SetFirstTime()
  63. { _fFirstGetInfo = FALSE; }
  64. TCHAR * PackString( BYTE *pBuffer, UINT *cbBufSize, const TCHAR * pszString);
  65. public:
  66. NET_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  67. const LPNETRESOURCE lpNetResource );
  68. virtual APIERR GetInfo() = 0;
  69. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize ) = 0;
  70. virtual ~NET_ENUMNODE() ;
  71. UINT QueryType() const
  72. { return _dwType; }
  73. UINT QueryScope() const
  74. { return _dwScope; }
  75. UINT QueryUsage() const
  76. { return _dwUsage; }
  77. LPNETRESOURCE QueryNetResource() const
  78. { return _lpNetResource; }
  79. BOOL IsFirstGetInfo() const
  80. { return _fFirstGetInfo; }
  81. };
  82. /*************************************************************************
  83. NAME: SHARE_ENUMNODE
  84. SYNOPSIS: Share type enum node
  85. INTERFACE:
  86. SHARE_ENUMNODE() - constructor
  87. ~SHARE_ENUMNODE() - destructor
  88. GetInfo() - call GetInfo and create the Iterator
  89. GetNetResource() - convert the iterator into net
  90. resource data object
  91. PARENT: NET_ENUMNODE
  92. USES: SHARE1_ENUM, SHARE1_ENUM_ITER
  93. HISTORY:
  94. terryk 04-Nov-1991 Code review changes. Attend:
  95. johnl davidhov chuckc
  96. **************************************************************************/
  97. class SHARE_ENUMNODE : public NET_ENUMNODE
  98. {
  99. private:
  100. SHARE1_ENUM _ShareEnum;
  101. SHARE1_ENUM_ITER *_pShareIter;
  102. public:
  103. SHARE_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  104. const LPNETRESOURCE lpNetResource );
  105. ~SHARE_ENUMNODE();
  106. virtual APIERR GetInfo();
  107. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  108. };
  109. /*************************************************************************
  110. NAME: SERVER_ENUMNODE
  111. SYNOPSIS: Server type enum node
  112. INTERFACE:
  113. SERVER_ENUMNODE() - constructor
  114. ~SERVER_ENUMNODE() - destructor
  115. GetInfo() - call GetInfo and create the Iterator
  116. GetNetResource() - convert the iterator into net
  117. resource data object
  118. PARENT: NET_ENUMNODE
  119. USES: SERVER1_ENUM, SERVER1_ENUM_ITER
  120. HISTORY:
  121. terryk 04-Nov-1991 Code review changes. Attend:
  122. johnl davidhov chuckc
  123. **************************************************************************/
  124. class SERVER_ENUMNODE : public NET_ENUMNODE
  125. {
  126. private:
  127. SERVER1_ENUM _ServerEnum;
  128. SERVER1_ENUM_ITER *_pServerIter;
  129. public:
  130. SERVER_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  131. const LPNETRESOURCE lpNetResource );
  132. ~SERVER_ENUMNODE();
  133. virtual APIERR GetInfo();
  134. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  135. };
  136. /*************************************************************************
  137. NAME: CONTEXT_ENUMNODE
  138. SYNOPSIS: Context server type enum node
  139. INTERFACE:
  140. CONTEXT_ENUMNODE() - constructor
  141. ~CONTEXT_ENUMNODE() - destructor
  142. GetInfo() - call GetInfo and create the Iterator
  143. GetNetResource() - convert the iterator into net
  144. resource data object
  145. PARENT: NET_ENUMNODE
  146. USES: CONTEXT_ENUM, CONTEXT_ENUM_ITER
  147. HISTORY:
  148. anirudhs 22-Mar-1995 Created from SERVER_ENUMNODE
  149. **************************************************************************/
  150. class CONTEXT_ENUMNODE : public NET_ENUMNODE
  151. {
  152. private:
  153. CONTEXT_ENUM _ServerEnum;
  154. CONTEXT_ENUM_ITER *_pServerIter;
  155. public:
  156. CONTEXT_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  157. const LPNETRESOURCE lpNetResource );
  158. ~CONTEXT_ENUMNODE();
  159. virtual APIERR GetInfo();
  160. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  161. };
  162. /*************************************************************************
  163. NAME: EMPTY_ENUMNODE
  164. SYNOPSIS: EMPTY type enum node. Always returns zero items.
  165. INTERFACE:
  166. EMPTY_ENUMNODE() - constructor
  167. ~EMPTY_ENUMNODE() - destructor
  168. GetInfo() - call GetInfo and create the Iterator
  169. GetNetResource() - convert the iterator into net
  170. resource data object
  171. PARENT: NET_ENUMNODE
  172. USES:
  173. HISTORY:
  174. chuckc 01-Aug-1992 created
  175. **************************************************************************/
  176. class EMPTY_ENUMNODE : public NET_ENUMNODE
  177. {
  178. private:
  179. public:
  180. EMPTY_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  181. const LPNETRESOURCE lpNetResource );
  182. ~EMPTY_ENUMNODE();
  183. virtual APIERR GetInfo();
  184. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  185. };
  186. /*************************************************************************
  187. NAME: USE_ENUMNODE
  188. SYNOPSIS: Use type enum node
  189. INTERFACE:
  190. USE_ENUMNODE() - constructor
  191. ~USE_ENUMNODE() - destructor
  192. GetInfo() - call GetInfo and create the Iterator
  193. GetNetResource() - convert the iterator into net
  194. resource data object
  195. PARENT: NET_ENUMNODE
  196. USES: DEVICE, ITER_DEVICE
  197. HISTORY:
  198. terryk 04-Nov-1991 Code review changes. Attend:
  199. johnl davidhov chuckc
  200. Yi-HsinS 9-Jun-1992 Use USE1_ENUM
  201. **************************************************************************/
  202. class USE_ENUMNODE : public NET_ENUMNODE
  203. {
  204. private:
  205. USE1_ENUM _UseEnum;
  206. USE1_ENUM_ITER *_pUseIter;
  207. CDfsEnumConnectedNode _dfsEnum;
  208. public:
  209. USE_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  210. const LPNETRESOURCE lpNetResource );
  211. ~USE_ENUMNODE();
  212. virtual APIERR GetInfo();
  213. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  214. };
  215. /*************************************************************************
  216. NAME: DOMAIN_ENUMNODE
  217. SYNOPSIS: domain type enum node
  218. INTERFACE:
  219. DOMAIN_ENUMNODE() - constructor
  220. ~DOMAIN_ENUMNODE() - destructor
  221. GetInfo() - call GetInfo and create the Iterator
  222. GetNetResource() - convert the iterator into net
  223. resource data object
  224. PARENT: NET_ENUMNODE
  225. USES: DEVICE, ITER_DEVICE
  226. HISTORY:
  227. terryk 04-Nov-1991 Code review changes. Attend:
  228. johnl davidhov chuckc
  229. terryk 10-Dec-1991 Added Other domain slist
  230. KeithMo 03-Aug-1992 Now uses new BROWSE_DOMAIN_ENUM
  231. whiz-bang domain enumerator.
  232. **************************************************************************/
  233. class DOMAIN_ENUMNODE : public NET_ENUMNODE
  234. {
  235. private:
  236. BROWSE_DOMAIN_ENUM _enumDomains;
  237. const BROWSE_DOMAIN_INFO * _pbdiNext;
  238. public:
  239. DOMAIN_ENUMNODE( UINT dwScope, UINT dwType, UINT dwUsage,
  240. const LPNETRESOURCE lpNetResource );
  241. virtual APIERR GetInfo();
  242. virtual UINT GetNetResource( BYTE *pBuffer, UINT *dwBufSize );
  243. }; // class DOMAIN_ENUMNODE
  244. #include <array.hxx>
  245. typedef NET_ENUMNODE * PNET_ENUMNODE;
  246. DECLARE_ARRAY_OF( PNET_ENUMNODE );
  247. /*************************************************************************
  248. NAME: NET_ENUM_HANDLE_TABLE
  249. SYNOPSIS: This is an array of pointer to NET_ENUMNODE object
  250. INTERFACE:
  251. ARRAY_OF_NETENUM() - constructor
  252. ~ARRAY_OF_NETENUM() - destructor
  253. IsValidRange() - check whether the handle is out of
  254. range or not
  255. IsValidHandle() - whether out of range and point to NULL
  256. QueryNextAvail() - return the Next available handle
  257. QueryNode() - get the issue in the specified position
  258. return NULL in case of error.
  259. SetNode() - set the specified position to the given
  260. object
  261. USES: ARRAY
  262. NOTES: Only one thread can ever read or write from the handle
  263. table. This is acceptable because all access operations
  264. are very fast (either an array lookup or table search).
  265. HISTORY:
  266. terryk 04-Nov-1991 Code review changes. Attend:
  267. johnl davidhov chuckc
  268. **************************************************************************/
  269. class NET_ENUM_HANDLE_TABLE : public BASE
  270. {
  271. private:
  272. ARRAY_OF( PNET_ENUMNODE ) _apNetEnumArray;
  273. UINT _cNumEntry;
  274. /* Note this method is not wrapped by a critical section because it is
  275. * only called by methods which will have previously called
  276. * EnterCriticalsection.
  277. */
  278. BOOL IsValidHandle( UINT iIndex ) const
  279. { return (IsValidRange( iIndex ) && ( _apNetEnumArray[iIndex] != NULL )); }
  280. public:
  281. NET_ENUM_HANDLE_TABLE( UINT cNumEntry );
  282. ~NET_ENUM_HANDLE_TABLE();
  283. BOOL IsValidRange( UINT iIndex ) const
  284. { return ( iIndex < _cNumEntry ); }
  285. INT QueryNextAvail();
  286. NET_ENUMNODE * QueryNode( UINT iIndex ) const;
  287. VOID SetNode( UINT iIndex, NET_ENUMNODE * pNetEnumNode );
  288. VOID ClearNode( UINT iIndex );
  289. };
  290. #endif