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.

293 lines
4.9 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1997
  3. All rights reserved.
  4. Module Name:
  5. prtshare.hxx
  6. Abstract:
  7. Printer Share header
  8. Author:
  9. Steve Kiraly (SteveKi) 17-Mar-1996
  10. Revision History:
  11. --*/
  12. #ifndef _PRTSHARE_HXX
  13. #define _PRTSHARE_HXX
  14. /********************************************************************
  15. Printer Printer class
  16. ********************************************************************/
  17. class TPrtPrinter {
  18. SIGNATURE( 'ptpr' )
  19. SAFE_NEW
  20. public:
  21. TPrtPrinter::
  22. TPrtPrinter(
  23. IN LPCTSTR pszServerName
  24. );
  25. TPrtPrinter::
  26. ~TPrtPrinter(
  27. VOID
  28. );
  29. BOOL
  30. TPrtPrinter::
  31. bValid(
  32. VOID
  33. ) const;
  34. BOOL
  35. TPrtPrinter::
  36. bRefresh(
  37. VOID
  38. );
  39. BOOL
  40. TPrtPrinter::
  41. bIsValidShareNameForThisPrinter(
  42. IN LPCTSTR pszShareName,
  43. IN LPCTSTR pszPrinterName = NULL
  44. ) const;
  45. #if DBG
  46. VOID
  47. TPrtPrinter::
  48. vPrint(
  49. VOID
  50. ) const;
  51. #endif
  52. private:
  53. //
  54. // Copying and assignment are not defined.
  55. //
  56. TPrtPrinter::
  57. TPrtPrinter(
  58. const TPrtPrinter &
  59. );
  60. TPrtPrinter &
  61. TPrtPrinter::
  62. operator =(
  63. const TPrtPrinter &
  64. );
  65. BOOL
  66. TPrtPrinter::
  67. bGetEnumData(
  68. VOID
  69. );
  70. BOOL _bValid;
  71. PRINTER_INFO_2 *_pPrinterInfo2;
  72. DWORD _cPrinterInfo2;
  73. TString _strServerName;
  74. };
  75. /********************************************************************
  76. Printer Share class
  77. ********************************************************************/
  78. class TPrtShare {
  79. SIGNATURE( 'ptsh' )
  80. SAFE_NEW
  81. public:
  82. enum tStatus {
  83. kSuccess,
  84. kInvalidLength,
  85. kInvalidDosFormat,
  86. kInvalidChar,
  87. };
  88. TPrtShare::
  89. TPrtShare(
  90. LPCTSTR pszServerName
  91. );
  92. TPrtShare::
  93. ~TPrtShare(
  94. VOID
  95. );
  96. BOOL
  97. TPrtShare::
  98. bValid(
  99. VOID
  100. ) const;
  101. BOOL
  102. TPrtShare::
  103. bRefresh(
  104. VOID
  105. );
  106. BOOL
  107. TPrtShare::
  108. bNewShareName(
  109. IN TString &strShareName,
  110. IN const TString &strBaseShareName
  111. ) const;
  112. BOOL
  113. TPrtShare::
  114. bIsValidShareNameForThisPrinter(
  115. IN LPCTSTR pszShareName,
  116. IN LPCTSTR pszPrinterName = NULL
  117. ) const;
  118. INT
  119. TPrtShare::
  120. iIsValidDosShare(
  121. LPCTSTR pszShareName
  122. ) const;
  123. INT
  124. TPrtShare::
  125. iIsValidNtShare(
  126. LPCTSTR pszShareName
  127. ) const;
  128. static
  129. BOOL
  130. TPrtShare::
  131. bNetworkInstalled(
  132. VOID
  133. );
  134. #if DBG
  135. VOID
  136. TPrtShare::
  137. vPrint(
  138. VOID
  139. ) const;
  140. #endif
  141. private:
  142. //
  143. // Copying and assignment are not defined.
  144. //
  145. TPrtShare::
  146. TPrtShare(
  147. const TPrtShare &
  148. );
  149. TPrtShare &
  150. TPrtShare::
  151. operator =(
  152. const TPrtShare &
  153. );
  154. BOOL
  155. TPrtShare::
  156. bIsShareNameUsedW(
  157. IN PCWSTR pszShareName
  158. ) const;
  159. BOOL
  160. TPrtShare::
  161. bIsShareNameUsedA(
  162. IN PCSTR pszShareName
  163. ) const;
  164. BOOL
  165. TPrtShare::
  166. bGetEnumData(
  167. VOID
  168. );
  169. VOID
  170. TPrtShare::
  171. vDestroy(
  172. VOID
  173. );
  174. BOOL _bValid;
  175. LPBYTE _pNetResBuf;
  176. DWORD _dwNetResCount;
  177. TString _strServerName;
  178. TPrtPrinter _PrtPrinter;
  179. static LPCTSTR _gszIllegalDosChars;
  180. static LPCTSTR _gszIllegalNtChars;
  181. BOOL
  182. TPrtShare::
  183. bLoad(
  184. VOID
  185. );
  186. VOID
  187. TPrtShare::
  188. vUnload(
  189. VOID
  190. );
  191. typedef
  192. NET_API_STATUS
  193. (NET_API_FUNCTION *PF_NETSHAREENUM)(
  194. IN LPTSTR servername,
  195. IN DWORD level,
  196. OUT LPBYTE *bufptr,
  197. IN DWORD prefmaxlen,
  198. OUT LPDWORD entriesread,
  199. OUT LPDWORD totalentries,
  200. IN OUT LPDWORD resume_handle
  201. );
  202. typedef
  203. NET_API_STATUS
  204. (NET_API_FUNCTION *PF_NETAPIBUFFERFREE)(
  205. IN LPVOID Buffer
  206. );
  207. #define NETAPI32_LIB "netapi32.dll"
  208. #define NETSHAREENUM "NetShareEnum"
  209. #define NETAPIBUFFERFREE "NetApiBufferFree"
  210. TLibrary *_pLibrary;
  211. PF_NETSHAREENUM _pfNetShareEnum;
  212. PF_NETAPIBUFFERFREE _pfNetApiBufferFree;
  213. };
  214. /********************************************************************
  215. Global functions.
  216. ********************************************************************/
  217. BOOL
  218. bCreateShareName(
  219. IN LPCTSTR pszServer,
  220. IN LPCTSTR pszPrinter,
  221. IN OUT LPTSTR pszBuffer,
  222. IN OUT PDWORD pcbSize
  223. );
  224. #endif