1 /* 2 * PROJECT: .inf file parser 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PROGRAMMER: Royce Mitchell III 5 * Eric Kohl 6 * Ge van Geldorp <gvg@reactos.org> 7 */ 8 9 #pragma once 10 11 #ifndef FIELD_OFFSET 12 #define FIELD_OFFSET(t,f) ((ptrdiff_t)&(((t*)0)->f)) 13 #endif 14 15 #define INF_STATUS_INSUFFICIENT_RESOURCES ((INFSTATUS)0xC000009A) 16 #define INF_STATUS_BAD_SECTION_NAME_LINE ((INFSTATUS)0xC0700001) 17 #define INF_STATUS_SECTION_NAME_TOO_LONG ((INFSTATUS)0xC0700002) 18 #define INF_STATUS_WRONG_INF_STYLE ((INFSTATUS)0xC0700003) 19 #define INF_STATUS_NOT_ENOUGH_MEMORY ((INFSTATUS)0xC0700004) 20 21 typedef struct _INFCACHEFIELD 22 { 23 struct _INFCACHEFIELD *Next; 24 struct _INFCACHEFIELD *Prev; 25 26 WCHAR Data[1]; 27 } INFCACHEFIELD, *PINFCACHEFIELD; 28 29 typedef struct _INFCACHELINE 30 { 31 struct _INFCACHELINE *Next; 32 struct _INFCACHELINE *Prev; 33 UINT Id; 34 35 LONG FieldCount; 36 37 PWCHAR Key; 38 39 PINFCACHEFIELD FirstField; 40 PINFCACHEFIELD LastField; 41 42 } INFCACHELINE, *PINFCACHELINE; 43 44 typedef struct _INFCACHESECTION 45 { 46 struct _INFCACHESECTION *Next; 47 struct _INFCACHESECTION *Prev; 48 49 PINFCACHELINE FirstLine; 50 PINFCACHELINE LastLine; 51 UINT Id; 52 53 LONG LineCount; 54 UINT NextLineId; 55 56 WCHAR Name[1]; 57 } INFCACHESECTION, *PINFCACHESECTION; 58 59 typedef struct _INFCACHE 60 { 61 LANGID LanguageId; 62 PINFCACHESECTION FirstSection; 63 PINFCACHESECTION LastSection; 64 UINT NextSectionId; 65 66 PINFCACHESECTION StringsSection; 67 } INFCACHE, *PINFCACHE; 68 69 typedef struct _INFCONTEXT 70 { 71 PINFCACHE Inf; 72 PINFCACHE CurrentInf; 73 UINT Section; 74 UINT Line; 75 } INFCONTEXT; 76 77 typedef int INFSTATUS; 78 79 /* FUNCTIONS ****************************************************************/ 80 81 extern INFSTATUS InfpParseBuffer(PINFCACHE file, 82 const WCHAR *buffer, 83 const WCHAR *end, 84 PULONG error_line); 85 extern PINFCACHESECTION InfpFreeSection(PINFCACHESECTION Section); 86 extern PINFCACHESECTION InfpAddSection(PINFCACHE Cache, 87 PCWSTR Name); 88 extern PINFCACHELINE InfpAddLine(PINFCACHESECTION Section); 89 extern PVOID InfpAddKeyToLine(PINFCACHELINE Line, 90 PCWSTR Key); 91 extern PVOID InfpAddFieldToLine(PINFCACHELINE Line, 92 PCWSTR Data); 93 extern PINFCACHELINE InfpFindKeyLine(PINFCACHESECTION Section, 94 PCWSTR Key); 95 extern PINFCACHESECTION InfpFindSection(PINFCACHE Cache, 96 PCWSTR Section); 97 98 extern INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, 99 PWCHAR *Buffer, 100 PULONG BufferSize); 101 102 extern INFSTATUS InfpFindFirstLine(PINFCACHE InfHandle, 103 PCWSTR Section, 104 PCWSTR Key, 105 PINFCONTEXT *Context); 106 extern INFSTATUS InfpFindNextLine(PINFCONTEXT ContextIn, 107 PINFCONTEXT ContextOut); 108 extern INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn, 109 PCWSTR Key, 110 PINFCONTEXT ContextOut); 111 extern INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn, 112 PCWSTR Key, 113 PINFCONTEXT ContextOut); 114 extern LONG InfpGetLineCount(HINF InfHandle, 115 PCWSTR Section); 116 extern LONG InfpGetFieldCount(PINFCONTEXT Context); 117 extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context, 118 ULONG FieldIndex, 119 PUCHAR ReturnBuffer, 120 ULONG ReturnBufferSize, 121 PULONG RequiredSize); 122 extern INFSTATUS InfpGetIntField(PINFCONTEXT Context, 123 ULONG FieldIndex, 124 INT *IntegerValue); 125 extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, 126 ULONG FieldIndex, 127 PWSTR ReturnBuffer, 128 ULONG ReturnBufferSize, 129 PULONG RequiredSize); 130 extern INFSTATUS InfpGetStringField(PINFCONTEXT Context, 131 ULONG FieldIndex, 132 PWSTR ReturnBuffer, 133 ULONG ReturnBufferSize, 134 PULONG RequiredSize); 135 extern INFSTATUS InfpGetData(PINFCONTEXT Context, 136 PWCHAR *Key, 137 PWCHAR *Data); 138 extern INFSTATUS InfpGetDataField(PINFCONTEXT Context, 139 ULONG FieldIndex, 140 PWCHAR *Data); 141 142 extern INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, 143 PCWSTR Section, 144 PINFCONTEXT *Context); 145 extern INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key); 146 extern INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data); 147 148 extern VOID InfpFreeContext(PINFCONTEXT Context); 149 PINFCACHELINE 150 InfpFindLineById(PINFCACHESECTION Section, UINT Id); 151 PINFCACHESECTION 152 InfpGetSectionForContext(PINFCONTEXT Context); 153 PINFCACHELINE 154 InfpGetLineForContext(PINFCONTEXT Context); 155 156 /* EOF */ 157