- Factor out .inf handling code from usetup
[reactos.git] / reactos / lib / inflib / infhostget.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: .inf file parser
4 * FILE: lib/inflib/infrosget.c
5 * PURPOSE: Read .inf routines for use on the host build system
6 * PROGRAMMER: Royce Mitchell III
7 * Eric Kohl
8 * Ge van Geldorp
9 */
10
11 /* INCLUDES *****************************************************************/
12
13 #include <errno.h>
14 #include "inflib.h"
15 #include "infhost.h"
16
17 #define NDEBUG
18 #include <debug.h>
19
20 int
21 InfHostFindFirstLine(HINF InfHandle,
22 const char *Section,
23 const char *Key,
24 PINFCONTEXT *Context)
25 {
26 INFSTATUS Status;
27
28 Status = InfpFindFirstLine(InfHandle, Section, Key, Context);
29 if (INF_SUCCESS(Status))
30 {
31 return 0;
32 }
33 else
34 {
35 errno = Status;
36 return -1;
37 }
38 }
39
40
41 int
42 InfHostFindNextLine(PINFCONTEXT ContextIn,
43 PINFCONTEXT ContextOut)
44 {
45 INFSTATUS Status;
46
47 Status = InfpFindNextLine(ContextIn, ContextOut);
48 if (INF_SUCCESS(Status))
49 {
50 return 0;
51 }
52 else
53 {
54 errno = Status;
55 return -1;
56 }
57 }
58
59
60 int
61 InfHostFindFirstMatchLine(PINFCONTEXT ContextIn,
62 const char *Key,
63 PINFCONTEXT ContextOut)
64 {
65 INFSTATUS Status;
66
67 Status = InfpFindFirstMatchLine(ContextIn, Key, ContextOut);
68 if (INF_SUCCESS(Status))
69 {
70 return 0;
71 }
72 else
73 {
74 errno = Status;
75 return -1;
76 }
77 }
78
79
80 int
81 InfHostFindNextMatchLine(PINFCONTEXT ContextIn,
82 const char *Key,
83 PINFCONTEXT ContextOut)
84 {
85 INFSTATUS Status;
86
87 Status = InfpFindNextMatchLine(ContextIn, Key, ContextOut);
88 if (INF_SUCCESS(Status))
89 {
90 return 0;
91 }
92 else
93 {
94 errno = Status;
95 return -1;
96 }
97 }
98
99
100 long
101 InfHostGetLineCount(HINF InfHandle,
102 PCTSTR Section)
103 {
104 return InfpGetLineCount(InfHandle, Section);
105 }
106
107
108 /* InfGetLineText */
109
110
111 long
112 InfHostGetFieldCount(PINFCONTEXT Context)
113 {
114 return InfpGetFieldCount(Context);
115 }
116
117
118 int
119 InfHostGetBinaryField(PINFCONTEXT Context,
120 unsigned long FieldIndex,
121 unsigned char *ReturnBuffer,
122 unsigned long ReturnBufferSize,
123 unsigned long *RequiredSize)
124 {
125 INFSTATUS Status;
126
127 Status = InfpGetBinaryField(Context, FieldIndex, ReturnBuffer,
128 ReturnBufferSize, RequiredSize);
129 if (INF_SUCCESS(Status))
130 {
131 return 0;
132 }
133 else
134 {
135 errno = Status;
136 return -1;
137 }
138 }
139
140
141 int
142 InfHostGetIntField(PINFCONTEXT Context,
143 unsigned long FieldIndex,
144 unsigned long *IntegerValue)
145 {
146 INFSTATUS Status;
147
148 Status = InfpGetIntField(Context, FieldIndex, IntegerValue);
149 if (INF_SUCCESS(Status))
150 {
151 return 0;
152 }
153 else
154 {
155 errno = Status;
156 return -1;
157 }
158 }
159
160
161 int
162 InfHostGetMultiSzField(PINFCONTEXT Context,
163 unsigned long FieldIndex,
164 char * ReturnBuffer,
165 unsigned long ReturnBufferSize,
166 unsigned long *RequiredSize)
167 {
168 INFSTATUS Status;
169
170 Status = InfpGetMultiSzField(Context, FieldIndex, ReturnBuffer,
171 ReturnBufferSize, RequiredSize);
172 if (INF_SUCCESS(Status))
173 {
174 return 0;
175 }
176 else
177 {
178 errno = Status;
179 return -1;
180 }
181 }
182
183
184 int
185 InfHostGetStringField(PINFCONTEXT Context,
186 unsigned long FieldIndex,
187 char *ReturnBuffer,
188 unsigned long ReturnBufferSize,
189 unsigned long *RequiredSize)
190 {
191 INFSTATUS Status;
192
193 Status = InfpGetStringField(Context, FieldIndex, ReturnBuffer,
194 ReturnBufferSize, RequiredSize);
195 if (INF_SUCCESS(Status))
196 {
197 return 0;
198 }
199 else
200 {
201 errno = Status;
202 return -1;
203 }
204 }
205
206
207 int
208 InfHostGetData(PINFCONTEXT Context,
209 char **Key,
210 char **Data)
211 {
212 INFSTATUS Status;
213
214 Status = InfpGetData(Context, Key, Data);
215 if (INF_SUCCESS(Status))
216 {
217 return 0;
218 }
219 else
220 {
221 errno = Status;
222 return -1;
223 }
224 }
225
226
227 int
228 InfHostGetDataField(PINFCONTEXT Context,
229 unsigned long FieldIndex,
230 char **Data)
231 {
232 INFSTATUS Status;
233
234 Status = InfpGetDataField(Context, FieldIndex, Data);
235 if (INF_SUCCESS(Status))
236 {
237 return 0;
238 }
239 else
240 {
241 errno = Status;
242 return -1;
243 }
244 }
245
246 VOID
247 InfHostFreeContext(PINFCONTEXT Context)
248 {
249 InfpFreeContext(Context);
250 }
251
252 /* EOF */