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.

556 lines
17 KiB

  1. /********************************************\
  2. *
  3. * File : rendserv.h
  4. * Author : Kevin Gallo
  5. * Created: 9/22/93
  6. *
  7. * Copyright (c) Microsoft Corp. 1993-1994
  8. *
  9. * Overview:
  10. *
  11. * Revision History:
  12. \********************************************/
  13. #ifndef _RENDSERV_H
  14. #define _RENDSERV_H
  15. // System includes
  16. #ifdef OLE2
  17. #define INC_OLE2 1
  18. #include <objbase.h>
  19. #endif
  20. #include "ifaxos.h"
  21. #ifdef IFAX
  22. #include "awfile.h"
  23. #include "sosutil.h"
  24. #include "device.h"
  25. #endif
  26. #include "render.h"
  27. // Library Name
  28. #ifdef WIN32
  29. #define LIB_RENDSERV "RNDSRV32.DLL"
  30. #else
  31. #define LIB_RENDSERV "RENDSERV.DLL"
  32. #endif
  33. // =================================================================
  34. // Errors -
  35. // These occupy the lowest 6 bits of the error
  36. // =================================================================
  37. #define RSMAKE_ERR(err) (ERR_FUNCTION_START+err)
  38. #define RSERR_GP_FAULT RSMAKE_ERR(0) // GP Fault
  39. #define RSERR_OPER_FAIL RSMAKE_ERR(1) // The desired operation failed.
  40. #define RSERR_BAD_OPER RSMAKE_ERR(2) // User tried to do something invalid
  41. #define RSERR_BAD_DATA RSMAKE_ERR(3) // Bad data was passed to a renderer.
  42. #define RSERR_DEV_FAIL RSMAKE_ERR(4) // Device failed.
  43. #define RSERR_PROP_FAIL RSMAKE_ERR(5) // Could not get a mapi property
  44. // =================================================================
  45. // Methods in subsystems
  46. // These occupy bits 6-11 - 64 values
  47. // =================================================================
  48. #define RSMAKE_METHOD(method) (method << 6)
  49. // =================================================================
  50. // General methods
  51. // =================================================================
  52. #define RSMETHOD_UNKNOWN RSMAKE_METHOD(0)
  53. #define RSMETHOD_OPEN RSMAKE_METHOD(1)
  54. #define RSMETHOD_CLOSE RSMAKE_METHOD(2)
  55. #define RSMETHOD_INIT RSMAKE_METHOD(3)
  56. #define RSMETHOD_READ RSMAKE_METHOD(4)
  57. #define RSMETHOD_WRITE RSMAKE_METHOD(5)
  58. #define RSMETHOD_RENDER RSMAKE_METHOD(6)
  59. #define RSMETHOD_ALLOC RSMAKE_METHOD(7)
  60. #define RSMETHOD_WINPROC RSMAKE_METHOD(8)
  61. #define RSMETHOD_START RSMAKE_METHOD(9)
  62. #define RSMETHOD_ERRREC RSMAKE_METHOD(10)
  63. // =================================================================
  64. //
  65. // System specific - start at 32
  66. //
  67. // =================================================================
  68. #define RSMETHOD_CUSTOM_START (32)
  69. #define RSMETHOD_GETDEVICES RSMAKE_METHOD(RSMETHOD_CUSTOM_START)
  70. // =================================================================
  71. //
  72. // Systems
  73. // These occupy bits 12-15 of the low WORD - 16 values
  74. //
  75. // =================================================================
  76. #define RSMAKE_SYS(sys) (sys << 12)
  77. #define RSSYS_UNKNOWN RSMAKE_SYS(0) // Unknown
  78. #define RSSYS_SOS RSMAKE_SYS(1) // SOS subsystem
  79. #define RSSYS_FILESYS RSMAKE_SYS(2) // File System
  80. #define RSSYS_NETWORK RSMAKE_SYS(3) // Network
  81. #define RSSYS_RENDERER RSMAKE_SYS(4) // Renderers
  82. #define RSSYS_RENDSERV RSMAKE_SYS(5) // Rendering Server
  83. #define RSSYS_DEVICE RSMAKE_SYS(6) // Devices
  84. #define RSSYS_THREAD RSMAKE_SYS(7) // Threads
  85. // =================================================================
  86. //
  87. // Error macros
  88. //
  89. // =================================================================
  90. #define RSFormCustomError(sys,method,err) ((WORD) (sys | method | err))
  91. #define RSFormIFError(sys,method,err) \
  92. (IFErrAssemble(PROCID_NONE,MODID_REND_SERVER,0,RSFormCustomError(sys,method,err)))
  93. #define RSGetErrCode(err) (err & 0x003f)
  94. #define RSGetErrMethod(err) (err & 0x0fc0)
  95. #define RSGetErrSys(err) (err & 0xf000)
  96. // =================================================================
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. typedef LPVOID LPRENDSERVER ;
  101. typedef enum {
  102. RS_BEGINNING = 0,
  103. RS_CURRENT = 1,
  104. RS_END = 2,
  105. } RSOrigin_t ;
  106. #ifdef IFAX
  107. typedef enum {
  108. RSD_NULL = ATTACH_BY_NULL,
  109. RSD_FILE = ATTACH_BY_REF_RESOLVESOS,
  110. RSD_AWFILE = ATTACH_BY_SAVED_SECFILE,
  111. RSD_PIPE = ATTACH_BY_PIPE,
  112. RSD_SCANNER_PIPE = ATTACH_BY_SCANNER_PIPE,
  113. RSD_PRINTER_PIPE = ATTACH_BY_PRINTER_PIPE,
  114. RSD_METAFILE_PIPE = ATTACH_BY_METAFILE_PIPE,
  115. RSD_TRANSPORT_PIPE = ATTACH_BY_TRANSPORT_PIPE,
  116. RSD_LINEARIZER = ATTACH_BY_LINEARIZER,
  117. #ifdef OLE2
  118. RSD_OLESTREAM,
  119. #endif
  120. RSD_DIRECT_COPY,
  121. } RSDeviceType_t ;
  122. #else
  123. typedef enum {
  124. RSD_NULL,
  125. RSD_FILE,
  126. RSD_AWG3_HANDLE,
  127. #ifdef OLE2
  128. RSD_OLESTREAM,
  129. #endif
  130. } RSDeviceType_t ;
  131. #endif
  132. // Define Job Context
  133. typedef WORD HJC ;
  134. //
  135. // Macros for combining Device IDs
  136. // Used to store ID in PR_ATTACH_DEVID property.
  137. // (major is high word and minor is low word)
  138. #define MAKE_DEVID(major,minor) MAKEWORD(minor,major)
  139. #define GET_MINOR_DEVID(id) LOBYTE(id)
  140. #define GET_MAJOR_DEVID(id) HIBYTE(id)
  141. // Encoding structure for PR_ENCODING property
  142. // For now use the encoded values not the real values (match caps structure)
  143. // We may want to set width and height to be exact values
  144. typedef
  145. struct Encoding_t {
  146. WORD cbStruct ; // Size of the structure
  147. DWORD Resolution ; // The data resolution - see buffer.h for types (AWRES_xxx)
  148. DWORD Encoding ; // The data encoding format - see buffer.h for types (xxx_DATA)
  149. DWORD PageSize ; // The page size - see buffer.h for types (AWPAPER_xxx)
  150. DWORD LengthLimit ; // The page length - see buffer.h for types (AWLENGTH_xxx)
  151. } Encoding_t , FAR * lpEncoding_t ;
  152. // This is the topology data structure
  153. #ifdef IFAX
  154. #pragma warning (disable: 4200)
  155. typedef
  156. struct TopNode {
  157. WORD cbSize ; // Size of node
  158. char szRenderName[16] ; // Renderers modules name (cannot be more than 12 characters)
  159. LPCSTR RenderInfoProc ; // Must be the Ordinal Number of the getinfo call
  160. char RenderParam[] ;
  161. } TopNode, FAR * lpTopNode ;
  162. typedef
  163. struct Topology {
  164. WORD cbSize ; // Size of the struct itself without nodes (just the header)
  165. WORD cbTotalSize ; // Total size of data in struct
  166. WORD nRenderers ; // Number of renderers
  167. WORD uOffset[] ; // Offsets into this struct where TopNode's are. There are nRenderers
  168. // of these.
  169. } Topology , FAR * lpTopology ;
  170. #define GET_TOPNODE(Top,idx) ((lpTopNode) (((LPBYTE)Top) + Top->uOffset[idx]))
  171. #pragma warning (default: 4200)
  172. #else
  173. // A topology will be a linked list of TopNodes
  174. typedef struct TopNode FAR * lpTopNode ;
  175. #pragma warning (disable: 4200)
  176. typedef struct TopNode {
  177. WORD cbSize ; // Size of node
  178. LPTSTR szRenderName ; // Renderers modules name - (this is the dll)
  179. LPCSTR RenderInfoProc ; // Will be passed directly to getprocaddress (i.e. ordinal or name)
  180. lpTopNode lpNext ; // Used to create linked list topology
  181. char RenderParam[] ;
  182. } TopNode ;
  183. #pragma warning (default: 4200)
  184. typedef struct Topology {
  185. WORD nRenderers ; // Number of renderers
  186. lpTopNode lpHead ; // Pointer to first renderer
  187. lpTopNode lpTail ; // Pointer to last renderer
  188. } Topology , FAR * lpTopology ;
  189. #endif
  190. /****
  191. @doc EXTERNAL RENDSERV
  192. @types RSProcessInfo_t | The Process Pipe information structure.
  193. @field HSESSION | hSession | Specifies the session handle for the device.
  194. @field DEVICESTR | szDeviceName | Specifies the name of the device to use.
  195. @field UCHAR | ucMajorDevId | Specifies the Major Id of the device.
  196. @field UCHAR | ucMinorDevId | Specifies the Minor Id of the device.
  197. @field LPVOID | lpMode | Specifies the mode structure to be passed to the device.
  198. @field UINT | cbMode | Specifies the size of mode structure.
  199. @comm There are other reserved fields in the structure which have not been
  200. mentioned here.
  201. @tagname RSProcessInfo_t
  202. ****/
  203. #ifdef IFAX
  204. typedef
  205. struct RSProcessPipeInfo_t {
  206. HSESSION hSession ;
  207. DEVICESTR szDeviceName ;
  208. UCHAR ucMajorDevId ;
  209. UCHAR ucMinorDevId ;
  210. LPVOID lpMode ;
  211. UINT cbMode ;
  212. } RSProcessPipeInfo_t , FAR * lpRSProcessPipeInfo_t ;
  213. #endif
  214. typedef
  215. struct RSDeviceInfo_t {
  216. RSDeviceType_t DevType ;
  217. Encoding_t Encoding ;
  218. union {
  219. LPTSTR lpszFileName ;
  220. HANDLE hFile ;
  221. #ifdef OLE2
  222. LPSTREAM lpstream ;
  223. #endif
  224. #ifdef IFAX
  225. hSecureFile SecFileName ;
  226. HPIPE hpipe ;
  227. LPMESSAGESOS lpMessage ;
  228. RSProcessPipeInfo_t ProcInfo ;
  229. #endif
  230. } ;
  231. } RSDeviceInfo_t ;
  232. typedef RSDeviceInfo_t FAR * lpRSDeviceInfo_t, FAR * FAR * lplpRSDeviceInfo_t ;
  233. typedef const RSDeviceInfo_t FAR * lpCRSDeviceInfo_t, FAR * FAR * lplpCRSDeviceInfo_t ;
  234. #ifdef IFAX
  235. #pragma warning (disable: 4200)
  236. typedef
  237. struct SOSProcessPipeInfo_t {
  238. HSESSION hSession ;
  239. DEVICESTR szDeviceName ;
  240. UCHAR ucMajorDevId ;
  241. UCHAR ucMinorDevId ;
  242. UINT cbMode ;
  243. BYTE Mode[] ;
  244. } SOSProcessPipeInfo_t , FAR * lpSOSProcessPipeInfo_t ;
  245. typedef
  246. struct SOSDeviceInfo_t {
  247. UINT cbSize ;
  248. RSDeviceType_t DevType ;
  249. Encoding_t Encoding ;
  250. union {
  251. char lpszFileName[] ;
  252. hSecureFile SecFileName ;
  253. HPIPE hpipe ;
  254. LPMESSAGESOS lpMessage ;
  255. SOSProcessPipeInfo_t ProcInfo ;
  256. } ;
  257. } SOSDeviceInfo_t , FAR * lpSOSDeviceInfo_t, FAR * FAR * lplpSOSDeviceInfo_t ;
  258. #pragma warning (default: 4200)
  259. #endif
  260. typedef void (WINAPI *LPFNACKPROC) (LPRENDSERVER lprs,WORD PageNum,WORD wValue,LPVOID lpvData) ;
  261. typedef void (WINAPI *LPFNSTATUSPROC) (LPRENDSERVER lprs,WORD PageNum,WORD kbytes,LPVOID lpvData) ;
  262. /********
  263. @doc EXTERNAL RENDSERV
  264. @api LPRENDSERVER | RSAlloc | Allocates a Render Server.
  265. @rdesc Returns a pointer to the Rendering Server or NULL if there was not enough memory.
  266. ********/
  267. EXPORT_DLL LPRENDSERVER WINAPI RSAlloc () ;
  268. EXPORT_DLL void WINAPI RSFree (LPRENDSERVER lprs) ;
  269. EXPORT_DLL BOOL WINAPI RSInit (LPRENDSERVER lprs,HJC hjc,HWND hwnd) ;
  270. EXPORT_DLL BOOL WINAPI RSOpen (LPRENDSERVER lprs,
  271. lpRSDeviceInfo_t lpSrcInfo,lpRSDeviceInfo_t lpTgtInfo,
  272. lpTopology lpTop,LPJOBINFO lpJobInfo) ;
  273. EXPORT_DLL BOOL WINAPI RSClose (LPRENDSERVER lprs) ;
  274. // Returns false if we did not process it
  275. EXPORT_DLL LRESULT WINAPI RSWndProc (LPRENDSERVER lprs,UINT msg,WPARAM wParam,LPARAM lParam) ;
  276. EXPORT_DLL BOOL WINAPI RSRender (LPRENDSERVER lprs,UINT nIterations) ;
  277. EXPORT_DLL BOOL WINAPI RSSetPage (LPRENDSERVER lprs,RSOrigin_t origin,int offset) ;
  278. // These will be called once a page or job ack
  279. // is received (indicating the target has confirmed them.
  280. //
  281. // The last page will call JobAck and not PageAck
  282. // - thus if these are 5 pages there will be 4 page acks and one job ack
  283. EXPORT_DLL void WINAPI RSSetPageAckCallback(LPRENDSERVER lprs,LPFNACKPROC lpfnAckProc,LPVOID lpvData) ;
  284. EXPORT_DLL void WINAPI RSSetJobAckCallback(LPRENDSERVER lprs,LPFNACKPROC lpfnAckProc,LPVOID lpvData) ;
  285. EXPORT_DLL void WINAPI RSSetStatusCallback(LPRENDSERVER lprs,LPFNSTATUSPROC lpfnStatusProc,LPVOID lpvData) ;
  286. EXPORT_DLL void WINAPI RSSetSrcJobAckCallback(LPRENDSERVER lprs,LPFNACKPROC lpfnAckProc,LPVOID lpvData) ;
  287. EXPORT_DLL void WINAPI RSPause (LPRENDSERVER lprs) ;
  288. EXPORT_DLL void WINAPI RSResume (LPRENDSERVER lprs) ;
  289. EXPORT_DLL void WINAPI RSAbort (LPRENDSERVER lprs) ;
  290. EXPORT_DLL BOOL WINAPI RSSpool (LPRENDSERVER lprs) ;
  291. EXPORT_DLL BOOL WINAPI RSIsBlocking(LPRENDSERVER lprs) ;
  292. EXPORT_DLL BOOL WINAPI RSIsPaused(LPRENDSERVER lprs) ;
  293. EXPORT_DLL BOOL WINAPI RSIsDone(LPRENDSERVER lprs) ;
  294. EXPORT_DLL BOOL WINAPI RSIsInit(LPRENDSERVER lprs) ;
  295. EXPORT_DLL BOOL WINAPI RSIsOpen(LPRENDSERVER lprs) ;
  296. // This will take the device structures and create a topology using format resolution
  297. // If this succeeds it will render the entire topology calling yield where appropriate
  298. // and then returning when complete or an error occurs
  299. // If this returns FALSE then this the function will fail and return FALSE
  300. typedef BOOL (WINAPI *LPFNYIELDPROC) (LPVOID lpvData) ;
  301. EXPORT_DLL BOOL WINAPI RSFormatAndRender (lpRSDeviceInfo_t lpSrcInfo,
  302. lpRSDeviceInfo_t lpTgtInfo,
  303. LPJOBINFO lpJobInfo,
  304. LPFNYIELDPROC lpfnYieldProc,
  305. LPVOID lpvData) ;
  306. #define ORD_RSFormatAndRender MAKEINTRESOURCE(100) // "RSFormatAndRender"
  307. typedef BOOL (* WINAPI LPFN_RSFormatAndRender)
  308. (lpRSDeviceInfo_t, lpRSDeviceInfo_t, LPJOBINFO, LPFNYIELDPROC, LPVOID);
  309. #ifdef IFAX
  310. typedef struct RSRInfo_t {
  311. DWORD dwIndex ;
  312. lpRSDeviceInfo_t lpSrcInfo ;
  313. lpRSDeviceInfo_t lpTgtInfo ;
  314. lpTopology lpTop ;
  315. LPJOBINFO lpJobInfo ;
  316. } RSRInfo_t ;
  317. /********
  318. @doc EXTERNAL RENDERSERV
  319. @types RSReason_t | The callback function can be called for any of these reasons.
  320. @emem RSREASON_NONE | No specific reason - simply a test.
  321. @emem RSREASON_INIT | This is to initialize the structure. The callback function
  322. is responsible for setting the following fields of the Render_t structure:
  323. lpSrcInfo: The source device information structure.
  324. lpTgtInfo: The target device information structure.
  325. lpTop : The topology structure.
  326. lpJobInfo: The job information structure if required by renderers.
  327. hjc : The job context identifier.
  328. hwnd : The hwnd to have messages for pipe posted to.
  329. @emem RSREASON_START | Indicates that the rendering will begin.
  330. @emem RSREASON_DONE | Indicates that rendering is complete.
  331. @emem RSREASON_DEINIT | Indicates the job information should be freed. Anything
  332. allocated in RSREASON_INIT should be freed. This is guaranteed to be call if
  333. the callback returned TRUE from the RSREASON_INIT callback - even if an error
  334. occurs.
  335. @emem RSREASON_STATUS | If the status flag was passed in the RSRender call then
  336. this contains status information. Not defined yet!
  337. @emem RSREASON_YIELD | If the yield flag was specified then this gives the callback
  338. the opportunity to do other work - such as process the message queue.
  339. @emem RSREASON_ERROR | Indicates an error has occurred and rendering will be terminated.
  340. ********/
  341. typedef enum {
  342. RSREASON_NONE = 0,
  343. RSREASON_INIT,
  344. RSREASON_START,
  345. RSREASON_DONE,
  346. RSREASON_DEINIT,
  347. RSREASON_STATUS,
  348. RSREASON_YIELD,
  349. RSREASON_ERROR,
  350. } RSReason_t ;
  351. typedef struct Render_t FAR * LPRender_t ;
  352. typedef BOOL (WINAPI *LPFNRENDSERVPROC) (LPVOID lpvData,DWORD fdwReason,LPRender_t lpRenderData) ;
  353. #define RSR_ASYNC_MODE 0x00000001 // The call will be asyncronous
  354. #define RSR_STATUS_MODE 0x00000002 // Callback will be done for status
  355. #define RSR_YIELD_MODE 0x00000004 // In sync mode yield will be called
  356. EXPORT_DLL BOOL WINAPI RSRenderData(DWORD fdwFlags,
  357. LPFNRENDSERVPROC lpfnRSProc,
  358. LPVOID lpvData) ;
  359. typedef struct Render_t {
  360. DWORD fdwFlags ;
  361. LPFNRENDSERVPROC lpfnRSProc ;
  362. LPVOID lpvData ;
  363. DWORD dwIndex ;
  364. lpRSDeviceInfo_t lpSrcInfo ;
  365. lpRSDeviceInfo_t lpTgtInfo ;
  366. lpTopology lpTop ;
  367. LPJOBINFO lpJobInfo ;
  368. HJC hjc ;
  369. HWND hwnd ;
  370. WORD wPageNum ;
  371. WORD wkbytes ;
  372. DWORD dwError ;
  373. LPRENDSERVER lprs ;
  374. } Render_t ;
  375. //
  376. // MAPI Specific calls
  377. //
  378. typedef LPVOID LPSOSREND ;
  379. LPSOSREND WINAPI SRSAlloc () ;
  380. void WINAPI SRSFree (LPSOSREND lprs) ;
  381. BOOL WINAPI SRSInit (LPSOSREND lprs) ;
  382. BOOL WINAPI SRSOpen (LPSOSREND lprs,ENTRYIDSOS src,ENTRYIDSOS tgt,HJC hjc,HWND hwnd) ;
  383. BOOL WINAPI SRSClose (LPSOSREND lprs) ;
  384. LRESULT WINAPI SRSWndProc (LPSOSREND lprs,UINT msg,WPARAM wParam,LPARAM lParam) ;
  385. // This will open the attachment
  386. BOOL WINAPI SRSSetCurAttachNum (LPSOSREND lprs,UINT num) ;
  387. // This will automatically advance to next attachment if autoadvance is TRUE (default)
  388. // If autoadvance is true - the job is done after the last attachent otherwise it
  389. // will be set to true after the current attachment is completed.
  390. //
  391. // If SetCurAttachNum is called the done flag will be reset to FALSE
  392. BOOL WINAPI SRSRender (LPSOSREND lprs,UINT nIterations) ;
  393. LPBUFFER WINAPI SRSGetBuf (LPSOSREND lprs) ;
  394. BOOL WINAPI SRSSetPage (LPSOSREND lprs,RSOrigin_t origin,int offset) ;
  395. BOOL WINAPI SRSGetAutoAdvance (LPSOSREND lprs) ;
  396. void WINAPI SRSSetAutoAdvance (LPSOSREND lprs,BOOL badv) ;
  397. ULONG WINAPI SRSGetNumAttach (LPSOSREND lprs) ;
  398. ULONG WINAPI SRSGetCurAttachNum (LPSOSREND lprs) ;
  399. void WINAPI SRSPause (LPSOSREND lprs) ;
  400. void WINAPI SRSResume (LPSOSREND lprs) ;
  401. void WINAPI SRSAbort (LPSOSREND lprs) ;
  402. BOOL WINAPI SRSSpool (LPSOSREND lprs) ;
  403. BOOL WINAPI SRSPartSave (LPSOSREND lprs) ;
  404. BOOL WINAPI SRSIsBlocking(LPSOSREND lprs) ;
  405. BOOL WINAPI SRSIsPaused(LPSOSREND lprs) ;
  406. BOOL WINAPI SRSIsDone(LPSOSREND lprs) ;
  407. BOOL WINAPI SRSIsInit(LPSOSREND lprs) ;
  408. BOOL WINAPI SRSIsOpen(LPSOSREND lprs) ;
  409. LPRENDSERVER WINAPI SRSGetRendServer(LPSOSREND lprs) ;
  410. BOOL WINAPI RSRecoverMsg (LPMESSAGESOS lpMsg) ;
  411. UINT WINAPI RSCalculatePageCount(lpRSDeviceInfo_t lpinfo) ;
  412. #endif
  413. #ifdef __cplusplus
  414. } // extern "C"
  415. #endif
  416. #endif // _RENDSERV_H