3446f8d3ce12820bef744e33515972c2ceb2cef9
[reactos.git] / reactos / lib / inflib / 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 #ifndef INFPRIV_H_INCLUDED
10 #define INFPRIV_H_INCLUDED
11
12 #ifndef FIELD_OFFSET
13 #define FIELD_OFFSET(t,f) ((ptrdiff_t)&(((t*)0)->f))
14 #endif
15
16 #define INF_STATUS_INSUFFICIENT_RESOURCES (0xC000009A)
17 #define INF_STATUS_BAD_SECTION_NAME_LINE (0xC0700001)
18 #define INF_STATUS_SECTION_NAME_TOO_LONG (0xC0700002)
19 #define INF_STATUS_WRONG_INF_STYLE (0xC0700003)
20 #define INF_STATUS_NOT_ENOUGH_MEMORY (0xC0700004)
21
22 typedef struct _INFCACHEFIELD
23 {
24 struct _INFCACHEFIELD *Next;
25 struct _INFCACHEFIELD *Prev;
26
27 TCHAR Data[1];
28 } INFCACHEFIELD, *PINFCACHEFIELD;
29
30 typedef struct _INFCACHELINE
31 {
32 struct _INFCACHELINE *Next;
33 struct _INFCACHELINE *Prev;
34
35 LONG FieldCount;
36
37 PTSTR 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
52 LONG LineCount;
53
54 TCHAR Name[1];
55 } INFCACHESECTION, *PINFCACHESECTION;
56
57 typedef struct _INFCACHE
58 {
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 CHAR *buffer,
78 const CHAR *end,
79 PULONG error_line);
80 extern PINFCACHESECTION InfpFreeSection(PINFCACHESECTION Section);
81 extern PINFCACHESECTION InfpAddSection(PINFCACHE Cache,
82 PCTSTR Name);
83 extern PINFCACHELINE InfpAddLine(PINFCACHESECTION Section);
84 extern PVOID InfpAddKeyToLine(PINFCACHELINE Line,
85 PCTSTR Key);
86 extern PVOID InfpAddFieldToLine(PINFCACHELINE Line,
87 PCTSTR Data);
88 extern PINFCACHELINE InfpFindKeyLine(PINFCACHESECTION Section,
89 PCTSTR Key);
90 extern PINFCACHESECTION InfpFindSection(PINFCACHE Cache,
91 PCTSTR Section);
92
93 extern INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle,
94 PCHAR *Buffer,
95 PULONG BufferSize);
96
97 extern INFSTATUS InfpFindFirstLine(PINFCACHE InfHandle,
98 PCTSTR Section,
99 PCTSTR Key,
100 PINFCONTEXT *Context);
101 extern INFSTATUS InfpFindNextLine(PINFCONTEXT ContextIn,
102 PINFCONTEXT ContextOut);
103 extern INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn,
104 PCTSTR Key,
105 PINFCONTEXT ContextOut);
106 extern INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn,
107 PCTSTR Key,
108 PINFCONTEXT ContextOut);
109 extern LONG InfpGetLineCount(HINF InfHandle,
110 PCTSTR 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 PTSTR ReturnBuffer,
123 ULONG ReturnBufferSize,
124 PULONG RequiredSize);
125 extern INFSTATUS InfpGetStringField(PINFCONTEXT Context,
126 ULONG FieldIndex,
127 PTSTR ReturnBuffer,
128 ULONG ReturnBufferSize,
129 PULONG RequiredSize);
130 extern INFSTATUS InfpGetData(PINFCONTEXT Context,
131 PTCHAR *Key,
132 PTCHAR *Data);
133 extern INFSTATUS InfpGetDataField(PINFCONTEXT Context,
134 ULONG FieldIndex,
135 PTCHAR *Data);
136
137 extern INFSTATUS InfpFindOrAddSection(PINFCACHE Cache,
138 PCTSTR Section,
139 PINFCONTEXT *Context);
140 extern INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCTSTR Key);
141 extern INFSTATUS InfpAddField(PINFCONTEXT Context, PCTSTR Data);
142
143 extern VOID InfpFreeContext(PINFCONTEXT Context);
144
145 #endif /* INFPRIV_H_INCLUDED */
146
147 /* EOF */