ReactOS 0.4.16-dev-338-g34e76ad
infpriv.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INFCACHEFIELD
 
struct  _INFCACHELINE
 
struct  _INFCACHESECTION
 
struct  _INFCACHE
 
struct  _INFCONTEXT
 

Macros

#define FIELD_OFFSET(t, f)   ((ptrdiff_t)&(((t*)0)->f))
 
#define INF_STATUS_INSUFFICIENT_RESOURCES   ((INFSTATUS)0xC000009A)
 
#define INF_STATUS_BAD_SECTION_NAME_LINE   ((INFSTATUS)0xC0700001)
 
#define INF_STATUS_SECTION_NAME_TOO_LONG   ((INFSTATUS)0xC0700002)
 
#define INF_STATUS_WRONG_INF_STYLE   ((INFSTATUS)0xC0700003)
 
#define INF_STATUS_NOT_ENOUGH_MEMORY   ((INFSTATUS)0xC0700004)
 

Typedefs

typedef struct _INFCACHEFIELD INFCACHEFIELD
 
typedef struct _INFCACHEFIELDPINFCACHEFIELD
 
typedef struct _INFCACHELINE INFCACHELINE
 
typedef struct _INFCACHELINEPINFCACHELINE
 
typedef struct _INFCACHESECTION INFCACHESECTION
 
typedef struct _INFCACHESECTIONPINFCACHESECTION
 
typedef struct _INFCACHE INFCACHE
 
typedef struct _INFCACHEPINFCACHE
 
typedef struct _INFCONTEXT INFCONTEXT
 
typedef int INFSTATUS
 

Functions

INFSTATUS InfpParseBuffer (PINFCACHE file, const WCHAR *buffer, const WCHAR *end, PULONG error_line)
 
PINFCACHESECTION InfpFreeSection (PINFCACHESECTION Section)
 
PINFCACHESECTION InfpAddSection (PINFCACHE Cache, PCWSTR Name)
 
PINFCACHELINE InfpAddLine (PINFCACHESECTION Section)
 
PVOID InfpAddKeyToLine (PINFCACHELINE Line, PCWSTR Key)
 
PVOID InfpAddFieldToLine (PINFCACHELINE Line, PCWSTR Data)
 
PINFCACHELINE InfpFindKeyLine (PINFCACHESECTION Section, PCWSTR Key)
 
PINFCACHESECTION InfpFindSection (PINFCACHE Cache, PCWSTR Section)
 
