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 34 LONG FieldCount; 35 36 PWCHAR Key; 37 38 PINFCACHEFIELD FirstField; 39 PINFCACHEFIELD LastField; 40 41 } INFCACHELINE, *PINFCACHELINE; 42 43 typedef struct _INFCACHESECTION 44 { 45 struct _INFCACHESECTION *Next; 46 struct _INFCACHESECTION *Prev; 47 48 PINFCACHELINE FirstLine; 49 PINFCACHELINE LastLine; 50 51 LONG LineCount; 52 53 WCHAR Name[1]; 54 } INFCACHESECTION, *PINFCACHESECTION; 55 56 typedef struct _INFCACHE 57 { 58 LANGID LanguageId; 59 PINFCACHESECTION FirstSection; 60 PINFCACHESECTION LastSection; 61 62 PINFCACHESECTION StringsSection; 63 } INFCACHE, *PINFCACHE; 64 65 typedef struct _INFCONTEXT 66 { 67 PINFCACHE Inf; 68 PINFCACHE CurrentInf; 69 PINFCACHESECTION Section; 70 PINFCACHELINE Line; 71 } INFCONTEXT; 72 73 typedef int INFSTATUS; 74 75 /* FUNCTIONS ****************************************************************/ 76 77 extern INFSTATUS InfpParseBuffer(PINFCACHE file, 78 const WCHAR *buffer, 79 const WCHAR *end, 80 PULONG error_line); 81 extern PINFCACHESECTION InfpFreeSection(PINFCACHESECTION Section); 82 extern PINFCACHESECTION InfpAddSection(PINFCACHE Cache, 83 PCWSTR Name); 84 extern PINFCACHELINE InfpAddLine(PINFCACHESECTION Section); 85 extern PVOID InfpAddKeyToLine(PINFCACHELINE Line, 86 PCWSTR Key); 87 extern PVOID InfpAddFieldToLine(PINFCACHELINE Line, 88 PCWSTR Data); 89 extern PINFCACHELINE InfpFindKeyLine(PINFCACHESECTION Section, 90 PCWSTR Key); 91 extern PINFCACHESECTION InfpFindSection(PINFCACHE Cache, 92 PCWSTR Section); 93 94 extern INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, 95 PWCHAR *Buffer, 96 PULONG BufferSize); 97 98 extern INFSTATUS InfpFindFirstLine(PINFCACHE InfHandle, 99 PCWSTR Section, 100 PCWSTR Key, 101 PINFCONTEXT *Context); 102 extern INFSTATUS InfpFindNextLine(PINFCONTEXT ContextIn, 103 PINFCONTEXT ContextOut); 104 extern INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn, 105 PCWSTR Key, 106 PINFCONTEXT ContextOut); 107 extern INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn, 108 PCWSTR Key, 109 PINFCONTEXT ContextOut); 110 extern LONG InfpGetLineCount(HINF InfHandle, 111 PCWSTR Section); 112 extern LONG InfpGetFieldCount(PINFCONTEXT Context); 113 extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context, 114 ULONG FieldIndex, 115 PUCHAR ReturnBuffer, 116 ULONG ReturnBufferSize, 117 PULONG RequiredSize); 118 extern INFSTATUS InfpGetIntField(PINFCONTEXT Context, 119 ULONG FieldIndex, 120 INT *IntegerValue); 121 extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, 122 ULONG FieldIndex, 123 PWSTR ReturnBuffer, 124 ULONG ReturnBufferSize, 125 PULONG RequiredSize); 126 extern INFSTATUS InfpGetStringField(PINFCONTEXT Context, 127 ULONG FieldIndex, 128 PWSTR ReturnBuffer, 129 ULONG ReturnBufferSize, 130 PULONG RequiredSize); 131 extern INFSTATUS InfpGetData(PINFCONTEXT Context, 132 PWCHAR *Key, 133 PWCHAR *Data); 134 extern INFSTATUS InfpGetDataField(PINFCONTEXT Context, 135 ULONG FieldIndex, 136 PWCHAR *Data); 137 138 extern INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, 139 PCWSTR Section, 140 PINFCONTEXT *Context); 141 extern INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key); 142 extern INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data); 143 144 extern VOID InfpFreeContext(PINFCONTEXT Context); 145 146 /* EOF */ 147