ReactOS 0.4.16-dev-334-g4d9f67c
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 */
25
26/* HELPER FUNCTIONS **********************************************************/
27
33{
34#if 0
35
37 PWCHAR InfData;
39
40 *Data = NULL;
41
44 NULL,
45 0,
46 &dwSize);
47 if (!Success)
48 return FALSE;
49
50 InfData = RtlAllocateHeap(ProcessHeap, 0, dwSize * sizeof(WCHAR));
51 if (!InfData)
52 return FALSE;
53
56 InfData,
57 dwSize,
58 NULL);
59 if (!Success)
60 {
61 RtlFreeHeap(ProcessHeap, 0, InfData);
62 return FALSE;
63 }
64
65 *Data = InfData;
66 return TRUE;
67
68#else
69
71 return !!*Data;
72
73#endif
74}
75
79 OUT PCWSTR* Key,
81{
83 PCWSTR InfData[2] = {NULL, NULL};
84
85 if (Key)
86 *Key = NULL;
87
88 if (Data)
89 *Data = NULL;
90
91 /*
92 * Verify that the INF file has only one value field, in addition to its key name.
93 * Note that SpInfGetFieldCount() does not count the key name as a field.
94 */
96 {
97 DPRINT1("SpInfGetFieldCount != 1\n");
98 return FALSE;
99 }
100
101 if (Key)
102 {
103 Success = INF_GetDataField(Context, 0, &InfData[0]);
104 if (!Success)
105 return FALSE;
106 }
107
108 if (Data)
109 {
110 Success = INF_GetDataField(Context, 1, &InfData[1]);
111 if (!Success)
112 {
113 INF_FreeData(InfData[0]);
114 return FALSE;
115 }
116 }
117
118 if (Key)
119 *Key = InfData[0];
120
121 if (Data)
122 *Data = InfData[1];
123
124 return TRUE;
125}
126
127/* EOF */
unsigned char BOOLEAN
HANDLE ProcessHeap
Definition: servman.c:15
#define DPRINT1
Definition: precomp.h:8
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SpInfGetFieldCount
Definition: infsupp.h:142
#define SpInfGetField
Definition: infsupp.h:147
#define SpInfGetStringField
Definition: infsupp.h:146
FORCEINLINE VOID INF_FreeData(IN PCWSTR InfData)
Definition: infsupp.h:154
SPINF_EXPORTS SpInfExports
Definition: infsupp.c:24
BOOLEAN INF_GetDataField(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PCWSTR *Data)
Definition: infsupp.c:29
BOOLEAN INF_GetData(IN PINFCONTEXT Context, OUT PCWSTR *Key, OUT PCWSTR *Data)
Definition: infsupp.c:77
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
_In_ DWORD FieldIndex
Definition: setupapi.h:1895
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
__wchar_t WCHAR
Definition: xmlstorage.h:180