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.

262 lines
6.5 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990 **/
  4. /**********************************************************************/
  5. /*
  6. * History
  7. * chuckc 12/7/90 Created
  8. * rustanl 1/24/91 Moved two enumerations (also used in BLT)
  9. * to lmobj.hxx.
  10. * rustanl 3/6/91 Change PSZ Connect param to const TCHAR *
  11. * terryk 10/7/91 type changes for NT
  12. * terryk 10/21/91 type changes for NT
  13. * terryk 10/31/91 add DEVICE2 object
  14. * KeithMo 31-Oct-1991 Removed x2ULONG stuff.
  15. * terryk 08-Nov-1991 Add BYTE *_pBuf to DEVICE object
  16. * terryk 18-Nov-1991 Code review changed. Attend: chuckc
  17. * Johnl davidhov terryk
  18. */
  19. #ifndef _LMODEV_HXX_
  20. #define _LMODEV_HXX_
  21. #include "lmobj.hxx"
  22. DLL_CLASS LM_RESOURCE; // declared in lmores.hxx
  23. enum LMO_DEV_STATE
  24. {
  25. LMO_DEV_BADSTATE,
  26. LMO_DEV_LOCAL,
  27. LMO_DEV_REMOTE,
  28. LMO_DEV_NOSUCH,
  29. LMO_DEV_UNAVAIL,
  30. LMO_DEV_UNKNOWN
  31. }; // enum LMO_DEV_STATE
  32. /**********************************************************\
  33. NAME: DEVICE
  34. WORKBOOK:
  35. SYNOPSIS: device class in lan manager object
  36. INTERFACE:
  37. DEVICE() - constructor
  38. ~DEVICE() - destructor
  39. QueryName() - query name
  40. GetInfo() - get information
  41. WriteInfo() - write information
  42. QueryType() - query type
  43. QueryState() - query state
  44. QueryStatus() - query status
  45. QueryRemoteType() - query remote type
  46. QueryRemoteName() - query remote name
  47. QueryServer() - Returns the server name in the form "\\server"
  48. Connect() - connect
  49. Disconnect() - disconnect
  50. PARENT: LM_OBJ
  51. USES: LM_DEV_STATE, LM_DEVICE
  52. CAVEATS:
  53. NOTES:
  54. HISTORY:
  55. chuckc 12/7/90 Created
  56. Johnl 08/13/91 Added QueryServer
  57. terryk 18-Nov-1991 Add CallAPI and SetInfo
  58. \**********************************************************/
  59. DLL_CLASS DEVICE : public LM_OBJ
  60. {
  61. private:
  62. TCHAR _szRemoteName[MAX_PATH+1];
  63. TCHAR _szServerName[MAX_PATH+1] ;
  64. NLS_STR _nlsDeviceName ;
  65. LMO_DEV_STATE _lmoDevState;
  66. LMO_DEVICE _lmoDevType;
  67. UINT _uStatus; // as defined by USE.H
  68. UINT _uRemoteType; // as defined by USE.H
  69. BYTE *_pBuf;
  70. protected:
  71. virtual APIERR ValidateName(VOID);
  72. virtual APIERR CallAPI( );
  73. virtual VOID SetInfo( );
  74. BYTE * QueryBufPtr()
  75. { return _pBuf; }
  76. VOID SetBufPtr( BYTE * pBuf )
  77. { _pBuf = pBuf; }
  78. LMO_DEV_STATE QueryDevState() const
  79. { return _lmoDevState; }
  80. VOID SetDevState( LMO_DEV_STATE lmoDevState )
  81. { _lmoDevState = lmoDevState; }
  82. LMO_DEVICE QueryDevType() const
  83. { return _lmoDevType; }
  84. VOID SetDevType( LMO_DEVICE lmoDevType )
  85. { _lmoDevType = lmoDevType; }
  86. VOID SetStatus( UINT uStatus )
  87. { _uStatus = uStatus; }
  88. VOID SetRemoteType( UINT uRemoteType )
  89. { _uRemoteType = uRemoteType; }
  90. VOID SetRemoteName( const TCHAR * pszRemoteName );
  91. VOID SetServerName( const TCHAR * pszServerName );
  92. public:
  93. DEVICE( const TCHAR * pchName );
  94. ~DEVICE();
  95. const TCHAR * QueryName( VOID ) const ;
  96. APIERR GetInfo( VOID );
  97. APIERR WriteInfo( VOID );
  98. UINT QueryType( VOID ) const;
  99. LMO_DEV_STATE QueryState( VOID ) const;
  100. UINT QueryStatus( VOID ) const;
  101. UINT QueryRemoteType( VOID ) const;
  102. const TCHAR * QueryRemoteName( VOID ) const;
  103. const TCHAR * QueryServer( VOID ) const ;
  104. APIERR Connect( LM_RESOURCE & resource, const TCHAR * pszPassword =
  105. NULL );
  106. APIERR Connect( const TCHAR * pszResource, const TCHAR * pszPassword
  107. = NULL );
  108. APIERR Disconnect( UINT uiForce = USE_NOFORCE );
  109. APIERR Disconnect( const TCHAR *pszRemote, UINT uiForce = USE_NOFORCE );
  110. #ifndef WIN32
  111. // WIN32BUGBUG
  112. static UINT AliasToUNC(TCHAR *pchRemoteName, const TCHAR *pchAlias) ;
  113. #endif
  114. }; // class DEVICE
  115. #ifdef WIN32
  116. /*************************************************************************
  117. NAME: DEVICE2
  118. SYNOPSIS: level 2 device object
  119. INTERFACE: DEVICE2() - constructor
  120. Connect() - connect to the network
  121. QueryUsername() - get the username
  122. PARENT: DEVICE
  123. CAVEATS:
  124. Provide level 2 device object for WIN32 access
  125. HISTORY:
  126. terryk 31-Oct-91 Created
  127. terryk 18-Nov-91 Add CallAPI and SetInfo
  128. JohnL 30-Jan-1992 Added Domain field
  129. AnirudhS 16-Jan-96 Added level 3 parameters to Connect
  130. **************************************************************************/
  131. DLL_CLASS DEVICE2 : public DEVICE
  132. {
  133. private:
  134. NLS_STR _nlsUsername;
  135. NLS_STR _nlsDomainName ;
  136. protected:
  137. APIERR SetUsername( const TCHAR * pszUsername )
  138. { _nlsUsername = pszUsername; return _nlsUsername.QueryError(); };
  139. APIERR SetDomainName( const TCHAR * pszDomainName )
  140. { _nlsDomainName = pszDomainName ; return _nlsDomainName.QueryError() ;}
  141. virtual APIERR CallAPI( );
  142. virtual VOID SetInfo( );
  143. public:
  144. DEVICE2( const TCHAR * pszName );
  145. APIERR Connect( const TCHAR * pszResource,
  146. const TCHAR * pszPassword = NULL,
  147. const TCHAR * pszUsername = NULL,
  148. const TCHAR * pszDomain = NULL,
  149. ULONG ulFlags = 0 ) ;
  150. const TCHAR * QueryUsername() const
  151. { return _nlsUsername.QueryPch(); }
  152. const TCHAR * QueryDomain( void ) const
  153. { return _nlsDomainName.QueryPch() ; }
  154. };
  155. #endif
  156. /*
  157. * iterate over valid devices
  158. */
  159. /**********************************************************\
  160. NAME: ITER_DEVICE
  161. WORKBOOK:
  162. SYNOPSIS: iterator device class
  163. INTERFACE:
  164. Next() - next object
  165. operator()() - next one
  166. ITER_DEVICE() - constructor
  167. ~ITEM_DEVICE() - destructor
  168. PARENT:
  169. USES:
  170. CAVEATS:
  171. NOTES:
  172. HISTORY:
  173. chuckc 12/7/90 Created
  174. \**********************************************************/
  175. DLL_CLASS ITER_DEVICE
  176. {
  177. public:
  178. const TCHAR * Next( VOID ) ;
  179. inline const TCHAR * operator()(VOID) { return Next(); }
  180. ITER_DEVICE(LMO_DEVICE DevType, LMO_DEV_USAGE Usage) ;
  181. ~ITER_DEVICE() ;
  182. private:
  183. const TCHAR * EnumDrives() ;
  184. const TCHAR * EnumLPTs() ;
  185. const TCHAR * EnumComms() ;
  186. TCHAR * _pszDevices ;
  187. TCHAR * _pszNext ;
  188. UINT _DevType ;
  189. LMO_DEV_USAGE _Usage ;
  190. };
  191. /*
  192. * general funcs for going between LMO types and NETAPU types
  193. */
  194. INT LMOTypeToNetType(LMO_DEVICE lmoDevType) ;
  195. LMO_DEVICE NetTypeToLMOType(ULONG netDevType) ;
  196. // end of lmodev.hxx
  197. #endif // _LMODEV_HXX_