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.

189 lines
5.2 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1997
  5. //
  6. // File: schemini.hxx
  7. //
  8. // Contents: Schema/Property class
  9. //
  10. // History: 28-Apr-97 Markand Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. struct StrMapEntry {
  14. LPWSTR m_str;
  15. void *m_data;
  16. };
  17. class StrMap {
  18. StrMapEntry *map;
  19. int count;
  20. int mapSize;
  21. public:
  22. StrMap();
  23. ~StrMap();
  24. BOOL CheckSpace();
  25. BOOL Add(LPWSTR str, void *data);
  26. void *Find(LPWSTR str);
  27. void *operator[] (LPWSTR str);
  28. DWORD GetEntries();
  29. LPWSTR GetEntryName(DWORD dwIndex);
  30. BOOL ClearEntry(DWORD dwIndex);
  31. };
  32. struct DWORDMapEntry {
  33. DWORD m_val;
  34. void *m_data;
  35. };
  36. class DWORDMap {
  37. DWORDMapEntry *map;
  38. int count;
  39. int mapSize;
  40. public:
  41. DWORDMap();
  42. ~DWORDMap();
  43. BOOL CheckSpace();
  44. BOOL Add(DWORD, void *data);
  45. void *Find(DWORD);
  46. void *operator[] (DWORD);
  47. BOOL ClearEntry(DWORD dwIndex);
  48. };
  49. class IIsSchemaClass {
  50. LPWSTR name;
  51. CLASSINFO classInfo;
  52. public:
  53. IIsSchemaClass(LPWSTR _name);
  54. ~IIsSchemaClass();
  55. LPWSTR getName() { return name; }
  56. HRESULT SetClassInfo(PCLASSINFO pClassInfo);
  57. HRESULT findProp(LPWSTR pszPropName);
  58. HRESULT findContainedClassName(LPWSTR pszContainName);
  59. PCLASSINFO GetclassInfo() { return (PCLASSINFO)&classInfo; }
  60. HRESULT SetclassInfo(PCLASSINFO pclassInfo);
  61. };
  62. struct PropValue {
  63. DWORD dwMetaID;
  64. DWORD dwPropID;
  65. DWORD dwSynID;
  66. DWORD dwMaxRange;
  67. DWORD dwMinRange;
  68. DWORD dwMetaType;
  69. DWORD dwFlags;
  70. DWORD dwMask;
  71. DWORD dwMetaFlags;
  72. DWORD dwUserGroup;
  73. BOOL fMultiValued;
  74. DWORD dwDefault;
  75. LPWSTR szDefault;
  76. };
  77. class IISSchemaProperty {
  78. LPWSTR name;
  79. DWORD propID;
  80. PROPERTYINFO propInfo;
  81. // DWORD syntaxID;
  82. public:
  83. // IISSchemaProperty(LPWSTR _name, int nameLen);
  84. IISSchemaProperty(DWORD id, LPWSTR _name, int nameLen);
  85. ~IISSchemaProperty();
  86. BOOL InitFromMetaData(METADATA_GETALL_RECORD *mdga, BYTE *data);
  87. BOOL InitPropertyDefaults(METADATA_GETALL_RECORD *mdga, BYTE *data);
  88. WCHAR *getName() { return name; }
  89. DWORD getPropID() { return propID; }
  90. DWORD getMetaID() { return propInfo.dwMetaID; }
  91. DWORD getSyntaxID() { return propInfo.dwSyntaxId; }
  92. DWORD getMetaFlags() { return propInfo.dwMetaFlags; }
  93. DWORD getUserGroup() { return propInfo.dwUserGroup; }
  94. DWORD getMask() { return propInfo.dwMask; }
  95. DWORD getdwDefault() { return propInfo.dwDefault; }
  96. DWORD * getdwDefaultAddr() { return &(propInfo.dwDefault); }
  97. WCHAR *getszDefault() { return propInfo.szDefault; }
  98. PPROPERTYINFO GetpropInfo() { return &propInfo; }
  99. HRESULT SetpropInfo(PROPERTYINFO *ppropInfo);
  100. };
  101. typedef IMSAdminBase * IMSAdminBasePtr;
  102. class MetaHandle {
  103. METADATA_HANDLE h;
  104. IMSAdminBasePtr pmb;
  105. public:
  106. MetaHandle(IMSAdminBasePtr _pmb);
  107. ~MetaHandle();
  108. operator METADATA_HANDLE*() { return &h;}
  109. operator METADATA_HANDLE() { return h;}
  110. void setpointer(IMSAdminBasePtr _pmb) {
  111. if (pmb)
  112. pmb->Release();
  113. pmb = _pmb;
  114. if (pmb)
  115. pmb->AddRef();
  116. }
  117. void close() {
  118. if (pmb != 0 && h != 0) {
  119. pmb->CloseKey(h);
  120. h = 0;
  121. }
  122. }
  123. };
  124. class IIsSchema {
  125. private:
  126. StrMap nameToClass;
  127. StrMap nameToProp;
  128. DWORDMap idToProp;
  129. HRESULT PropNameWToIISSchemaProp(LPWSTR propNameW, IISSchemaProperty **prop);
  130. public:
  131. IIsSchema();
  132. HRESULT LoadAllData(IMSAdminBasePtr &pmb,
  133. MetaHandle &root,
  134. WCHAR *subdir,
  135. BYTE **buf,
  136. DWORD *size,
  137. DWORD *count);
  138. HRESULT InitSchema(WCHAR *basename);
  139. HRESULT IdToPropNameW(DWORD id, LPWSTR buf);
  140. HRESULT PropNameWToSyntaxId(LPWSTR propNameW, DWORD *syntaxID);
  141. HRESULT PropNameWToId(LPWSTR propNameW, DWORD *syntaxID);
  142. HRESULT ConvertID_To_PropName(DWORD dwIdentifier, LPWSTR pszPropertyName);
  143. HRESULT ConvertPropName_To_ID(LPWSTR pszPropertyName, PDWORD pdwIdentifier);
  144. HRESULT LookupSyntaxID(LPWSTR pszPropertyName, PDWORD pdwSyntaxId);
  145. HRESULT ValidateClassName( LPWSTR pszClassName);
  146. HRESULT ValidateContainedClassName(LPWSTR szClass, LPWSTR szContainName);
  147. HRESULT ValidatePropertyName( LPWSTR szPropName);
  148. HRESULT ValidateProperty( LPWSTR szClassName, LPWSTR szPropName);
  149. HRESULT LookupMDFlags(DWORD dwMetaID, PDWORD pdwAttribute, PDWORD pdwUserType);
  150. HRESULT LookupBitMask( LPWSTR pszPropertyName, PDWORD pdwMaskBits);
  151. HRESULT LookupFlagPropName( LPWSTR pszPropertyName, LPWSTR pszFlagPropertyName);
  152. HRESULT LookupMetaID( LPWSTR pszPropertyName, PDWORD pdwMetaId);
  153. HRESULT LookupPropID( LPWSTR pszPropertyName, PDWORD pdwPropId);
  154. HRESULT GetDefaultProperty(LPWSTR szPropName, PDWORD pdwNumValues, PDWORD pdwSyntax, LPBYTE *pBuffer);
  155. HRESULT GetTotalEntries(PDWORD pdwEntries);
  156. DWORD GetClassEntries();
  157. DWORD GetPropEntries();
  158. LPWSTR GetClassName(DWORD dwIndex);
  159. LPWSTR GetPropName(DWORD dwIndex);
  160. HRESULT RemoveEntry(BOOL bClass, LPWSTR pszName);
  161. PCLASSINFO GetClassInfo(LPWSTR pszName);
  162. PPROPERTYINFO GetPropertyInfo(LPWSTR pszName);
  163. HRESULT SetClassInfo(LPWSTR pszName, PCLASSINFO pClassInfo);
  164. HRESULT SetPropertyInfo(LPWSTR pszName, PPROPERTYINFO pPropInfo);
  165. };
  166. extern WCHAR *grabProp(WCHAR *out, WCHAR *in);
  167. extern BOOL DataForSyntaxID(PROPERTYINFO *pp, METADATA_RECORD *mdr);
  168. extern DWORD SyntaxToMetaID(DWORD syntaxID);
  169. extern WCHAR *SyntaxIdToString(DWORD syntaxID);
  170. extern void InitPropValue( PropValue *pv, PROPERTYINFO *pi );