Leaked source code of windows server 2003
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.

168 lines
7.5 KiB

  1. // --------------------------------------------------------------------------------
  2. // Ibdystm.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // Steven J. Bailey
  5. // --------------------------------------------------------------------------------
  6. #ifndef __IBDYSTM_H
  7. #define __IBDYSTM_H
  8. // --------------------------------------------------------------------------------
  9. // Depends
  10. // --------------------------------------------------------------------------------
  11. #include "mimeole.h"
  12. #include "vstream.h"
  13. #include "inetconv.h"
  14. // --------------------------------------------------------------------------------
  15. // Forwards
  16. // --------------------------------------------------------------------------------
  17. class CMimePropertySet;
  18. class CInternetConverter;
  19. class CMessageBody;
  20. typedef CMessageBody *LPMESSAGEBODY;
  21. // --------------------------------------------------------------------------------
  22. // CBodyStream - {62A83704-52A2-11d0-8205-00C04FD85AB4}
  23. // --------------------------------------------------------------------------------
  24. DEFINE_GUID(IID_CBodyStream, 0x62a83704, 0x52a2, 0x11d0, 0x82, 0x5, 0x0, 0xc0, 0x4f, 0xd8, 0x5a, 0xb4);
  25. // -----------------------------------------------------------------------------
  26. // DOCCONVTYPE
  27. // -----------------------------------------------------------------------------
  28. typedef enum tagDOCCONVTYPE {
  29. DCT_NONE = 1000,
  30. DCT_ENCODE = 1001,
  31. DCT_DECODE = 1002,
  32. DCT_DECENC = 1003
  33. } DOCCONVTYPE;
  34. // -----------------------------------------------------------------------------
  35. // ENCODINGMAP
  36. // -----------------------------------------------------------------------------
  37. typedef struct tagENCODINGMAP {
  38. ENCODINGTYPE ietEncoding;
  39. LPCSTR pszName;
  40. BOOL fValidBodyEncoding; // Allowed to perform body encoding
  41. } ENCODINGMAP, *LPENCODINGMAP;
  42. BOOL FIsValidBodyEncoding(ENCODINGTYPE ietEncoding);
  43. // -----------------------------------------------------------------------------
  44. // Public
  45. // -----------------------------------------------------------------------------
  46. extern const ENCODINGMAP g_rgEncodingMap[IET_LAST];
  47. // -----------------------------------------------------------------------------
  48. // CONVERSIONMAP
  49. // -----------------------------------------------------------------------------
  50. typedef struct tagCONVERSIONMAP {
  51. DOCCONVTYPE rgDestType[IET_LAST];
  52. } CONVERSIONMAP, *LPCONVERSIONMAP;
  53. // -----------------------------------------------------------------------------
  54. // Public
  55. // -----------------------------------------------------------------------------
  56. extern const CONVERSIONMAP g_rgConversionMap[IET_LAST];
  57. // -----------------------------------------------------------------------------
  58. // BODYSTREAMINIT
  59. // -----------------------------------------------------------------------------
  60. typedef struct tagBODYSTREAMINIT {
  61. LPINETCSETINFO pCharset; // Current character set
  62. BOOL fRemoveNBSP; // Conversion Flags
  63. ENCODINGTYPE ietInternal; // Internal Encoding Type
  64. ENCODINGTYPE ietExternal; // External Encoding Type
  65. CODEPAGEID cpiInternal; // Internal Code Page Id
  66. CODEPAGEID cpiExternal; // Extneral Code Page Id
  67. } BODYSTREAMINIT, *LPBODYSTREAMINIT;
  68. // -----------------------------------------------------------------------------
  69. // Wraps a ILockBytes object. CBodyStream is the interface that is
  70. // always returned by IMimeBody::GetData or QueryInterface(IID_IStream, ...)
  71. // -----------------------------------------------------------------------------
  72. class CBodyStream : public IStream
  73. {
  74. public:
  75. // -------------------------------------------------------------------------
  76. // Construction
  77. // -------------------------------------------------------------------------
  78. CBodyStream(void);
  79. ~CBodyStream(void);
  80. // -------------------------------------------------------------------------
  81. // IUnknown
  82. // -------------------------------------------------------------------------
  83. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  84. STDMETHODIMP_(ULONG) AddRef(void);
  85. STDMETHODIMP_(ULONG) Release(void);
  86. // -------------------------------------------------------------------------
  87. // IStream
  88. // -------------------------------------------------------------------------
  89. #ifndef WIN16
  90. STDMETHODIMP Read(LPVOID, ULONG, ULONG *);
  91. #else
  92. STDMETHODIMP Read(VOID HUGEP *, ULONG, ULONG *);
  93. #endif // !WIN16
  94. STDMETHODIMP Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER *);
  95. STDMETHODIMP CopyTo(LPSTREAM, ULARGE_INTEGER, ULARGE_INTEGER *, ULARGE_INTEGER *);
  96. STDMETHODIMP Stat(STATSTG *, DWORD);
  97. STDMETHODIMP Clone(LPSTREAM *) {
  98. return E_NOTIMPL; }
  99. #ifndef WIN16
  100. STDMETHODIMP Write(const void *, ULONG, ULONG *) {
  101. #else
  102. STDMETHODIMP Write(const void HUGEP *, ULONG, ULONG *) {
  103. #endif // !WIN16
  104. return TrapError(STG_E_ACCESSDENIED); }
  105. STDMETHODIMP SetSize(ULARGE_INTEGER) {
  106. return E_NOTIMPL; }
  107. STDMETHODIMP Commit(DWORD) {
  108. return E_NOTIMPL; }
  109. STDMETHODIMP Revert(void) {
  110. return E_NOTIMPL; }
  111. STDMETHODIMP LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) {
  112. return E_NOTIMPL; }
  113. STDMETHODIMP UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) {
  114. return E_NOTIMPL; }
  115. // -------------------------------------------------------------------------
  116. // CBodyStream
  117. // -------------------------------------------------------------------------
  118. HRESULT HrInitialize(LPBODYSTREAMINIT pInitInfo, LPMESSAGEBODY pBody);
  119. private:
  120. // -------------------------------------------------------------------------
  121. // Utilities
  122. // -------------------------------------------------------------------------
  123. HRESULT HrConvertToOffset(ULARGE_INTEGER uliOffset);
  124. HRESULT HrConvertToEnd(void);
  125. HRESULT HrConvertData(LPBLOB pConvert);
  126. HRESULT HrConvertDataLast(void);
  127. // -------------------------------------------------------------------------
  128. // Initialization Helpers
  129. // -------------------------------------------------------------------------
  130. void GetEncodeWrapInfo(LPCONVINITINFO pInitInfo, LPMESSAGEBODY pBody);
  131. void GetCodePageInfo(LPCONVINITINFO pInitInfo, BOOL fIsText, CODEPAGEID cpiSource, CODEPAGEID cpiDest);
  132. void ComputeCodePageMapping(LPBODYSTREAMINIT pInitInfo);
  133. void GenerateDefaultMacBinaryHeader(LPMACBINARY pMacBinary);
  134. private:
  135. // -------------------------------------------------------------------------
  136. // Private Data
  137. // -------------------------------------------------------------------------
  138. LONG m_cRef; // Reference count
  139. LPSTR m_pszFileName; // File Name of this body stream...
  140. DOCCONVTYPE m_dctConvert; // Body Conversion type
  141. ULARGE_INTEGER m_uliIntOffset; // 64bit Addressable internal lockbyte space
  142. ULARGE_INTEGER m_uliIntSize; // Size of data in m_pLockBytes
  143. LARGE_INTEGER m_liLastWrite; // Last location writen to in m_cVirtualStream
  144. ILockBytes *m_pLockBytes; // Lock bytes
  145. CVirtualStream m_cVirtualStream; // Full encode/encode
  146. CInternetConverter *m_pEncoder; // Internet Encoder
  147. CInternetConverter *m_pDecoder; // Internet Encoder
  148. CRITICAL_SECTION m_cs; // Critical Section for m_pStream
  149. };
  150. #endif // __IBDYSTM_H