- Factor out .inf handling code from usetup
[reactos.git] / reactos / lib / inflib / infpriv.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: .inf file parser
4 * FILE: lib/inflib/infcache.h
5 * PURPOSE: INF file parser that caches contents of INF file in memory
6 * PROGRAMMER: Royce Mitchell III
7 * Eric Kohl
8 * Ge van Geldorp <gvg@reactos.org>
9 */
10
11 #ifndef INFPRIV_H_INCLUDED
12 #define INFPRIV_H_INCLUDED
13
14
15 #define INF_STATUS_INSUFFICIENT_RESOURCES (0xC000009A)
16 #define INF_STATUS_BAD_SECTION_NAME_LINE (0xC0700001)
17 #define INF_STATUS_SECTION_NAME_TOO_LONG (0xC0700002)
18 #define INF_STATUS_WRONG_INF_STYLE (0xC0700003)
19 #define INF_STATUS_NOT_ENOUGH_MEMORY (0xC0700004)
20
21 typedef struct _INFCONTEXT
22 {
23 PVOID Inf;
24 PVOID Section;
25 PVOID Line;
26 } INFCONTEXT;
27
28 typedef struct _INFCACHEFIELD
29 {
30 struct _INFCACHEFIELD *Next;
31 struct _INFCACHEFIELD *Prev;
32
33 TCHAR Data[1];
34 } INFCACHEFIELD, *PINFCACHEFIELD;
35
36 typedef struct _INFCACHELINE
37 {
38 struct _INFCACHELINE *Next;
39 struct _INFCACHELINE *Prev;
40
41 LONG FieldCount;
42
43 PTCHAR Key;
44
45 PINFCACHEFIELD FirstField;
46 PINFCACHEFIELD LastField;
47
48 } INFCACHELINE, *PINFCACHELINE;
49
50 typedef struct _INFCACHESECTION
51 {
52 struct _INFCACHESECTION *Next;
53 struct _INFCACHESECTION *Prev;
54
55 PINFCACHELINE FirstLine;
56 PINFCACHELINE LastLine;
57
58 LONG LineCount;
59
60 TCHAR Name[1];
61 } INFCACHESECTION, *PINFCACHESECTION;
62
63 typedef struct _INFCACHE
64 {
65 PINFCACHESECTION FirstSection;
66 PINFCACHESECTION LastSection;
67
68 PINFCACHESECTION StringsSection;
69 } INFCACHE, *PINFCACHE;
70
71 typedef long 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 InfpCacheFreeSection(PINFCACHESECTION Section);
80 extern PINFCACHELINE InfpCacheFindKeyLine(PINFCACHESECTION Section,
81 PTCHAR Key);
82
83 extern INFSTATUS InfpFindFirstLine(HINF InfHandle,
84 PCTSTR Section,
85 PCTSTR Key,
86 PINFCONTEXT *Context);
87 extern INFSTATUS InfpFindNextLine(PINFCONTEXT ContextIn,
88 PINFCONTEXT ContextOut);
89 extern INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn,
90 PCTSTR Key,
91 PINFCONTEXT ContextOut);
92 extern INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn,
93 PCTSTR Key,
94 PINFCONTEXT ContextOut);
95 extern LONG InfpGetLineCount(HINF InfHandle,
96 PCTSTR Section);
97 extern LONG InfpGetFieldCount(PINFCONTEXT Context);
98 extern INFSTATUS InfpGetBinaryField(PINFCONTEXT Context,
99 ULONG FieldIndex,
100 PUCHAR ReturnBuffer,
101 ULONG ReturnBufferSize,
102 PULONG RequiredSize);
103 extern INFSTATUS InfpGetIntField(PINFCONTEXT Context,
104 ULONG FieldIndex,
105 PLONG IntegerValue);
106 extern INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context,
107 ULONG FieldIndex,
108 PTSTR ReturnBuffer,
109 ULONG ReturnBufferSize,
110 PULONG RequiredSize);
111 extern INFSTATUS InfpGetStringField(PINFCONTEXT Context,
112 ULONG FieldIndex,
113 PTSTR ReturnBuffer,
114 ULONG ReturnBufferSize,
115 PULONG RequiredSize);
116 extern INFSTATUS InfpGetData(PINFCONTEXT Context,
117 PTCHAR *Key,
118 PTCHAR *Data);
119 extern INFSTATUS InfpGetDataField(PINFCONTEXT Context,
120 ULONG FieldIndex,
121 PTCHAR *Data);
122 extern VOID InfpFreeContext(PINFCONTEXT Context);
123
124 #endif /* INFPRIV_H_INCLUDED */
125
126 /* EOF */