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.

186 lines
9.4 KiB

  1. // --------------------------------------------------------------------------------
  2. // VariantX.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // --------------------------------------------------------------------------------
  5. #ifndef __VARIANTX_H
  6. #define __VARIANTX_H
  7. // --------------------------------------------------------------------------------
  8. // Forward Decls
  9. // --------------------------------------------------------------------------------
  10. typedef class CMimePropertyContainer *LPCONTAINER;
  11. typedef struct tagMIMEVARIANT *LPMIMEVARIANT;
  12. typedef struct tagPROPSYMBOL *LPPROPSYMBOL;
  13. typedef struct tagHEADOPTIONS *LPHEADOPTIONS;
  14. // --------------------------------------------------------------------------------
  15. // MIMEVARTYPE
  16. // --------------------------------------------------------------------------------
  17. typedef enum tagMIMEVARTYPE {
  18. MVT_EMPTY, // The Variant is Empty
  19. MVT_STRINGA, // Ansi/multibyte string
  20. MVT_STRINGW, // Unicode String
  21. MVT_VARIANT, // PropVariant
  22. MVT_STREAM, // Internal type used to when saving properties
  23. MVT_LAST // Illegal, don't use
  24. } MIMEVARTYPE;
  25. // ---------------------------------------------------------------------------------------
  26. // ISSUPPORTEDVT
  27. // ---------------------------------------------------------------------------------------
  28. #define ISSUPPORTEDVT(_vt) \
  29. (VT_LPSTR == _vt || VT_LPWSTR == _vt || VT_FILETIME == _vt || VT_UI4 == _vt || VT_I4 == _vt || VT_STREAM == _vt)
  30. // ---------------------------------------------------------------------------------------
  31. // ISVALIDVARTYPE
  32. // ---------------------------------------------------------------------------------------
  33. #define ISVALIDVARTYPE(_vartype) \
  34. (_vartype > MVT_EMPTY && _vartype < MVT_LAST)
  35. // ---------------------------------------------------------------------------------------
  36. // ISVALIDSTRINGA - Validates a PROPSTRINGA
  37. // ---------------------------------------------------------------------------------------
  38. #define ISVALIDSTRINGA(_pStringA) \
  39. (NULL != (_pStringA) && NULL != (_pStringA)->pszVal && '\0' == (_pStringA)->pszVal[(_pStringA)->cchVal])
  40. // ---------------------------------------------------------------------------------------
  41. // ISVALIDSTRINGW - Validates a PROPSTRINGW
  42. // ---------------------------------------------------------------------------------------
  43. #define ISVALIDSTRINGW(_pStringW) \
  44. (NULL != (_pStringW) && NULL != (_pStringW)->pszVal && L'\0' == (_pStringW)->pszVal[(_pStringW)->cchVal])
  45. // ---------------------------------------------------------------------------------------
  46. // ISSTRINGA - Determines if a MIMEVARIANT is a valid MVT_STRINGA
  47. // ---------------------------------------------------------------------------------------
  48. #define ISSTRINGA(_pVariant) \
  49. (NULL != (_pVariant) && MVT_STRINGA == (_pVariant)->type && ISVALIDSTRINGA(&((_pVariant)->rStringA)))
  50. // ---------------------------------------------------------------------------------------
  51. // ISSTRINGW - Determines if a MIMEVARIANT is a valid MVT_STRINGW
  52. // ---------------------------------------------------------------------------------------
  53. #define ISSTRINGW(_pVariant) \
  54. (NULL != (_pVariant) && MVT_STRINGW == (_pVariant)->type && ISVALIDSTRINGW(&((_pVariant)->rStringW)))
  55. // ---------------------------------------------------------------------------------------
  56. // PSZSTRINGA - Derefs rStringA.pszVal or uses _pszDefault if not a valid string
  57. // ---------------------------------------------------------------------------------------
  58. #define PSZSTRINGA(_pVariant) \
  59. (ISSTRINGA((_pVariant)) ? (_pVariant)->rStringA.pszVal : NULL)
  60. // ---------------------------------------------------------------------------------------
  61. // PSZDEFSTRINGA - Derefs rStringA.pszVal or uses _pszDefault if not a valid string
  62. // ---------------------------------------------------------------------------------------
  63. #define PSZDEFSTRINGA(_pVariant, _pszDefault) \
  64. (ISSTRINGA((_pVariant)) ? (_pVariant)->rStringA.pszVal : _pszDefault)
  65. // --------------------------------------------------------------------------------
  66. // PROPSTRINGA
  67. // --------------------------------------------------------------------------------
  68. typedef struct tagPROPSTRINGA {
  69. LPSTR pszVal; // Pointer to multibyte string
  70. ULONG cchVal; // Number of characters in psz
  71. } PROPSTRINGA, *LPPROPSTRINGA;
  72. typedef const PROPSTRINGA *LPCPROPSTRINGA;
  73. // --------------------------------------------------------------------------------
  74. // PROPSTRINGW
  75. // --------------------------------------------------------------------------------
  76. typedef struct tagPROPSTRINGW {
  77. LPWSTR pszVal; // Pointer to multibyte string
  78. ULONG cchVal; // Number of characters in psz
  79. } PROPSTRINGW, *LPPROPSTRINGW;
  80. typedef const PROPSTRINGW *LPCPROPSTRINGW;
  81. // --------------------------------------------------------------------------------
  82. // MIMEVARIANT
  83. // --------------------------------------------------------------------------------
  84. typedef struct tagMIMEVARIANT {
  85. MIMEVARTYPE type; // Property Data Type
  86. BYTE fCopy; // The data was copied, don't free it
  87. union {
  88. PROPSTRINGA rStringA; // MVT_STRINGA
  89. PROPSTRINGW rStringW; // MVT_STRINGW
  90. PROPVARIANT rVariant; // MVT_VARIANT
  91. LPSTREAM pStream; // MVT_STREAM
  92. };
  93. } MIMEVARIANT, *LPMIMEVARIANT;
  94. typedef const MIMEVARIANT *LPCMIMEVARIANT;
  95. // --------------------------------------------------------------------------------
  96. // Convert Variant Flags (WARNING: DO NOT OVERFLAG PROPDATAFLAGS WITH THESE)
  97. // --------------------------------------------------------------------------------
  98. #define CVF_NOALLOC FLAG32 // Tells the converter to copy data if it can
  99. // --------------------------------------------------------------------------------
  100. // VARIANTCONVERT
  101. // --------------------------------------------------------------------------------
  102. typedef struct tagVARIANTCONVERT {
  103. LPHEADOPTIONS pOptions; // Header Options
  104. LPPROPSYMBOL pSymbol; // Property Symbol
  105. LPINETCSETINFO pCharset; // Charset to use in conversion
  106. ENCODINGTYPE ietSource; // Encoding of source item
  107. DWORD dwFlags; // Property Data Flags
  108. DWORD dwState; // PRSTATE_xxx Flags
  109. } VARIANTCONVERT, *LPVARIANTCONVERT;
  110. // --------------------------------------------------------------------------------
  111. // HrMimeVariantCopy
  112. // --------------------------------------------------------------------------------
  113. HRESULT HrMimeVariantCopy(
  114. /* in */ DWORD dwFlags, // CVF_xxx Flags
  115. /* in */ LPMIMEVARIANT pSource,
  116. /* out */ LPMIMEVARIANT pDest);
  117. // --------------------------------------------------------------------------------
  118. // HrConvertVariant
  119. // --------------------------------------------------------------------------------
  120. HRESULT HrConvertVariant(
  121. /* in */ LPHEADOPTIONS pOptions,
  122. /* in */ LPPROPSYMBOL pSymbol,
  123. /* in */ LPINETCSETINFO pCharset,
  124. /* in */ ENCODINGTYPE ietSource,
  125. /* in */ DWORD dwFlags,
  126. /* in */ DWORD dwState,
  127. /* in */ LPMIMEVARIANT pSource,
  128. /* in,out */ LPMIMEVARIANT pDest,
  129. /* out,opt */ BOOL *pfRfc1522=NULL);
  130. // --------------------------------------------------------------------------------
  131. // MimeVariantFree
  132. // --------------------------------------------------------------------------------
  133. void MimeVariantFree(
  134. /* in */ LPMIMEVARIANT pVariant);
  135. // --------------------------------------------------------------------------------
  136. // MimeVariantCleanupFileName
  137. // --------------------------------------------------------------------------------
  138. void MimeVariantCleanupFileName(
  139. /* in */ CODEPAGEID codepage,
  140. /* in,out */ LPMIMEVARIANT pVariant);
  141. // --------------------------------------------------------------------------------
  142. // MimeVariantStripComments
  143. // --------------------------------------------------------------------------------
  144. HRESULT MimeVariantStripComments(
  145. /* in */ LPMIMEVARIANT pSource,
  146. /* in,out */ LPMIMEVARIANT pDest,
  147. /* in,out */ LPBYTE pbScratch,
  148. /* in */ ULONG cbScratch);
  149. // ---------------------------------------------------------------------------------------
  150. // MimeVT_To_PropVT
  151. // ---------------------------------------------------------------------------------------
  152. inline VARTYPE MimeVT_To_PropVT(LPMIMEVARIANT pVariant) {
  153. Assert(pVariant);
  154. if (MVT_STRINGA == pVariant->type)
  155. return(VT_LPSTR);
  156. else if (MVT_STRINGW == pVariant->type)
  157. return(VT_LPWSTR);
  158. else if (MVT_VARIANT == pVariant->type)
  159. return(pVariant->rVariant.vt);
  160. else
  161. return(VT_EMPTY);
  162. }
  163. #endif // __VARIANTX_H