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.

239 lines
6.8 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. pcmtestfactory.cpp
  5. Abstract:
  6. implementation of a nodefactory for Precompiled manifest testing
  7. Author:
  8. Xiaoyu Wu (xiaoyuw) June 2000
  9. Revision History:
  10. --*/
  11. #include "stdinc.h"
  12. #if SXS_PRECOMPILED_MANIFESTS_ENABLED
  13. #include "fusioneventlog.h"
  14. #include "pcmtestfactory.h"
  15. #include "stdio.h"
  16. #include "fusioneventlog.h"
  17. #include <ole2.h>
  18. #include "xmlparser.hxx"
  19. #include "xmlparsertest.hxx"
  20. //---------------------------------------------------------------------------
  21. HRESULT STDMETHODCALLTYPE PCMTestFactory::NotifyEvent(
  22. /* [in] */ IXMLNodeSource __RPC_FAR *pSource,
  23. /* [in] */ XML_NODEFACTORY_EVENT iEvt)
  24. {
  25. UNUSED(pSource);
  26. UNUSED(iEvt);
  27. // do nothing because PCM does not contain NotifyEvent record
  28. return NOERROR;
  29. }
  30. //---------------------------------------------------------------------------
  31. HRESULT STDMETHODCALLTYPE PCMTestFactory::BeginChildren(
  32. /* [in] */ IXMLNodeSource __RPC_FAR *pSource,
  33. /* [in] */ XML_NODE_INFO __RPC_FAR *pNodeInfo)
  34. {
  35. HRESULT hr = NOERROR;
  36. UNUSED(pSource);
  37. UNUSED(pNodeInfo);
  38. m_pFileStream->fprintf("BeginChildren\n");
  39. return hr;
  40. }
  41. //---------------------------------------------------------------------------
  42. HRESULT STDMETHODCALLTYPE PCMTestFactory::EndChildren(
  43. /* [in] */ IXMLNodeSource __RPC_FAR *pSource,
  44. /* [in] */ BOOL fEmptyNode,
  45. /* [in] */ XML_NODE_INFO __RPC_FAR *pNodeInfo)
  46. {
  47. HRESULT hr = NOERROR ;
  48. UNUSED(pSource);
  49. UNUSED(fEmptyNode);
  50. UNUSED(pNodeInfo);
  51. m_pFileStream->fprintf("EndChildren");
  52. if ( fEmptyNode ) {
  53. m_pFileStream->fprintf("(fEmpty=TRUE)\n");
  54. }else
  55. m_pFileStream->fprintf("(fEmpty=FALSE)\n");
  56. return hr;
  57. }
  58. VOID PCMTestFactory::PrintXMLNodeType(DWORD dwType)
  59. {
  60. m_pFileStream->fprintf("\t\tdwType = ");
  61. switch(dwType) {
  62. case XML_CDATA:
  63. m_pFileStream->fprintf("XML_CDATA\n");
  64. break;
  65. case XML_COMMENT :
  66. m_pFileStream->fprintf("XML_COMMENT\n");
  67. break ;
  68. case XML_WHITESPACE :
  69. m_pFileStream->fprintf("XML_WHITESPACE\n");
  70. break ;
  71. case XML_ELEMENT :
  72. m_pFileStream->fprintf("XML_ELEMENT\n");
  73. break ;
  74. case XML_ATTRIBUTE :
  75. m_pFileStream->fprintf("XML_ATTRIBUTE\n");
  76. break ;
  77. case XML_PCDATA :
  78. m_pFileStream->fprintf("XML_PCDATA\n");
  79. break ;
  80. case XML_PI:
  81. m_pFileStream->fprintf("XML_PI\n");
  82. break;
  83. case XML_XMLDECL :
  84. m_pFileStream->fprintf("XML_XMLDECL\n");
  85. break;
  86. case XML_DOCTYPE :
  87. m_pFileStream->fprintf("XML_DOCTYPE\n");
  88. break;
  89. case XML_ENTITYDECL :
  90. m_pFileStream->fprintf("XML_ENTITYDECL\n");
  91. break;
  92. case XML_ELEMENTDECL :
  93. m_pFileStream->fprintf("XML_ELEMENTDECL\n");
  94. break;
  95. case XML_ATTLISTDECL :
  96. m_pFileStream->fprintf("XML_ATTLISTDECL\n");
  97. break;
  98. case XML_NOTATION :
  99. m_pFileStream->fprintf("XML_NOTATION\n");
  100. break;
  101. case XML_ENTITYREF :
  102. m_pFileStream->fprintf("XML_ENTITYREF\n");
  103. break;
  104. case XML_DTDATTRIBUTE:
  105. m_pFileStream->fprintf("XML_DTDATTRIBUTE\n");
  106. break;
  107. case XML_GROUP :
  108. m_pFileStream->fprintf("XML_GROUP\n");
  109. break;
  110. case XML_INCLUDESECT :
  111. m_pFileStream->fprintf("XML_INCLUDESECT\n");
  112. break;
  113. case XML_NAME :
  114. m_pFileStream->fprintf("XML_NAME\n");
  115. break;
  116. case XML_NMTOKEN :
  117. m_pFileStream->fprintf("XML_NMTOKEN\n");
  118. break;
  119. case XML_STRING :
  120. m_pFileStream->fprintf("XML_STRING\n");
  121. break;
  122. case XML_PEREF :
  123. m_pFileStream->fprintf("XML_PEREF\n");
  124. break;
  125. case XML_MODEL :
  126. m_pFileStream->fprintf("XML_MODEL\n");
  127. break;
  128. case XML_ATTDEF :
  129. m_pFileStream->fprintf("XML_ATTDEF\n");
  130. break;
  131. case XML_ATTTYPE :
  132. m_pFileStream->fprintf("XML_ATTTYPE\n");
  133. break;
  134. case XML_ATTPRESENCE :
  135. m_pFileStream->fprintf("XML_ATTPRESENCE\n");
  136. break;
  137. case XML_DTDSUBSET :
  138. m_pFileStream->fprintf("XML_DTDSUBSET\n");
  139. break;
  140. case XML_LASTNODETYPE :
  141. m_pFileStream->fprintf("XML_LASTNODETYPE\n");
  142. break;
  143. default :
  144. m_pFileStream->fprintf(" NOT KNOWN TYPE! ERROR!!\n");
  145. } // end of switch
  146. }
  147. //---------------------------------------------------------------------------
  148. HRESULT STDMETHODCALLTYPE PCMTestFactory::CreateNode(
  149. /* [in] */ IXMLNodeSource __RPC_FAR *pSource,
  150. /* [in] */ PVOID pNode,
  151. /* [in] */ USHORT cNumRecs,
  152. /* [in] */ XML_NODE_INFO* __RPC_FAR * __RPC_FAR apNodeInfo)
  153. {
  154. HRESULT hr = NOERROR;
  155. DWORD i;
  156. UNUSED(pSource);
  157. UNUSED(pNode);
  158. UNUSED(apNodeInfo);
  159. UNUSED(cNumRecs);
  160. m_pFileStream->fprintf("CreateNode\n");
  161. for( i = 0; i < cNumRecs; i++)
  162. PrintSingleXMLNode(apNodeInfo[i]);
  163. return hr;
  164. }
  165. VOID PCMTestFactory::PrintSingleXMLNode(XML_NODE_INFO * pNode)
  166. {
  167. m_pFileStream->fprintf("\tXML_NODE_INFO: \n");
  168. m_pFileStream->fprintf("\t\tdwSize = %d \n", pNode->dwSize);
  169. PrintXMLNodeType(pNode->dwType);
  170. m_pFileStream->fprintf("\t\tdwSubType = %d \n", pNode->dwSubType);
  171. m_pFileStream->fprintf("\t\tfTerminal = %d \n", pNode->fTerminal);
  172. m_pFileStream->fwrite((PVOID)(pNode->pwcText), sizeof(WCHAR), pNode->ulLen);
  173. m_pFileStream->fprintf("\t\tulLen = %d \n", pNode->ulLen);
  174. m_pFileStream->fprintf("\t\tulNsPrefixLen = %d \n", pNode->ulNsPrefixLen);
  175. m_pFileStream->fprintf("\t\tpNode = NULL\n");
  176. m_pFileStream->fprintf("\t\tpReserved = NULL \n\n");
  177. }
  178. STDMETHODIMP_(ULONG)
  179. PCMTestFactory::AddRef()
  180. {
  181. return ::SxpInterlockedIncrement(&m_cRef);
  182. }
  183. STDMETHODIMP_(ULONG)
  184. PCMTestFactory::Release()
  185. {
  186. ULONG lRet = ::SxspInterlockedDecrement(&m_cRef);
  187. if (!lRet)
  188. FUSION_DELETE_SINGLETON(this);
  189. return lRet;
  190. }
  191. STDMETHODIMP
  192. PCMTestFactory::QueryInterface(REFIID riid, void** ppv)
  193. {
  194. if (riid == __uuidof(this))
  195. {
  196. *ppv = this;
  197. }
  198. else if (riid == IID_IUnknown
  199. || riid == IID_IXMLNodeFactory)
  200. {
  201. *ppv = static_cast<IXMLNodeFactory*> (this);
  202. }
  203. else
  204. {
  205. *ppv = NULL;
  206. return E_NOINTERFACE;
  207. }
  208. AddRef();
  209. return S_OK;
  210. }
  211. #endif