Source code of Windows XP (NT5)
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.

134 lines
3.8 KiB

  1. //---------------------------------------------------------------------------------------
  2. //
  3. // @doc
  4. //
  5. // @module pputils.h | Passport utilities.
  6. //
  7. // Author: stevefu
  8. //
  9. // Date: 05/01/2000
  10. //
  11. //---------------------------------------------------------------------------------------
  12. #if !defined(PPUTILITIES_H__INCLUDED_)
  13. #define PPUTILITIES_H__INCLUDED_
  14. #pragma once
  15. #include "nsconst.h"
  16. // Useful macros
  17. #define PPF_BOOL(b) (((b) == false) ? (k_szFalse) : (k_szTrue))
  18. #define PPF_CHAR(p) ((((LPCSTR )(p)) == NULL) ? ("<NULL>") : ((LPCSTR )(p)))
  19. #define PPF_WCHAR(p) ((((LPCWSTR )(p)) == NULL) ? (L"<NULL>") : ((LPCWSTR )(p)))
  20. ////////////////////////////////////////////////////////////////////////////////////////
  21. // String utilities
  22. void Mbcs2Unicode(LPCSTR pszIn, unsigned codepage, BOOL bNEC, CStringW& wOut);
  23. void Unicode2Mbcs(LPCWSTR pwszIn, unsigned codepage, BOOL bNEC, CStringA& wOut);
  24. void FixUpHtmlDecimalCharacters(CStringW& str);
  25. void HtmlEscapeString(CStringW& str, LPCWSTR escch = L"\"<>" );
  26. void HtmlEscapeString(CStringA& str, LPCSTR escch = "\"<>");
  27. void UrlEscapeString(CStringW& wStr );
  28. void UrlEscapeString(CStringA& oStr);
  29. CStringA UrlEscapeStr(const CStringA& oStr);
  30. void UrlUnescapeString(CStringW& wStr );
  31. void UrlUnescapeString(CStringA& aStr);
  32. void BSTRMove(BSTR& src, CStringW& dest);
  33. void BSTRMove(BSTR& src, CStringA& dest);
  34. long HexToNum(wchar_t c);
  35. long FromHex(LPCWSTR pszHexString);
  36. void EncodeXMLString(CStringW& str );
  37. void EncodeXMLString(CStringA& str);
  38. void EncodeWMLString(CStringW& str );
  39. void EncodeWMLString(CStringA& str);
  40. void EncodeHDMLString(CStringW& str );
  41. void EncodeHDMLString(CStringA& str);
  42. void ToHexStr(CStringA& outputToAppend, LPCWSTR instr) throw();
  43. void ToHexStr(CStringA& outputToAppend, unsigned short in) throw();
  44. void ToHexStr(CStringA& outputToAppend, unsigned long in) throw();
  45. void ToHexStr(CStringA& outputToAppend, PBYTE pData, ULONG len) throw();
  46. ////////////////////////////////////////////////////////////////////////////////////////
  47. // ini file processing
  48. typedef struct tag_ConfigIniPair
  49. {
  50. CString strIniKey;
  51. CString strIniValue;
  52. } IniSettingPair;
  53. BOOL GetPrivateProfilePairs(
  54. LPCTSTR lpFileName,
  55. LPCTSTR lpSectionName,
  56. ATL::CAtlArray<IniSettingPair>& r
  57. );
  58. ////////////////////////////////////////////////////////////////////////////////////////
  59. // Browser info
  60. //
  61. class CBrowserInfo
  62. {
  63. protected:
  64. BOOL m_bIsBrowserHigh;
  65. BOOL m_bIsWebTVBased;
  66. unsigned int m_nBrowserIndex;
  67. unsigned int m_nBrowserMajorVersion;
  68. unsigned int m_nBrowserMinorVersion;
  69. CStringA m_strBrowserVersion;
  70. CStringA m_strUserAgent;
  71. public:
  72. CBrowserInfo(LPCSTR pszUserAgentStr = NULL);
  73. ~CBrowserInfo();
  74. BOOL Initialize(LPCSTR pszUserAgent);
  75. enum BROWSER_NAME_ID
  76. {
  77. BROWSER_UNKNOWN=0,
  78. BROWSER_IE=1,
  79. BROWSER_NETSCAPE=2,
  80. BROWSER_PASSPORT_CLIENT=3,
  81. BROWSER_UP=4,
  82. BROWSER_DoCoMo=5,
  83. BROWSER_WEBTV=6,
  84. BROWSER_ROGERS=7,
  85. BROWSER_MSTV=8,
  86. BROWSER_MMEPHONE = 9,
  87. BROWSER_IE_WINCE = 10,
  88. BROWSER_AVANTGO
  89. };
  90. unsigned int GetBrowserNameIndex();
  91. unsigned int GetBrowserMajorVersion();
  92. unsigned int GetBrowserMinorVersion();
  93. LPCSTR GetBrowserVersionString();
  94. BOOL IsHighBrowser();
  95. BOOL IsWebTVBased();
  96. BOOL IfUserAgentHasStr(LPCSTR str);
  97. };
  98. ////////////////////////////////////////////////////////////////////////////////////////
  99. // URL helper: ATLSvr CUrl.
  100. // It does not provide an easy way to set name-value pair on query string. Anyone feel strong
  101. // about needing one?
  102. //
  103. //
  104. // Time helper, birthdate helper: ATLSvr CTime, CTimeSpan
  105. //
  106. //
  107. // cookie helper: ATLSvr CCookie
  108. //
  109. #endif //PPUTILITIES_H__INCLUDED_