ReactOS 0.4.16-dev-91-g764881a
forms.c File Reference
#include "precomp.h"
#include <marshalling/forms.h>
Include dependency graph for forms.c:

Go to the source code of this file.

Functions

BOOL WINAPI AddFormA (HANDLE hPrinter, DWORD Level, PBYTE pForm)
 
BOOL WINAPI AddFormW (HANDLE hPrinter, DWORD Level, PBYTE pForm)
 
BOOL WINAPI DeleteFormA (HANDLE hPrinter, PSTR pFormName)
 
BOOL WINAPI DeleteFormW (HANDLE hPrinter, PWSTR pFormName)
 
BOOL WINAPI EnumFormsA (HANDLE hPrinter, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI EnumFormsW (HANDLE hPrinter, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI GetFormA (HANDLE hPrinter, PSTR pFormName, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI GetFormW (HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI SetFormA (HANDLE hPrinter, PSTR pFormName, DWORD Level, PBYTE pForm)
 
BOOL WINAPI SetFormW (HANDLE hPrinter, PWSTR pFormName, DWORD Level, PBYTE pForm)
 

Function Documentation

◆ AddFormA()

BOOL WINAPI AddFormA ( HANDLE  hPrinter,
DWORD  Level,
PBYTE  pForm 
)

Definition at line 12 of file forms.c.

13{
14 FORM_INFO_2W pfi2W;
15 PFORM_INFO_2A pfi2A;
16 DWORD len;
17 BOOL res;
18
19 pfi2A = (PFORM_INFO_2A)pForm;
20
21 TRACE("AddFormA(%p, %lu, %p)\n", hPrinter, Level, pForm);
22
23 if ((Level < 1) || (Level > 2))
24 {
25 ERR("Level = %d, unsupported!\n", Level);
27 return FALSE;
28 }
29
30 if (!pfi2A)
31 {
33 return FALSE;
34 }
35
36 ZeroMemory(&pfi2W, sizeof(FORM_INFO_2W));
37
38 if (pfi2A->pName)
39 {
40 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pName, -1, NULL, 0);
41 pfi2W.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
42 MultiByteToWideChar(CP_ACP, 0, pfi2A->pName, -1, pfi2W.pName, len);
43 }
44
45 pfi2W.Flags = pfi2A->Flags;
46 pfi2W.Size = pfi2A->Size;
47 pfi2W.ImageableArea = pfi2A->ImageableArea;
48
49 if (Level > 1)
50 {
51 if (pfi2A->pKeyword)
52 {
53 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pKeyword, -1, NULL, 0);
54 pfi2W.pKeyword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
55 MultiByteToWideChar(CP_ACP, 0, pfi2A->pKeyword, -1, (LPWSTR)pfi2W.pKeyword, len);
56 }
57
58 if (pfi2A->pMuiDll)
59 {
60 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pMuiDll, -1, NULL, 0);
61 pfi2W.pMuiDll = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
62 MultiByteToWideChar(CP_ACP, 0, pfi2A->pMuiDll, -1, (LPWSTR)pfi2W.pMuiDll, len);
63 }
64
65 if (pfi2A->pDisplayName)
66 {
67 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pDisplayName, -1, NULL, 0);
68 pfi2W.pDisplayName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
70 }
71 pfi2W.StringType = pfi2A->StringType;
72 pfi2W.dwResourceId = pfi2A->dwResourceId;
73 pfi2W.wLangId = pfi2A->wLangId;
74 }
75
76 res = AddFormW( hPrinter, Level, (PBYTE)&pfi2W );
77
78 if (pfi2W.pName) HeapFree(GetProcessHeap(), 0, pfi2W.pName);
79 if (pfi2W.pKeyword) HeapFree(GetProcessHeap(), 0, (LPWSTR)pfi2W.pKeyword);
80 if (pfi2W.pMuiDll) HeapFree(GetProcessHeap(), 0, (LPWSTR)pfi2W.pMuiDll);
82
83 return res;
84}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLenum GLsizei len
Definition: glext.h:6722
BYTE * PBYTE
Definition: pedump.c:66
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwResourceId
Definition: winspool.h:651
SIZEL Size
Definition: winspool.h:646
RECTL ImageableArea
Definition: winspool.h:647
LPCSTR pKeyword
Definition: winspool.h:648
LPCSTR pDisplayName
Definition: winspool.h:652
DWORD StringType
Definition: winspool.h:649
DWORD Flags
Definition: winspool.h:644
LPSTR pName
Definition: winspool.h:645
LANGID wLangId
Definition: winspool.h:653
LPCSTR pMuiDll
Definition: winspool.h:650
LPCWSTR pMuiDll
Definition: winspool.h:663
DWORD dwResourceId
Definition: winspool.h:664
LPWSTR pName
Definition: winspool.h:658
LPCWSTR pDisplayName
Definition: winspool.h:665
SIZEL Size
Definition: winspool.h:659
LANGID wLangId
Definition: winspool.h:666
LPCSTR pKeyword
Definition: winspool.h:661
DWORD Flags
Definition: winspool.h:657
DWORD StringType
Definition: winspool.h:662
RECTL ImageableArea
Definition: winspool.h:660
#define ZeroMemory
Definition: winbase.h:1712
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
struct _FORM_INFO_2A * PFORM_INFO_2A
WINBOOL WINAPI AddFormW(HANDLE hPrinter, DWORD Level, LPBYTE pForm)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ AddFormW()

