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