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.

158 lines
4.4 KiB

  1. #ifndef PARSE_LABEL_H
  2. #define PARSE_LABEL_H
  3. #include "ratings.h"
  4. //t-markh 8/98
  5. //extends GetBool() to true/false, yes/no, pass/fail for
  6. //PICSRules support
  7. enum PICSRulesBooleanSwitch
  8. {
  9. PR_BOOLEAN_TRUEFALSE,
  10. PR_BOOLEAN_PASSFAIL,
  11. PR_BOOLEAN_YESNO
  12. };
  13. //t-markh 8/98
  14. //Definitions used by GetBool for PICSRules types
  15. #define PR_YESNO_YES 1
  16. #define PR_YESNO_NO 0
  17. #define PR_PASSFAIL_PASS 1
  18. #define PR_PASSFAIL_FAIL 0
  19. void SkipWhitespace(LPSTR *ppsz);
  20. BOOL IsEqualToken(LPCSTR pszTokenStart, LPCSTR pszTokenEnd, LPCSTR pszTokenToMatch);
  21. LPSTR FindTokenEnd(LPSTR pszStart);
  22. HRESULT GetBool(LPSTR *ppszToken, BOOL *pfOut, PICSRulesBooleanSwitch PRBoolSwitch=PR_BOOLEAN_TRUEFALSE);
  23. HRESULT ParseNumber(LPSTR *ppszNumber, INT *pnOut, BOOL fPICSRules=FALSE);
  24. HRESULT ParseTime(LPSTR pszTime, DWORD *pOut, BOOL fPICSRules=FALSE);
  25. class COptionsBase
  26. {
  27. protected:
  28. COptionsBase();
  29. UINT m_cRef;
  30. public:
  31. void AddRef();
  32. void Release();
  33. virtual void Delete();
  34. DWORD m_timeUntil; /* 'until' time, in UTC net format (secs since 1/1/1970) */
  35. DWORD m_fdwFlags; /* see LBLOPT_XXX below */
  36. LPSTR m_pszInvalidString; /* ptr to invalid or unrecognized string */
  37. LPSTR m_pszURL; /* value of "for" option, may be NULL */
  38. BOOL CheckUntil(DWORD timeCurrent); /* returns TRUE if 'until' option checks out */
  39. BOOL CheckURL(LPCSTR pszURL); /* returns TRUE if 'for' option checks out */
  40. };
  41. const DWORD LBLOPT_GENERIC = 0x01;
  42. const DWORD LBLOPT_INVALID = 0x02;
  43. const DWORD LBLOPT_EXPIRED = 0x04;
  44. const DWORD LBLOPT_WRONGURL = 0x08;
  45. const DWORD LBLOPT_URLCHECKED = 0x10;
  46. class CStaticOptions : public COptionsBase
  47. {
  48. public:
  49. CStaticOptions() { }
  50. };
  51. class CDynamicOptions : public COptionsBase
  52. {
  53. public:
  54. CDynamicOptions *m_pNext;
  55. CDynamicOptions() { m_pNext = NULL; }
  56. virtual void Delete();
  57. };
  58. class CParsedRating
  59. {
  60. public:
  61. LPSTR pszTransmitName;
  62. INT nValue;
  63. COptionsBase *pOptions;
  64. BOOL fFound; /* TRUE if matches a rating in the installed system */
  65. BOOL fFailed; /* TRUE if exceeded user's limit */
  66. };
  67. class CParsedServiceInfo
  68. {
  69. private:
  70. CParsedServiceInfo *m_pNext;
  71. COptionsBase *m_poptCurrent;
  72. CDynamicOptions *m_poptList;
  73. LPSTR m_pszCurrent; /* for parsing routines */
  74. void SkipWhitespace() { ::SkipWhitespace(&m_pszCurrent); }
  75. public:
  76. LPCSTR m_pszServiceName; /* service name URL, may be NULL if not reported */
  77. LPCSTR m_pszErrorString; /* points to error string if error reported by site */
  78. LPCSTR m_pszInvalidString; /* pointer to invalid or unrecognized string found */
  79. BOOL m_fInstalled; /* TRUE if this rating system is installed on this machine */
  80. CStaticOptions m_opt;
  81. array<CParsedRating> aRatings;
  82. CParsedServiceInfo();
  83. ~CParsedServiceInfo();
  84. CParsedServiceInfo *Next() { return m_pNext; }
  85. void Append(CParsedServiceInfo *pNew);
  86. HRESULT Parse(LPSTR *ppszServiceInfo);
  87. HRESULT ParseServiceError();
  88. HRESULT ParseOptions(LPSTR pszTokenEnd, COptionsBase *pOpt,
  89. CDynamicOptions **ppOptOut, LPCSTR pszOptionEndToken);
  90. HRESULT ParseExtension(COptionsBase *pOpt);
  91. HRESULT ParseExtensionData(COptionsBase *pOpt);
  92. HRESULT ParseRating();
  93. HRESULT ParseSingleLabel();
  94. HRESULT ParseLabels();
  95. };
  96. class CParsedLabelList
  97. {
  98. private:
  99. LPSTR m_pszList;
  100. LPSTR m_pszCurrent;
  101. HRESULT ParseServiceInfo();
  102. void SkipWhitespace() { ::SkipWhitespace(&m_pszCurrent); }
  103. public:
  104. CParsedServiceInfo m_ServiceInfo;
  105. LPCSTR m_pszInvalidString; /* pointer to invalid or unrecognized string found */
  106. LPSTR m_pszURL; /* copy of URL we were originally given */
  107. LPSTR m_pszOriginalLabel; /* copy of original, raw rating label */
  108. BOOL m_fRated; /* TRUE if site is considered rated */
  109. BOOL m_fDenied; /* TRUE if site is denied by a helper */
  110. BOOL m_fIsHelper; /* TRUE if site is judged by a helper */
  111. BOOL m_fNoRating; /* TRUE if site contains no ratings */
  112. BOOL m_fIsCustomHelper;
  113. LPSTR m_pszRatingName;
  114. LPSTR m_pszRatingReason;
  115. CParsedLabelList();
  116. ~CParsedLabelList();
  117. HRESULT Parse(LPSTR pszCopy);
  118. };
  119. extern "C" {
  120. HRESULT ParseLabelList(LPCSTR pszList, CParsedLabelList **ppParsed);
  121. void FreeParsedLabelList(CParsedLabelList *pList);
  122. }; /* extern "C" */
  123. #endif