BOOL WINAPI AddFormW ( HANDLE  hPrinter,
DWORD  Level,
PBYTE  pForm 
)

Definition at line 87 of file forms.c.

88{
89 DWORD dwErrorCode;
90 WINSPOOL_FORM_CONTAINER FormInfoContainer;
91 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
92
93 TRACE("AddFormW(%p, %lu, %p)\n", hPrinter, Level, pForm);
94
95 // Sanity checks.
96 if (!pHandle)
97 {
98 dwErrorCode = ERROR_INVALID_HANDLE;
99 return FALSE;
100 }
101
102 if ((Level < 1) || (Level > 2))
103 {
104 ERR("Level = %d, unsupported!\n", Level);
106 return FALSE;
107 }
108
109 FormInfoContainer.FormInfo.pFormInfo1 = (WINSPOOL_FORM_INFO_1*)pForm;
110 FormInfoContainer.Level = Level;
111
112 // Do the RPC call
114 {
115 dwErrorCode = _RpcAddForm(pHandle->hPrinter, &FormInfoContainer);
116 }
118 {
119 dwErrorCode = RpcExceptionCode();
120 ERR("_RpcAddForm failed with exception code %lu!\n", dwErrorCode);
121 }
123
124 SetLastError(dwErrorCode);
125 return (dwErrorCode == ERROR_SUCCESS);
126}
DWORD _RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
Definition: forms.c:12
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
HANDLE hPrinter
Definition: precomp.h:50
union _WINSPOOL_FORM_CONTAINER::@3436 FormInfo
WINSPOOL_FORM_INFO_1 * pFormInfo1
Definition: winspool.idl:620
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE

◆ DeleteFormA()

BOOL WINAPI DeleteFormA ( HANDLE  hPrinter,
PSTR  pFormName 
)

Definition at line 129 of file forms.c.

130{
131 UNICODE_STRING FormNameW;
132 BOOL Ret;
133
134 TRACE("DeleteFormA(%p, %s)\n", hPrinter, pFormName);
135
136 AsciiToUnicode(&FormNameW, pFormName);
137
138 Ret = DeleteFormW( hPrinter, FormNameW.Buffer );
139
140 RtlFreeUnicodeString(&FormNameW);
141
142 return Ret;
143}
wstring AsciiToUnicode(const char *AsciiString)
Definition: tools.cpp:220
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
WINBOOL WINAPI DeleteFormW(HANDLE hPrinter, LPWSTR pFormName)

◆ DeleteFormW()

BOOL WINAPI DeleteFormW ( HANDLE  hPrinter,
PWSTR  pFormName 
)

Definition at line 146 of file forms.c.

147{
148 DWORD dwErrorCode;
149 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
150
151 TRACE("DeleteFormW(%p, %S)\n", hPrinter, pFormName);
152
153 // Sanity checks.
154 if (!pHandle)
155 {
156 dwErrorCode = ERROR_INVALID_HANDLE;
157 return FALSE;
158 }
159
160 // Do the RPC call
162 {
163 dwErrorCode = _RpcDeleteForm(pHandle->hPrinter, pFormName);
164 }
166 {
167 dwErrorCode = RpcExceptionCode();
168 ERR("_RpcDeleteForm failed with exception code %lu!\n", dwErrorCode);
169 }
171
172 SetLastError(dwErrorCode);
173 return (dwErrorCode == ERROR_SUCCESS);
174}
DWORD _RpcDeleteForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName)
Definition: forms.c:31

