2017-06-30 19:07:02 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Setup Library
|
|
|
|
* FILE: base/setup/lib/infsupp.c
|
2018-01-06 15:47:37 +00:00
|
|
|
* PURPOSE: Interfacing with Setup* API .INF Files support functions
|
2017-06-30 19:07:02 +00:00
|
|
|
* PROGRAMMERS: Hervé Poussineau
|
|
|
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
#include "infsupp.h"
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2018-01-06 15:47:37 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These externs should be defined by the user of this library.
|
|
|
|
* They are kept there for reference and ease of usage.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
pSpInfCloseInfFile SpInfCloseInfFile = NULL;
|
|
|
|
pSpInfFindFirstLine SpInfFindFirstLine = NULL;
|
|
|
|
pSpInfFindNextLine SpInfFindNextLine = NULL;
|
|
|
|
pSpInfGetFieldCount SpInfGetFieldCount = NULL;
|
|
|
|
pSpInfGetBinaryField SpInfGetBinaryField = NULL;
|
|
|
|
pSpInfGetIntField SpInfGetIntField = NULL;
|
|
|
|
pSpInfGetMultiSzField SpInfGetMultiSzField = NULL;
|
|
|
|
pSpInfGetStringField SpInfGetStringField = NULL;
|
|
|
|
pSpInfGetField SpInfGetField = NULL;
|
|
|
|
pSpInfOpenInfFile SpInfOpenInfFile = NULL;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-06-30 19:07:02 +00:00
|
|
|
/* HELPER FUNCTIONS **********************************************************/
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
INF_GetDataField(
|
|
|
|
IN PINFCONTEXT Context,
|
|
|
|
IN ULONG FieldIndex,
|
2018-01-06 15:47:37 +00:00
|
|
|
OUT PCWSTR* Data)
|
2017-06-30 19:07:02 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
BOOL Success;
|
|
|
|
PWCHAR InfData;
|
|
|
|
DWORD dwSize;
|
|
|
|
|
|
|
|
*Data = NULL;
|
|
|
|
|
2018-01-06 15:47:37 +00:00
|
|
|
Success = SpInfGetStringField(Context,
|
|
|
|
FieldIndex,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&dwSize);
|
2017-06-30 19:07:02 +00:00
|
|
|
if (!Success)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
InfData = RtlAllocateHeap(ProcessHeap, 0, dwSize * sizeof(WCHAR));
|
|
|
|
if (!InfData)
|
|
|
|
return FALSE;
|
|
|
|
|
2018-01-06 15:47:37 +00:00
|
|
|
Success = SpInfGetStringField(Context,
|
|
|
|
FieldIndex,
|
|
|
|
InfData,
|
|
|
|
dwSize,
|
|
|
|
NULL);
|
2017-06-30 19:07:02 +00:00
|
|
|
if (!Success)
|
|
|
|
{
|
|
|
|
RtlFreeHeap(ProcessHeap, 0, InfData);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Data = InfData;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-01-06 15:47:37 +00:00
|
|
|
*Data = SpInfGetField(Context, FieldIndex);
|
2017-06-30 19:07:02 +00:00
|
|
|
return !!*Data;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
INF_GetData(
|
|
|
|
IN PINFCONTEXT Context,
|
2018-01-06 15:47:37 +00:00
|
|
|
OUT PCWSTR* Key,
|
|
|
|
OUT PCWSTR* Data)
|
2017-06-30 19:07:02 +00:00
|
|
|
{
|
|
|
|
BOOL Success;
|
2018-01-06 15:47:37 +00:00
|
|
|
PCWSTR InfData[2] = {NULL, NULL};
|
2017-06-30 19:07:02 +00:00
|
|
|
|
|
|
|
if (Key)
|
|
|
|
*Key = NULL;
|
|
|
|
|
|
|
|
if (Data)
|
|
|
|
*Data = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that the INF file has only one value field, in addition to its key name.
|
2018-01-06 15:47:37 +00:00
|
|
|
* Note that SpInfGetFieldCount() does not count the key name as a field.
|
2017-06-30 19:07:02 +00:00
|
|
|
*/
|
2018-01-06 15:47:37 +00:00
|
|
|
if (SpInfGetFieldCount(Context) != 1)
|
2017-06-30 19:07:02 +00:00
|
|
|
{
|
2018-01-06 15:47:37 +00:00
|
|
|
DPRINT1("SpInfGetFieldCount != 1\n");
|
2017-06-30 19:07:02 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Key)
|
|
|
|
{
|
|
|
|
Success = INF_GetDataField(Context, 0, &InfData[0]);
|
|
|
|
if (!Success)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Data)
|
|
|
|
{
|
|
|
|
Success = INF_GetDataField(Context, 1, &InfData[1]);
|
|
|
|
if (!Success)
|
|
|
|
{
|
|
|
|
INF_FreeData(InfData[0]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Key)
|
|
|
|
*Key = InfData[0];
|
|
|
|
|
|
|
|
if (Data)
|
|
|
|
*Data = InfData[1];
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|