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.

95 lines
2.2 KiB

  1. #ifndef _PROFILE_SCHEMA_H
  2. #define _PROFILE_SCHEMA_H
  3. #include "BstrHash.h"
  4. #ifndef __no_msxml_dll_import__
  5. #include "xmltlh.h"
  6. //#import <msxml.dll> rename_namespace("MSXML")
  7. //#import "msxml.dll"
  8. //#define MSXML
  9. #endif
  10. typedef CRawCIBstrHash<int> RAWBSTR2INT;
  11. #define INVALID_POS (UINT)(-1)
  12. #define FULL_SCHEMA (DWORD)(-1)
  13. class CProfileSchema
  14. {
  15. public:
  16. // Read the raw blob according to the schema, and output the positions of
  17. // each element. Output array size MUST be >= Count()
  18. HRESULT parseProfile(LPSTR raw, UINT size, UINT* positions, UINT* bitFlagPositions, DWORD* pdwAttrs);
  19. // parck profile ..., when cEles == -1, assuming full schema
  20. BSTR packProfile(void *elements[], DWORD cEles/* = FULL_SCHEMA */);
  21. BSTR packMaskProfile(void *elements[], int maskElemPosition);
  22. enum AttrType {
  23. tText=0,
  24. tChar,
  25. tByte,
  26. tWord,
  27. tLong,
  28. tDate,
  29. tInvalid
  30. };
  31. CProfileSchema();
  32. ~CProfileSchema();
  33. BOOL isOk() const { return m_isOk; }
  34. _bstr_t getErrorInfo() const { return m_szReason; }
  35. long GetAgeSeconds() const;
  36. #ifndef __no_msxml_dll_import__
  37. BOOL Read(MSXML::IXMLElementPtr &root);
  38. #endif
  39. BOOL ReadFromArray(UINT numAttributes, LPTSTR names[], AttrType types[], short sizes[], BYTE readOnly[] = NULL);
  40. int m_maskPos;
  41. // Number of attributes
  42. int Count() const { return m_numAtts; }
  43. // Find the index by name
  44. int GetIndexByName(BSTR name) const;
  45. BSTR GetNameByIndex(int index) const;
  46. // Get the type of an attribute
  47. AttrType GetType(UINT index) const;
  48. // Can I write to this attribute?
  49. BOOL IsReadOnly(UINT index) const;
  50. // Get the inherent size of an attribute
  51. // Returns -1 if the type is length prefixed
  52. int GetBitSize(UINT index) const;
  53. int GetByteSize(UINT index) const;
  54. CProfileSchema* AddRef();
  55. void Release();
  56. protected:
  57. long m_refs;
  58. BOOL m_isOk;
  59. _bstr_t m_szReason;
  60. // Valid until this time
  61. SYSTEMTIME m_validUntil;
  62. // Array of attribute types
  63. UINT m_numAtts;
  64. AttrType *m_atts;
  65. short *m_sizes;
  66. BYTE *m_readOnly;
  67. RAWBSTR2INT m_indexes;
  68. };
  69. // Init functions for fixed schemas
  70. CProfileSchema* InitAuthSchema();
  71. CProfileSchema* InitSecureSchema();
  72. #endif