◆ EnumFormsA()

BOOL WINAPI EnumFormsA ( HANDLE  hPrinter,
DWORD  Level,
PBYTE  pForm,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 177 of file forms.c.

178{
179 DWORD dwErrorCode, i;
180 PFORM_INFO_1W pfi1w = (PFORM_INFO_1W)pForm;
181 PFORM_INFO_2W pfi2w = (PFORM_INFO_2W)pForm;
182
183 TRACE("EnumFormsA(%p, %lu, %p, %lu, %p, %p)\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
184
185 if ( EnumFormsW( hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned ) )
186 {
187 for ( i = 0; i < *pcReturned; i++ )
188 {
189 switch ( Level )
190 {
191 case 2:
192 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w[i].pKeyword);
193 if (dwErrorCode != ERROR_SUCCESS)
194 {
195 goto Cleanup;
196 }
197 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w[i].pMuiDll);
198 if (dwErrorCode != ERROR_SUCCESS)
199 {
200 goto Cleanup;
201 }
202 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w[i].pDisplayName);
203 if (dwErrorCode != ERROR_SUCCESS)
204 {
205 goto Cleanup;
206 }
207 dwErrorCode = UnicodeToAnsiInPlace(pfi2w[i].pName);
208 if (dwErrorCode != ERROR_SUCCESS)
209 {
210 goto Cleanup;
211 }
212 break;
213 case 1:
214 dwErrorCode = UnicodeToAnsiInPlace(pfi1w[i].pName);
215 if (dwErrorCode != ERROR_SUCCESS)
216 {
217 goto Cleanup;
218 }
219 }
220 }
221 return TRUE;
222 }
223Cleanup:
224 return FALSE;
225}
#define TRUE
Definition: types.h:120
static const WCHAR Cleanup[]
Definition: register.c:80
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static LPSTR pName
Definition: security.c:75
DWORD UnicodeToAnsiInPlace(PWSTR pwszField)
Definition: utils.c:28
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WINBOOL WINAPI EnumFormsW(HANDLE hPrinter, DWORD Level, LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
struct _FORM_INFO_2W * PFORM_INFO_2W
struct _FORM_INFO_1W * PFORM_INFO_1W

◆ EnumFormsW()

BOOL WINAPI EnumFormsW ( HANDLE  hPrinter,
DWORD  Level,
PBYTE  pForm,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 228 of file forms.c.

229{
230 DWORD dwErrorCode;
231 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
232
233 TRACE("EnumFormsW(%p, %lu, %p, %lu, %p, %p)\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
234
235 // Sanity checks.
236 if (!pHandle)
237 {
238 dwErrorCode = ERROR_INVALID_HANDLE;
239 goto Cleanup;
240 }
241
242 if ((Level < 1) || (Level > 2))
243 {
244 ERR("Level = %d, unsupported!\n", Level);
245 dwErrorCode = ERROR_INVALID_LEVEL;
246 goto Cleanup;
247 }
248
249 // Do the RPC call
251 {
252 dwErrorCode = _RpcEnumForms(pHandle->hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
253 }
255 {
256 dwErrorCode = RpcExceptionCode();
257 ERR("_RpcEnumForms failed with exception code %lu!\n", dwErrorCode);
258 }
260
261 if (dwErrorCode == ERROR_SUCCESS)
262 {
263 // Replace relative offset addresses in the output by absolute pointers.
264 ASSERT(Level >= 1 && Level <= 2);
265 MarshallUpStructuresArray(cbBuf, pForm, *pcReturned, pFormInfoMarshalling[Level]->pInfo, pFormInfoMarshalling[Level]->cbStructureSize, TRUE);
266 }
267
268Cleanup:
269 SetLastError(dwErrorCode);
270 return (dwErrorCode == ERROR_SUCCESS);
271}
DWORD _RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
Definition: forms.c:50
static const MARSHALLING * pFormInfoMarshalling[]
Definition: forms.h:36
BOOL WINAPI MarshallUpStructuresArray(DWORD cbSize, PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:202
#define ASSERT(a)
Definition: mode.c:44

◆ GetFormA()

BOOL WINAPI GetFormA ( HANDLE  hPrinter,
PSTR  pFormName,
DWORD  Level,
PBYTE  pForm,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 274 of file forms.c.

275{
276 DWORD dwErrorCode, len;
277 LPWSTR FormNameW = NULL;
278 PFORM_INFO_1W pfi1w = (PFORM_INFO_1W)pForm;
279 PFORM_INFO_2W pfi2w = (PFORM_INFO_2W)pForm;
280
281 TRACE("GetFormA(%p, %s, %lu, %p, %lu, %p)\n", hPrinter, pFormName, Level, pForm, cbBuf, pcbNeeded);
282
283 if (pFormName)
284 {
285 len = MultiByteToWideChar(CP_ACP, 0, pFormName, -1, NULL, 0);
286 FormNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
287 MultiByteToWideChar(CP_ACP, 0, pFormName, -1, FormNameW, len);
288 }
289
290 if ( GetFormW( hPrinter, FormNameW, Level, pForm, cbBuf, pcbNeeded ) )
291 {
292 switch ( Level )
293 {
294 case 2:
295 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w->pKeyword);
296 if (dwErrorCode != ERROR_SUCCESS)
297 {
298 goto Cleanup;
299 }
300 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w->pMuiDll);
301 if (dwErrorCode != ERROR_SUCCESS)
302 {
303 goto Cleanup;
304 }
305 dwErrorCode = UnicodeToAnsiInPlace((LPWSTR)pfi2w->pDisplayName);
306 if (dwErrorCode != ERROR_SUCCESS)
307 {
308 goto Cleanup;
309 }
310 dwErrorCode = UnicodeToAnsiInPlace(pfi2w->pName);
311 if (dwErrorCode != ERROR_SUCCESS)
312 {
313 goto Cleanup;
314 }
315 break;
316 case 1:
317 dwErrorCode = UnicodeToAnsiInPlace(pfi1w->pName);
318 if (dwErrorCode != ERROR_SUCCESS)
319 {
320 goto Cleanup;
321 }
322 }
323 }
324Cleanup:
325 if (FormNameW) HeapFree(GetProcessHeap(), 0, FormNameW);
326 return (dwErrorCode == ERROR_SUCCESS);
327}
LPWSTR pName
Definition: winspool.h:634
WINBOOL WINAPI GetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level, LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded)

◆ GetFormW()

BOOL WINAPI GetFormW ( HANDLE  hPrinter,
PWSTR  pFormName,
DWORD  Level,
PBYTE  pForm,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 330 of file forms.c.

331{
332 DWORD dwErrorCode;
333 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
334
335 TRACE("GetFormW(%p, %S, %lu, %p, %lu, %p)\n", hPrinter, pFormName, Level, pForm, cbBuf, pcbNeeded);
336
337 // Sanity checks.
338 if (!pHandle)
339 {
340 dwErrorCode = ERROR_INVALID_HANDLE;
341 goto Cleanup;
342 }
343
344 // Dismiss invalid levels already at this point.
345 if ((Level < 1) || (Level > 2))
346 {
347 ERR("Level = %d, unsupported!\n", Level);
348 dwErrorCode = ERROR_INVALID_LEVEL;
349 goto Cleanup;
350 }
351
352 if (cbBuf && pForm)
353 ZeroMemory(pForm, cbBuf);
354
355 // Do the RPC call
357 {
358 dwErrorCode = _RpcGetForm(pHandle->hPrinter, pFormName, Level, pForm, cbBuf, pcbNeeded);
359 }
361 {
362 dwErrorCode = RpcExceptionCode();
363 ERR("_RpcGetForm failed with exception code %lu!\n", dwErrorCode);
364 }
366
367 if (dwErrorCode == ERROR_SUCCESS)
368 {
369 // Replace relative offset addresses in the output by absolute pointers.
370 ASSERT(Level >= 1 && Level <= 2);
371 MarshallUpStructure(cbBuf, pForm, pFormInfoMarshalling[Level]->pInfo, pFormInfoMarshalling[Level]->cbStructureSize, TRUE);
372 }
373
374Cleanup:
375 SetLastError(dwErrorCode);
376 return (dwErrorCode == ERROR_SUCCESS);
377}
DWORD _RpcGetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded)
Definition: forms.c:82
BOOL WINAPI MarshallUpStructure(DWORD cbSize, PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:137

◆ SetFormA()

BOOL WINAPI SetFormA ( HANDLE  hPrinter,
PSTR  pFormName,
DWORD  Level,
PBYTE  pForm 
)

Definition at line 380 of file forms.c.

381{
382 FORM_INFO_2W pfi2W;
383 FORM_INFO_2A * pfi2A;
384 LPWSTR FormNameW = NULL;
385 DWORD len;
386 BOOL res;
387
388 pfi2A = (FORM_INFO_2A *) pForm;
389
390 TRACE("SetFormA(%p, %s, %lu, %p)\n", hPrinter, pFormName, Level, pForm);
391
392 if ((Level < 1) || (Level > 2))
393 {
394 ERR("Level = %d, unsupported!\n", Level);
396 return FALSE;
397 }
398
399 if (!pfi2A)
400 {
402 return FALSE;
403 }
404
405 if (pFormName)
406 {
407 len = MultiByteToWideChar(CP_ACP, 0, pFormName, -1, NULL, 0);
408 FormNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
409 MultiByteToWideChar(CP_ACP, 0, pFormName, -1, FormNameW, len);
410 }
411
412 ZeroMemory(&pfi2W, sizeof(FORM_INFO_2W));
413
414 if (pfi2A->pName)
415 {
416 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pName, -1, NULL, 0);
417 pfi2W.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
418 MultiByteToWideChar(CP_ACP, 0, pfi2A->pName, -1, pfi2W.pName, len);
419 }
420
421 pfi2W.Flags = pfi2A->Flags;
422 pfi2W.Size = pfi2A->Size;
423 pfi2W.ImageableArea = pfi2A->ImageableArea;
424
425 if (Level > 1)
426 {
427 if (pfi2A->pKeyword)
428 {
429 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pKeyword, -1, NULL, 0);
430 pfi2W.pKeyword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
431 MultiByteToWideChar(CP_ACP, 0, pfi2A->pKeyword, -1, (LPWSTR)pfi2W.pKeyword, len);
432 }
433
434 if (pfi2A->pMuiDll)
435 {
436 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pMuiDll, -1, NULL, 0);
437 pfi2W.pMuiDll = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
438 MultiByteToWideChar(CP_ACP, 0, pfi2A->pMuiDll, -1, (LPWSTR)pfi2W.pMuiDll, len);
439 }
440
441 if (pfi2A->pDisplayName)
442 {
443 len = MultiByteToWideChar(CP_ACP, 0, pfi2A->pDisplayName, -1, NULL, 0);
444 pfi2W.pDisplayName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
446 }
447 pfi2W.StringType = pfi2A->StringType;
448 pfi2W.dwResourceId = pfi2A->dwResourceId;
449 pfi2W.wLangId = pfi2A->wLangId;
450 }
451
452 res = SetFormW( hPrinter, FormNameW, Level, (PBYTE)&pfi2W );
453
454 if (FormNameW) HeapFree(GetProcessHeap(), 0, FormNameW);
455 if (pfi2W.pName) HeapFree(GetProcessHeap(), 0, pfi2W.pName);
456 if (pfi2W.pKeyword) HeapFree(GetProcessHeap(), 0, (LPWSTR)pfi2W.pKeyword);
457 if (pfi2W.pMuiDll) HeapFree(GetProcessHeap(), 0, (LPWSTR)pfi2W.pMuiDll);
458 if (pfi2W.pDisplayName) HeapFree(GetProcessHeap(), 0, (LPWSTR)pfi2W.pDisplayName);
459
460 return res;
461}
WINBOOL WINAPI SetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level, LPBYTE pForm)

