[NEWINFLIB]
[reactos.git] / reactos / lib / newinflib / infpriv.h
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 LCID LocaleId;
59 PINFCACHESECTION FirstSection;
60 PINFCACHESECTION LastSection;
61
62 PINFCACHESECTION StringsSection;
63 } INFCACHE, *PINFCACHE;
64
65 typedef struct _INFCONTEXT
66 {
67 PINFCACHE Inf;
68 PINFCACHESECTION Section;
69 PINFCACHELINE Line;
70 } INFCONTEXT;
71
72 typedef int INFSTATUS;
73
74 /* FUNCTIONS ****************************************************************/
75
76 extern INFSTATUS InfpParseBuffer(PINFCACHE file,
77 const WCHAR *buffer,
78 const WCHAR *end,
79 PULONG error_line);
80 extern PINFCACHESECTION InfpFreeSection(PINFCACHESECTION Section);
81 extern PINFCACHESECTION InfpAddSection(PINFCACHE Cache,
82 PCWSTR Name);
83 extern PINFCACHELINE InfpAddLine(PINFCACHESECTION Section);
84 extern PVOID InfpAddKeyToLine(PINFCACHELINE Line,
85 PCWSTR Key);
86 extern PVOID InfpAddFieldToLine(PINFCACHELINE Line,
87 PCWSTR Data);
88 extern PINFCACHELINE InfpFindKeyLine(PINFCACHESECTION Section,
89 PCWSTR Key);
90 extern PINFCACHESECTION InfpFindSection(PINFCACHE Cache,
91 PCWSTR Section);
92
93 extern INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle,
94 PWCHAR *Buffer,
95 PULONG BufferSize);
96
97 extern INFSTATUS InfpFindFirstLine(PINFCACHE InfHandle,
98 PCWSTR Section,
99 PCWSTR Key,
100 PINFCONTEXT *Context);
101 extern INFSTATUS InfpFindNextLine(PINFCONTEXT ContextIn,
102 PINFCONTEXT ContextOut);
103 extern INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn,
104 PCWSTR Key,
105 PINFCONTEXT ContextOut);
106 extern INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn,
107 PCWSTR Key,
108 PINFCONTEXT ContextOut);
109 extern LONG InfpGetLineCount(HINF InfHandle,
110 PCWSTR Section);
111 extern LONG InfpGetFieldCount(PINFCONTEXT Context);
112 extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context,
113 ULONG FieldIndex,
114 PUCHAR ReturnBuffer,
115 ULONG ReturnBufferSize,
116 PULONG RequiredSize);
117 extern INFSTATUS InfpGetIntField(PINFCONTEXT Context,
118 ULONG FieldIndex,
119 PLONG IntegerValue);
120 extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context,
121 ULONG FieldIndex,
122 PWSTR ReturnBuffer,
123 ULONG ReturnBufferSize,
124 PULONG RequiredSize);
125 extern INFSTATUS InfpGetStringField(PINFCONTEXT Context,
126 ULONG FieldIndex,
127 PWSTR ReturnBuffer,
128 ULONG ReturnBufferSize,
129 PULONG RequiredSize);
130 extern INFSTATUS InfpGetData(PINFCONTEXT Context,
131 PWCHAR *Key,
132 PWCHAR *Data);
133 extern INFSTATUS InfpGetDataField(PINFCONTEXT Context,
134 ULONG FieldIndex,
135 PWCHAR *Data);
136
137 extern INFSTATUS InfpFindOrAddSection(PINFCACHE Cache,
138 PCWSTR Section,
139 PINFCONTEXT *Context);
140 extern INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key);
141 extern INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data);
142
143 extern VOID InfpFreeContext(PINFCONTEXT Context);
144
145 /* EOF */