home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / C_C++ / BorlandCompiler / freecommandLinetools.exe / Include / msgemit.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-27  |  17.5 KB  |  440 lines

  1. // --msgemit.h--------------------------------------------------------------
  2. //
  3. // API entry points for the msgemit static link library.
  4. // Contains helper functions for converting MAPI messages to 
  5. // 822-style headers and 822-style ASCII headers to MAPI messages.
  6. //
  7. // Copyright (C) Microsoft Corp., 1986-1996.  All rights reserved.
  8. //
  9. // ---------------------------------------------------------------------------
  10.  
  11. #ifndef _MSGEMIT_H
  12. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  13. #define _MSGEMIT_H
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif // __cplusplus
  18.  
  19. // Constants for the binary encode and decode functions.
  20. const ULONG nBytesEncodePerLine     =   24; // # of bytes encoded per line
  21. const ULONG nCharsPerEncodedByte    =   3;  // # of chars written per encoded byte
  22.  
  23. // Convenient macro for determining the number of data bytes (not
  24. // counting the null terminator) in a string.
  25. static __inline ULONG cbStrBytes(
  26.     IN LPCSTR pszString)     // string pointer
  27. {
  28.     return (lstrlenA(pszString));
  29. }
  30.  
  31. //$--HrCreateDateTimeString@-------------------------------------------------
  32. //
  33. // DESCRIPTION: Builds a date & time (UT) created string for a MAPI message file time
  34. //
  35. // INPUT:       lpFileTime  --  file time structure pointer (UT)
  36. //
  37. // OUTPUT:      lppTimeString   --  Pointer to time string output buffer
  38. //
  39. // RETURNS:     HRESULT     --  NOERROR if successful,
  40. //                              E_INVALIDARG if bad input,
  41. //                              E_OUTOFMEMORY if memory problems,
  42. //                              E_FAIL otherwise
  43. //
  44. // ---------------------------------------------------------------------------
  45.  
  46. HRESULT HrCreateDateTimeStringW(
  47.     IN LPFILETIME lpFileTime,      // file time structure pointer
  48.     OUT LPWSTR * lppTimeString);   // pointer to time string buffer
  49.  
  50. HRESULT HrCreateDateTimeStringA(
  51.     IN LPFILETIME lpFileTime,      // file time structure pointer
  52.     OUT LPSTR * lppTimeString);    // pointer to time string buffer
  53.  
  54. #ifdef UNICODE
  55. #define HrCreateDateTimeString  HrCreateDateTimeStringW
  56. #else
  57. #define HrCreateDateTimeString  HrCreateDateTimeStringA
  58. #endif
  59.  
  60. //$--HrCreateImportanceString------------------------------------------------
  61. //
  62. // DESCRIPTION: Creates an message importance string from a MAPI message importance value
  63. //
  64. // INPUT:       ulImportance    --  message's PR_IMPORTANCE value
  65. //              
  66. // OUTPUT:      lppImportance --  Pointer to importance string buffer
  67. //
  68. // RETURNS:     HRESULT     --  NOERROR if successful,
  69. //                              E_INVALIDARG if invalid parameter,
  70. //                              E_OUTOFMEMORY if memory problems,
  71. //                              E_FAIL otherwise.
  72. //
  73. // ---------------------------------------------------------------------------
  74.  
  75. HRESULT HrCreateImportanceString(                   //  RETURNS:    HRESULT
  76.                     IN ULONG ulImportance,            // message's PR_IMPORTANCE value
  77.                     OUT LPSTR * lppImportance);  // pointer to importance string buffer
  78.  
  79. //$--HrEmitTagDataLine-------------------------------------------------------
  80. //
  81. // DESCRIPTION: Emits a line constructed from a static tag and dynamic
  82. //              data to the specified stream.
  83. //
  84. // INPUT:       lpszTag --  tag portion of line
  85. //              lpData      --  data portion of line    (may be "")
  86. //              lpStream    --  stream to write line to
  87. //
  88. // RETURNS:     HRESULT     --  NOERROR if successful,
  89. //                              E_INVALIDARG if invalid parameter,d
  90. //                              E_FAIL otherwise
  91. //
  92. // ---------------------------------------------------------------------------
  93.  
  94. HRESULT HrEmitTagDataLine(   
  95.         IN LPCSTR lpszTag,      // static portion of line
  96.         IN LPSTR lpData,        // dynamic portion of line
  97.         IN LPSTREAM lpStream);  // stream to write line to
  98.  
  99. //$--HrCreatePriorityString-------------------------------------------------------
  100. //
  101. // DESCRIPTION: Creates message priority data string from a MAPI priority value
  102. //
  103. // INPUT:       ulPriority  --  message's PR_PRIORITY value
  104. //
  105. // OUTPUT:      lppPriorityString --  message priority data string pointer
  106. //
  107. // RETURNS:     HRESULT     --  NOERROR if successful,
  108. //                              E_INVALIDARG if invalid parameter,
  109. //                              E_OUTOFMEMORY if memory problems
  110. //                              E_FAIL otherwise
  111. //
  112. // ---------------------------------------------------------------------------
  113.  
  114. HRESULT HrCreatePriorityString(   
  115.         IN ULONG ulPriority,            // message's PR_PRIORITY value
  116.         OUT LPSTR * lppPriorityString); // message priority data string pointer
  117.  
  118. //$--HrEDKEncodeBinaryStreamDataToStream-----------------------------------------------
  119. //
  120. // DESCRIPTION: Copies binary data from an input stream or
  121. //              specified output stream,
  122. //              encoding each byte as a two-character
  123. //              hexadecimal ASCII representation of the byte.
  124. //              E.g. 255 becomes 'FF'.
  125. //
  126. // INPUT:       
  127. //              lpStreamIn  --  input stream pointer
  128. //              lpStreamOut --  output stream pointer
  129. //
  130. // RETURNS:     HRESULT     --  NOERROR if successful,
  131. //                              E_INVALIDARG if invalid parameter,
  132. //                              E_FAIL otherwise
  133. //
  134. // ---------------------------------------------------------------------------
  135. HRESULT HrEDKEncodeBinaryStreamDataToStream(               
  136.                     IN LPSTREAM lpStreamIn,     // input stream pointer
  137.                     IN LPSTREAM lpStreamOut);   // output stream pointer
  138.  
  139. //$--HrCreateExternalTraceString------------------------------------------------
  140. //
  141. // DESCRIPTION: Creates a string from a message's external trace information.
  142. //
  143. // INPUT:       lAction --  trace action
  144. //              lpCountry   --  country
  145. //              lpADMDName  --  ADMD name
  146. //              lpPRMDId    --  PRMD identifier
  147. //          
  148. // OUTPUT:      lppTraceString  --  pointer to trace information string buffer
  149. //
  150. // RETURNS:     HRESULT     --  NOERROR if successful,
  151. //                              E_INVALIDARG if invalid parameter,
  152. //                              E_OUTOFMEMORY if memory problems
  153. //                              E_FAIL otherwise,
  154. //
  155. // -----------------------------------------------------------------------------
  156.  
  157. HRESULT HrCreateExternalTraceString(        
  158.     IN LONG lAction,             // trace action
  159.     IN LPSTR lpCountry,          // country name
  160.     IN LPSTR lpADMDName,         // ADMD name
  161.     IN LPSTR lpPRMDId,           // PRMD identifier    
  162.     OUT LPSTR * lppTraceString); // trace information string pointer
  163.  
  164. //$--HrCreateInternalTraceString------------------------------------------------
  165. //
  166. // DESCRIPTION: Creates a string from a message's internal trace information.
  167. //
  168. // INPUT:       lAction        --  trace action
  169. //              lpCountry   --  country
  170. //              lpADMDName  --  ADMD name
  171. //              lpPRMDId    --  PRMD identifier
  172. //                lpMTAName    --  MTA name
  173. //          
  174. // OUTPUT:      lppTraceString  --  pointer to trace information string buffer
  175. //
  176. // RETURNS:     HRESULT     --  NOERROR if successful,
  177. //                              E_INVALIDARG if invalid parameter,
  178. //                              E_OUTOFMEMORY if memory problems
  179. //                              E_FAIL otherwise,
  180. //
  181. // -----------------------------------------------------------------------------
  182.  
  183. HRESULT HrCreateInternalTraceString(        
  184.     IN LONG lAction,             // trace action
  185.     IN LPSTR lpCountry,          // country name
  186.     IN LPSTR lpADMDName,         // ADMD name
  187.     IN LPSTR lpPRMDId,           // PRMD identifier    
  188.     IN LPSTR lpMTAName,             // MTA name
  189.     OUT LPSTR * lppTraceString); // trace information string pointer
  190.  
  191. //$--HrGetRecipientList------------------------------------------
  192. //
  193. // DESCRIPTION: Utility function which retrieves columns 
  194. // desired from a MAPI recipient table.
  195. //
  196. // INPUT:   lpMessage   --  pointer to MAPI message
  197. //          lpPropTags  --  list of columns (properties) to retrieve
  198. //          
  199. // OUTPUT:  lppRows --  pointer to array of rows returned pointer.
  200. //
  201. // RETURNS: HRESULT --  NOERROR if successful,
  202. //                      E_INVALIDARG if bad input,
  203. //                      E_FAIL otherwise
  204. //
  205. // -------------------------------------------------------------
  206. HRESULT HrGetRecipientList(           
  207.         IN LPMESSAGE lpMessage,         // MAPI message pointer
  208.         IN LPSPropTagArray lpPropTags,  // properties (columns) desired
  209.         OUT LPSRowSet * lppRows);       // pointer to rows returned
  210.  
  211. //$--HrParseTagAndData-------------------------------------------------------
  212. //
  213. // DESCRIPTION: Parse ASCII 822-style header line into
  214. //              tag and data components.
  215. //
  216. // INPUT:       lpStream    --  stream pointer to read from
  217. //
  218. // OUTPUT:      pcbRead --  number of bytes read from stream
  219. //              ppTag   --  pointer to tag buffer
  220. //              ppData  --  pointer to data buffer
  221. //
  222. // RETURNS:     HRESULT --  NOERROR if successful,
  223. //                          E_INVALIDARG if bad input
  224. //                          E_OUTOFMEMORY if memory problem
  225. //                          E_EOF if end of stream
  226. //                          E_FAIL otherwise
  227. //
  228. // ---------------------------------------------------------------------------
  229. HRESULT HrParseTagAndData(
  230.         IN LPSTREAM lpStream,   // stream pointer
  231.         OUT ULONG * pcbRead,    // # of bytes read
  232.         OUT LPSTR * lppTag,     // pointer to tag buffer
  233.         OUT LPSTR * lppData);   // pointer to data buffer
  234.  
  235. //$--HrParseDateTimeString----------------------------------------------------
  236. //
  237. // DESCRIPTION: Parses a date and time string into a file time
  238. //              structure.
  239. //
  240. // INPUT:       lpDateTimeString    --  date and time string
  241. //
  242. // OUTPUT:      pFileTime   --  file time pointer
  243. //
  244. // RETURNS:     HRESULT --  NOERROR if successful,
  245. //                          E_INVALIDARG if bad input,
  246. //                          E_FAIL otherwise
  247. //
  248. // ----------------------------------------------------------------------------
  249. HRESULT HrParseDateTimeString(
  250.     IN LPSTR lpDateTimeString,      // date and time string
  251.     OUT FILETIME * pFileTime);      // file time pointer
  252.  
  253. //$--HrParsePriorityString----------------------------------------------------
  254. //
  255. // DESCRIPTION: Convert a priority string to its associated
  256. //              integer value.
  257. //
  258. // INPUT:       lpPriority  --  priority string
  259. //             
  260. // OUTPUT:      pulPriority --  pointer to priority value
  261. //
  262. // RETURNS:     HRESULT --  NOERROR if successful,
  263. //                          E_INVALIDARG if bad input,
  264. //                          E_FAIL otherwise
  265. //
  266. // ----------------------------------------------------------------------------
  267. HRESULT HrParsePriorityString(
  268.     IN LPSTR lpPriority,        // Priority string
  269.     OUT ULONG * pulPriority);   // priority value pointer
  270.  
  271. //$--HrParseImportanceString----------------------------------------------------
  272. //
  273. // DESCRIPTION: Convert an importance string to its associated
  274. //              integer value.
  275. //
  276. // INPUT:       lpImportance  --  importance string
  277. //             
  278. // OUTPUT:      pulImportance --  pointer to importance value
  279. //
  280. // RETURNS:     HRESULT --  NOERROR if successful,
  281. //                          E_INVALIDARG if bad input,
  282. //                          E_FAIL otherwise
  283. //
  284. // ----------------------------------------------------------------------------
  285. HRESULT HrParseImportanceString(
  286.     IN LPSTR lpImportance,      // Importance string
  287.     OUT ULONG * pulImportance); // importance value pointer
  288.  
  289. //$--HrParseExternalTraceString-------------------------------------------------
  290. //
  291. // DESCRIPTION: Parse External-Received-By or 
  292. //              External-Attempted-By trace string into a
  293. //              its separate components.
  294. //
  295. // INPUT:       lpTraceString   --  External-Received/Attempted-By trace string
  296. //
  297. // OUTPUT:      plAction   --  trace action
  298. //              pCountry  --  country name
  299. //              pADMDName --  ADMD name
  300. //              pPRMDId   --  PRMD identifier
  301. //
  302. // RETURNS: HRESULT --  NOERROR if successful,
  303. //                      E_INVALIDARG if bad input
  304. //                      E_FAIL otherwise
  305. //
  306. // ----------------------------------------------------------------------------
  307. HRESULT HrParseExternalTraceString(
  308.     IN LPSTR lpTraceString,      // trace information string
  309.     OUT LONG * plAction,         // trace action pointer
  310.     OUT CHAR * pCountry,         // country name
  311.     OUT CHAR * pADMDName,        // ADMD name
  312.     OUT CHAR * pPRMDId);         // PRMD identifier
  313.  
  314. //$--HrParseInternalTraceString-------------------------------------------------
  315. //
  316. // DESCRIPTION: Parse Internal-Received-By or 
  317. //              Internal-Attempted-By trace string into 
  318. //              its separate components.
  319. //
  320. // INPUT:       lpTraceString   --  Internal-Received/Attempted-By trace string
  321. //
  322. // OUTPUT:      plAction  --  trace action
  323. //              pCountry  --  country name
  324. //              pADMDName --  ADMD name
  325. //              pPRMDId   --  PRMD identifier
  326. //              pMTAName  --  MTA name
  327. //
  328. // RETURNS: HRESULT --  NOERROR if successful,
  329. //                      E_INVALIDARG if bad input
  330. //                      E_FAIL otherwise
  331. //
  332. // -----------------------------------------------------------------------------
  333. HRESULT HrParseInternalTraceString(
  334.     IN LPSTR lpTraceString,      // trace information string
  335.     OUT LONG * plAction,         // trace action pointer
  336.     OUT CHAR * pCountry,         // country name
  337.     OUT CHAR * pADMDName,        // ADMD name
  338.     OUT CHAR * pPRMDId,          // PRMD identifier
  339.     OUT CHAR * pMTAName);        // MTA name
  340.  
  341. //$--HrParseAttachmentHeader--------------------------------------------------
  342. //
  343. // DESCRIPTION: Parse attachment header data into its file name
  344. //              and file size components.
  345. //
  346. // INPUT:   lpHeader    --  attachment header data string
  347. //
  348. // OUTPUT:  lppFileName --  attachment file name
  349. //          pcb         --  pointer to # of bytes in attachment
  350. //
  351. // RETURNS: HRESULT --  NOERROR if successful,
  352. //                      E_INVALIDARG if bad input,
  353. //                      E_FAIL otherwise.
  354. //
  355. // ----------------------------------------------------------------------------
  356. HRESULT HrParseAttachmentHeader(
  357.     IN LPSTR lpHeader,         // attachment header data string
  358.     OUT LPSTR * lppFileName,   // attachment file name
  359.     OUT ULONG * pcb);          // pointer to number of bytes in file name
  360.  
  361. //$--HrEDKDecodeBinaryStreamDataToStream-----------------------------------------------
  362. //
  363. // DESCRIPTION: Read attachment hexadecimal encoding from input
  364. //              stream to attachment.
  365. //
  366. // INPUT:       cb  --  number of bytes in binary attachment.
  367. //              lpStream    --  stream pointer
  368. //              lpAttach    --  attachment pointer
  369. //
  370. // RETURNS:     HRESULT --  NOERROR if successful,
  371. //                          E_INVALIDARG if bad input
  372. //                          E_FAIL otherwise.
  373. //
  374. // ----------------------------------------------------------------------------
  375.  
  376. HRESULT HrEDKDecodeBinaryStreamDataToStream(
  377.     IN LPSTREAM lpStreamIn,     // input stream
  378.     IN ULONG cb,                // number of bytes in original binary data
  379.     IN LPSTREAM lpStreamOut);   // output stream
  380.  
  381. //$--HrEDKParseSubjectPrefix---------------------------------------------------
  382. //
  383. // DESCRIPTION: Break a subject into its prefix component & its
  384. //              original subject component.  (The prefix is everything
  385. //              up to and including the first colon and the first space
  386. //              after the colon, if any.
  387. //
  388. // INPUT:       pszSubject --  subject text
  389. //
  390. // OUTPUT       ppszPrefix  --  prefix string pointer
  391. //              ppszOrigSub --  original subject pointer
  392. //
  393. // RETURNS:     HRESULT --  NOERROR if successful,
  394. //                          E_INVALIDARG if bad input,
  395. //                          E_OUTOFMEMORY if memory propblems,
  396. //                          E_FAIL otherwise.
  397. //
  398. // ----------------------------------------------------------------------------
  399. HRESULT HrEDKParseSubjectPrefix(
  400.             IN LPSTR pszSubject,       // subject text
  401.             OUT LPSTR * ppszPrefix,    // subject prefix
  402.             OUT LPSTR * ppszOrigSub);  // original subject text
  403.  
  404. //$--nEDKEncodedBytes-------------------------------------------------------------
  405. //
  406. // DESCRIPTION: Returns the number of encoded bytes based on the number of 
  407. //              un-encoded bytes.
  408. //
  409. // INPUT:       cbUnencoded --  # of un-encoded bytes
  410. //
  411. // RETURNS:     ULONG   --  # of encoded bytes
  412. //
  413. // NOTE:        This is implemented as a static __inline macro for 
  414. //              efficiency and because it is so simple.
  415. //
  416. //-----------------------------------------------------------------------------
  417. static __inline ULONG nEDKEncodedBytes(
  418.             IN ULONG cbUnencoded)   // # of un-encoded bytes
  419. {
  420.     ASSERTERROR(cbUnencoded != 0, "Bad cbUnencoded");   // debug check
  421.  
  422.     if ( (cbUnencoded % nBytesEncodePerLine) == 0 )
  423.     {
  424.         return ( (nCharsPerEncodedByte * cbUnencoded) + 
  425.                  (cbUnencoded/nBytesEncodePerLine) );
  426.     }
  427.     else
  428.     {
  429.         return ( (nCharsPerEncodedByte * cbUnencoded) + 
  430.                  (cbUnencoded/nBytesEncodePerLine) + 1 );
  431.     }
  432. }
  433.  
  434. #ifdef __cplusplus
  435. }
  436. #endif // __cplusplus
  437.  
  438. #pragma option pop /*P_O_Pop*/
  439. #endif
  440.