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.

237 lines
5.8 KiB

  1. #pragma once
  2. extern const string ASM_NAMESPACE_URI;
  3. extern string g_CdfOutputPath;
  4. extern string g_AsmsBuildRootPath;
  5. #define AWFUL_SPACE_HACK TRUE
  6. HRESULT
  7. SxspSimplifyGetAttribute(
  8. ATL::CComPtr<IXMLDOMNamedNodeMap> Attributes,
  9. string bstAttribName,
  10. string &bstDestination,
  11. string bstNamespaceURI = ASM_NAMESPACE_URI
  12. );
  13. HRESULT
  14. SxspSimplifyPutAttribute(
  15. ATL::CComPtr<IXMLDOMDocument> Document,
  16. ATL::CComPtr<IXMLDOMNamedNodeMap> Attributes,
  17. const string bstAttribName,
  18. const string bstValue,
  19. const string bstNamespaceURI = ASM_NAMESPACE_URI
  20. );
  21. HRESULT
  22. SxspExtractPathPieces(
  23. _bstr_t bstSourceName,
  24. _bstr_t &bstPath,
  25. _bstr_t &bstName
  26. );
  27. HRESULT
  28. CreateDocumentNode(
  29. VARIANT vt,
  30. _bstr_t bstAttribName,
  31. _bstr_t bstNamespace,
  32. IXMLDOMNode **pNewNode
  33. );
  34. HRESULT
  35. ConstructXMLDOMObject(
  36. string SourceName,
  37. ATL::CComPtr<IXMLDOMDocument> &result
  38. );
  39. template<class T> class CListing {
  40. private:
  41. int iListLength, iListMaxLength;
  42. T* pListData;
  43. void _ExpandList( int newamount )
  44. {
  45. T* pNewListData = new T[newamount];
  46. if ( pListData )
  47. {
  48. for ( int i = 0; i < iListLength; i++ )
  49. {
  50. pNewListData[i] = pListData[i];
  51. }
  52. delete[] pListData;
  53. }
  54. pListData = pNewListData;
  55. iListMaxLength = newamount;
  56. }
  57. public:
  58. int GetLength() { return iListLength; }
  59. void ClearList() { if ( pListData ) delete[] pListData; };
  60. CListing()
  61. {
  62. iListLength = 0;
  63. pListData = new T[iListMaxLength = 10];
  64. }
  65. ~CListing()
  66. {
  67. ClearList();
  68. }
  69. BOOL Contains( T item )
  70. {
  71. for ( int i = 0; i < iListLength; i++ ) {
  72. if ( pListData[i] == item ) return TRUE;
  73. }
  74. return FALSE;
  75. }
  76. void Add( T item )
  77. {
  78. if ( iListLength >= iListMaxLength )
  79. {
  80. _ExpandList( iListMaxLength + 10 );
  81. }
  82. pListData[iListLength++] = item;
  83. }
  84. T& Get( int i ) {
  85. if ( i >= iListMaxLength )
  86. {
  87. _ExpandList( i + 10 );
  88. }
  89. return pListData[i];
  90. }
  91. };
  92. enum ErrorLevel
  93. {
  94. ErrorFatal,
  95. ErrorWarning,
  96. ErrorSpew
  97. };
  98. extern bool g_bDisplaySpew, g_bDisplayWarnings;
  99. static inline void ReportError( ErrorLevel el, stringstream& message )
  100. {
  101. if ( ( el == ErrorSpew ) && g_bDisplaySpew )
  102. cout << "SPEW: " << message.str() << endl;
  103. else if ( ( el == ErrorWarning ) && g_bDisplayWarnings )
  104. cout << "WARNING: " << message.str() << endl;
  105. else if ( el == ErrorFatal )
  106. cerr << "ERROR: " << message.str() << endl;
  107. }
  108. class CPostbuildProcessListEntry
  109. {
  110. private:
  111. string manifestFullPath;
  112. string manifestFileName;
  113. string manifestPathOnly;
  114. public:
  115. string version;
  116. string name;
  117. string language;
  118. ATL::CComPtr<IXMLDOMDocument> DocumentPointer;
  119. string getManifestFullPath() const { return manifestFullPath; }
  120. string getManifestFileName() const { return manifestFileName; }
  121. string getManifestPathOnly() const { return manifestPathOnly; }
  122. void setManifestLocation( string root, string where );
  123. bool operator==(const CPostbuildProcessListEntry& right) const
  124. {
  125. return !(*this < right) && !(right < *this);
  126. }
  127. static bool stringPointerLessThan(const std::string* x, const std::string* y)
  128. {
  129. return x->compare(*y) < 0;
  130. }
  131. bool operator<(const CPostbuildProcessListEntry& right) const
  132. {
  133. // the order is arbitrary,
  134. const std::string* leftStrings[] =
  135. { &this->name, &this->version, &this->language, &this->manifestFullPath, &this->manifestFileName, &this->manifestPathOnly };
  136. const std::string* rightStrings[] =
  137. { &right.name, &right.version, &right.language, &right.manifestFullPath, &right.manifestFileName, &right.manifestPathOnly };
  138. return std::lexicographical_compare(
  139. leftStrings, leftStrings + NUMBER_OF(leftStrings),
  140. rightStrings, rightStrings + NUMBER_OF(rightStrings),
  141. stringPointerLessThan
  142. );
  143. }
  144. friend ostream& operator<<(ostream& ost, const CPostbuildProcessListEntry& thing );
  145. };
  146. typedef vector<CPostbuildProcessListEntry> CPostbuildItemVector;
  147. extern CPostbuildItemVector PostbuildEntries;
  148. class CFileStreamBase : public IStream
  149. {
  150. public:
  151. CFileStreamBase()
  152. : m_cRef(0),
  153. m_hFile(INVALID_HANDLE_VALUE),
  154. m_bSeenFirstCharacter(false)
  155. { }
  156. virtual ~CFileStreamBase();
  157. bool OpenForRead( string pszPath );
  158. bool OpenForWrite( string pszPath );
  159. bool Close();
  160. // IUnknown methods:
  161. STDMETHODIMP_(ULONG) AddRef();
  162. STDMETHODIMP_(ULONG) Release();
  163. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
  164. // ISequentialStream methods:
  165. STDMETHODIMP Read(void *pv, ULONG cb, ULONG *pcbRead);
  166. STDMETHODIMP Write(void const *pv, ULONG cb, ULONG *pcbWritten);
  167. // IStream methods:
  168. STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  169. STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize);
  170. STDMETHODIMP CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
  171. STDMETHODIMP Commit(DWORD grfCommitFlags);
  172. STDMETHODIMP Revert();
  173. STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  174. STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  175. STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  176. STDMETHODIMP Clone(IStream **ppIStream);
  177. protected:
  178. LONG m_cRef;
  179. HANDLE m_hFile;
  180. bool m_bSeenFirstCharacter;
  181. private:
  182. CFileStreamBase(const CFileStreamBase &r); // intentionally not implemented
  183. CFileStreamBase &operator =(const CFileStreamBase &r); // intentionally not implemented
  184. };
  185. wstring SwitchStringRep( const string& );
  186. string SwitchStringRep( const wstring& );
  187. typedef std::map<wstring, wstring> StringStringMap;
  188. typedef std::map<wstring, wstring> StringStringPair;
  189. typedef wstring InvalidEquivalence;
  190. StringStringMap MapFromDefLine( const wstring& source );
  191. string JustifyPath( const string& path );