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.

189 lines
5.5 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. DWORD getdwBinDataLen() { return propInfo.dwBinDataLen; }
  101. };
  102. typedef IMSAdminBase * IMSAdminBasePtr;
  103. class MetaHandle {
  104. METADATA_HANDLE h;
  105. IMSAdminBasePtr pmb;
  106. public:
  107. MetaHandle(IMSAdminBasePtr _pmb);
  108. ~MetaHandle();
  109. operator METADATA_HANDLE*() { return &h;}
  110. operator METADATA_HANDLE() { return h;}
  111. void setpointer(IMSAdminBasePtr _pmb) {
  112. if (pmb)
  113. pmb->Release();
  114. pmb = _pmb;
  115. if (pmb)
  116. pmb->AddRef();
  117. }
  118. void close() {
  119. if (pmb != 0 && h != 0) {
  120. pmb->CloseKey(h);
  121. h = 0;
  122. }
  123. }
  124. };
  125. class IIsSchema {
  126. private:
  127. StrMap nameToClass;
  128. StrMap nameToProp;
  129. DWORDMap idToProp;
  130. HRESULT PropNameWToIISSchemaProp(LPWSTR propNameW, IISSchemaProperty **prop);
  131. public:
  132. IIsSchema();
  133. HRESULT LoadAllData(IMSAdminBasePtr &pmb,
  134. MetaHandle &root,
  135. WCHAR *subdir,
  136. BYTE **buf,
  137. DWORD *size,
  138. DWORD *count);
  139. HRESULT InitSchema(WCHAR *basename, CCredentials& Credentials);
  140. HRESULT IdToPropNameW(DWORD id, LPWSTR buf);
  141. HRESULT PropNameWToSyntaxId(LPWSTR propNameW, DWORD *syntaxID);
  142. HRESULT PropNameWToId(LPWSTR propNameW, DWORD *syntaxID);
  143. HRESULT ConvertID_To_PropName(DWORD dwIdentifier, LPWSTR pszPropertyName);
  144. HRESULT ConvertPropName_To_ID(LPWSTR pszPropertyName, PDWORD pdwIdentifier);
  145. HRESULT LookupSyntaxID(LPWSTR pszPropertyName, PDWORD pdwSyntaxId);
  146. HRESULT ValidateClassName( LPWSTR pszClassName);
  147. HRESULT ValidateContainedClassName(LPWSTR szClass, LPWSTR szContainName);
  148. HRESULT ValidatePropertyName( LPWSTR szPropName);
  149. HRESULT ValidateProperty( LPWSTR szClassName, LPWSTR szPropName);
  150. HRESULT LookupMDFlags(DWORD dwMetaID, PDWORD pdwAttribute, PDWORD pdwUserType);
  151. HRESULT LookupBitMask( LPWSTR pszPropertyName, PDWORD pdwMaskBits);
  152. HRESULT LookupFlagPropName( LPWSTR pszPropertyName, LPWSTR pszFlagPropertyName);
  153. HRESULT LookupMetaID( LPWSTR pszPropertyName, PDWORD pdwMetaId);
  154. HRESULT LookupPropID( LPWSTR pszPropertyName, PDWORD pdwPropId);
  155. HRESULT GetDefaultProperty(LPWSTR szPropName, PDWORD pdwNumValues, PDWORD pdwSyntax, LPBYTE *pBuffer);
  156. HRESULT GetTotalEntries(PDWORD pdwEntries);
  157. DWORD GetClassEntries();
  158. DWORD GetPropEntries();
  159. LPWSTR GetClassName(DWORD dwIndex);
  160. LPWSTR GetPropName(DWORD dwIndex);
  161. HRESULT RemoveEntry(BOOL bClass, LPWSTR pszName);
  162. PCLASSINFO GetClassInfo(LPWSTR pszName);
  163. PPROPERTYINFO GetPropertyInfo(LPWSTR pszName);
  164. HRESULT SetClassInfo(LPWSTR pszName, PCLASSINFO pClassInfo);
  165. HRESULT SetPropertyInfo(LPWSTR pszName, PPROPERTYINFO pPropInfo);
  166. };
  167. extern WCHAR *grabProp(WCHAR *out, WCHAR *in);
  168. extern BOOL DataForSyntaxID(PROPERTYINFO *pp, METADATA_RECORD *mdr);
  169. extern DWORD SyntaxToMetaID(DWORD syntaxID);
  170. extern WCHAR *SyntaxIdToString(DWORD syntaxID);
  171. extern void InitPropValue( PropValue *pv, PROPERTYINFO *pi );