[WINSPOOL]
[reactos.git] / reactos / win32ss / printing / base / winspool / printprocessors.c
1 /*
2 * PROJECT: ReactOS Spooler API
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Functions related to Print Processors
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 static void
11 _MarshallUpDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1)
12 {
13 // Replace relative offset addresses in the output by absolute pointers.
14 pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName + (ULONG_PTR)pDatatypesInfo1);
15 }
16
17 static void
18 _MarshallUpPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1)
19 {
20 // Replace relative offset addresses in the output by absolute pointers.
21 pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName + (ULONG_PTR)pPrintProcessorInfo1);
22 }
23
24 BOOL WINAPI
25 AddPrintProcessorW(PWSTR pName, PWSTR pEnvironment, PWSTR pPathName, PWSTR pPrintProcessorName)
26 {
27 UNIMPLEMENTED;
28 return FALSE;
29 }
30
31 BOOL WINAPI
32 DeletePrintProcessorW(PWSTR pName, PWSTR pEnvironment, PWSTR pPrintProcessorName)
33 {
34 UNIMPLEMENTED;
35 return FALSE;
36 }
37
38 BOOL WINAPI
39 EnumPrintProcessorDatatypesA(PSTR pName, LPSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
40 {
41 UNIMPLEMENTED;
42 return FALSE;
43 }
44
45 BOOL WINAPI
46 EnumPrintProcessorDatatypesW(PWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
47 {
48 DWORD dwErrorCode;
49 DWORD i;
50 PBYTE p = pDatatypes;
51
52 // Do the RPC call
53 RpcTryExcept
54 {
55 dwErrorCode = _RpcEnumPrintProcessorDatatypes(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
56 }
57 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
58 {
59 dwErrorCode = RpcExceptionCode();
60 ERR("_RpcEnumPrintProcessorDatatypes failed with exception code %lu!\n", dwErrorCode);
61 }
62 RpcEndExcept;
63
64 if (dwErrorCode == ERROR_SUCCESS)
65 {
66 // Replace relative offset addresses in the output by absolute pointers.
67 for (i = 0; i < *pcReturned; i++)
68 {
69 _MarshallUpDatatypesInfo((PDATATYPES_INFO_1W)p);
70 p += sizeof(DATATYPES_INFO_1W);
71 }
72 }
73
74 SetLastError(dwErrorCode);
75 return (dwErrorCode == ERROR_SUCCESS);
76 }
77
78 BOOL WINAPI
79 EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
80 {
81 DWORD dwErrorCode;
82 DWORD i;
83 PBYTE p = pPrintProcessorInfo;
84
85 // Do the RPC call
86 RpcTryExcept
87 {
88 dwErrorCode = _RpcEnumPrintProcessors(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned);
89 }
90 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
91 {
92 dwErrorCode = RpcExceptionCode();
93 ERR("_RpcEnumPrintProcessors failed with exception code %lu!\n", dwErrorCode);
94 }
95 RpcEndExcept;
96
97 if (dwErrorCode == ERROR_SUCCESS)
98 {
99 // Replace relative offset addresses in the output by absolute pointers.
100 for (i = 0; i < *pcReturned; i++)
101 {
102 _MarshallUpPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p);
103 p += sizeof(PRINTPROCESSOR_INFO_1W);
104 }
105 }
106
107 SetLastError(dwErrorCode);
108 return (dwErrorCode == ERROR_SUCCESS);
109 }
110
111 BOOL WINAPI
112 GetPrintProcessorDirectoryW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
113 {
114 BOOL bReturnValue = FALSE;
115 DWORD dwErrorCode;
116
117 // Do the RPC call
118 RpcTryExcept
119 {
120 dwErrorCode = _RpcGetPrintProcessorDirectory(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded);
121 SetLastError(dwErrorCode);
122 bReturnValue = (dwErrorCode == ERROR_SUCCESS);
123 }
124 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
125 {
126 ERR("_RpcGetPrintProcessorDirectory failed with exception code %lu!\n", RpcExceptionCode());
127 }
128 RpcEndExcept;
129
130 return bReturnValue;
131 }