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.

173 lines
4.2 KiB

  1. #include "stdafx.h"
  2. #define MAX_INFFILE_SIZE 0x60000
  3. #define MAX_LINE_NUMBER 5000
  4. #define MAX_SECTION_NUMBER 1000
  5. const char REPORT_FILE_NAME[] = "d:\\outinf\\report.txt";
  6. const char SRC_INF_PATH[] = "d:\\temp";
  7. const char DEST_INF_PATH[] = "d:\\outinf";
  8. const int FILE_BREAK_SIZE = 0xFFFFFFFF; // 0xFFFFFFFF means dump to only one inf
  9. typedef struct tagCommonAlias
  10. {
  11. DWORD refCount;
  12. LPSTR lpAlias;
  13. LPSTR lpContents;
  14. } COMMON_ALIAS, *PCOMMON_ALIAS, *LPCOMMON_ALIAS;
  15. class CCommonAlias
  16. {
  17. public:
  18. CCommonAlias();
  19. ~CCommonAlias();
  20. VOID ClearAll(VOID);
  21. int GetSize() const { return m_Alias.GetSize(); }
  22. LPCOMMON_ALIAS GetAt(int i) { return (LPCOMMON_ALIAS)m_Alias[i]; }
  23. LPCOMMON_ALIAS AddOneAlias(LPSTR, LPSTR);
  24. private:
  25. CPtrArray m_Alias;
  26. };
  27. typedef struct tagCommonSection
  28. {
  29. DWORD refCount;
  30. TCHAR sectName[32];
  31. TCHAR contents[128];
  32. } COMMON_SECTION, *PCOMMON_SECTION, *LPCOMMON_SECTION;
  33. class CCommonSection
  34. {
  35. public:
  36. CCommonSection();
  37. ~CCommonSection();
  38. VOID ClearAll(VOID);
  39. int GetSize() const { return m_sections.GetSize(); }
  40. LPCOMMON_SECTION GetAt(int i) const { return (LPCOMMON_SECTION)m_sections[i]; }
  41. LPCOMMON_SECTION AddOneSection(LPSTR, LPSTR);
  42. private:
  43. CPtrArray m_sections;
  44. };
  45. typedef struct _SECTION
  46. {
  47. TCHAR name[256];
  48. UINT startLine, endLine;
  49. } SECTION, *PSECTION, *LPSECTION;
  50. class CMonitor
  51. {
  52. public:
  53. CMonitor() { bDupInstSection = FALSE;
  54. pAlias = NULL;
  55. AddRegSectionBuf = NULL;
  56. numCommonSects = 0; }
  57. ~CMonitor() { if (AddRegSectionBuf) free(AddRegSectionBuf); }
  58. public:
  59. BOOL bDupInstSection;
  60. TCHAR AliasName[48];
  61. LPCOMMON_ALIAS pAlias;
  62. TCHAR InstallSectionName[64];
  63. TCHAR AddRegSectionName[64];
  64. TCHAR ID[16];
  65. int numCommonSects;
  66. LPCOMMON_SECTION CommonSects[8];
  67. LPSTR AddRegSectionBuf;
  68. };
  69. class CManufacturer
  70. {
  71. public:
  72. CManufacturer() { pAlias = NULL; }
  73. ~CManufacturer();
  74. public:
  75. TCHAR name[64];
  76. TCHAR AliasName[64];
  77. LPCOMMON_ALIAS pAlias;
  78. CPtrArray MonitorArray;
  79. CPtrArray m_MonitorIDArray;
  80. };
  81. class CMonitorInf
  82. {
  83. public:
  84. CMonitorInf() { pReadFileBuf = NULL; }
  85. public:
  86. LPSTR pReadFileBuf;
  87. UINT numLines;
  88. LPSTR lines[MAX_LINE_NUMBER];
  89. UINT numSections;
  90. SECTION sections[MAX_SECTION_NUMBER];
  91. CPtrArray ManufacturerArray;
  92. private:
  93. CHAR m_lineBuf[256];
  94. LPSTR m_tokens[10];
  95. public:
  96. ~CMonitorInf();
  97. LPSECTION SeekSection(LPCSTR);
  98. BOOL ParseInf(VOID);
  99. private:
  100. BOOL ParseOneManufacturer(CManufacturer *);
  101. BOOL ParseOneMonitor(CMonitor *);
  102. VOID Pack(VOID);
  103. BOOL FillupAlias(VOID);
  104. LPCOMMON_ALIAS LookupCommonAlias(LPCSTR, LPCOMMON_ALIAS, UINT);
  105. };
  106. class CSumInf
  107. {
  108. public:
  109. CSumInf();
  110. ~CSumInf();
  111. VOID Initialize(LPCSTR);
  112. VOID AddOneManufacturer(CManufacturer*);
  113. VOID CheckDupSections(VOID);
  114. VOID CheckDupMonIDs(VOID);
  115. VOID CheckDupAlias(VOID);
  116. VOID DumpMonitorInf(LPCSTR, int);
  117. private:
  118. VOID MergeOneManufacturer(CManufacturer *, CManufacturer *);
  119. int DumpManufacturers(LPCSTR, int, int, int);
  120. VOID DumpManufactureSection(FILE *, CManufacturer *);
  121. VOID DumpInstallSection(FILE *, CManufacturer *);
  122. VOID DumpCommonAddRegSection(FILE *, int, int);
  123. VOID DumpAddRegSection(FILE *, CManufacturer *);
  124. VOID DumpCommonStringSection(FILE *, int, int);
  125. VOID DumpCommonHeader(FILE *, int);
  126. private:
  127. CPtrArray m_ManufacturerArray;
  128. CPtrArray m_SectionNameArray;
  129. public:
  130. FILE *m_fpReport;
  131. };
  132. ///////////////////////////////////////////////////////////
  133. // Global variables
  134. extern CCommonSection gCommonSections;
  135. extern CCommonAlias gCommonAlias;
  136. extern CSumInf gSumInf;
  137. extern TCHAR gszMsg[];
  138. extern TCHAR gszInputFileName[];
  139. ///////////////////////////////////////////////////////////
  140. // Global Functions
  141. extern VOID TokenizeInf(LPSTR, CMonitorInf *);
  142. extern UINT TokenOneLine(LPSTR, CHAR, LPSTR);
  143. extern VOID ReadOneMonitorInf(LPCSTR, CMonitorInf *);