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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 Context
,
72 IN OUT PWSTR ReturnBuffer
,
73 IN ULONG ReturnBufferSize
,
74 OUT PULONG RequiredSize
)
76 return InfGetMultiSzField(Context
, FieldIndex
, ReturnBuffer
, ReturnBufferSize
, RequiredSize
);
81 IN PINFCONTEXT Context
,
83 IN OUT PWSTR ReturnBuffer
,
84 IN ULONG ReturnBufferSize
,
85 OUT PULONG RequiredSize
)
87 return InfGetStringField(Context
, FieldIndex
, ReturnBuffer
, ReturnBufferSize
, RequiredSize
);
98 UNICODE_STRING FileNameU
;
102 RtlInitUnicodeString(&FileNameU
, FileName
);
103 Status
= InfOpenFile(
107 *ErrorLine
= (UINT
)ErrorLineUL
;
108 if (!NT_SUCCESS(Status
))
109 return INVALID_HANDLE_VALUE
;
114 #endif /* __REACTOS__ */
118 IN PINFCONTEXT Context
,
123 return InfGetData(Context
, Key
, Data
);
125 static PWCHAR pLastCallData
[4] = { NULL
, NULL
, NULL
, NULL
};
126 static DWORD currentIndex
= 0;
132 if (Key
) *Key
= NULL
;
133 if (Data
) *Data
= NULL
;
135 if (SetupGetFieldCount(Context
) != 1)
138 for (i
= 0; i
<= 1; i
++)
140 ret
= SetupGetStringFieldW(
148 HeapFree(GetProcessHeap(), 0, pLastCallData
[i
+ currentIndex
]);
149 pLastCallData
[i
+ currentIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
150 ret
= SetupGetStringFieldW(
153 pLastCallData
[i
+ currentIndex
],
161 *Key
= pLastCallData
[0 + currentIndex
];
163 *Data
= pLastCallData
[1 + currentIndex
];
165 #endif /* !__REACTOS__ */
170 IN PINFCONTEXT Context
,
175 return InfGetDataField(Context
, FieldIndex
, Data
);
177 static PWCHAR pLastCallsData
[] = { NULL
, NULL
, NULL
};
178 static DWORD NextIndex
= 0;
184 ret
= SetupGetStringFieldW(
192 HeapFree(GetProcessHeap(), 0, pLastCallsData
[NextIndex
]);
193 pLastCallsData
[NextIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
194 ret
= SetupGetStringFieldW(
197 pLastCallsData
[NextIndex
],
203 *Data
= pLastCallsData
[NextIndex
];
204 NextIndex
= (NextIndex
+ 1) % (sizeof(pLastCallsData
) / sizeof(pLastCallsData
[0]));
206 #endif /* !__REACTOS__ */
210 INF_OpenBufferedFileA(
222 Status
= InfOpenBufferedFile(
227 *ErrorLine
= (UINT
)ErrorLineUL
;
228 if (!NT_SUCCESS(Status
))
229 return INVALID_HANDLE_VALUE
;
233 return INVALID_HANDLE_VALUE
;
234 #endif /* !__REACTOS__ */