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.

417 lines
16 KiB

  1. #ifndef _LHPROT_H
  2. #define _LHPROT_H
  3. #pragma message("Including: " __FILE__)
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <buffers.h>
  8. // Function prototypes encode/decode of linearized headers: These API's are exported by LHUtil
  9. //------------------------ Prototype Definitions -------------------------
  10. /***************************************************************************
  11. @doc EXTERNAL LINEARIZER SRVRDLL
  12. @topic Linearized Header Helper Functions |
  13. These functions are used by the LMI Provider to get or modify fields
  14. in the header portion of the Linearized Data File:
  15. <t DiscardLinHeader>, <t CreateSimpleHeader>, <t DecodeLinHeader>
  16. They typically use callback functions to read and write the actual
  17. data from the file:
  18. <t Linearizer Data CallBack>,
  19. <t Linearizer Seek CallBack>
  20. @xref <t LINHEADER>, <t Extended Linearized Header>
  21. @end
  22. ***************************************************************************/
  23. /********
  24. @doc EXTERNAL LINEARIZER SRVRDLL
  25. @type NONE | GETPUTMODE | Mode of operation for the Linearizer
  26. Seek Callback and Linearizer Data Callback functions.
  27. @emem GPM_GETBUF |
  28. @emem GPM_PUTBUF |
  29. @emem GPM_PUTDATA |
  30. @emem GPM_GETDATA |
  31. @emem GPM_OPENPIPEREAD |
  32. @emem GPM_OPENPIPEWRITE |
  33. @emem GPM_CLOSEPIPEREAD |
  34. @emem GPM_CLOSEPIPEWRITE |
  35. @emem GPM_GETEOF |
  36. @comm LHUtil should only use GPM_GETDATA and GPM_PUTDATA enumerations.
  37. @end
  38. ********/
  39. // gpm = mode of callback
  40. // GPM_PUTDATA
  41. // GPM_GETDATA
  42. // GPM_OPENPIPEREAD
  43. // GPM_OPENPIPEWRITE
  44. // GPM_CLOSEPIPEREAD
  45. // GPM_CLOSEPIPEWRITE
  46. // dwDataContext = File Handle cast to DWORD for GETDATA and PUTDATA
  47. // Property Tag for OPENPIPE
  48. // Stream Pointer for CLOSEPIPE
  49. // lpb = buffer pointer for GETDATA and PUTDATA
  50. // uLen = Length of Read/Write for GETDATA and PUTDATA
  51. // Object Type for OPENPIPE
  52. // OT_ATTACH
  53. // OT_MESSAGE
  54. // etc.
  55. // lpObject = MAPI Object to open stream on OPENPIPE
  56. //
  57. // Returns value: GETDATA, PUTDATA: Bytes/read/written. 0 for failure.
  58. // OPENPIPE: lpIStream to read/write from, 0 on failure.
  59. // CLOSEPIPE: 0 on failure, non-zero on success
  60. // Callback to get & put data from PSI or open/close pipe handles
  61. // Mode can be one of
  62. typedef enum
  63. {
  64. GPM_GETBUF,
  65. GPM_PUTBUF,
  66. GPM_PUTDATA,
  67. GPM_GETDATA,
  68. GPM_OPENPIPEREAD,
  69. GPM_OPENPIPEWRITE,
  70. GPM_CLOSEPIPEREAD,
  71. GPM_CLOSEPIPEWRITE,
  72. GPM_GETEOF,
  73. }
  74. GETPUTMODE;
  75. // Call back to open a stream on a mapi object needs to know what kind of object
  76. // it is.
  77. typedef enum
  78. {
  79. OT_ATTACH, // Object is an lpAttach
  80. OT_MESSAGE // Object is an lpMessage
  81. }
  82. OBJECT_TYPE;
  83. // Same params as _llseek
  84. /********
  85. @doc EXTERNAL LINEARIZER SRVRDLL
  86. @cb LONG | Linearizer Seek CallBack | Callback function for seeking in the
  87. data stream.
  88. @parm HFILE | hFile | file handle
  89. @parm LONG | lOffset | offset to seek
  90. @parm INT | nOrigin | 0 moves the file pointer lOffset bytes from the beginning of the file.
  91. 1 moves the file pointer lOffset bytes from the current position.
  92. 2 moves the file pointer lOffset bytes from the end of the file.
  93. @rdesc Returns HFILE_ERROR (-1) on error, othersize, returns the new file pointer position.
  94. @comm This function should be implemented by the caller of <t Linearized Header Helper Functions>.
  95. @xref <t Linearized Header Helper Functions>, <t Extended Linearized Header>
  96. @end
  97. ********/
  98. #ifndef DOS16
  99. typedef LONG (WINAPI *LPSEEKCB) (HFILE hf, LONG offset, INT nOrigin);
  100. #else
  101. typedef LONG (*LPSEEKCB) (HFILE hf, LONG offset, INT nOrigin); //DOS - is cdecl function
  102. #endif
  103. /********
  104. @doc EXTERNAL LINEARIZER SRVRDLL
  105. @cb LONG | Linearizer Data CallBack | Callback function for reading/writing in the
  106. data stream.
  107. @parm GETPUTMODE | gpm | Desired action from callback.
  108. @parm DWORD | dwDataContext | handle of file/stream.
  109. @parm LPBYTE | lpb | buffer for read/write data
  110. @parm UINT | uLen | size of buffer
  111. @parm LPBUFFER | lpbfDontUse | reserved buffer parameter.
  112. @rdesc Returns DWORD specific to the action.
  113. @comm This function should be implemented by the caller of <t Linearized Header Helper Functions>.
  114. @xref <t DiscardLinHeader>, <t DecodeLinHeader>, <t CreateSimpleHeader>, <t Linearized Header Helper Functions>,
  115. @end
  116. ********/
  117. typedef DWORD (WINAPI * LPDATACB)
  118. (GETPUTMODE gpm, DWORD dwDataContext, LPBYTE lpb, UINT uLen, LPVOID lpReserved);
  119. // Callback to read/write data from a pipe
  120. // dwHandle: LOWORD is the pipe handle
  121. // lpBuf is an LPBUFFER if we are writing, NULL if we are reading
  122. // Return value on read is LPBUFFER for success. 0 for failure.
  123. // on write is 0 for failure, non-zero for success
  124. // END_OF_JOB buffer terminates data stream.
  125. typedef LPBUFFER (WINAPI * LPSTREAMDATACB)(DWORD dwHandle, DWORD cbData, LPBUFFER lpbf);
  126. /*******
  127. @doc EXTERNAL LINEARIZER SRVRDLL
  128. @types LINHEADER | Linearizer Header structure
  129. @field WORD | uHeaderSize | Size of this header in bytes.
  130. @field WORD | uTotalSize | Total size occupied by this header.
  131. @field WORD | uMsgType | Can be any of the following.
  132. @flag LINMSG_SEND | Normal send message. Message must contain
  133. sender information & at least one recipient.
  134. @flag LINMSG_POLLREQ_ADDRESS | Polls for a document for a particular
  135. address. Extended header must contain sender information, the
  136. address for which messages are desired (as the pollname), and
  137. the password decided upon.
  138. @flag LINMSG_POLLREQ_FILE | Polls for a directory or file on the
  139. recipient system. The extended header must contain sender
  140. information, the file system path to be accessed (as the
  141. pollname), and the password decided upon.
  142. @flag LINMSG_POLLREQ_MSGNAME | Polls for a particular message name.
  143. The extended header must contain sender information, the
  144. message name wanted (as the pollname), and the password decided
  145. upon.
  146. @flag LINMSG_POLLREQ_G3 | Standard G3 compliant poll request. Polls for
  147. any file which has been stored at the recipient machine. Neither
  148. pollname nor password are required.
  149. @flag LINMSG_RELAYREQ | This is a request to send a relay message. If
  150. password validation is required the extended header may contain
  151. a password.
  152. @field WORD | uFlags | Can be a combination of any of the following:
  153. @flag LIN_ENCRYPTED | Indicates that the message data is encrypted. If no
  154. other specific encryption bits are set, baseline password encryption is
  155. assumed.
  156. @flag LIN_PUBKEY_ENCRYPTED | Indicates that public key encryption was used.
  157. @flag LIN_IMAGE_ONLY | Indicates that the message data contains rendered images
  158. only. Correct setting of this flag is not mandatory.
  159. @flag LIN_RAWDATA_ONLY | Indicates that the message data portion consists of
  160. raw unframed data. If this flag is set, the extended header must contain
  161. the description for this data. This Flag is *never* set for data on the
  162. wire. It is only meant to allow more efficient exchange of data between
  163. the client and the LMI provider. For example, the client might generate
  164. an MH encoded file and put it into a linearized format using this flag. The
  165. LMI provider would then interpret the header and send the raw data along
  166. the wire. Not currently used.
  167. @flag LIN_NULL_BODY | Introduced in version 2. Indicates that there is no
  168. body, or that the body contains no useful information (for example, it
  169. may be all white space with no important formatting information).
  170. In other words, the recipient is free to discard the body. If this
  171. flag is not set, the message data MUST contain a valid body.
  172. @flag LIN_MASK_COMPRESS | Introduced in version 2. Mask that extracts
  173. compression level. Currently must be set to 0 or 1.
  174. @field WORD | uNumRecipients | Tells the number of recipients this message
  175. is intended for. Also indicates the size of the <e LINHEADER.rguRecipTypes[]>
  176. array.
  177. @field WORD | rguRecipTypes[] | An array of size <e LINHEADER.uNumRecipients>
  178. each element of which indicates what kind of operations the recieving system
  179. needs to perform for this recipient. The sending machine needs to update these
  180. types before sending an instance of this message to any recipient (see the
  181. example below). All other detailed information about the recipients are
  182. in the extended header. The different types are:
  183. @flag RECIP_DISPLAY |
  184. This instance of the message is not intended for this recipient. Information
  185. is provided for display purposes only.
  186. @flag RECIP_LOCAL |
  187. The recipient is local to the receiving machine.
  188. @flag RECIP_RELAY |
  189. The recipient has to be reached via a series of relay points. The
  190. uHopIndex field in the extended header points to the current hop if
  191. the receiver is a relay point. The uHopIndex field forms a linked
  192. list of all the remaining hops.
  193. @flag RECIP_RELAYPOINT |
  194. This is a relay point for one of the relay recipients. The message
  195. password and params specify the relay password and options if any.
  196. NextHopIndex specifies the next relay point if any in this route.
  197. @comm This header needs to be created by the caller and passed in to the linearizer. It
  198. then needs to be specialized (that is, the recipient types need to be correctly set)
  199. before starting the actual transmission.
  200. @ex Specializing a Linearized Header |
  201. Suppose a message has two recipients A & B, each at different machines (phone numbers).
  202. When sending to the recipient A, the recipient types should be marked as :
  203. Recipient A: RECIP_LOCAL
  204. Recipient B: RECIP_DISPLAY
  205. When sending to the recipient B, the recipient types should be marked as :
  206. Recipient A: RECIP_DISPLAY
  207. Recipient B: RECIP_LOCAL
  208. @xref <t Extended Linearized Header>, <t Microsoft At Work Linearized File Format>
  209. *******/
  210. #pragma warning (disable: 4200)
  211. // Linearized file header
  212. typedef struct _LINHEADER {
  213. WORD uHeaderSize;
  214. WORD uTotalSize;
  215. WORD uMsgType;
  216. WORD uFlags;
  217. WORD uNumRecipients;
  218. WORD rguRecipTypes[];
  219. } LINHEADER, FAR * LPLINHEADER, NEAR * NPLINHEADER;
  220. #pragma warning (default:4200)
  221. // Possible message types (uMsgType)
  222. #define LINMSG_SEND 1
  223. #define LINMSG_POLLREQ_ADDRESS 2
  224. #define LINMSG_POLLREQ_FILE 3
  225. #define LINMSG_POLLREQ_MSGNAME 4
  226. #define LINMSG_POLLREQ_G3 5
  227. #define LINMSG_RELAYREQ 6
  228. // Message type flags (uFlags). All undefined bits are reserved
  229. #define LIN_ENCRYPTED 0x0001
  230. #define LIN_PUBKEY_ENCRYPTED 0x0002
  231. #define LIN_IMAGE_ONLY 0x0004
  232. #define LIN_RAWDATA_ONLY 0x0008
  233. // New flags in version 2
  234. #define LIN_NULL_BODY 0x0010
  235. #define LIN_MASK_COMPRESS 0x00E0
  236. #define LIN_SHIFT_COMPRESS 5
  237. // Possible Recipient Types (rguRecipTypes)
  238. #define RECIP_DISPLAY 1
  239. #define RECIP_LOCAL 2
  240. #define RECIP_RELAY 3
  241. #define RECIP_RELAYPOINT 4
  242. /********
  243. @doc EXTERNAL LINEARIZER SRVRDLL
  244. @api BOOL | DiscardLinHeader | Seeks past the linearized header.
  245. @parm HFILE | hFile | File handle of linearized data.
  246. @parm LPDATACB | lpfnReadCB | <t Linearizer Data CallBack>
  247. @parm LPSEEKCB | lpfnSeekCB | <t Linearizer Seek CallBack>
  248. @parm BOOL | fVerify | TRUE to verify integrity of linheader
  249. @parm LPUINT | lpvCompress | Return compression version here. Ignored if NULL.
  250. @rdesc TRUE on success.
  251. @comm This function seeks past the linearized headers of a linearized file.
  252. @xref <t Linearized Header Helper Functions>
  253. @end
  254. ********/
  255. BOOL WINAPI DiscardLinHeader(HFILE hf, LPDATACB lpfnReadCB,
  256. LPSEEKCB lpfnSeekCB, BOOL fVerify, LPUINT lpvCompress);
  257. /********
  258. @doc EXTERNAL LINEARIZER SRVRDLL
  259. @api BOOL | CreateSimpleHeader | Creates a simple linearized header.
  260. @parm HFILE | hFile | File handle to write to.
  261. @parm LPSTR | lpszFromAdd | Email address of sender
  262. @parm LPSTR | lpszFromName | Display name of sender
  263. @parm LPSTR | lpszToAddress | Address of recipient
  264. @parm LPSTR | lpszToName | Display name of recipient
  265. @parm LPSTR | lpszSubject | Message subject
  266. @parm LPDATACB | lpfnReadCB | <t Linearizer Data CallBack>
  267. @parm BOOL | fHash | Must be set to TRUE
  268. @rdesc TRUE on success.
  269. @comm This function creates a simple linearized header including one
  270. recipient. This is typically used to create a linearized header
  271. for received G3 faxes.
  272. @xref <t Linearized Header Helper Functions>
  273. @end
  274. ********/
  275. BOOL WINAPI CreateSimpleHeader(HFILE hf, LPSTR lpszFromAdd, LPSTR lpszFromName,
  276. LPSTR lpszToAddress, LPSTR lpszToName, LPSTR lpszSubject, LPDATACB lpfnWriteCB,
  277. BOOL fHash);
  278. /********
  279. @doc EXTERNAL LINEARIZER SRVRDLL
  280. @api BOOL | DecodeLinHeader | Decodes a linearized header.
  281. @parm HFILE | hFile | File handle of linearized data.
  282. @parm LPDATACB | lpfnReadCB | <t Linearizer Data CallBack>
  283. @parm LPSEEKCB | lpfnSeekCB | <t Linearizer Seek CallBack>
  284. @parm LPLINHEADER | lplh | Linearized header
  285. @parm DWORD | dwAddBufLen | size of lpszFromAddress buffer
  286. @parm LPSTR | lpszFromAddress | return sender's address here
  287. @parm DWORD | dwNameBufLen | size of lpszFromName buffer
  288. @parm LPSTR | lpszFromName | return sender's display name here
  289. @parm DWORD | dwSubBufLen | size of lpszSubject
  290. @parm LPSTR | lpszSubject | return message subject here
  291. @parm BOOL | fVerify | TRUE to verify integrity of linheader
  292. @rdesc TRUE on success.
  293. @comm This function decodes the linearized header into it's subject,
  294. sender name and sender email address.
  295. @xref <t Linearized Header Helper Functions>
  296. @end
  297. ********/
  298. BOOL WINAPI DecodeLinHeader(HFILE hf, LPDATACB lpfnReadCB, LPSEEKCB lpfnSeekCB,
  299. LPLINHEADER lplh, DWORD dwAddBufLen, LPSTR lpszFromAddress,
  300. DWORD dwNameBufLen, LPSTR lpszFromName, DWORD dwSubBufLen,
  301. LPSTR lpszSubject, BOOL fVerify);
  302. /********
  303. @doc EXTERNAL LINEARIZER SRVRDLL
  304. @api BOOL | LHSetCompress | This function sets the compression level
  305. of an existing linearized file.
  306. @parm HFILE | hFile | File handle of linearized data.
  307. @parm LPDATACB | lpfnReadCB | <t Linearizer Data CallBack> or NULL to use _lread.
  308. @parm LPDATACB | lpfnWriteCB | <t Linearizer Data CallBack> or NULL to use _lwrite.
  309. @parm LPSEEKCB | lpfnSeekCB | <t Linearizer Seek CallBack> or NULL to use _llseek.
  310. @parm UINT | vCompress | Compression level (Currently 0 and 1 are supported.)
  311. @rdesc TRUE on success.
  312. @comm This function doesn't effect actual data compression, only the header value.
  313. @xref <t Linearized Header Helper Functions>
  314. @end
  315. ********/
  316. // Sets compression level of linearized file.
  317. BOOL WINAPI LHSetCompress
  318. (
  319. HFILE hf, // read/write handle
  320. LPDATACB lpfnReadCB, // NULL for _lread
  321. LPDATACB lpfnWriteCB, // NULL for _lwrite
  322. LPSEEKCB lpfnSeekCB, // NULL for _llseek
  323. UINT vCompress // compression level
  324. );
  325. // This takes ptrs to space to hold the decoded strings. Pass in NULL if
  326. // you are not interested. Passing in all NULL's makes this function
  327. // equivalent to DiscardLinHeader(slightly more inefficient though).
  328. // The maximum buffer size required for any of the strings in 512 bytes.
  329. // For 99.99% of the cases, the recommended max sizes below shouldbe
  330. // good enough
  331. #define MAX_SUBJECT_LENGTH 255
  332. #ifndef MAX_ADDRESS_LENGTH
  333. #define MAX_ADDRESS_LENGTH 128
  334. #endif
  335. #ifdef __cplusplus
  336. } // extern "C" {
  337. #endif
  338. #endif // _LHPROT_H