◆ SetFormW()

BOOL WINAPI SetFormW ( HANDLE  hPrinter,
PWSTR  pFormName,
DWORD  Level,
PBYTE  pForm 
)

Definition at line 464 of file forms.c.

465{
466 DWORD dwErrorCode;
467 WINSPOOL_FORM_CONTAINER FormInfoContainer;
468 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
469
470 TRACE("SetFormW(%p, %S, %lu, %p)\n", hPrinter, pFormName, Level, pForm);
471
472 // Sanity checks.
473 if (!pHandle)
474 {
475 ERR("Level = %d, unsupported!\n", Level);
476 dwErrorCode = ERROR_INVALID_HANDLE;
477 return FALSE;
478 }
479
480 FormInfoContainer.FormInfo.pFormInfo1 = (WINSPOOL_FORM_INFO_1*)pForm;
481 FormInfoContainer.Level = Level;
482
483 // Do the RPC call
485 {
486 dwErrorCode = _RpcSetForm(pHandle->hPrinter, pFormName, &FormInfoContainer);
487 }
489 {
490 dwErrorCode = RpcExceptionCode();
491 }
493
494 SetLastError(dwErrorCode);
495 return (dwErrorCode == ERROR_SUCCESS);
496}
DWORD _RpcSetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
Definition: forms.c:114