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.

235 lines
6.5 KiB

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