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.

357 lines
12 KiB

  1. /********************************************\
  2. *
  3. * File : fmtres.h
  4. * Author : Kevin Gallo
  5. * Created: 9/27/93
  6. *
  7. * Copyright (c) Microsoft Corp. 1993-1994
  8. *
  9. * Overview:
  10. *
  11. * Revision History:
  12. \********************************************/
  13. #ifndef _FMTRES_H
  14. #define _FMTRES_H
  15. // System includes
  16. #include "ifaxos.h"
  17. #include "rendserv.h"
  18. #ifdef IFAX
  19. #include "awnsfapi.h"
  20. #include "awnsfint.h"
  21. #include "printer.h"
  22. #include "scanner.h"
  23. #include "sosutil.h"
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. //
  29. // Format Resolution Initializers
  30. //
  31. EXPORT_DLL BOOL WINAPI FRInitResolvers() ;
  32. EXPORT_DLL BOOL WINAPI FRFreeResolvers() ;
  33. // =================================================================
  34. //
  35. // Format Resolution Error Codes
  36. //
  37. // *******
  38. // These are returned in GetLastError only. See below for the function return values.
  39. // *******
  40. //
  41. // Format IFErrAssemble(PROCID_NONE,MODID_FMTRES,0,error code)
  42. //
  43. // The error code is a 16 bit value specific to the format resolution
  44. //
  45. // Bits 0 - 3 indicate the error type (4)
  46. // Bits 4 - 8 indicate the extended error type (specific to each error) (4)
  47. // Bits 10 - 15 are specific data or errors to each extended error (8)
  48. //
  49. // =================================================================
  50. #define FRMAKE_ERR(err) (err)
  51. // All system errors are possible return values as well
  52. #define FRERR_NONE FRMAKE_ERR(0) // No error
  53. #define FRERR_UNRESOLVED FRMAKE_ERR(1) // Unresolved - incompatible type
  54. #define FRERR_FR_FAIL FRMAKE_ERR(2) // The desired fmtres function failed (invalid params/other/etc..)
  55. #define FRERR_DEV_FAIL FRMAKE_ERR(3) // Device failed.
  56. #define FRERR_SOS_CORRUPT FRMAKE_ERR(4) // Message store was corrupt
  57. #define FRERR_FS_FAIL FRMAKE_ERR(5) // File System failure
  58. #define FRERR_SYSTEM_FAIL FRMAKE_ERR(6) // System failure (out of memory/load lib/etc...)
  59. // =================================================================
  60. // EXTENDED ERRORS:
  61. //
  62. // The extended error code is different for every error and must be determined based on the type of error
  63. //
  64. // =================================================================
  65. #define FRMAKE_EXTERR(exterr) ((exterr) << 4)
  66. // Used for all errors
  67. #define FREXTERR_NONE FRMAKE_EXTERR(0) // No extended error code
  68. // Extended errors for FRERR_UNRESOLVED
  69. // We need a NO_PROP since the INCOMP_PROP can only store 32 values and there are 32 possible bits
  70. #define FREXTERR_INCOMP_PROP FRMAKE_EXTERR(1) // At least one attachment had incompatible properties
  71. // - Data contains prop index (high 3 bits) and src value index (low 5)
  72. #define FREXTERR_NO_PROP FRMAKE_EXTERR(2) // At least one attachment had a property with no values
  73. // - Data contains prop index (high 3 bits) and src value index (low 5)
  74. #define FREXTERR_INCOMP_PROT FRMAKE_EXTERR(3) // The protocol was incompatible
  75. // - Data contains protocol vers (3 bits) of src (high) and tgt (low)
  76. // Data contains reason for encryption failure
  77. // 0 - Means machine does not support encryption at all
  78. // 1 - Means at least one attachment could not be snet encrypted (basically lin images to snowball)
  79. #define FREXTERR_NO_ENCRYPT FRMAKE_EXTERR(4) // Could not resolve because the target did not support encryption
  80. #define FREXTERR_NEED_RNDRS FRMAKE_EXTERR(5) // Renderers were needed but cannot be used with this job type
  81. // Extended errors for FRERR_SOS_CORRUPT
  82. #define FREXTERR_OPEN_FAIL FRMAKE_EXTERR(1) // Could not open an attachment or message
  83. #define FREXTERR_GETPROP_FAIL FRMAKE_EXTERR(2) // There was a property missing
  84. #define FREXTERR_BAD_VALUE FRMAKE_EXTERR(3) // Property had an invalid value
  85. #define FREXTERR_SAVE_FAIL FRMAKE_EXTERR(4) // Could not save changes
  86. #define FREXTERR_SETPROP_FAIL FRMAKE_EXTERR(5) // Could not set a property value
  87. #define FREXTERR_BAD_MSG FRMAKE_EXTERR(6) // The message was not properly formed
  88. // Extended errors for FRERR_DEV_FAIL and
  89. // Extended errors for FRERR_SYSTEM_FAIL
  90. #define FREXTERR_NOT_ENOUGH_MEM FRMAKE_EXTERR(1) // Out of memory
  91. #define FREXTERR_LOAD_LIBRARY FRMAKE_EXTERR(2) // Load Library failed
  92. #define FREXTERR_GETPROCADDRESS FRMAKE_EXTERR(3) // Get Proc Address failed
  93. // Extended errors for FRERR_FR_FAIL
  94. #define FREXTERR_INVALID_PARAM FRMAKE_EXTERR(1) // Invalid Parameter
  95. #define FREXTERR_INVALID_STEP FRMAKE_EXTERR(2) // Invalid step (e.g. open called before init)
  96. // =================================================================
  97. // ERROR DATA
  98. //
  99. // The error data is different for every error/extended error pair
  100. //
  101. // =================================================================
  102. #define FRMAKE_ERRDATA(exterr) ((exterr) << 8)
  103. #define FRGET_ERRDATA(exterr) (((WORD)(exterr)) >> 8)
  104. //
  105. // These are the property indexes for FREXTERR_INCOMP_PROP extended error
  106. //
  107. #define FR_PROP_UNKNOWN (0)
  108. #define FR_PROP_ENCODING (1)
  109. #define FR_PROP_RESOLUTION (2)
  110. #define FR_PROP_PAGESIZE (3)
  111. #define FR_PROP_BRAND (4)
  112. #define FR_PROP_LENLIMIT (5)
  113. #define FRFormCustomError(err,exterr,data) ((WORD) (((err) | (exterr)) | FRMAKE_ERRDATA(data)))
  114. #define FRFormIFError(err,exterr,data) \
  115. (IFErrAssemble(PROCID_NONE,MODID_FORMAT_RES,0,FRFormCustomError((err),(exterr),(data))))
  116. #define FRGetError(err) (((WORD)(err)) & 0x000f)
  117. #define FRGetExtError(err) (((WORD)(err)) & 0x00f0)
  118. #define FRGetErrorCode(err) (((WORD)(err)) & 0x00ff)
  119. #define FRGetErrorData(err) FRGET_ERRDATA(err)
  120. #define FRSetErrorData(dwerr,data) (((dwerr) & 0xffff00ff) | FRMAKE_ERRDATA(data))
  121. #ifdef IFAX
  122. //
  123. // Format resolution flags
  124. //
  125. // These flags are passed in to the Resolve and CanResolve calls to indicate the target device
  126. //
  127. typedef enum {
  128. FRES_NORMAL = 0, // Use the default destination
  129. FRES_SPOOL = 1, // Spool to file
  130. FRES_VIEW = 2, // Use viewer output format
  131. FRES_PRINT = 3, // Send to printer
  132. FRES_XMIT = 4, // Send to transport
  133. FRES_PRINTALL = 5, // Send to printer (all attachments)
  134. FRES_LOCAL_SEND = 6, // Send to local user
  135. } FRDEST ;
  136. // Function return Codes
  137. //
  138. // These are the codes returned from format resolution Resolve and CanResolve
  139. //
  140. // If the return value is anything but FR_RESOLVED then GetLastError will contain the extended error information
  141. // - values for GetLastError are above
  142. //
  143. #define FR_UNRESOLVED 0x0000
  144. #define FR_RESOLVED 0x0001
  145. #define FR_COMPATIBLE 0x0002
  146. #define FR_UPDATE 0x0004
  147. #define FR_NON_RT 0x0008 // Non real-time (too slow or uses foreground resources)
  148. #define FR_SOS_ERR 0x4000
  149. #define FR_SYSTEM_ERR 0x8000
  150. #define CHK_FR_ERR(n) ((n & (FR_SOS_ERR | FR_SYSTEM_ERR)) != 0)
  151. //
  152. // Some typedefs
  153. //
  154. typedef BC REMCAPS ;
  155. typedef LPBC LPREMCAPS ;
  156. //
  157. // Context based calls
  158. // These are used for better division of work. Some can be done beforehand.
  159. //
  160. typedef LPVOID LPFORMATRES ;
  161. LPFORMATRES WINAPI FRAlloc() ;
  162. void WINAPI FRFree(LPFORMATRES lpfr) ;
  163. BOOL WINAPI FRInit(LPFORMATRES lpfr,HSOSCLIENT hsc,LPSOSMSG lpSrcMsg,LPSOSMSG lpTgtMsg) ;
  164. void WINAPI FRDeInit(LPFORMATRES lpfr) ;
  165. BOOL WINAPI FROpen(LPFORMATRES lpfr,
  166. FRDEST Dest,
  167. lpRSProcessPipeInfo_t lpProcInfo,
  168. LPREMCAPS lpRemCaps) ;
  169. void WINAPI FRClose(LPFORMATRES lpfr) ;
  170. BOOL WINAPI FRResolve(LPFORMATRES lpfr) ;
  171. BOOL WINAPI FRCanResolve(LPFORMATRES lpfr) ;
  172. //
  173. // These will perform the operation completely
  174. //
  175. UINT WINAPI FRResolveMsg (HSOSCLIENT hsc,
  176. LPSOSMSG lpSrcMsg,
  177. LPSOSMSG lpTgtMsg,
  178. FRDEST Dest,
  179. lpRSProcessPipeInfo_t lpProcInfo) ;
  180. UINT WINAPI FRCanResolveMsg (HSOSCLIENT hsc,
  181. LPSOSMSG lpSrcMsg,
  182. LPSOSMSG lpTgtMsg,
  183. FRDEST Dest,
  184. lpRSProcessPipeInfo_t lpProcInfo) ;
  185. UINT WINAPI FRCompareRemCaps (HSOSCLIENT hsc,
  186. LPSOSMSG lpSrcMsg,
  187. LPSOSMSG lpTgtMsg,
  188. LPREMCAPS lpRemCaps) ;
  189. UINT WINAPI FRResolveRemote (HSOSCLIENT hsc,
  190. LPSOSMSG lpSrcMsg,
  191. LPSOSMSG lpTgtMsg,
  192. FRDEST Dest,
  193. lpRSProcessPipeInfo_t lpProcInfo,
  194. LPREMCAPS lpRemCaps) ;
  195. #endif
  196. // The target message needs to allocated and open
  197. EXPORT_DLL BOOL WINAPI FRResolveEncoding (lpEncoding_t lpSrcEnc,
  198. lpEncoding_t lpTgtEnc,
  199. lpTopology FAR * lplpTop) ;
  200. #ifdef WIN32
  201. EXPORT_DLL BOOL WINAPI FRAddNode (lpTopology FAR * lpTop, LPSTR lpszName, LPSTR RenderProc, LPVOID lpParam , UINT cbParam) ;
  202. EXPORT_DLL BOOL WINAPI FRAddTopNode (lpTopology FAR * lpTop, lpTopNode lpNode) ;
  203. #endif
  204. EXPORT_DLL void WINAPI FRFreeTopology (lpTopology lpTop) ;
  205. //
  206. // Page size and resolution APIs
  207. //
  208. /***********************************************************************
  209. @doc PRINTER EXTERNAL
  210. @types PAPERFORMAT|Structure to hold the Paper Format Information.
  211. @field USHORT|usPaperType|The Size of the Paper.
  212. @field USHORT|usPaperWidth|The width of the Paper in mm.
  213. @field USHORT|usPaperHeight|The height of the Paper in mm.
  214. @field USHORT|usXImage|The number of pixels in x direction that will be
  215. created in an image for this page size at the resolution specified by
  216. the field usResInHorz by the printer driver.
  217. @field USHORT|usYImage|The number of scanlines that will be renderd for this
  218. page size at the resolution specified in usResInVert by the printer
  219. driver.
  220. @field USHORT|usResInHorz|The resolution in dpi (rounded to the closest
  221. hundredth) in the x direction.
  222. @field USHORT|usResInVert|The resolution in dpi (rounded to the closest
  223. hundredth) in the y direction.
  224. @field USHORT|usResInVert|The resolution in dpi (rounded to the closest
  225. hundredth) in the y direction.
  226. @field USHORT|usAspectXY|The AspectXY for a given resolution. The is equal
  227. to the square root of the sum of squares of the resolution(in dpi)
  228. in x and y directions.
  229. *************************************************************************/
  230. typedef struct _PAPERFORMAT{
  231. USHORT usPaperType; // the equivalent windows paper size
  232. USHORT usPaperWidth; //in mm
  233. USHORT usPaperHeight; //in mm
  234. USHORT usXImage; //in pixels
  235. USHORT usYImage; //in pixels
  236. USHORT usResInHorz; //the resolution in dpi in x dir
  237. USHORT usResInVert; //the resolution in dpi in y dir
  238. USHORT usAspectXY; //for the gdi info
  239. } PAPERFORMAT, * PPAPERFORMAT;
  240. typedef PAPERFORMAT FAR * LPPAPERFORMAT;
  241. typedef PAPERFORMAT NEAR * NPPAPERFORMAT;
  242. EXPORT_DLL USHORT WINAPI GetStdBytesPerLine(ULONG ulResolution,ULONG ulPaperSize);
  243. EXPORT_DLL DWORD WINAPI GetStdPixelsPerLine(ULONG ulResolution,ULONG ulPaperSize);
  244. EXPORT_DLL DWORD WINAPI GetStdLinesPerPage(ULONG ulResolution,ULONG ulPaperSize);
  245. EXPORT_DLL USHORT WINAPI GetXResolution(ULONG ulResolution);
  246. EXPORT_DLL USHORT WINAPI GetYResolution(ULONG ulResolution);
  247. EXPORT_DLL BOOL WINAPI GetPaperFormatInfo(LPPAPERFORMAT lpPf,ULONG ulAwPaperSize,USHORT usXRes,USHORT usYRes);
  248. EXPORT_DLL WORD WINAPI AWPaperToFaxWidth(ULONG ulPaperSize);
  249. EXPORT_DLL ULONG WINAPI FaxWidthToAWPaper(WORD Width);
  250. EXPORT_DLL WORD WINAPI AWPaperToFaxLength(ULONG ulPaperSize);
  251. #ifdef IFAX
  252. // Given an encoding and an association returns either the same encoding or a new one
  253. BOOL WINAPI FRGetAssocEncoding (lpEncoding_t lpEnc,LPSTR lpExt) ;
  254. // This will return the paper sizes supported with the given input paper and zoom options
  255. // This will return at ulPaperSize if ulZoomOption is 0
  256. ULONG WINAPI GetZoomCaps(ULONG ulPaperSize,ULONG ulZoomOption) ;
  257. // This will give the zoom value to use to get ZoomPaperSize from OrigPaperSize
  258. // Returns 0 if not possible
  259. ULONG WINAPI GetZoomValue(ULONG ulOrigPaperSize,ULONG ulZoomPaperSize) ;
  260. //
  261. // Debug functions - stubbed out in retail
  262. //
  263. // Returns TRUE if the fmtres version is debug, FALSE if retail (basically whether this does anything)
  264. // The parameters are bit arrays, not enumerated values
  265. // -1 will disable a filter
  266. BOOL WINAPI FRSetDestCapFilter(DWORD dwEnc,DWORD dwRes,DWORD dwPageSize,DWORD dwLenLimit) ;
  267. BOOL WINAPI FRGetDestCapFilter(LPDWORD dwEnc,LPDWORD dwRes,LPDWORD dwPageSize,LPDWORD dwLenLimit) ;
  268. #endif
  269. #ifdef __cplusplus
  270. } // extern "C"
  271. #endif
  272. #endif // _FMTRES_H