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.

137 lines
3.9 KiB

  1. #ifndef _MIMEDB_H_
  2. #define _MIMEDB_H_
  3. #define ALLOC_BLOCK 10
  4. typedef struct tagMIMECODEPAGE {
  5. UINT uiCodePage;
  6. LPWSTR wszHeaderCharset;
  7. LPWSTR wszBodyCharset;
  8. LPWSTR wszWebCharset;
  9. UINT uidFixedWidthFont;
  10. UINT uidProportionalFont;
  11. UINT uidDescription;
  12. UINT uiFamilyCodePage;
  13. DWORD dwFlags;
  14. } MIMECODEPAGE;
  15. typedef struct tagMIMEREGCHARSET
  16. {
  17. LPCWSTR szCharset;
  18. UINT uiCodePage;
  19. UINT uiInternetEncoding;
  20. DWORD dwFlags;
  21. } MIMECHARSET;
  22. typedef struct tagMIMERFC1766
  23. {
  24. LCID LcId;
  25. LPCWSTR szRfc1766;
  26. UINT uidLCID;
  27. DWORD dwFlags;
  28. } MIMERFC1766;
  29. extern MIMECODEPAGE MimeCodePage[];
  30. extern const MIMERFC1766 MimeRfc1766[];
  31. extern const MIMECHARSET MimeCharSet[];
  32. #ifdef __cplusplus
  33. //
  34. // CMimeDatabase declaration without IMimeDatabase Interface
  35. //
  36. class CMimeDatabase // This would support IMimeDatabase when available
  37. {
  38. MIMECONTF dwMimeSource;
  39. public:
  40. // Possible IMimeDatabase methods
  41. STDMETHODIMP GetNumberOfCodePageInfo(UINT *pcCodePage);
  42. STDMETHODIMP EnumCodePageInfo(void);
  43. STDMETHODIMP GetCodePageInfo(UINT uiCodePage, LANGID LangId, PMIMECPINFO pcpInfo);
  44. STDMETHODIMP GetCodePageInfoWithIndex(UINT uidx, LANGID LangId, PMIMECPINFO pcpInfo);
  45. STDMETHODIMP GetCharsetInfo(BSTR Charset, PMIMECSETINFO pcsetInfo);
  46. STDMETHODIMP ValidateCP(UINT uiCodePage);
  47. STDMETHODIMP SetMimeDBSource(MIMECONTF dwSource)
  48. {
  49. if ((dwSource != MIMECONTF_MIME_IE4) &&
  50. (dwSource != MIMECONTF_MIME_LATEST) &&
  51. (dwSource != MIMECONTF_MIME_REGISTRY))
  52. {
  53. return E_INVALIDARG;
  54. }
  55. dwMimeSource = dwSource;
  56. return S_OK;
  57. }
  58. CMimeDatabase(void)
  59. {
  60. dwMimeSource = MIMECONTF_MIME_LATEST;
  61. }
  62. protected:
  63. void FreeMimeDatabase(void);
  64. BOOL CheckFont(BYTE bGDICharset);
  65. };
  66. //
  67. // Globals
  68. //
  69. extern CMimeDatabase *g_pMimeDatabase;
  70. //
  71. // CMimeDatabase declaration without IMimeDatabase Interface
  72. //
  73. class CMimeDatabaseReg // This would support IMimeDatabase when available
  74. {
  75. public:
  76. // Possible IMimeDatabase methods
  77. STDMETHODIMP GetNumberOfCodePageInfo(UINT *pcCodePage);
  78. STDMETHODIMP EnumCodePageInfo(void);
  79. STDMETHODIMP GetCodePageInfo(UINT uiCodePage, PMIMECPINFO pcpInfo);
  80. STDMETHODIMP GetCodePageInfoWithIndex(UINT uidx, PMIMECPINFO pcpInfo);
  81. STDMETHODIMP GetCharsetInfo(BSTR Charset, PMIMECSETINFO pcsetInfo);
  82. STDMETHODIMP ValidateCP(UINT uiCodePage);
  83. STDMETHODIMP LcidToRfc1766A(LCID Locale, LPSTR pszRfc1766, int iMaxLength);
  84. STDMETHODIMP LcidToRfc1766W(LCID Locale, LPWSTR pwszRfc1766, int nChar);
  85. STDMETHODIMP Rfc1766ToLcidA(PLCID pLocale, LPCSTR pszRfc1766);
  86. STDMETHODIMP Rfc1766ToLcidW(PLCID pLocale, LPCWSTR pwszRfc1766);
  87. void EnsureRfc1766Table(void);
  88. // Constructor & Destructor
  89. CMimeDatabaseReg();
  90. ~CMimeDatabaseReg();
  91. protected:
  92. void BuildCodePageMimeDatabase(void);
  93. void BuildCharsetMimeDatabase(void);
  94. void FreeMimeDatabase(void);
  95. int FindCodePageFromCache(UINT uiCodePage);
  96. BOOL FindCodePageFromRegistry(UINT uiCodePage, MIMECPINFO *pCPInfo);
  97. int FindCharsetFromCache(BSTR Charset);
  98. int FindCharsetFromRegistry(BSTR Charset, BOOL fFromAlias);
  99. BOOL CheckFont(BYTE bGDICharset);
  100. void QSortCodePageInfo(LONG left, LONG right);
  101. void QSortCharsetInfo(LONG left, LONG right);
  102. void BuildRfc1766Table(void);
  103. void FreeRfc1766Table(void);
  104. CRITICAL_SECTION _cs;
  105. BOOL _fAllCPCached;
  106. PMIMECPINFO _pCodePage;
  107. UINT _cCodePage;
  108. UINT _cMaxCodePage;
  109. PMIMECSETINFO _pCharset;
  110. UINT _cCharset;
  111. UINT _cMaxCharset;
  112. };
  113. extern CMimeDatabaseReg *g_pMimeDatabaseReg;
  114. #endif // __cplusplus
  115. #endif // _MIMEDB_H_