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.

104 lines
3.1 KiB

  1. #ifndef _DATASNIF_HXX
  2. #define _DATASNIF_HXX
  3. //+---------------------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  7. //
  8. // File: datasnif.hxx
  9. //
  10. // Contents: Stream Mime type checking (attempts to guess the MIME type
  11. // of a buffer by simple pattern matching).
  12. //
  13. // Classes: ContentAnalyzer
  14. //
  15. // Functions: private:
  16. //
  17. // CContentAnalyzer::SampleData
  18. // CContentAnalyzer::IsBMP
  19. // CContentAnalyzer::GetDataFormat
  20. // CContentAnalyzer::FormatAgreesWithData
  21. // CContentAnalyzer::MatchDWordAtOffset
  22. // CContentAnalyzer::FindAppFromExt
  23. // CContentAnalyzer::CheckTextHeaders
  24. // CContentAnalyzer::CheckBinaryHeaders
  25. //
  26. // public:
  27. // ContentAnalyzer::FindMimeFromData
  28. // ::FindMimeFromData
  29. //
  30. //
  31. // 05-26-96 AdriaanC (Adriaan Canter) Created
  32. // 07-16-96 AdriaanC (Adriaan Canter) Modified
  33. // 08-07-96 AdriaanC (Adriaan Canter) Modified
  34. // 08-14-96 AdriaanC (Adriaan Canter) Modified
  35. //
  36. //----------------------------------------------------------------------------
  37. class CContentAnalyzer
  38. {
  39. private:
  40. int _cbSample;
  41. int _cbText;
  42. int _cbNL;
  43. int _cbCR;
  44. int _cbFF;
  45. int _cbCtrl;
  46. int _cbHigh;
  47. char* _pBuf;
  48. WCHAR* _wzEncoding;
  49. WCHAR* _wzMimeType;
  50. DWORD _grfFlags;
  51. BOOL _fBinary;
  52. BOOL _fFoundHTML; // Patterns requiring searching through buffer
  53. BOOL _fFoundXBitMap; //
  54. BOOL _fFoundMacBinhex; //
  55. BOOL _fFoundCDF;
  56. BOOL _fFoundTextScriptlet;
  57. BOOL _fFoundXML;
  58. WCHAR _wzMimeTypeFromExt[SZMIMESIZE_MAX];
  59. private:
  60. inline void SampleData();
  61. inline BOOL IsBMP();
  62. inline DWORD GetDataFormat(LPCWSTR);
  63. inline BOOL FormatAgreesWithData(DWORD);
  64. inline BOOL MatchDWordAtOffset(DWORD, int);
  65. inline BOOL FindAppFromExt(LPSTR, LPSTR, DWORD);
  66. inline BOOL CheckTextHeaders();
  67. inline BOOL CheckBinaryHeaders();
  68. public:
  69. CContentAnalyzer() : _cbSample(0), _cbText(0), _cbNL(0), _cbCR(0),
  70. _cbFF(0), _cbCtrl(0), _cbHigh(0), _pBuf(0), _grfFlags(0),
  71. _fFoundHTML(FALSE), _fFoundXBitMap(FALSE), _fFoundMacBinhex(FALSE),
  72. _fBinary(FALSE), _fFoundCDF(FALSE), _fFoundTextScriptlet(FALSE),
  73. _fFoundXML(FALSE) {}
  74. LPCWSTR FindMimeFromData(LPCWSTR, char*, int, LPCWSTR, DWORD);
  75. BOOL FindMimeFromExt(
  76. LPCWSTR wzFileName,
  77. CHAR *szFileName,
  78. CHAR *szMimeTypeFromExt,
  79. DWORD *pdwExtMimeTypeDataFormat,
  80. CHAR **ppszFileExt);
  81. };
  82. LPCWSTR FindMimeFromData(LPCWSTR pwzFilename, LPVOID pBuffer,
  83. DWORD cbBufferSize, LPCWSTR pwzMimeProposed, DWORD grfFlags);
  84. // private flags for bad header
  85. #endif // _DATASNIF_HXX