INFSTATUS InfpBuildFileBuffer (PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
 
INFSTATUS InfpFindFirstLine (PINFCACHE InfHandle, PCWSTR Section, PCWSTR Key, PINFCONTEXT *Context)
 
INFSTATUS InfpFindNextLine (PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
 
INFSTATUS InfpFindFirstMatchLine (PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
 
INFSTATUS InfpFindNextMatchLine (PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
 
LONG InfpGetLineCount (HINF InfHandle, PCWSTR Section)
 
LONG InfpGetFieldCount (PINFCONTEXT Context)
 
INFSTATUS InfpGetBinaryField (PINFCONTEXT Context, ULONG FieldIndex, PUCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
INFSTATUS InfpGetIntField (PINFCONTEXT Context, ULONG FieldIndex, INT *IntegerValue)
 
INFSTATUS InfpGetMultiSzField (PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
INFSTATUS InfpGetStringField (PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
INFSTATUS InfpGetData (PINFCONTEXT Context, PWCHAR *Key, PWCHAR *Data)
 
INFSTATUS InfpGetDataField (PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
 
INFSTATUS InfpFindOrAddSection (PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context)
 
INFSTATUS InfpAddLineWithKey (PINFCONTEXT Context, PCWSTR Key)
 
INFSTATUS InfpAddField (PINFCONTEXT Context, PCWSTR Data)
 
VOID InfpFreeContext (PINFCONTEXT Context)
 
PINFCACHELINE InfpFindLineById (PINFCACHESECTION Section, UINT Id)
 
PINFCACHESECTION InfpGetSectionForContext (PINFCONTEXT Context)
 
PINFCACHELINE InfpGetLineForContext (PINFCONTEXT Context)
 

Macro Definition Documentation

◆ FIELD_OFFSET

#define FIELD_OFFSET (   t,
  f 
)    ((ptrdiff_t)&(((t*)0)->f))

Definition at line 12 of file infpriv.h.

◆ INF_STATUS_BAD_SECTION_NAME_LINE

#define INF_STATUS_BAD_SECTION_NAME_LINE   ((INFSTATUS)0xC0700001)

Definition at line 16 of file infpriv.h.

◆ INF_STATUS_INSUFFICIENT_RESOURCES

#define INF_STATUS_INSUFFICIENT_RESOURCES   ((INFSTATUS)0xC000009A)

Definition at line 15 of file infpriv.h.

◆ INF_STATUS_NOT_ENOUGH_MEMORY

#define INF_STATUS_NOT_ENOUGH_MEMORY   ((INFSTATUS)0xC0700004)

Definition at line 19 of file infpriv.h.

◆ INF_STATUS_SECTION_NAME_TOO_LONG

#define INF_STATUS_SECTION_NAME_TOO_LONG   ((INFSTATUS)0xC0700002)

Definition at line 17 of file infpriv.h.

◆ INF_STATUS_WRONG_INF_STYLE

#define INF_STATUS_WRONG_INF_STYLE   ((INFSTATUS)0xC0700003)

Definition at line 18 of file infpriv.h.

Typedef Documentation

◆ INFCACHE

◆ INFCACHEFIELD

◆ INFCACHELINE

◆ INFCACHESECTION

◆ INFCONTEXT

◆ INFSTATUS

typedef int INFSTATUS

Definition at line 77 of file infpriv.h.

◆ PINFCACHE

◆ PINFCACHEFIELD

◆ PINFCACHELINE

◆ PINFCACHESECTION

Function Documentation

◆ InfpAddField()

INFSTATUS InfpAddField ( PINFCONTEXT  Context,
PCWSTR  Data 
)

Definition at line 254 of file infput.c.

255{
257
258 if (NULL == Context)
259 {
260 DPRINT1("Invalid parameter\n");
262 }
263
266 {
267 DPRINT("Failed to add field\n");
269 }
270
271 return INF_STATUS_SUCCESS;
272}
#define DPRINT1
Definition: precomp.h:8
#define INF_STATUS_INVALID_PARAMETER
Definition: builddep.h:79
#define INF_STATUS_SUCCESS
Definition: builddep.h:77
#define INF_STATUS_NO_MEMORY
Definition: builddep.h:78
#define NULL
Definition: types.h:112
PINFCACHELINE InfpGetLineForContext(PINFCONTEXT Context)
Definition: infcore.c:310
static PVOID InfpAddFieldToLine(PINFCACHELINE Line, PCSTR Data)
Definition: inffile.c:331
#define DPRINT
Definition: sndvol32.h:73
Definition: ncftp.h:79

Referenced by InfHostAddField().

◆ InfpAddFieldToLine()

PVOID InfpAddFieldToLine ( PINFCACHELINE  Line,
PCWSTR  Data 
)

Definition at line 353 of file infcore.c.

355{
356 PINFCACHEFIELD Field;
357 ULONG Size;
358
360 Data[strlenW(Data) + 1]);
361 Field = (PINFCACHEFIELD)MALLOC(Size);
362 if (Field == NULL)
363 {
364 DPRINT1("MALLOC() failed\n");
365 return NULL;
366 }
367 ZEROMEMORY (Field,
368 Size);
369 strcpyW(Field->Data, Data);
370
371 /* Append key */
372 if (Line->FirstField == NULL)
373 {
374 Line->FirstField = Field;
375 Line->LastField = Field;
376 }
377 else
378 {
379 Line->LastField->Next = Field;
380 Field->Prev = Line->LastField;
381 Line->LastField = Field;
382 }
383 Line->FieldCount++;
384
385 return (PVOID)Field;
386}
#define MALLOC(Size)
Definition: builddep.h:73
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74
struct _INFCACHEFIELD * PINFCACHEFIELD
#define strlenW(s)
Definition: unicode.h:34
#define strcpyW(d, s)
Definition: unicode.h:35
struct _INFCACHEFIELD * Prev
Definition: inffile.c:30
CHAR Data[1]
Definition: inffile.c:32
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by add_field_from_token().

◆ InfpAddKeyToLine()

PVOID InfpAddKeyToLine ( PINFCACHELINE  Line,
PCWSTR  Key 
)

Definition at line 324 of file infcore.c.

326{
327 if (Line == NULL)
328 {
329 DPRINT1("Invalid Line\n");
330 return NULL;
331 }
332
333 if (Line->Key != NULL)
334 {
335 DPRINT1("Line already has a key\n");
336 return NULL;
337 }
338
339 Line->Key = (PWCHAR)MALLOC((strlenW(Key) + 1) * sizeof(WCHAR));
340 if (Line->Key == NULL)
341 {
342 DPRINT1("MALLOC() failed\n");
343 return NULL;
344 }
345
346 strcpyW(Line->Key, Key);
347
348 return (PVOID)Line->Key;
349}
uint16_t * PWCHAR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by add_field_from_token().

◆ InfpAddLine()

PINFCACHELINE InfpAddLine ( PINFCACHESECTION  Section)

Definition at line 217 of file infcore.c.

218{
220
221 if (Section == NULL)
222 {
223 DPRINT("Invalid parameter\n");
224 return NULL;
225 }
226
228 if (Line == NULL)
229 {
230 DPRINT("MALLOC() failed\n");
231 return NULL;
232 }
234 sizeof(INFCACHELINE));
235 Line->Id = ++Section->NextLineId;
236
237 /* Append line */
238 if (Section->FirstLine == NULL)
239 {
240 Section->FirstLine = Line;
241 Section->LastLine = Line;
242 }
243 else
244 {
245 Section->LastLine->Next = Line;
246 Line->Prev = Section->LastLine;
247 Section->LastLine = Line;
248 }
249 Section->LineCount++;
250
251 return Line;
252}
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHELINE * Next
Definition: inffile.c:37
PINFCACHELINE LastLine
Definition: inffile.c:55
PINFCACHELINE FirstLine
Definition: inffile.c:54
UINT NextLineId
Definition: infpriv.h:54
LONG LineCount
Definition: inffile.c:57

Referenced by add_field_from_token(), and InfpAddLineWithKey().

◆ InfpAddLineWithKey()

INFSTATUS InfpAddLineWithKey ( PINFCONTEXT  Context,
PCWSTR  Key 
)

Definition at line 224 of file infput.c.

225{
226 PINFCACHESECTION Section;
228
229 if (NULL == Context)
230 {
231 DPRINT1("Invalid parameter\n");
233 }
234
236 Line = InfpAddLine(Section);
237 if (NULL == Line)
238 {
239 DPRINT("Failed to create line\n");
241 }
242 Context->Line = Line->Id;
243
244 if (NULL != Key && NULL == InfpAddKeyToLine(Line, Key))
245 {
246 DPRINT("Failed to add key\n");
248 }
249
250 return INF_STATUS_SUCCESS;
251}
PINFCACHESECTION InfpGetSectionForContext(PINFCONTEXT Context)
Definition: infcore.c:273
PINFCACHELINE InfpAddLine(PINFCACHESECTION Section)
Definition: infcore.c:217
static PVOID InfpAddKeyToLine(PINFCACHELINE Line, PCSTR Key)
Definition: inffile.c:309

Referenced by InfHostAddLine().

◆ InfpAddSection()

PINFCACHESECTION InfpAddSection ( PINFCACHE  Cache,
PCWSTR  Name 
)

Definition at line 171 of file infcore.c.

173{
174 PINFCACHESECTION Section = NULL;
175 ULONG Size;
176
177 if (Cache == NULL || Name == NULL)
178 {
179 DPRINT("Invalid parameter\n");
180 return NULL;
181 }
182
183 /* Allocate and initialize the new section */
185 Name[strlenW(Name) + 1]);
186 Section = (PINFCACHESECTION)MALLOC(Size);
187 if (Section == NULL)
188 {
189 DPRINT("MALLOC() failed\n");
190 return NULL;
191 }
192 ZEROMEMORY (Section,
193 Size);
194 Section->Id = ++Cache->NextSectionId;
195
196 /* Copy section name */
197 strcpyW(Section->Name, Name);
198
199 /* Append section */
200 if (Cache->FirstSection == NULL)
201 {
202 Cache->FirstSection = Section;
203 Cache->LastSection = Section;
204 }
205 else
206 {
207 Cache->LastSection->Next = Section;
208 Section->Prev = Cache->LastSection;
209 Cache->LastSection = Section;
210 }
211
212 return Section;
213}
struct _INFCACHESECTION * PINFCACHESECTION
Definition: fatfs.h:173
struct _INFCACHESECTION * Prev
Definition: inffile.c:52
CHAR Name[1]
Definition: inffile.c:59

Referenced by add_section_from_token(), and InfpFindOrAddSection().

◆ InfpBuildFileBuffer()

INFSTATUS InfpBuildFileBuffer ( PINFCACHE  InfHandle,
PWCHAR Buffer,
PULONG  BufferSize 
)

Definition at line 90 of file infput.c.

93{
94 OUTPUTBUFFER OutBuf;
95 PINFCACHESECTION CacheSection;
96 PINFCACHELINE CacheLine;
97 PINFCACHEFIELD CacheField;
98 PWCHAR p;
99 BOOLEAN NeedQuotes;
100
101 OutBuf.Buffer = NULL;
102 OutBuf.Current = NULL;
103 OutBuf.FreeSize = 0;
104 OutBuf.TotalSize = 0;
105 OutBuf.Status = INF_STATUS_SUCCESS;
106
107 /* Iterate through list of sections */
108 CacheSection = Cache->FirstSection;
109 while (CacheSection != NULL)
110 {
111 DPRINT("Processing section %S\n", CacheSection->Name);
112 if (CacheSection != Cache->FirstSection)
113 {
114 Output(&OutBuf, EOL);
115 }
116 Output(&OutBuf, L"[");
117 Output(&OutBuf, CacheSection->Name);
118 Output(&OutBuf, L"]");
119 Output(&OutBuf, EOL);
120
121 /* Iterate through list of lines */
122 CacheLine = CacheSection->FirstLine;
123 while (CacheLine != NULL)
124 {
125 if (NULL != CacheLine->Key)
126 {
127 DPRINT("Line with key %S\n", CacheLine->Key);
128 Output(&OutBuf, CacheLine->Key);
129 Output(&OutBuf, L" = ");
130 }
131 else
132 {
133 DPRINT("Line without key\n");
134 }
135
136 /* Iterate through list of lines */
137 CacheField = CacheLine->FirstField;
138 while (CacheField != NULL)
139 {
140 if (CacheField != CacheLine->FirstField)
141 {
142 Output(&OutBuf, L",");
143 }
144 p = CacheField->Data;
145 NeedQuotes = FALSE;
146 while (L'\0' != *p && ! NeedQuotes)
147 {
148 NeedQuotes = (BOOLEAN)(L',' == *p || L';' == *p ||
149 L'\\' == *p);
150 p++;
151 }
152 if (NeedQuotes)
153 {
154 Output(&OutBuf, L"\"");
155 Output(&OutBuf, CacheField->Data);
156 Output(&OutBuf, L"\"");
157 }
158 else
159 {
160 Output(&OutBuf, CacheField->Data);
161 }
162
163 /* Get the next field */
164 CacheField = CacheField->Next;
165 }
166
167 Output(&OutBuf, EOL);
168 /* Get the next line */
169 CacheLine = CacheLine->Next;
170 }
171
172 /* Get the next section */
173 CacheSection = CacheSection->Next;
174 }
175
176 if (INF_SUCCESS(OutBuf.Status))
177 {
178 *Buffer = OutBuf.Buffer;
179 *BufferSize = OutBuf.TotalSize - OutBuf.FreeSize;
180 }
181 else if (NULL != OutBuf.Buffer)
182 {
183 FREE(OutBuf.Buffer);
184 }
185
186 return INF_STATUS_SUCCESS;
187}
unsigned char BOOLEAN
#define FREE(ptr, size)
Definition: auth_des.c:64
#define INF_SUCCESS(x)
Definition: builddep.h:82
Definition: bufpool.h:45
#define FALSE
Definition: types.h:117
GLfloat GLfloat p
Definition: glext.h:8902
#define EOL
Definition: infput.c:14
#define L(x)
Definition: ntvdm.h:50
#define BOOLEAN
Definition: pedump.c:73
@ Output
Definition: arc.h:85
struct _INFCACHEFIELD * Next
Definition: inffile.c:29
PINFCACHEFIELD FirstField
Definition: inffile.c:44
PCHAR Key
Definition: inffile.c:42
struct _INFCACHESECTION * Next
Definition: inffile.c:51
PWCHAR Buffer
Definition: infput.c:19
PWCHAR Current
Definition: infput.c:20
INFSTATUS Status
Definition: infput.c:23
ULONG TotalSize
Definition: infput.c:21
ULONG FreeSize
Definition: infput.c:22
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by InfHostWriteFile(), and InfWriteFile().

◆ InfpFindFirstLine()

INFSTATUS InfpFindFirstLine ( PINFCACHE  InfHandle,
PCWSTR  Section,
PCWSTR  Key,
PINFCONTEXT Context 
)

Definition at line 173 of file infget.c.

177{
178 PINFCACHESECTION CacheSection;
179 PINFCACHELINE CacheLine;
180
181 if (Cache == NULL || Section == NULL || Context == NULL)
182 {
183 DPRINT1("Invalid parameter\n");
185 }
186
187 CacheSection = InfpFindSection(Cache, Section);
188 if (NULL == CacheSection)
189 {
190 DPRINT("Section not found\n");
192 }
193
194 if (Key != NULL)
195 {
196 CacheLine = InfpFindKeyLine(CacheSection, Key);
197 }
198 else
199 {
200 CacheLine = CacheSection->FirstLine;
201 }
202
203 if (NULL == CacheLine)
204 {
205 DPRINT("Key not found\n");
207 }
208
209 *Context = MALLOC(sizeof(INFCONTEXT));
210 if (NULL == *Context)
211 {
212 DPRINT1("MALLOC() failed\n");
214 }
215 (*Context)->Inf = (PVOID)Cache;
216 (*Context)->Section = CacheSection->Id;
217 (*Context)->Line = CacheLine->Id;
218
219 return INF_STATUS_SUCCESS;
220}
#define INF_STATUS_NOT_FOUND
Definition: builddep.h:80
PINFCACHESECTION InfpFindSection(PINFCACHE Cache, PCWSTR Name)
Definition: infcore.c:143
PINFCACHELINE InfpFindKeyLine(PINFCACHESECTION Section, PCWSTR Key)
Definition: infcore.c:390
void * PVOID
Definition: typedefs.h:50

Referenced by InfFindFirstLine(), InfHostFindFirstLine(), and InfpGetSubstitutionString().

◆ InfpFindFirstMatchLine()

INFSTATUS InfpFindFirstMatchLine ( PINFCONTEXT  ContextIn,
PCWSTR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 251 of file infget.c.

254{
255 PINFCACHESECTION Section;
256 PINFCACHELINE CacheLine;
257
258 if (ContextIn == NULL || ContextOut == NULL || Key == NULL || *Key == 0)
260
261 Section = InfpGetSectionForContext(ContextIn);
262 if (Section == NULL)
264
265 CacheLine = Section->FirstLine;
266 while (CacheLine != NULL)
267 {
268 if (CacheLine->Key != NULL && strcmpiW (CacheLine->Key, Key) == 0)
269 {
270
271 if (ContextIn != ContextOut)
272 {
273 ContextOut->Inf = ContextIn->Inf;
274 ContextOut->Section = ContextIn->Section;
275 }
276 ContextOut->Line = CacheLine->Id;
277
278 return INF_STATUS_SUCCESS;
279 }
280
281 CacheLine = CacheLine->Next;
282 }
283
285}
#define strcmpiW(s1, s2)
Definition: unicode.h:45
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
UINT Section
Definition: infsupp.h:26

Referenced by InfFindFirstMatchLine(), and InfHostFindFirstMatchLine().

◆ InfpFindKeyLine()

PINFCACHELINE InfpFindKeyLine ( PINFCACHESECTION  Section,
PCWSTR  Key 
)

Definition at line 390 of file infcore.c.

392{
394
395 Line = Section->FirstLine;
396 while (Line != NULL)
397 {
398 if (Line->Key != NULL && strcmpiW(Line->Key, Key) == 0)
399 {
400 return Line;
401 }
402
403 Line = Line->Next;
404 }
405
406 return NULL;
407}

Referenced by InfpFindFirstLine().

◆ InfpFindLineById()

PINFCACHELINE InfpFindLineById ( PINFCACHESECTION  Section,
UINT  Id 
)

Definition at line 292 of file infcore.c.

293{
295
296 for (Line = Section->FirstLine;
297 Line != NULL;
298 Line = Line->Next)
299 {
300 if (Line->Id == Id)
301 {
302 return Line;
303 }
304 }
305
306 return NULL;
307}
DWORD Id

Referenced by InfpGetLineForContext().

◆ InfpFindNextLine()

INFSTATUS InfpFindNextLine ( PINFCONTEXT  ContextIn,
PINFCONTEXT  ContextOut 
)

Definition at line 224 of file infget.c.

226{
227 PINFCACHELINE CacheLine;
228
229 if (ContextIn == NULL || ContextOut == NULL)
231
232 CacheLine = InfpGetLineForContext(ContextIn);
233 if (CacheLine == NULL)
235
236 if (CacheLine->Next == NULL)
238
239 if (ContextIn != ContextOut)
240 {
241 ContextOut->Inf = ContextIn->Inf;
242 ContextOut->Section = ContextIn->Section;
243 }
244 ContextOut->Line = CacheLine->Next->Id;
245
246 return INF_STATUS_SUCCESS;
247}

Referenced by InfFindNextLine(), and InfHostFindNextLine().

◆ InfpFindNextMatchLine()

INFSTATUS InfpFindNextMatchLine ( PINFCONTEXT  ContextIn,
PCWSTR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 289 of file infget.c.

292{
293 PINFCACHESECTION Section;
294 PINFCACHELINE CacheLine;
295
296 if (ContextIn == NULL || ContextOut == NULL || Key == NULL || *Key == 0)
298
299 Section = InfpGetSectionForContext(ContextIn);
300 if (Section == NULL)
302
303 CacheLine = InfpGetLineForContext(ContextIn);
304 while (CacheLine != NULL)
305 {
306 if (CacheLine->Key != NULL && strcmpiW (CacheLine->Key, Key) == 0)
307 {
308
309 if (ContextIn != ContextOut)
310 {
311 ContextOut->Inf = ContextIn->Inf;
312 ContextOut->Section = ContextIn->Section;
313 }
314 ContextOut->Line = CacheLine->Id;
315
316 return INF_STATUS_SUCCESS;
317 }
318
319 CacheLine = CacheLine->Next;
320 }
321
323}

Referenced by InfFindNextMatchLine(), and InfHostFindNextMatchLine().

◆ InfpFindOrAddSection()

INFSTATUS InfpFindOrAddSection ( PINFCACHE  Cache,
PCWSTR  Section,
PINFCONTEXT Context 
)

Definition at line 190 of file infput.c.

193{
194 PINFCACHESECTION CacheSection;
195 DPRINT("InfpFindOrAddSection section %S\n", Section);
196
197 *Context = MALLOC(sizeof(INFCONTEXT));
198 if (NULL == *Context)
199 {
200 DPRINT1("MALLOC() failed\n");
202 }
203
204 (*Context)->Inf = Cache;
205 (*Context)->Line = 0;
206 CacheSection = InfpFindSection(Cache, Section);
207 if (NULL == CacheSection)
208 {
209 DPRINT("Section not found, creating it\n");
210 CacheSection = InfpAddSection(Cache, Section);
211 if (NULL == CacheSection)
212 {
213 DPRINT("Failed to create section\n");
214 FREE(*Context);
216 }
217 }
218
219 (*Context)->Section = CacheSection->Id;
220 return INF_STATUS_SUCCESS;
221}
PINFCACHESECTION InfpAddSection(PINFCACHE Cache, PCWSTR Name)
Definition: infcore.c:171

Referenced by InfFindOrAddSection(), and InfHostFindOrAddSection().

◆ InfpFindSection()

PINFCACHESECTION InfpFindSection ( PINFCACHE  Cache,
PCWSTR  Section 
)

Definition at line 143 of file infcore.c.

145{
146 PINFCACHESECTION Section = NULL;
147
148 if (Cache == NULL || Name == NULL)
149 {
150 return NULL;
151 }
152
153 /* iterate through list of sections */
154 Section = Cache->FirstSection;
155 while (Section != NULL)
156 {
157 if (strcmpiW(Section->Name, Name) == 0)
158 {
159 return Section;
160 }
161
162 /* get the next section*/
163 Section = Section->Next;
164 }
165
166 return NULL;
167}

Referenced by add_section_from_token(), InfpFindFirstLine(), InfpFindOrAddSection(), and InfpParseBuffer().

◆ InfpFreeContext()

VOID InfpFreeContext ( PINFCONTEXT  Context)

Definition at line 679 of file infget.c.

680{
681 FREE(Context);
682}

Referenced by InfFreeContext(), InfHostFreeContext(), and InfpGetSubstitutionString().

◆ InfpFreeSection()

PINFCACHESECTION InfpFreeSection ( PINFCACHESECTION  Section)

Definition at line 119 of file infcore.c.

120{
121 PINFCACHESECTION Next;
122
123 if (Section == NULL)
124 {
125 return NULL;
126 }
127
128 /* Release all keys */
129 Next = Section->Next;
130 while (Section->FirstLine != NULL)
131 {
132 Section->FirstLine = InfpFreeLine (Section->FirstLine);
133 }
134 Section->LastLine = NULL;
135
136 FREE (Section);
137
138 return Next;
139}
static PINFCACHELINE InfpFreeLine(PINFCACHELINE Line)
Definition: infcore.c:86

Referenced by InfCloseFile(), and InfHostCloseFile().

◆ InfpGetBinaryField()

INFSTATUS InfpGetBinaryField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PUCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 377 of file infget.c.

382{
383 PINFCACHELINE CacheLine;
384 PINFCACHEFIELD CacheField;
385 ULONG Index;
386 ULONG Size;
387 PUCHAR Ptr;
388
389 if (Context == NULL || FieldIndex == 0)
390 {
391 DPRINT("Invalid parameter\n");
393 }
394
395 if (RequiredSize != NULL)
396 *RequiredSize = 0;
397
398 CacheLine = InfpGetLineForContext(Context);
399
400 if (FieldIndex > (ULONG)CacheLine->FieldCount)
402
403 CacheField = CacheLine->FirstField;
404 for (Index = 1; Index < FieldIndex; Index++)
405 CacheField = CacheField->Next;
406
407 Size = (ULONG)CacheLine->FieldCount - FieldIndex + 1;
408
409 if (RequiredSize != NULL)
411
412 if (ReturnBuffer != NULL)
413 {
416
417 /* Copy binary data */
418 Ptr = ReturnBuffer;
419 while (CacheField != NULL)
420 {
421 *Ptr = (UCHAR)strtoulW(CacheField->Data, NULL, 16);
422
423 Ptr++;
424 CacheField = CacheField->Next;
425 }
426 }
427
428 return INF_STATUS_SUCCESS;
429}
#define INF_STATUS_BUFFER_OVERFLOW
Definition: builddep.h:81
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define strtoulW(s1, s2, b)
Definition: unicode.h:47
_In_ DWORD FieldIndex
Definition: setupapi.h:1895
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1897
ULONG FieldCount
Definition: inffile.c:40
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InfGetBinaryField(), and InfHostGetBinaryField().

◆ InfpGetData()

INFSTATUS InfpGetData ( PINFCONTEXT  Context,
PWCHAR Key,
PWCHAR Data 
)

Definition at line 610 of file infget.c.

613{
614 PINFCACHELINE CacheKey;
615
616 if (Context == NULL || Data == NULL)
617 {
618 DPRINT("Invalid parameter\n");
620 }
621
622 CacheKey = InfpGetLineForContext(Context);
623 if (Key != NULL)
624 *Key = CacheKey->Key;
625
626 if (Data != NULL)
627 {
628 if (CacheKey->FirstField == NULL)
629 {
630 *Data = NULL;
631 }
632 else
633 {
634 *Data = CacheKey->FirstField->Data;
635 }
636 }
637
638 return INF_STATUS_SUCCESS;
639}

Referenced by InfGetData(), InfHostGetData(), and InfpGetSubstitutionString().

◆ InfpGetDataField()

INFSTATUS InfpGetDataField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PWCHAR Data 
)

Definition at line 643 of file infget.c.

646{
647 PINFCACHELINE CacheLine;
648 PINFCACHEFIELD CacheField;
649 ULONG Index;
650
651 if (Context == NULL || Data == NULL)
652 {
653 DPRINT("Invalid parameter\n");
655 }
656
657 CacheLine = InfpGetLineForContext(Context);
658
659 if (FieldIndex > (ULONG)CacheLine->FieldCount)
661
662 if (FieldIndex == 0)
663 {
664 *Data = CacheLine->Key;
665 }
666 else
667 {
668 CacheField = CacheLine->FirstField;
669 for (Index = 1; Index < FieldIndex; Index++)
670 CacheField = CacheField->Next;
671
672 *Data = CacheField->Data;
673 }
674
675 return INF_STATUS_SUCCESS;
676}

Referenced by InfGetDataField(), and InfHostGetDataField().

◆ InfpGetFieldCount()

LONG InfpGetFieldCount ( PINFCONTEXT  Context)

Definition at line 365 of file infget.c.

366{
368
370 if (Line == NULL)
371 return 0;
372 return Line->FieldCount;
373}

Referenced by InfGetFieldCount(), and InfHostGetFieldCount().

◆ InfpGetIntField()

INFSTATUS InfpGetIntField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
INT IntegerValue 
)

Definition at line 433 of file infget.c.

436{
437 PINFCACHELINE CacheLine;
438 PINFCACHEFIELD CacheField;
439 ULONG Index;
440 PWCHAR Ptr;
441
442 if (Context == NULL || IntegerValue == NULL)
443 {
444 DPRINT("Invalid parameter\n");
446 }
447
448 CacheLine = InfpGetLineForContext(Context);
449
450 if (FieldIndex > (ULONG)CacheLine->FieldCount)
451 {
452 DPRINT("Invalid parameter\n");
454 }
455
456 if (FieldIndex == 0)
457 {
458 Ptr = CacheLine->Key;
459 }
460 else
461 {
462 CacheField = CacheLine->FirstField;
463 for (Index = 1; Index < FieldIndex; Index++)
464 CacheField = CacheField->Next;
465
466 Ptr = CacheField->Data;
467 }
468
469 *IntegerValue = (LONG)strtolW(Ptr, NULL, 0);
470
471 return INF_STATUS_SUCCESS;
472}
long LONG
Definition: pedump.c:60
#define strtolW(s, e, b)
Definition: unicode.h:39

Referenced by InfGetIntField(), and InfHostGetIntField().

◆ InfpGetLineCount()

LONG InfpGetLineCount ( HINF  InfHandle,
PCWSTR  Section 
)

Definition at line 327 of file infget.c.

329{
331 PINFCACHESECTION CacheSection;
332
333 if (InfHandle == NULL || Section == NULL)
334 {
335 DPRINT("Invalid parameter\n");
336 return -1;
337 }
338
339 Cache = (PINFCACHE)InfHandle;
340
341 /* Iterate through list of sections */
342 CacheSection = Cache->FirstSection;
343 while (CacheSection != NULL)
344 {
345 /* Are the section names the same? */
346 if (strcmpiW(CacheSection->Name, Section) == 0)
347 {
348 return CacheSection->LineCount;
349 }
350
351 /* Get the next section */
352 CacheSection = CacheSection->Next;
353 }
354
355 DPRINT("Section not found\n");
356
357 return -1;
358}
struct _INFCACHE * PINFCACHE

Referenced by InfGetLineCount(), and InfHostGetLineCount().

◆ InfpGetLineForContext()

PINFCACHELINE InfpGetLineForContext ( PINFCONTEXT  Context)

Definition at line 310 of file infcore.c.

311{
312 PINFCACHESECTION Section;
313
315 if (Section == NULL)
316 {
317 return NULL;
318 }
319
320 return InfpFindLineById(Section, Context->Line);
321}
PINFCACHELINE InfpFindLineById(PINFCACHESECTION Section, UINT Id)
Definition: infcore.c:292

Referenced by InfpAddField(), InfpFindNextLine(), InfpFindNextMatchLine(), InfpGetBinaryField(), InfpGetData(), InfpGetDataField(), InfpGetFieldCount(), InfpGetIntField(), InfpGetMultiSzField(), and InfpGetStringField().

◆ InfpGetMultiSzField()

INFSTATUS InfpGetMultiSzField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PWSTR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 476 of file infget.c.

481{
482 PINFCACHELINE CacheLine;
483 PINFCACHEFIELD CacheField;
484 PINFCACHEFIELD FieldPtr;
485 ULONG Index;
486 ULONG Size;
487 PWCHAR Ptr;
488
489 if (Context == NULL || FieldIndex == 0)
490 {
491 DPRINT("Invalid parameter\n");
493 }
494
495 if (RequiredSize != NULL)
496 *RequiredSize = 0;
497
498 CacheLine = InfpGetLineForContext(Context);
499
500 if (FieldIndex > (ULONG)CacheLine->FieldCount)
502
503 CacheField = CacheLine->FirstField;
504 for (Index = 1; Index < FieldIndex; Index++)
505 CacheField = CacheField->Next;
506
507 /* Calculate the required buffer size */
508 FieldPtr = CacheField;
509 Size = 0;
510 while (FieldPtr != NULL)
511 {
512 Size += ((ULONG)strlenW(FieldPtr->Data) + 1);
513 FieldPtr = FieldPtr->Next;
514 }
515 Size++;
516
517 if (RequiredSize != NULL)
519
520 if (ReturnBuffer != NULL)
521 {
524
525 /* Copy multi-sz string */
526 Ptr = ReturnBuffer;
527 FieldPtr = CacheField;
528 while (FieldPtr != NULL)
529 {
530 Size = (ULONG)strlenW(FieldPtr->Data) + 1;
531
532 strcpyW(Ptr, FieldPtr->Data);
533
534 Ptr = Ptr + Size;
535 FieldPtr = FieldPtr->Next;
536 }
537 *Ptr = 0;
538 }
539
540 return INF_STATUS_SUCCESS;
541}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))

Referenced by InfGetMultiSzField(), and InfHostGetMultiSzField().

◆ InfpGetSectionForContext()

PINFCACHESECTION InfpGetSectionForContext ( PINFCONTEXT  Context)

Definition at line 273 of file infcore.c.

274{
276
277 if (Context == NULL)
278 {
279 return NULL;
280 }
281
282 Cache = (PINFCACHE)Context->Inf;
283 if (Cache == NULL)
284 {
285 return NULL;
286 }
287
288 return InfpFindSectionById(Cache, Context->Section);
289}
PINFCACHESECTION InfpFindSectionById(PINFCACHE Cache, UINT Id)
Definition: infcore.c:255
if(dx< 0)
Definition: linetemp.h:194

Referenced by InfpAddLineWithKey(), InfpFindFirstMatchLine(), InfpFindNextMatchLine(), and InfpGetLineForContext().

◆ InfpGetStringField()

INFSTATUS InfpGetStringField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PWSTR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 545 of file infget.c.

550{
551 PINFCACHELINE CacheLine;
552 PINFCACHEFIELD CacheField;
553 ULONG Index;
554 PWCHAR Ptr;
555 SIZE_T Size;
556
557 if (Context == NULL)
558 {
559 DPRINT("Invalid parameter\n");
561 }
562
563 if (RequiredSize != NULL)
564 *RequiredSize = 0;
565
566 CacheLine = InfpGetLineForContext(Context);
567
568 if (FieldIndex > (ULONG)CacheLine->FieldCount)
570
571 if (FieldIndex == 0)
572 {
573 Ptr = CacheLine->Key;
574 }
575 else
576 {
577 CacheField = CacheLine->FirstField;
578 for (Index = 1; Index < FieldIndex; Index++)
579 CacheField = CacheField->Next;
580
581 Ptr = CacheField->Data;
582 }
583
584// Size = (ULONG)strlenW(Ptr) + 1;
586 Ptr,
587 NULL,
588 0);
589
590 if (RequiredSize != NULL)
591 *RequiredSize = (ULONG)Size + 1;
592
593 if (ReturnBuffer != NULL)
594 {
595 if (ReturnBufferSize <= Size)
597
598// strcpyW(ReturnBuffer, Ptr);
600 Ptr,
601 ReturnBuffer,
603 }
604
605 return INF_STATUS_SUCCESS;
606}
static size_t InfpSubstituteString(PINFCACHE Inf, const WCHAR *text, WCHAR *buffer, size_t size)
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by InfGetStringField(), and InfHostGetStringField().

◆ InfpParseBuffer()

INFSTATUS InfpParseBuffer ( PINFCACHE  file,
const WCHAR buffer,
const WCHAR end,
PULONG  error_line 
)

Definition at line 865 of file infcore.c.

869{
870 struct parser parser;
871 const WCHAR *pos = buffer;
872
874 parser.end = end;
875 parser.file = file;
876 parser.line = NULL;
878 parser.stack_pos = 0;
880 parser.line_pos = 1;
881 parser.error = 0;
882 parser.token_len = 0;
883
884 /* parser main loop */
885 while (pos)
887
888 if (parser.error)
889 {
890 if (error_line)
891 *error_line = parser.line_pos;
892 return parser.error;
893 }
894
895 /* find the [strings] section */
896 file->StringsSection = InfpFindSection(file,
897 L"Strings");
898
899 return INF_STATUS_SUCCESS;
900}
GLuint GLuint end
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
@ LINE_START
Definition: infcore.c:27
static const parser_state_func parser_funcs[NB_PARSER_STATES]
Definition: infcore.c:69
Definition: fci.c:127
Definition: import.c:81
unsigned int line_pos
Definition: inffile.c:96
PINFCACHESECTION cur_section
Definition: inffile.c:94
int stack_pos
Definition: inffile.c:92
const CHAR * end
Definition: inffile.c:88
enum parser_state state
Definition: import.c:95
unsigned int token_len
Definition: inffile.c:98
const CHAR * start
Definition: inffile.c:87
unsigned int error
Definition: inffile.c:97
FILE * file
Definition: import.c:82
PINFCACHELINE line
Definition: inffile.c:95