xref: /reactos/base/setup/lib/spapisup/infsupp.h (revision d7c1d220)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Setup Library
4  * FILE:            base/setup/lib/infsupp.h
5  * PURPOSE:         Interfacing with Setup* API .INF Files support functions
6  * PROGRAMMERS:     Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7  */
8 
9 #pragma once
10 
11 #include "spapisup.h"
12 
13 // FIXME: Temporary measure until all the users of this header
14 // (usetup...) use or define SetupAPI-conforming APIs.
15 #if defined(_SETUPAPI_H_) || defined(_INC_SETUPAPI)
16 
17 #include <setupapi.h>
18 
19 #else
20 
21 typedef PVOID HINF;
22 typedef struct _INFCONTEXT
23 {
24     HINF Inf;
25     HINF CurrentInf;
26     UINT Section;
27     UINT Line;
28 } INFCONTEXT, *PINFCONTEXT;
29 
30 #endif
31 
32 C_ASSERT(sizeof(INFCONTEXT) == 2 * sizeof(HINF) + 2 * sizeof(UINT));
33 
34 /* Lower the MAX_INF_STRING_LENGTH value in order to avoid too much stack usage */
35 #undef MAX_INF_STRING_LENGTH
36 #define MAX_INF_STRING_LENGTH   1024 // Still larger than in infcommon.h
37 
38 #ifndef INF_STYLE_OLDNT
39 #define INF_STYLE_OLDNT 0x00000001
40 #endif
41 
42 #ifndef INF_STYLE_WIN4
43 #define INF_STYLE_WIN4  0x00000002
44 #endif
45 
46 
47 /* FUNCTIONS *****************************************************************/
48 
49 // #define SetupCloseInfFile InfCloseFile
50 typedef VOID
51 (WINAPI* pSpInfCloseInfFile)(
52     IN HINF InfHandle);
53 
54 // #define SetupFindFirstLineW InfpFindFirstLineW
55 typedef BOOL
56 (WINAPI* pSpInfFindFirstLine)(
57     IN HINF InfHandle,
58     IN PCWSTR Section,
59     IN PCWSTR Key,
60     IN OUT PINFCONTEXT Context);
61 
62 // #define SetupFindNextLine InfFindNextLine
63 typedef BOOL
64 (WINAPI* pSpInfFindNextLine)(
65     IN  PINFCONTEXT ContextIn,
66     OUT PINFCONTEXT ContextOut);
67 
68 // #define SetupGetFieldCount InfGetFieldCount
69 typedef ULONG
70 (WINAPI* pSpInfGetFieldCount)(
71     IN PINFCONTEXT Context);
72 
73 // #define SetupGetBinaryField InfGetBinaryField
74 typedef BOOL
75 (WINAPI* pSpInfGetBinaryField)(
76     IN  PINFCONTEXT Context,
77     IN  ULONG FieldIndex,
78     OUT PUCHAR ReturnBuffer,
79     IN  ULONG ReturnBufferSize,
80     OUT PULONG RequiredSize);
81 
82 // #define SetupGetIntField InfGetIntField
83 typedef BOOL
84 (WINAPI* pSpInfGetIntField)(
85     IN PINFCONTEXT Context,
86     IN ULONG FieldIndex,
87     OUT INT *IntegerValue); // PINT
88 
89 // #define SetupGetMultiSzFieldW InfGetMultiSzField
90 typedef BOOL
91 (WINAPI* pSpInfGetMultiSzField)(
92     IN  PINFCONTEXT Context,
93     IN  ULONG FieldIndex,
94     OUT PWSTR ReturnBuffer,
95     IN  ULONG ReturnBufferSize,
96     OUT PULONG RequiredSize);
97 
98 // #define SetupGetStringFieldW InfGetStringField
99 typedef BOOL
100 (WINAPI* pSpInfGetStringField)(
101     IN  PINFCONTEXT Context,
102     IN  ULONG FieldIndex,
103     OUT PWSTR ReturnBuffer,
104     IN  ULONG ReturnBufferSize,
105     OUT PULONG RequiredSize);
106 
107 // #define pSetupGetField
108 typedef PCWSTR
109 (WINAPI* pSpInfGetField)(
110     IN PINFCONTEXT Context,
111     IN ULONG FieldIndex);
112 
113 /* A version of SetupOpenInfFileW with support for a user-provided LCID */
114 // #define SetupOpenInfFileExW InfpOpenInfFileW
115 typedef HINF
116 (WINAPI* pSpInfOpenInfFile)(
117     IN PCWSTR FileName,
118     IN PCWSTR InfClass,
119     IN DWORD InfStyle,
120     IN LCID LocaleId,
121     OUT PUINT ErrorLine);
122 
123 typedef struct _SPINF_EXPORTS
124 {
125     pSpInfCloseInfFile    SpInfCloseInfFile;
126     pSpInfFindFirstLine   SpInfFindFirstLine;
127     pSpInfFindNextLine    SpInfFindNextLine;
128     pSpInfGetFieldCount   SpInfGetFieldCount;
129     pSpInfGetBinaryField  SpInfGetBinaryField;
130     pSpInfGetIntField     SpInfGetIntField;
131     pSpInfGetMultiSzField SpInfGetMultiSzField;
132     pSpInfGetStringField  SpInfGetStringField;
133     pSpInfGetField        SpInfGetField;
134     pSpInfOpenInfFile     SpInfOpenInfFile;
135 } SPINF_EXPORTS, *PSPINF_EXPORTS;
136 
137 extern /*SPLIBAPI*/ SPINF_EXPORTS SpInfExports;
138 
139 #define SpInfCloseInfFile       (SpInfExports.SpInfCloseInfFile)
140 #define SpInfFindFirstLine      (SpInfExports.SpInfFindFirstLine)
141 #define SpInfFindNextLine       (SpInfExports.SpInfFindNextLine)
142 #define SpInfGetFieldCount      (SpInfExports.SpInfGetFieldCount)
143 #define SpInfGetBinaryField     (SpInfExports.SpInfGetBinaryField)
144 #define SpInfGetIntField        (SpInfExports.SpInfGetIntField)
145 #define SpInfGetMultiSzField    (SpInfExports.SpInfGetMultiSzField)
146 #define SpInfGetStringField     (SpInfExports.SpInfGetStringField)
147 #define SpInfGetField           (SpInfExports.SpInfGetField)
148 #define SpInfOpenInfFile        (SpInfExports.SpInfOpenInfFile)
149 
150 /* HELPER FUNCTIONS **********************************************************/
151 
152 FORCEINLINE
153 VOID
INF_FreeData(IN PCWSTR InfData)154 INF_FreeData(
155     IN PCWSTR InfData)
156 {
157 #if 0
158     if (InfData)
159         RtlFreeHeap(ProcessHeap, 0, InfData);
160 #else
161     UNREFERENCED_PARAMETER(InfData);
162 #endif
163 }
164 
165 BOOLEAN
166 INF_GetDataField(
167     IN PINFCONTEXT Context,
168     IN ULONG FieldIndex,
169     OUT PCWSTR* Data);
170 
171 BOOLEAN
172 INF_GetData(
173     IN PINFCONTEXT Context,
174     OUT PCWSTR* Key,
175     OUT PCWSTR* Data);
176 
177 /* EOF */
178