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