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.

182 lines
3.9 KiB

  1. //++
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CXMLParser.h
  7. //
  8. // Abstract: ( references CXMLParser.cpp )
  9. // This file contains the functions used by Filelist in order to real the
  10. // XML encoded list of files/directories. It also performs translations
  11. // between symbols like %windir% to C:\windows
  12. //
  13. // Revision History:
  14. // Eugene Mesgar (eugenem) 6/16/99
  15. // created
  16. // Kanwaljit Marok (kmarok) 6/06/00
  17. // ported
  18. //
  19. //--
  20. #ifndef _XMLFILELISTPARSER_H
  21. #define _XMLFILELISTPARSER_H
  22. #ifndef MAX_BUFFER
  23. #define MAX_BUFFER 1500
  24. #endif
  25. #define MAX_REPLACE_ENTRIES 50
  26. #define NUM_FILE_TYPES 3
  27. #define INCLUDE_COLL 0
  28. #define EXCLUDE_COLL 1
  29. #define SNAPSHOT_COLL 2
  30. #include <xmlparser.h>
  31. //
  32. // Public File type
  33. //
  34. #define INCLUDE_TYPE _TEXT('i')
  35. #define EXCLUDE_TYPE _TEXT('e')
  36. #define SNAPSHOT_TYPE _TEXT('s')
  37. class CXMLFileListParser
  38. {
  39. //
  40. // # of times we've initialized the com space
  41. //
  42. LONG m_clComInitialized;
  43. //
  44. // references the currently open document
  45. //
  46. IXMLDocument *m_pDoc;
  47. //
  48. // references the named sub collection
  49. //
  50. IXMLElementCollection *m_pDir[NUM_FILE_TYPES];
  51. IXMLElementCollection *m_pFiles[NUM_FILE_TYPES];
  52. IXMLElementCollection *m_pExt[NUM_FILE_TYPES];
  53. //
  54. // version
  55. //
  56. DWORD m_adwVersion[4];
  57. //
  58. // default node type
  59. //
  60. TCHAR m_chDefaultType;
  61. public:
  62. BOOL Init(LPCTSTR pszFile);
  63. BOOL Init();
  64. //
  65. // return symbol translated versions
  66. // pchType values == 'S', 'I', 'E' (snapshot,include,exclude)
  67. //
  68. LONG GetDirectory(LONG ilElement,
  69. LPTSTR pszBuf,
  70. LONG lBufMax,
  71. TCHAR chType);
  72. LONG GetDirectory(LONG ilElement,
  73. LPTSTR pszBuf,
  74. LONG lBufMax,
  75. TCHAR chType,
  76. BOOL *pfDisable);
  77. LONG GetExt (LONG ilElement, LPTSTR pszBuf, LONG lBufMax, TCHAR chType);
  78. LONG GetFile(LONG ilElement, LPTSTR pszBuf, LONG lBufMax, TCHAR chType);
  79. //
  80. // file list version info ( pointer to 4 dword array );
  81. //
  82. BOOL GetVersion(LPDWORD pdwVersion);
  83. //
  84. // get the default type
  85. //
  86. TCHAR GetDefaultType();
  87. //
  88. // return the number of elements in the sets
  89. //
  90. LONG GetDirectoryCount(TCHAR chType);
  91. LONG GetExtCount(TCHAR chType);
  92. LONG GetFileCount(TCHAR chType);
  93. //
  94. // Debug function to print current file translations supported.
  95. //
  96. void DebugPrintTranslations();
  97. CXMLFileListParser();
  98. virtual ~CXMLFileListParser();
  99. private:
  100. //
  101. // load & unloading the symbolic location->true location mappings
  102. // there is just dummy code in here which hard codes some generic mapping.
  103. //
  104. BOOL PopulateReplaceEntries();
  105. BOOL DepopulateReplaceEntries();
  106. //
  107. // inplace search and function which search&replaces on the
  108. // symbol->location mappings
  109. //
  110. LONG SearchAndReplace(LPTSTR szBuf, LONG lMaxBuf);
  111. //
  112. // the true guts of the GetExt/File/Directory functions
  113. //
  114. LONG GetFileInfo(IXMLElementCollection *pCol,
  115. LONG ilElement,
  116. LPTSTR pszBuf,
  117. LONG lBufMax,
  118. BOOL *pfDisable);
  119. BOOL LoadOneCollection(IXMLElement *pColHead,
  120. IXMLElementCollection **pCol );
  121. LONG GetCollectionSize(IXMLElementCollection *pCol);
  122. //
  123. // init broken down
  124. //
  125. BOOL ParseFile(LPCTSTR pszFile);
  126. BOOL LoadCollections();
  127. BOOL ParseVersion(IXMLElement *pVerElement);
  128. //
  129. // helper functions
  130. //
  131. LONG ConvertAndFreeBSTR(BSTR bstrIn, LPTSTR szpOut, LONG lMaxBuf);
  132. LONG TranslateType(TCHAR chType);
  133. };
  134. #endif