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 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
);
99 UNICODE_STRING FileNameU
;
103 RtlInitUnicodeString(&FileNameU
, FileName
);
104 Status
= InfOpenFile(
109 *ErrorLine
= (UINT
)ErrorLineUL
;
110 if (!NT_SUCCESS(Status
))
111 return INVALID_HANDLE_VALUE
;
116 #endif /* __REACTOS__ */
120 IN PINFCONTEXT Context
,
125 return InfGetData(Context
, Key
, Data
);
127 static PWCHAR pLastCallData
[4] = { NULL
, NULL
, NULL
, NULL
};
128 static DWORD currentIndex
= 0;
134 if (Key
) *Key
= NULL
;
135 if (Data
) *Data
= NULL
;
137 if (SetupGetFieldCount(Context
) != 1)
140 for (i
= 0; i
<= 1; i
++)
142 ret
= SetupGetStringFieldW(
150 HeapFree(GetProcessHeap(), 0, pLastCallData
[i
+ currentIndex
]);
151 pLastCallData
[i
+ currentIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
152 ret
= SetupGetStringFieldW(
155 pLastCallData
[i
+ currentIndex
],
163 *Key
= pLastCallData
[0 + currentIndex
];
165 *Data
= pLastCallData
[1 + currentIndex
];
167 #endif /* !__REACTOS__ */
172 IN PINFCONTEXT Context
,
177 return InfGetDataField(Context
, FieldIndex
, Data
);
179 static PWCHAR pLastCallsData
[] = { NULL
, NULL
, NULL
};
180 static DWORD NextIndex
= 0;
186 ret
= SetupGetStringFieldW(
194 HeapFree(GetProcessHeap(), 0, pLastCallsData
[NextIndex
]);
195 pLastCallsData
[NextIndex
] = HeapAlloc(GetProcessHeap(), 0, dwSize
* sizeof(WCHAR
));
196 ret
= SetupGetStringFieldW(
199 pLastCallsData
[NextIndex
],
205 *Data
= pLastCallsData
[NextIndex
];
206 NextIndex
= (NextIndex
+ 1) % (sizeof(pLastCallsData
) / sizeof(pLastCallsData
[0]));
208 #endif /* !__REACTOS__ */
212 INF_OpenBufferedFileA(
225 Status
= InfOpenBufferedFile(
231 *ErrorLine
= (UINT
)ErrorLineUL
;
232 if (!NT_SUCCESS(Status
))
233 return INVALID_HANDLE_VALUE
;
237 return INVALID_HANDLE_VALUE
;
238 #endif /* !__REACTOS__ */