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.

362 lines
9.8 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. PrtDest.c
  5. Abstract:
  6. This module provides RpcXlate support for the RxPrintDest APIs.
  7. Author:
  8. John Rogers (JohnRo) 15-Jul-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 15-Jul-1991 JohnRo
  14. Created.
  15. 16-Jul-1991 JohnRo
  16. Estimate bytes needed for print APIs.
  17. 17-Jul-1991 JohnRo
  18. Extracted RxpDebug.h from Rxp.h.
  19. 26-Aug-1991 JohnRo
  20. Reduce recompiles.
  21. --*/
  22. // These must be included first:
  23. #include <windef.h> // IN, LPTSTR, etc.
  24. #include <lmcons.h> // NET_API_STATUS, etc.
  25. // These may be included in any order:
  26. #include <apinums.h> // API_ equates.
  27. #include <lmerr.h> // NERR_ and ERROR_ equates.
  28. #include <netdebug.h> // NetpAssert().
  29. #include <remdef.h> // REM16_, REMSmb_, equates.
  30. #include <rx.h> // RxRemoteApi().
  31. #include <rxp.h> // RxpEstimatedBytesNeeded().
  32. #include <rxprint.h> // My prototypes.
  33. DBGSTATIC NET_API_STATUS
  34. RxpGetPrintDestInfoDescs(
  35. IN DWORD InfoLevel,
  36. IN BOOL AddOrSetInfoApi,
  37. OUT LPDESC * DataDesc16,
  38. OUT LPDESC * DataDesc32,
  39. OUT LPDESC * DataDescSmb
  40. )
  41. {
  42. switch (InfoLevel) {
  43. case 0 :
  44. if (AddOrSetInfoApi == TRUE) {
  45. return (ERROR_INVALID_LEVEL);
  46. }
  47. *DataDesc16 = REM16_print_dest_0;
  48. *DataDesc32 = REM32_print_dest_0;
  49. *DataDescSmb = REMSmb_print_dest_0;
  50. return (NERR_Success);
  51. case 1 :
  52. if (AddOrSetInfoApi == TRUE) {
  53. return (ERROR_INVALID_LEVEL);
  54. }
  55. *DataDesc16 = REM16_print_dest_1;
  56. *DataDesc32 = REM32_print_dest_1;
  57. *DataDescSmb = REMSmb_print_dest_1;
  58. return (NERR_Success);
  59. case 2 :
  60. if (AddOrSetInfoApi == TRUE) {
  61. return (ERROR_INVALID_LEVEL);
  62. }
  63. *DataDesc16 = REM16_print_dest_2;
  64. *DataDesc32 = REM32_print_dest_2;
  65. *DataDescSmb = REMSmb_print_dest_2;
  66. return (NERR_Success);
  67. case 3 :
  68. *DataDesc16 = REM16_print_dest_3;
  69. *DataDesc32 = REM32_print_dest_3;
  70. *DataDescSmb = REMSmb_print_dest_3;
  71. return (NERR_Success);
  72. default :
  73. return (ERROR_INVALID_LEVEL);
  74. }
  75. /* NOTREACHED */
  76. } // RxpGetPrintDestInfoDescs
  77. SPLERR SPLENTRY
  78. RxPrintDestAdd(
  79. IN LPTSTR pszServer,
  80. IN DWORD uLevel,
  81. IN LPBYTE pbBuf,
  82. IN DWORD cbBuf
  83. )
  84. {
  85. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  86. NET_API_STATUS Status;
  87. NetpAssert( pszServer != NULL );
  88. NetpAssert( *pszServer != '\0' );
  89. Status = RxpGetPrintDestInfoDescs(
  90. uLevel,
  91. TRUE, // this is an Add or SetInfo API
  92. & DataDesc16,
  93. & DataDesc32,
  94. & DataDescSmb);
  95. if (Status != NERR_Success) {
  96. return (Status);
  97. }
  98. return( RxRemoteApi(
  99. API_WPrintDestAdd,
  100. pszServer,
  101. REMSmb_DosPrintDestAdd_P,
  102. DataDesc16,
  103. DataDesc32,
  104. DataDescSmb,
  105. NULL, // no aux 16 desc
  106. NULL, // no aux 32 desc
  107. NULL, // no aux SMB desc
  108. FALSE, // not a null session API
  109. // rest of API's arguments, in 32-bit LM 2.x format:
  110. uLevel,
  111. pbBuf,
  112. cbBuf) );
  113. } // RxPrintDestAdd
  114. SPLERR SPLENTRY
  115. RxPrintDestControl(
  116. IN LPTSTR pszServer,
  117. IN LPTSTR pszDevName,
  118. IN DWORD uControl
  119. )
  120. {
  121. NetpAssert( pszServer != NULL );
  122. NetpAssert( *pszServer != '\0' );
  123. return( RxRemoteApi(
  124. API_WPrintDestControl,
  125. pszServer,
  126. REMSmb_DosPrintDestControl_P,
  127. NULL, // no data desc 16
  128. NULL, // no data desc 32
  129. NULL, // no data desc SMB
  130. NULL, // no aux 16 desc
  131. NULL, // no aux 32 desc
  132. NULL, // no aux SMB desc
  133. FALSE, // not a null session API
  134. // rest of API's arguments, in 32-bit LM 2.x format:
  135. pszDevName,
  136. uControl) );
  137. } // RxPrintDestControl
  138. SPLERR SPLENTRY
  139. RxPrintDestDel(
  140. IN LPTSTR pszServer,
  141. IN LPTSTR pszPrinterName
  142. )
  143. {
  144. NetpAssert( pszServer != NULL );
  145. NetpAssert( *pszServer != '\0' );
  146. return( RxRemoteApi(
  147. API_WPrintDestDel,
  148. pszServer,
  149. REMSmb_DosPrintDestDel_P,
  150. NULL, // no data desc 16
  151. NULL, // no data desc 32
  152. NULL, // no data desc SMB
  153. NULL, // no aux 16 desc
  154. NULL, // no aux 32 desc
  155. NULL, // no aux SMB desc
  156. FALSE, // not a null session API
  157. // rest of API's arguments, in 32-bit LM 2.x format:
  158. pszPrinterName) );
  159. } // RxPrintDestDel
  160. SPLERR SPLENTRY
  161. RxPrintDestEnum(
  162. IN LPTSTR pszServer,
  163. IN DWORD uLevel,
  164. OUT LPBYTE pbBuf,
  165. IN DWORD cbBuf,
  166. IN LPDWORD pcReturned,
  167. OUT LPDWORD TotalEntries
  168. )
  169. {
  170. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  171. NET_API_STATUS Status;
  172. NetpAssert( pszServer != NULL );
  173. NetpAssert( *pszServer != '\0' );
  174. if ( (pbBuf==NULL) || (cbBuf==0) ) {
  175. // Avoid assertion in common code (RxRemoteApi).
  176. return (ERROR_MORE_DATA);
  177. }
  178. Status = RxpGetPrintDestInfoDescs(
  179. uLevel,
  180. FALSE, // not an add or setinfo API
  181. & DataDesc16,
  182. & DataDesc32,
  183. & DataDescSmb);
  184. if (Status != NERR_Success) {
  185. return (Status);
  186. }
  187. return( RxRemoteApi(
  188. API_WPrintDestEnum,
  189. pszServer,
  190. REMSmb_DosPrintDestEnum_P,
  191. DataDesc16,
  192. DataDesc32,
  193. DataDescSmb,
  194. NULL, // no aux 16 desc
  195. NULL, // no aux 32 desc
  196. NULL, // no aux SMB desc
  197. FALSE, // not a null session API
  198. // rest of API's arguments, in 32-bit LM 2.x format:
  199. uLevel,
  200. pbBuf,
  201. cbBuf,
  202. pcReturned,
  203. TotalEntries) );
  204. } // RxPrintDestEnum
  205. SPLERR SPLENTRY
  206. RxPrintDestGetInfo(
  207. IN LPTSTR pszServer,
  208. IN LPTSTR pszName,
  209. IN DWORD uLevel,
  210. OUT LPBYTE pbBuf,
  211. IN DWORD cbBuf,
  212. OUT LPDWORD BytesNeeded // estimated (probably too large).
  213. )
  214. {
  215. DWORD BytesNeeded16;
  216. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  217. NET_API_STATUS Status;
  218. NetpAssert( pszServer != NULL );
  219. NetpAssert( *pszServer != '\0' );
  220. Status = RxpGetPrintDestInfoDescs(
  221. uLevel,
  222. FALSE, // not an add or setinfo API
  223. & DataDesc16,
  224. & DataDesc32,
  225. & DataDescSmb);
  226. if (Status != NERR_Success) {
  227. return (Status);
  228. }
  229. Status = RxRemoteApi(
  230. API_WPrintDestGetInfo,
  231. pszServer,
  232. REMSmb_DosPrintDestGetInfo_P,
  233. DataDesc16,
  234. DataDesc32,
  235. DataDescSmb,
  236. NULL, // no aux desc 16
  237. NULL, // no aux desc 32
  238. NULL, // no aux desc SMB
  239. FALSE, // not a null session API
  240. // rest of API's arguments, in 32-bit LM 2.x format:
  241. pszName,
  242. uLevel,
  243. pbBuf,
  244. cbBuf,
  245. & BytesNeeded16); // downlevel buffer size needed.
  246. // If buffer too small, convert BytesNeeded to native num.
  247. if ( (Status == ERROR_MORE_DATA) || (Status == NERR_BufTooSmall) ) {
  248. *BytesNeeded = RxpEstimateBytesNeeded(BytesNeeded16);
  249. } else {
  250. *BytesNeeded = cbBuf;
  251. }
  252. return (Status);
  253. } // RxPrintDestGetInfo
  254. SPLERR SPLENTRY
  255. RxPrintDestSetInfo(
  256. IN LPTSTR pszServer,
  257. IN LPTSTR pszName,
  258. IN DWORD uLevel,
  259. IN LPBYTE pbBuf,
  260. IN DWORD cbBuf,
  261. IN DWORD uParmNum
  262. )
  263. {
  264. LPDESC DataDesc16, DataDesc32, DataDescSmb;
  265. NET_API_STATUS Status;
  266. NetpAssert( pszServer != NULL );
  267. NetpAssert( *pszServer != '\0' );
  268. Status = RxpGetPrintDestInfoDescs(
  269. uLevel,
  270. TRUE, // This is an add or setinfo API.
  271. & DataDesc16,
  272. & DataDesc32,
  273. & DataDescSmb);
  274. if (Status != NERR_Success) {
  275. return (Status);
  276. }
  277. if (uParmNum == PARMNUM_ALL) {
  278. return( RxRemoteApi(
  279. API_WPrintDestSetInfo,
  280. pszServer,
  281. REMSmb_DosPrintDestSetInfo_P,
  282. DataDesc16,
  283. DataDesc32,
  284. DataDescSmb,
  285. NULL, // no aux 16 desc
  286. NULL, // no aux 32 desc
  287. NULL, // no aux SMB desc
  288. FALSE, // not a null session API
  289. // rest of API's arguments, in 32-bit LM 2.x format:
  290. pszName,
  291. uLevel,
  292. pbBuf,
  293. cbBuf,
  294. uParmNum) );
  295. } else {
  296. // Level 3 parmnums and field indexes are identical, so no need to
  297. // convert here. (Field index equates would be in remdef.h otherwise.)
  298. return( RxpSetField (
  299. API_WPrintDestSetInfo,
  300. pszServer,
  301. "z", // object desc
  302. pszName, // object to set
  303. REMSmb_DosPrintDestSetInfo_P, // parm desc
  304. DataDesc16,
  305. DataDesc32,
  306. DataDescSmb,
  307. pbBuf, // native info buffer
  308. uParmNum, // parmnum to send
  309. uParmNum, // field index
  310. uLevel
  311. ) );
  312. }
  313. /* NOTREACHED */
  314. } // RxPrintDestSetInfo