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.

453 lines
18 KiB

  1. #ifndef _LIN_H
  2. #define _LIN_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*
  7. * For File Linearizer, define NO_MAPI, undefine MAPI1
  8. */
  9. #ifndef NO_MAPI
  10. #if defined(MAPI1) && !defined(MAPIDEFS_H)
  11. // MAPI include files
  12. #include <mapiwin.h>
  13. #include <mapidbg.h>
  14. #undef HTASK
  15. #include <ole2.h>
  16. #include <mapidefs.h>
  17. #include <mapicode.h>
  18. #include <mapitags.h>
  19. #include <mapiguid.h>
  20. #include <mapispi.h>
  21. #include <imessage.h>
  22. #include <mapix.h>
  23. #include <mapiutil.h>
  24. #include <tnef.h>
  25. #endif
  26. #endif
  27. #include <lhprot.h>
  28. #pragma message("Including: " __FILE__)
  29. #ifdef WIN32
  30. #define _loadds
  31. #endif
  32. /***************************************************************************
  33. Name : linearizer.h
  34. Comment : Contains all linearizer access API declarations
  35. Functions : (see Prototypes just below)
  36. ***************************************************************************/
  37. // version number of the linearized format. This must be from 1 to 7 max.
  38. // Must be 1 fro Snowball-compatible version of linearizer. Increment this
  39. // count when the linearized format changes so that msgs encoded in the
  40. // new format can no longer be decoded by older versions of the linearizer.
  41. // (even though the newer linearizers can still decode msg encoded with older
  42. // ones). Used in NSF
  43. /***************************************************************************
  44. @doc EXTERNAL LINEARIZER SRVRDLL
  45. @topic Microsoft At Work Linearized File Format |
  46. This section describes the format of a Microsoft At Work
  47. linearized file. This is the standard format used for
  48. transmitting any Microsoft At Work rendered image,
  49. or any binary file using an Microsoft At Work LMI provider.
  50. A linearized message consists of three parts. The first part is
  51. a header defined by the <t LINHEADER> structure. This is a simple
  52. C structure which can be read & manipulated at offset 0 of the file.
  53. The second part contains extended header information. This includes
  54. items like the message subject, recipient address information,
  55. sender address information, poll names and so on. Because the size
  56. of this portion can vary (depending on the number of recipients &
  57. size of the strings), it is encoded using ASN1. The format for this
  58. part is explained in <t Extended Linearized Header>. To make it
  59. easier to understand and construct this part, helper functions are
  60. provided to manipulate items in this part.
  61. The third part contains the message data. For binary files this
  62. would contain all the attached files along with their descriptions.
  63. For rendered messages, this contains the rendered images for all
  64. the pages. This part may be encrypted if the user chose to send
  65. his message secured. LMI providers do not need to interpret or create
  66. this portion of the message.
  67. @xref <t LINHEADER>, <t Extended Linearized Header>
  68. ***************************************************************************/
  69. #define LINHEADER_OFFSET 0
  70. // Errors
  71. #define ERR_NOMEMORY 0x0001
  72. #define ERR_SEC_NOMATCH 0x8000
  73. #define ERR_FILE_ERROR 0x0040
  74. #define ERR_MAPI_ERROR 0x0008
  75. #define ERR_GENERAL_FAILURE 0x0080
  76. #define NO_ENCRYPT 0
  77. #define KEY_ENCRYPT 1
  78. #define PASSWORD_ENCRYPT 2
  79. /********
  80. @doc EXTERNAL LINEARIZER SRVRDLL
  81. @type NONE | Extended Linearized Header |
  82. @comm This describes the format of the extended header part
  83. of any Microsoft At Work linearized message. This header
  84. is encoded using the CCITT standard ASN.1 encoding. This
  85. means that all fields are tagged with a type and a length
  86. followed by the value.
  87. @comm These are a number of fields which can be part of the header.
  88. Unless mentioned explicitly, all fields are optional.
  89. @flag HDRTAG_SUBJECT | An ASCII string containing the subject of the
  90. message. Used by the cover page renderer.
  91. @flag HDRTAG_POLLNAME | An ASCII string containing the name of the
  92. object being polled for if the message type is LINMSG_POLLREQ_ADDRESS,
  93. LINMSG_POLLREQ_FILE or LINMSG_POLLREQ_MSGNAME.
  94. @flag HDRTAG_PASSWORD | A password string to be associated with the
  95. message. This would typically be valid for poll requests or relay
  96. request messages.
  97. @flag HDRTAG_FROM | A <t Linearized Header Recipient> structure giving
  98. details about the originator of the message.
  99. @flag HDRTAG_TO | An array of <t Linearized Header Recipient> structures giving
  100. details for all recipients on the TO list of the message.
  101. @flag HDRTAG_CC | An array of <t Linearized Header Recipient> structures giving
  102. details for all recipients on the CC list of the message.
  103. @flag HDRTAG_BCC | An array of <t Linearized Header Recipient> structures giving
  104. details for all recipients on the BCC list of the message.
  105. @flag HDRTAG_RAWATTACH | If the LIN_RAWDATA_ONLY flag is set in the <e LINHEADER.uFlags>
  106. field of the header, then this field contains a <t Linearized Header Raw Data>
  107. structure describing this data.
  108. @comm In general, Microsoft At Work enabled servers do not have to deal
  109. with this portion of the header. The Microsoft At Work client will
  110. create and decipher this. Some LMI providers might need to interpret
  111. it to add more value, like responding to poll requests without
  112. involving the client or automatically printing out received image faxes.
  113. To make it easier for these people to use, a library of routines to build and
  114. decipher these will be provided. Please see <t Linearized Header Helper Functions>.
  115. @xref <t LINHEADER>, <t Microsoft At Work Linearized File Format>,
  116. <t Linearized Header Recipient>, <t Linearized Header Raw Data>, <t Linearized Header Helper Functions>
  117. ********/
  118. /********
  119. @doc EXTERNAL LINEARIZER SRVRDLL
  120. @type NONE | Linearized Header Recipient |
  121. @comm This describes the format for each recipient information structure in
  122. the extended linearized header. The structure is itself ASN.1 encoded,
  123. and just like the header, is composed of several fields. Unless
  124. otherwise indicated fields are optional. A lot of the fields are used
  125. for digital cover pages.
  126. @flag RECIPTAG_VOICEPHONE | String containing the voice phone number for the
  127. recipient if any.
  128. @flag RECIPTAG_LOCATION1 | String containing the first line of the recipients
  129. physical routing address (for exampe, Company Name).
  130. @flag RECIPTAG_LOCATION2 | String containing the second line of the recipients
  131. physical routing address (for example, Microsoft Way).
  132. @flag RECIPTAG_LOCATION3 | String containing the third line of the recipients
  133. physical routing address (for example, Redmond WA 98052).
  134. @flag RECIPTAG_FRIENDLYNAME | String containing the friendly name for the
  135. recipient (as you want displayed on the cover page).
  136. @flag RECIPTAG_ADDRESS | String containing the Microsoft At Work address for
  137. the recipient (eg. BillG@+1-206-8828080)
  138. @flag RECIPTAG_ALTADDRESS | Alternate Microsoft At Work address for the recipient.
  139. @flag RECIPTAG_PASSWORD | If the recipient is of type RECIP_RELAYPOINT this
  140. contains a password to validate use of this station as a relay point.
  141. @flag RECIPTAG_PARAMS | If the recipient is of type RECIP_RELAYPOINT this
  142. contains any parameters for this point (for example, send at cheap times).
  143. @flag RECIPTAG_NEXTHOPINDEX | Used if the recipient is of type RECIP_RELAY.
  144. It indicates the index of the next hop for this relay message. This
  145. field essentially creates a linked list of recipient relay points
  146. for routing of the message.
  147. @xref <t Extended Linearized Header>
  148. ********/
  149. /********
  150. @doc EXTERNAL LINEARIZER SRVRDLL
  151. @type NONE | Linearized Header Raw Data |
  152. @comm The structure for a describing a
  153. raw attached format. The structure is ASN.1 encoded, and just like
  154. the header, is composed of several fields. Unless otherwise indicated
  155. fields are optional.
  156. @flag ATTTAG_TYPE | A dword describing the type of data being attached. See
  157. <t STD_DATA_TYPES> for the list of possible types.
  158. @comm The data type implies the format for the raw data. Any parameters
  159. required for the raw data should be encoded as part of the data.
  160. @xref <t Extended Linearized Header>
  161. @end
  162. ********/
  163. /********
  164. @doc EXTERNAL LINEARIZER SRVRDLL
  165. @api DWORD | LinOpenSession | Opens a session with the linearizer.
  166. A new session has to be opened for every new encoding/decoding
  167. operation.
  168. @parm DWORD | dwDataContext | Context. This is a file handle cast to
  169. a DWORD.
  170. @parm LPDATACB | lpfnData | A callback function which is used by the
  171. linearizer to read the input data stream if delinearizing, or
  172. write the output data stream if linearizing. Parameters are
  173. exactly the same as _lread/_lwrite. The dwDataContext parameter
  174. is passed back as the second parameter to this function.
  175. @parm LPSTREAMDATACB | lpfnStreamData | A callback function used
  176. to write to attachment pipe handles while delinearizing,
  177. or to read from attach pipes while linearizing.
  178. @parm LPTSTR | lpszOurAddress | Far ptr to string containing the
  179. address of this machine. Must be of the form
  180. \<name\>@\<phone number\>, where \<phone number\> is the
  181. canonical phone number, ie of the form
  182. +\<country code\>[\<area code\>]\<local number\>
  183. @parm LPTSTR | lpszOurDisplayName | Far ptr to string containing
  184. the friendly name of this machine.
  185. @rdesc DWORD | Session handle on success, FALSE on failure.
  186. @comm Any session opened with LinOpenSession *must* be closed by
  187. a corresponding call to LinCloseSession.
  188. @end
  189. ********/
  190. #if defined(FILELINZ)
  191. DWORD FAR PASCAL LinOpenSession(DWORD dwDataContext,
  192. LPDATACB lpfnData, LPSTREAMDATACB lpfnStreamData,
  193. LPTSTR lpszOurAddress, LPTSTR lpszOurDisplayName);
  194. BOOL WINAPI LinSetSecurityParams
  195. (
  196. DWORD dwLinInst, // handle from LinOpenSession
  197. WORD wEncrypt, // 0=none, 1=key, 2=password
  198. BOOL fSign, // reserved for future use
  199. LPSTR lpszPass, // password or address for public key
  200. DWORD dwSecInst, // 1 for password encrypt/decrypt
  201. LPSTR lpszUser // user's address for private key
  202. );
  203. #elif defined (MAPI1)
  204. #ifndef NO_MAPI
  205. DWORD FAR PASCAL LinOpenSession(DWORD dwDataContext, LPMAPISUP lpMAPISup,
  206. LPDATACB lpfnData, LPSTREAMDATACB lpfnStreamData,
  207. LPTSTR lpszOurAddress, LPTSTR lpszOurDisplayName);
  208. #endif
  209. BOOL WINAPI LinSetSecurityParams
  210. (
  211. DWORD dwLinInst, // handle from LinOpenSession
  212. WORD wEncrypt, // 0=none, 1=key, 2=password
  213. BOOL fSign, // reserved for future use
  214. LPSTR lpszPass, // password or address for public key
  215. DWORD dwSecInst, // 1 for password encrypt/decrypt
  216. LPSTR lpszUser // user's address for private key
  217. );
  218. #endif
  219. // API to get back a mapping from a byte offset into the linearized
  220. // stream to an attach num/page number. This works for both encoding
  221. // and decoding. Only the last ten page/attachment boundaries are
  222. // stored. Valid only if the byte offset is smaller than the number of
  223. // bytes of the stream that the linearizer has already processed.
  224. // Return Value:
  225. // HIBYTE(HIWORD): Attachment number. 0 means we havent yet started
  226. // processing any attachments.
  227. // LOBYTE(HIWORD): Page number. For binary attachments this is always
  228. // going to be 1. For images, if this is 0 we havent yet
  229. // processed any pages.
  230. // LOWORD: Byte offset within the current attachment/page in 256 byte
  231. // chunks. Multiply by 256 to get the actual byte offset.
  232. DWORD WINAPI GetPosition(DWORD dwLinInst, DWORD dwPos);
  233. /********
  234. @doc EXTERNAL LINEARIZER SRVRDLL
  235. @api BOOL | LinCloseSession | Closes a previously opened linearizer
  236. session.
  237. @parm DWORD | dwLinInst | a valid linearizer session handle previously
  238. returned by LinOpenSession.
  239. @rdesc BOOL | TRUE for success.
  240. @comm Any session opened with LinOpenSession *must* be closed by
  241. a corresponding call to LinCloseSession.
  242. @end
  243. ********/
  244. BOOL FAR PASCAL _loadds LinCloseSession(DWORD dwLinInst);
  245. /***************************************************************************
  246. Name : LinEncodeMessage
  247. Purpose : Linearizes a message
  248. Parameters: dwLinInst: Linearizer instance returned from LinOpenSession
  249. hamc/lpMessage: Handle to an open message in the store. For
  250. linearizing this is the message to be sent.
  251. Returns : 0 for success. Only error conditions are out of memory or
  252. invalid parameter structures.
  253. Comment :
  254. ***************************************************************************/
  255. /********
  256. @doc EXTERNAL LINEARIZER SRVRDLL
  257. @api DWORD | LinEncodeHeader | Creates a linearized header.
  258. @parm DWORD | dwLinInst | A valid linearizer session handle previously
  259. returned by LinOpenSession.
  260. @parm HFILE | hFile | A handle to an open file that the linearized
  261. header is to be written to.
  262. @rdesc DWORD | 0 for success. Only error conditions are out of memory or
  263. invalid parameter structures.
  264. @end
  265. ********/
  266. #if defined (FILELINZ)
  267. DWORD FAR PASCAL _loadds LinEncodeHeader(DWORD dwLinInst, HFILE hFile);
  268. #elif defined (MAPI1)
  269. #if !defined (NO_MAPI)
  270. DWORD FAR PASCAL _loadds LinEncodeHeader(DWORD dwLinInst, LPMESSAGE lpMessage);
  271. DWORD FAR PASCAL _loadds LinEncodeMessage(DWORD dwLinInst, LPMESSAGE lpMessage);
  272. DWORD FAR PASCAL _loadds LinEncodeData(DWORD dwLinInst, LPMESSAGE lpMessage);
  273. #endif
  274. #endif
  275. /***************************************************************************
  276. Name : LinDecodeMessage
  277. Purpose : Decodes a linearized message
  278. Parameters: dwLinInst: Handle returned by a previous LinOpenSession
  279. lpMessage: Handle to a newly created Mapi message which
  280. needs to be filled in.
  281. Returns : 0 for success.
  282. Comment :
  283. ***************************************************************************/
  284. /********
  285. @doc EXTERNAL LINEARIZER SRVRDLL
  286. @api DWORD | LinDecodeHeader | Decodes a linearized header.
  287. @parm DWORD | dwLinInst | A valid linearizer sesison handle previously
  288. returned by LinOpenSession.
  289. @parm HFILE | hFile | A handle to an open CLF file that the linearized
  290. header is decoded and writtin to.
  291. @rdesc DWORD | 0 for success. Only error conditions are out of memory or
  292. invalid parameter structures.
  293. @end
  294. ********/
  295. // Decode Header must be called before calling decode message.
  296. #if defined (FILELINZ)
  297. DWORD FAR PASCAL _loadds LinDecodeHeader(DWORD dwLinInst, HFILE hFile);
  298. #elif defined (MAPI1)
  299. #if !defined (NO_MAPI)
  300. DWORD FAR PASCAL _loadds LinDecodeHeader(DWORD dwlinst, LPMESSAGE lpMessage,
  301. LPDWORD lpdwRet, LPFILETIME lpft);
  302. DWORD FAR PASCAL _loadds LinDecodeMessage(DWORD dwLinInst, LPMESSAGE lpMessage);
  303. DWORD FAR PASCAL _loadds LinDecodeData(DWORD dwLinInst, LPMESSAGE lpMessage);
  304. #endif
  305. #endif
  306. /********
  307. @doc EXTERNAL LINEARIZER SRVRDLL
  308. @api DWORD | LinReplaceHeader | Replace a linearized header.
  309. @parm DWORD | dwLinInst | A valid linearizer sesison handle previously
  310. returned by LinOpenSession.
  311. @parm HFILE | hFile | A handle to an open CLF file that contains the
  312. information for the new linearized header.
  313. @parm DWORD | dwOldStream | A valid linearizer sesison handle previously
  314. returned by LinOpenSession.
  315. @parm LPDATACB | lpfnOldRead | A callback function which is used by the
  316. linearizer to read the input data stream if delinearizing, or
  317. write the output data stream if linearizing. Parameters are
  318. exactly the same as _lread/_lwrite. The dwDataContext parameter
  319. is passed back as the second parameter to this function.
  320. @parm DWORD | dwNewStream | A valid linearizer sesison handle previously
  321. returned by LinOpenSession.
  322. @parm LPDATACB | lpfnNewWrite | A callback function which is used by the
  323. linearizer to read the input data stream if delinearizing, or
  324. write the output data stream if linearizing. Parameters are
  325. exactly the same as _lread/_lwrite. The dwDataContext parameter
  326. is passed back as the second parameter to this function.
  327. @rdesc DWORD | 0 for success. Only error conditions are out of memory or
  328. invalid parameter structures.
  329. @comm This api takes an existing linearized file, strips the old
  330. linearized header, and replaces it with the new linearized
  331. header as specified by the CLF file.
  332. @end
  333. ********/
  334. #if defined (FILELINZ)
  335. DWORD FAR PASCAL _loadds LinReplaceHeader(HFILE hfHeaderCLF,
  336. DWORD dwOldStream, LPDATACB lpfnOldRead, // Old stream
  337. DWORD dwNewStream, LPDATACB lpfnNewWrite); // New stream
  338. #endif
  339. #ifdef __cplusplus
  340. } // extern "C" {
  341. #endif
  342. #endif // LIN_H