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.

279 lines
6.1 KiB

  1. #define STF_HASH_BUCKETS 509
  2. #define BUCKET_GROW_RATE 32
  3. typedef struct {
  4. UINT Count;
  5. UINT Size;
  6. UINT Elements[];
  7. } HASHBUCKET, *PHASHBUCKET;
  8. typedef struct _tagTABLEENTRY {
  9. //
  10. // Entry string members
  11. //
  12. PCTSTR String;
  13. BOOL StringReplaced;
  14. BOOL Quoted;
  15. BOOL Binary;
  16. // If more added, update pFreeTableEntryPtr
  17. //
  18. // Linkage
  19. //
  20. UINT Line;
  21. struct _tagTABLEENTRY *Next, *Prev;
  22. } TABLEENTRY, *PTABLEENTRY;
  23. typedef struct {
  24. PTABLEENTRY FirstCol; // The head of the column list
  25. } TABLELINE, *PTABLELINE;
  26. typedef struct _tagSTFINFLINE {
  27. PCTSTR Key; OPTIONAL
  28. PCTSTR Data;
  29. DWORD LineFlags;
  30. struct _tagSTFINFLINE *Next, *Prev;
  31. struct _tagSTFINFSECTION *Section;
  32. } STFINFLINE, *PSTFINFLINE;
  33. #define LINEFLAG_KEY_QUOTED 0x0001
  34. #define LINEFLAG_ALL_COMMENTS 0x0002
  35. #define LINEFLAG_TRAILING_COMMENTS 0x0004
  36. typedef struct _tagSTFINFSECTION {
  37. PCTSTR Name;
  38. PSTFINFLINE FirstLine;
  39. PSTFINFLINE LastLine;
  40. UINT LineCount;
  41. struct _tagSTFINFSECTION *Next, *Prev;
  42. } STFINFSECTION, *PSTFINFSECTION;
  43. typedef struct {
  44. //
  45. // File spec
  46. //
  47. PCTSTR DirSpec;
  48. PCTSTR SourceStfFileSpec;
  49. PCTSTR SourceInfFileSpec;
  50. PCTSTR DestStfFileSpec;
  51. PCTSTR DestInfFileSpec;
  52. HANDLE SourceStfFile;
  53. HANDLE SourceInfFile;
  54. HANDLE DestStfFile;
  55. HANDLE DestInfFile;
  56. HINF SourceInfHandle;
  57. //
  58. // Memory structure of setup table
  59. //
  60. HANDLE FileMapping; // handle for performing file mapping of SourceStfFileSpec
  61. PCSTR FileText; // A pointer to the mapped text
  62. GROWBUFFER Lines; // An array of PTABLELINE pointers
  63. UINT LineCount; // The number of elements in the array
  64. POOLHANDLE ColumnStructPool; // A pool for TABLEENTRY structs
  65. POOLHANDLE ReplacePool; // A pool for TABLEENTRY strings that are replaced
  66. POOLHANDLE TextPool; // A pool for TABLEENTRY strings converted to UNICODE
  67. POOLHANDLE InfPool; // A pool for appended INF data
  68. PHASHBUCKET * HashBuckets; // A pointer to an array of HASKBUCKET structs
  69. UINT MaxObj; // The highest sequencer used for an object line
  70. PSTFINFSECTION FirstInfSection; // The first section of the parsed INF
  71. PSTFINFSECTION LastInfSection; // The last section of the parsed INF
  72. BOOL InfIsUnicode;
  73. } SETUPTABLE, *PSETUPTABLE;
  74. #define INSERT_COL_LAST 0xffffffff
  75. #define NO_OFFSET 0xffffffff
  76. #define NO_LENGTH 0xffffffff
  77. #define NO_LINE 0xffffffff
  78. #define INVALID_COL 0xffffffff
  79. #define INSERT_LINE_LAST 0xffffffff
  80. BOOL
  81. CreateSetupTable (
  82. IN PCTSTR SourceStfFileSpec,
  83. OUT PSETUPTABLE TablePtr
  84. );
  85. BOOL
  86. WriteSetupTable (
  87. IN PSETUPTABLE TablePtr
  88. );
  89. VOID
  90. DestroySetupTable (
  91. IN OUT PSETUPTABLE TablePtr
  92. );
  93. PTABLEENTRY
  94. FindTableEntry (
  95. IN PSETUPTABLE TablePtr,
  96. IN PCTSTR FirstColText,
  97. IN UINT Col,
  98. OUT PUINT Line, OPTIONAL
  99. OUT PCTSTR *String OPTIONAL
  100. );
  101. PTABLEENTRY
  102. GetTableEntry (
  103. IN PSETUPTABLE TablePtr,
  104. IN UINT Line,
  105. IN UINT Col,
  106. OUT PCTSTR *StringPtr OPTIONAL
  107. );
  108. PCTSTR
  109. GetTableEntryStr (
  110. IN PSETUPTABLE TablePtr,
  111. IN PTABLEENTRY TableEntry
  112. );
  113. BOOL
  114. ReplaceTableEntryStr (
  115. IN OUT PSETUPTABLE TablePtr,
  116. IN OUT PTABLEENTRY TableEntryPtr,
  117. IN PCTSTR NewString
  118. );
  119. BOOL
  120. InsertTableEntryStr (
  121. IN OUT PSETUPTABLE TablePtr,
  122. IN PTABLEENTRY InsertBeforePtr,
  123. IN PCTSTR NewString
  124. );
  125. BOOL
  126. DeleteTableEntryStr (
  127. IN OUT PSETUPTABLE TablePtr,
  128. IN PTABLEENTRY DeleteEntryPtr
  129. );
  130. BOOL
  131. AppendTableEntryStr (
  132. IN OUT PSETUPTABLE TablePtr,
  133. IN UINT Line,
  134. IN PCTSTR NewString
  135. );
  136. BOOL
  137. AppendTableEntry (
  138. IN OUT PSETUPTABLE TablePtr,
  139. IN UINT DestLine,
  140. IN PTABLEENTRY SrcEntry
  141. );
  142. BOOL
  143. InsertEmptyLineInTable (
  144. IN OUT PSETUPTABLE TablePtr,
  145. IN UINT InsertBeforeLine
  146. );
  147. BOOL
  148. DeleteLineInTable (
  149. IN OUT PSETUPTABLE TablePtr,
  150. IN UINT LineToDelete
  151. );
  152. PCTSTR *
  153. ParseCommaList (
  154. IN PSETUPTABLE TablePtr,
  155. IN PCTSTR CommaListString
  156. );
  157. VOID
  158. FreeCommaList (
  159. IN PSETUPTABLE TablePtr,
  160. IN PCTSTR *ArgList
  161. );
  162. PCTSTR
  163. GetDestDir (
  164. IN PSETUPTABLE TablePtr,
  165. IN UINT Line
  166. );
  167. VOID
  168. FreeDestDir (
  169. IN PSETUPTABLE TablePtr,
  170. IN PCTSTR DestDir
  171. );
  172. PSTFINFSECTION
  173. StfAddInfSectionToTable (
  174. IN PSETUPTABLE TablePtr,
  175. IN PCTSTR SectionName
  176. );
  177. PSTFINFLINE
  178. StfAddInfLineToTable (
  179. IN PSETUPTABLE TablePtr,
  180. IN PSTFINFSECTION SectionPtr,
  181. IN PCTSTR Key, OPTIONAL
  182. IN PCTSTR Data,
  183. IN DWORD LineFlags
  184. );
  185. PSTFINFSECTION
  186. StfFindInfSectionInTable (
  187. IN PSETUPTABLE TablePtr,
  188. IN PCTSTR SectionName
  189. );
  190. PSTFINFLINE
  191. StfFindLineInInfSection (
  192. IN PSETUPTABLE TablePtr,
  193. IN PSTFINFSECTION Section,
  194. IN PCTSTR Key
  195. );
  196. BOOL
  197. StfDeleteLineInInfSection (
  198. IN OUT PSETUPTABLE TablePtr,
  199. IN PSTFINFLINE InfLine
  200. );
  201. BOOL
  202. StfDeleteSectionInInfFile (
  203. IN OUT PSETUPTABLE TablePtr,
  204. IN PSTFINFSECTION Section
  205. );
  206. UINT
  207. StfGetInfSectionLineCount (
  208. IN PSTFINFSECTION Section
  209. );
  210. PSTFINFLINE
  211. StfGetFirstLineInSectionStruct (
  212. IN PSTFINFSECTION Section
  213. );
  214. PSTFINFLINE
  215. StfGetNextLineInSection (
  216. IN PSTFINFLINE PrevLine
  217. );
  218. PSTFINFLINE
  219. StfGetFirstLineInSectionStr (
  220. IN PSETUPTABLE Table,
  221. IN PCTSTR Section
  222. );
  223. BOOL
  224. InfParse_ReadInfIntoTable (
  225. IN OUT PSETUPTABLE TablePtr
  226. );
  227. BOOL
  228. InfParse_WriteInfToDisk (
  229. IN PSETUPTABLE TablePtr
  230. );