3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/inffile.c
23 * PURPOSE: .inf files support functions
24 * PROGRAMMER: Hervé Poussineau
27 /* INCLUDES ******************************************************************/
38 /* FUNCTIONS *****************************************************************/
46 InfCloseFile(InfHandle
);
54 IN OUT PINFCONTEXT Context
)
59 ret
= InfFindFirstLine(InfHandle
, Section
, Key
, &pContext
);
63 memcpy(Context
, pContext
, sizeof(INFCONTEXT
));
64 InfFreeContext(pContext
);
70 IN PINFCONTEXT ContextIn
,
71 OUT PINFCONTEXT ContextOut
)
73 return InfFindNextLine(ContextIn
, ContextOut
);
78 IN PINFCONTEXT Context
,
80 IN OUT BYTE
* ReturnBuffer
,
81 IN ULONG ReturnBufferSize
,
82 OUT PULONG RequiredSize
)
84 return InfGetBinaryField(Context
, FieldIndex
, ReturnBuffer
, ReturnBufferSize
, RequiredSize
);
89 IN PINFCONTEXT Context
)
91 return (DWORD
)InfGetFieldCount(Context
);
96 IN PINFCONTEXT Context
,
98 OUT PINT IntegerValue
)
103 ret
= InfGetIntField(Context
, FieldIndex
, &IntegerValueL
);
104 *IntegerValue
= (INT
)IntegerValueL
;
109 InfpGetMultiSzFieldW(
110 IN PINFCONTEXT Context
,
112 IN OUT PWSTR ReturnBuffer
,
113 IN ULONG ReturnBufferSize
,
114 OUT PULONG RequiredSize
)
116 return InfGetMultiSzField(Context
, FieldIndex
, ReturnBuffer
, ReturnBufferSize
, RequiredSize
);
121 IN PINFCONTEXT Context
,
123 IN OUT PWSTR ReturnBuffer
,
124 IN ULONG ReturnBufferSize
,
125 OUT PULONG RequiredSize
)
127 return InfGetStringField(Context
, FieldIndex
, ReturnBuffer
, ReturnBufferSize
, RequiredSize
);
138 UNICODE_STRING FileNameU
;
142 RtlInitUnicodeString(&FileNameU
, FileName
);
143 Status
= InfOpenFile(
147 *ErrorLine
= (UINT
)ErrorLineUL
;
148 if (!NT_SUCCESS(Status
))
149 return INVALID_HANDLE_VALUE
;
154 #endif /* __REACTOS__ */
158 IN PINFCONTEXT Context
,
163 return InfGetData(Context
, Key
, Data
);
165 static PWCHAR pLastCallData
[4] = { NULL
, NULL
, NULL
, NULL
};
166 static DWORD currentIndex
= 0;
172 if (Key
) *Key
= NULL
;
173 if (Data
) *Data
= NULL
;
175 if (SetupGetFieldCount(Context
) != 1)
178 for (i
= 0; i
<= 1; i
++)
180 ret
= SetupGetStringFieldW(
188 HeapFree(GetProcessHeap(), 0, pLastCallData
[i
+ currentIndex
]);
189 pLastCallData
[i
+ currentIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
190 ret
= SetupGetStringFieldW(
193 pLastCallData
[i
+ currentIndex
],
201 *Key
= pLastCallData
[0 + currentIndex
];
203 *Data
= pLastCallData
[1 + currentIndex
];
205 #endif /* !__REACTOS__ */
210 IN PINFCONTEXT Context
,
215 return InfGetDataField(Context
, FieldIndex
, Data
);
217 static PWCHAR pLastCallsData
[] = { NULL
, NULL
, NULL
};
218 static DWORD NextIndex
= 0;
224 ret
= SetupGetStringFieldW(
232 HeapFree(GetProcessHeap(), 0, pLastCallsData
[NextIndex
]);
233 pLastCallsData
[NextIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
234 ret
= SetupGetStringFieldW(
237 pLastCallsData
[NextIndex
],
243 *Data
= pLastCallsData
[NextIndex
];
244 NextIndex
= (NextIndex
+ 1) % (sizeof(pLastCallsData
) / sizeof(pLastCallsData
[0]));
246 #endif /* !__REACTOS__ */
250 INF_OpenBufferedFileA(
262 Status
= InfOpenBufferedFile(
267 *ErrorLine
= (UINT
)ErrorLineUL
;
268 if (!NT_SUCCESS(Status
))
269 return INVALID_HANDLE_VALUE
;
273 return INVALID_HANDLE_VALUE
;
274 #endif /* !__REACTOS__ */