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.

344 lines
6.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1998
  3. All rights reserved.
  4. Module Name:
  5. prndata.cxx
  6. Abstract:
  7. Type safe printer data class
  8. Author:
  9. Steve Kiraly (SteveKi) 24-Aug-1998
  10. Revision History:
  11. --*/
  12. #ifndef _PRNDATA_HXX
  13. #define _PRNDATA_HXX
  14. class TPrinterDataAccess
  15. {
  16. public:
  17. enum EResourceType
  18. {
  19. kResourceServer,
  20. kResourcePrinter,
  21. kResourceUnknown,
  22. };
  23. enum EAccessType
  24. {
  25. kAccessFull,
  26. kAccessRead,
  27. kAccessUnknown,
  28. };
  29. TPrinterDataAccess::
  30. TPrinterDataAccess(
  31. IN LPCTSTR pszPrinter,
  32. IN EResourceType eResourceType,
  33. IN EAccessType eAccessType
  34. );
  35. TPrinterDataAccess::
  36. TPrinterDataAccess(
  37. IN HANDLE hPrinter
  38. );
  39. TPrinterDataAccess::
  40. ~TPrinterDataAccess(
  41. VOID
  42. );
  43. BOOL
  44. TPrinterDataAccess::
  45. Init(
  46. VOID
  47. ) const;
  48. HRESULT
  49. TPrinterDataAccess::
  50. Get(
  51. IN LPCTSTR pszValue,
  52. IN OUT BOOL &bData
  53. );
  54. HRESULT
  55. TPrinterDataAccess::
  56. Get(
  57. IN LPCTSTR pszValue,
  58. IN OUT DWORD &dwData
  59. );
  60. HRESULT
  61. TPrinterDataAccess::
  62. Get(
  63. IN LPCTSTR pszValue,
  64. IN OUT TString &strString
  65. );
  66. HRESULT
  67. TPrinterDataAccess::
  68. Get(
  69. IN LPCTSTR pszValue,
  70. IN OUT TString **pstrString,
  71. IN OUT UINT &nItemCount
  72. );
  73. HRESULT
  74. TPrinterDataAccess::
  75. Get(
  76. IN LPCTSTR pszValue,
  77. IN OUT PVOID pData,
  78. IN UINT nSize
  79. );
  80. HRESULT
  81. TPrinterDataAccess::
  82. Get(
  83. IN LPCTSTR pszKey,
  84. IN LPCTSTR pszValue,
  85. IN OUT BOOL &bData
  86. );
  87. HRESULT
  88. TPrinterDataAccess::
  89. Get(
  90. IN LPCTSTR pszKey,
  91. IN LPCTSTR pszValue,
  92. IN OUT DWORD &dwData
  93. );
  94. HRESULT
  95. TPrinterDataAccess::
  96. Get(
  97. IN LPCTSTR pszKey,
  98. IN LPCTSTR pszValue,
  99. IN OUT TString &strString
  100. );
  101. HRESULT
  102. TPrinterDataAccess::
  103. Get(
  104. IN LPCTSTR pszKey,
  105. IN LPCTSTR pszValue,
  106. IN OUT PVOID pData,
  107. IN UINT nSize
  108. );
  109. HRESULT
  110. TPrinterDataAccess::
  111. Get(
  112. IN LPCTSTR pszKey,
  113. IN LPCTSTR pszValue,
  114. IN OUT TString **pstrString,
  115. IN OUT UINT &nItemCount
  116. );
  117. HRESULT
  118. TPrinterDataAccess::
  119. Set(
  120. IN LPCTSTR pszValue,
  121. IN BOOL bData
  122. );
  123. HRESULT
  124. TPrinterDataAccess::
  125. Set(
  126. IN LPCTSTR pszValue,
  127. IN DWORD dwData
  128. );
  129. HRESULT
  130. TPrinterDataAccess::
  131. Set(
  132. IN LPCTSTR pszValue,
  133. IN TString &strString
  134. );
  135. HRESULT
  136. TPrinterDataAccess::
  137. Set(
  138. IN LPCTSTR pszValue,
  139. IN OUT PVOID pData,
  140. IN UINT nSize
  141. );
  142. HRESULT
  143. TPrinterDataAccess::
  144. Set(
  145. IN LPCTSTR pszKey,
  146. IN LPCTSTR pszValue,
  147. IN BOOL bData
  148. );
  149. HRESULT
  150. TPrinterDataAccess::
  151. Set(
  152. IN LPCTSTR pszKey,
  153. IN LPCTSTR pszValue,
  154. IN DWORD dwData
  155. );
  156. HRESULT
  157. TPrinterDataAccess::
  158. Set(
  159. IN LPCTSTR pszKey,
  160. IN LPCTSTR pszValue,
  161. IN TString &strString
  162. );
  163. HRESULT
  164. TPrinterDataAccess::
  165. Set(
  166. IN LPCTSTR pszKey,
  167. IN LPCTSTR pszValue,
  168. IN OUT PVOID pData,
  169. IN UINT nSize
  170. );
  171. HRESULT
  172. TPrinterDataAccess::
  173. Delete(
  174. IN LPCTSTR pszValue
  175. );
  176. HRESULT
  177. TPrinterDataAccess::
  178. Delete(
  179. IN LPCTSTR pszKey,
  180. IN LPCTSTR pszValue
  181. );
  182. HRESULT
  183. TPrinterDataAccess::
  184. GetDataSize(
  185. IN LPCTSTR pszValue,
  186. IN DWORD dwType,
  187. IN DWORD &nSize
  188. );
  189. VOID
  190. TPrinterDataAccess::
  191. RelaxReturnTypeCheck(
  192. IN BOOL bCheckState
  193. );
  194. private:
  195. enum EDataType
  196. {
  197. kDataTypeBool,
  198. kDataTypeDword,
  199. kDataTypeString,
  200. kDataTypeStruct,
  201. kDataTypeMultiString,
  202. kDataTypeUnknown,
  203. };
  204. struct ClassTypeMap
  205. {
  206. DWORD Reg;
  207. EDataType Class;
  208. };
  209. ACCESS_MASK
  210. TPrinterDataAccess::
  211. PrinterAccessFlags(
  212. IN EResourceType eResourceType,
  213. IN EAccessType eAccessType
  214. ) const;
  215. DWORD
  216. TPrinterDataAccess::
  217. ClassTypeToRegType(
  218. IN EDataType eDataType
  219. ) const;
  220. TPrinterDataAccess::EDataType
  221. TPrinterDataAccess::
  222. RegTypeToClassType(
  223. IN DWORD dwDataType
  224. ) const;
  225. VOID
  226. TPrinterDataAccess::
  227. InitializeClassVariables(
  228. VOID
  229. );
  230. HRESULT
  231. TPrinterDataAccess::
  232. GetDataSizeHelper(
  233. IN LPCTSTR pszKey,
  234. IN LPCTSTR pszValue,
  235. IN DWORD dwType,
  236. IN LPDWORD dwNeeded
  237. );
  238. HRESULT
  239. TPrinterDataAccess::
  240. GetDataHelper(
  241. IN LPCTSTR pszKey,
  242. IN LPCTSTR pszValue,
  243. IN EDataType eDataType,
  244. IN PVOID pData,
  245. IN UINT nSize,
  246. IN LPDWORD pdwNeeded
  247. );
  248. HRESULT
  249. TPrinterDataAccess::
  250. SetDataHelper(
  251. IN LPCTSTR pszKey,
  252. IN LPCTSTR pszValue,
  253. IN EDataType eDataType,
  254. IN PVOID pData,
  255. IN UINT nSize
  256. );
  257. HRESULT
  258. TPrinterDataAccess::
  259. DeleteDataHelper(
  260. IN LPCTSTR pszKey,
  261. IN LPCTSTR pszValue
  262. );
  263. HRESULT
  264. TPrinterDataAccess::
  265. GetDataStringHelper(
  266. IN LPCTSTR pszKey,
  267. IN LPCTSTR pszValue,
  268. IN OUT TString &strString
  269. );
  270. HRESULT
  271. TPrinterDataAccess::
  272. GetDataMuliSzStringHelper(
  273. IN LPCTSTR pszKey,
  274. IN LPCTSTR pszValue,
  275. IN OUT TString **pstrString,
  276. IN UINT &nItemCount
  277. );
  278. HANDLE m_hPrinter;
  279. EAccessType m_eAccessType;
  280. BOOL m_bAcceptedHandle;
  281. BOOL m_bRelaxReturnedTypeCheck;
  282. };
  283. #endif