ReactOS  0.4.14-dev-50-g13bb5e2
infsupp.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Setup Library
4  * FILE: base/setup/lib/infsupp.c
5  * PURPOSE: Interfacing with Setup* API .INF Files support functions
6  * PROGRAMMERS: HervĂ© Poussineau
7  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8  */
9 
10 /* INCLUDES *****************************************************************/
11 
12 #include "precomp.h"
13 #include "infsupp.h"
14 
15 #define NDEBUG
16 #include <debug.h>
17 
18 /* GLOBALS *******************************************************************/
19 
20 /*
21  * These externs should be defined by the user of this library.
22  * They are kept there for reference and ease of usage.
23  */
24 #if 0
25 
36 
37 #endif
38 
39 /* HELPER FUNCTIONS **********************************************************/
40 
41 BOOLEAN
45  OUT PCWSTR* Data)
46 {
47 #if 0
48 
49  BOOL Success;
50  PWCHAR InfData;
51  DWORD dwSize;
52 
53  *Data = NULL;
54 
56  FieldIndex,
57  NULL,
58  0,
59  &dwSize);
60  if (!Success)
61  return FALSE;
62 
63  InfData = RtlAllocateHeap(ProcessHeap, 0, dwSize * sizeof(WCHAR));
64  if (!InfData)
65  return FALSE;
66 
68  FieldIndex,
69  InfData,
70  dwSize,
71  NULL);
72  if (!Success)
73  {
74  RtlFreeHeap(ProcessHeap, 0, InfData);
75  return FALSE;
76  }
77 
78  *Data = InfData;
79  return TRUE;
80 
81 #else
82 
84  return !!*Data;
85 
86 #endif
87 }
88 
89 BOOLEAN
92  OUT PCWSTR* Key,
93  OUT PCWSTR* Data)
94 {
95  BOOL Success;
96  PCWSTR InfData[2] = {NULL, NULL};
97 
98  if (Key)
99  *Key = NULL;
100 
101  if (Data)
102  *Data = NULL;
103 
104  /*
105  * Verify that the INF file has only one value field, in addition to its key name.
106  * Note that SpInfGetFieldCount() does not count the key name as a field.
107  */
108  if (SpInfGetFieldCount(Context) != 1)
109  {
110  DPRINT1("SpInfGetFieldCount != 1\n");
111  return FALSE;
112  }
113 
114  if (Key)
115  {
116  Success = INF_GetDataField(Context, 0, &InfData[0]);
117  if (!Success)
118  return FALSE;
119  }
120 
121  if (Data)
122  {
123  Success = INF_GetDataField(Context, 1, &InfData[1]);
124  if (!Success)
125  {
126  INF_FreeData(InfData[0]);
127  return FALSE;
128  }
129  }
130 
131  if (Key)
132  *Key = InfData[0];
133 
134  if (Data)
135  *Data = InfData[1];
136 
137  return TRUE;
138 }
139 
140 /* EOF */
PCWSTR(WINAPI * pSpInfGetField)(IN PINFCONTEXT Context, IN ULONG FieldIndex)
Definition: infsupp.h:134
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
BOOL(WINAPI * pSpInfGetMultiSzField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:112
#define TRUE
Definition: types.h:120
HINF(WINAPI * pSpInfOpenInfFile)(IN PCWSTR FileName, IN PCWSTR InfClass, IN DWORD InfStyle, IN LCID LocaleId, OUT PUINT ErrorLine)
Definition: infsupp.h:143
pSpInfCloseInfFile SpInfCloseInfFile
Definition: infsupp.c:86
pSpInfFindNextLine SpInfFindNextLine
Definition: infsupp.c:88
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
ULONG(WINAPI * pSpInfGetFieldCount)(IN PINFCONTEXT Context)
Definition: infsupp.h:85
uint16_t * PWCHAR
Definition: typedefs.h:54
BOOL(WINAPI * pSpInfFindFirstLine)(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.h:67
pSpInfFindFirstLine SpInfFindFirstLine
Definition: infsupp.c:87
pSpInfGetBinaryField SpInfGetBinaryField
Definition: infsupp.c:90
BOOL(WINAPI * pSpInfFindNextLine)(IN PINFCONTEXT ContextIn, OUT PINFCONTEXT ContextOut)
Definition: infsupp.h:77
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char BOOLEAN
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:42
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
pSpInfGetFieldCount SpInfGetFieldCount
Definition: infsupp.c:89
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ DWORD FieldIndex
Definition: setupapi.h:1890
pSpInfGetStringField SpInfGetStringField
Definition: infsupp.c:93
unsigned long DWORD
Definition: ntddk_ex.h:95
pSpInfGetField SpInfGetField
Definition: infsupp.c:94
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:157
pSpInfGetIntField SpInfGetIntField
Definition: infsupp.c:91
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:90
BOOL(WINAPI * pSpInfGetBinaryField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PUCHAR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:92
HANDLE ProcessHeap
Definition: servman.c:15
pSpInfGetMultiSzField SpInfGetMultiSzField
Definition: infsupp.c:92
pSpInfOpenInfFile SpInfOpenInfFile
Definition: infsupp.c:95
#define DPRINT1
Definition: precomp.h:8
VOID(WINAPI * pSpInfCloseInfFile)(IN HINF InfHandle)
Definition: infsupp.h:60
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
BOOL(WINAPI * pSpInfGetStringField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.h:123
BOOL(WINAPI * pSpInfGetIntField)(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT INT *IntegerValue)
Definition: infsupp.h:103